55 wxLogTrace( MASK_3D_SG,
56 wxT(
"%s:%s:%d * [BUG] inappropriate parent to SGFACESET (type %s)" ),
57 __FILE__, __FUNCTION__, __LINE__,
132 if(
nullptr == aParent )
151 if(
nullptr == aNodeName || 0 == aNodeName[0] )
154 if( !
m_Name.compare( aNodeName ) )
201 if(
nullptr == aNode )
257 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [BUG] unlinkNode() did not find its target" ),
258 __FILE__, __FUNCTION__, __LINE__ );
277 wxCHECK( aNode,
false );
288 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [BUG] assigning multiple Colors nodes" ),
289 __FILE__, __FUNCTION__, __LINE__ );
317 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [BUG] assigning multiple Colors nodes" ),
318 __FILE__, __FUNCTION__, __LINE__ );
346 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [BUG] assigning multiple Normals nodes" ),
347 __FILE__, __FUNCTION__, __LINE__ );
375 wxLogTrace( MASK_3D_SG,
376 wxT(
"%s:%s:%d * [BUG] assigning multiple CoordIndex nodes" ),
377 __FILE__, __FUNCTION__, __LINE__ );
391 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [BUG] object type '%s' is not a valid type for "
392 "this object '%d'" ),
393 __FILE__, __FUNCTION__, __LINE__,
403 return addNode( aNode,
false );
449 aFile <<
" geometry DEF " <<
GetName() <<
" IndexedFaceSet {\n";
454 aFile <<
"USE " <<
GetName() <<
"\n";
460 aFile <<
" geometry IndexedFaceSet {\n";
473 aFile <<
" normalPerVertex TRUE\n";
495 if(
nullptr == parentNode )
513 wxCHECK( parentNode ==
m_Parent,
false );
517 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] bad stream" ),
518 __FILE__, __FUNCTION__, __LINE__ );
533 aFile <<
"[" <<
GetName() <<
"]";
538 for( i = 0; i <
NITEMS; ++i )
569 for(
int jj = 0; jj <
NITEMS; ++jj )
570 aFile.write( (
char*) &items[jj],
sizeof(
bool ) );
606 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [BUG] non-empty node" ),
607 __FILE__, __FUNCTION__, __LINE__ );
615 for(
int i = 0; i <
NITEMS; ++i )
616 aFile.read( (
char*) &items[i],
sizeof(
bool ) );
618 if( ( items[0] && items[1] ) || ( items[3] && items[4] ) || ( items[5] && items[6] ) )
620 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] corrupt data; multiple item definitions "
622 __FILE__, __FUNCTION__, __LINE__,
623 static_cast<int>( aFile.tellg() ) );
634 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] corrupt data; bad child coords tag at "
636 __FILE__, __FUNCTION__, __LINE__,
637 static_cast<int>( aFile.tellg() ) );
647 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] corrupt data; corrupt data while "
648 "reading coords '%s'" ),
649 __FILE__, __FUNCTION__, __LINE__,
660 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] corrupt data; bad ref coords tag at "
662 __FILE__, __FUNCTION__, __LINE__,
663 static_cast<int>( aFile.tellg() ) );
672 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] corrupt data; cannot find ref "
674 __FILE__, __FUNCTION__, __LINE__,
682 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] corrupt data; type is not SGCOORDS "
684 __FILE__, __FUNCTION__, __LINE__,
698 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] corrupt data; bad coord index tag at "
700 __FILE__, __FUNCTION__, __LINE__,
701 static_cast<int>( aFile.tellg() ) );
711 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] corrupt data while reading coord "
713 __FILE__, __FUNCTION__, __LINE__,
724 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] corrupt data; bad child normals tag "
726 __FILE__, __FUNCTION__, __LINE__,
727 static_cast<int>( aFile.tellg() ) );
737 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] corrupt data while reading normals "
739 __FILE__, __FUNCTION__, __LINE__,
750 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] corrupt data; bad ref normals tag at "
752 __FILE__, __FUNCTION__, __LINE__,
753 static_cast<int>( aFile.tellg() ) );
762 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] corrupt: cannot find ref normals "
764 __FILE__, __FUNCTION__, __LINE__,
772 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] corrupt: type is not SGNORMALS '%s'" ),
773 __FILE__, __FUNCTION__, __LINE__,
787 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] corrupt data; bad child colors tag "
789 __FILE__, __FUNCTION__, __LINE__,
790 static_cast<int>( aFile.tellg() ) );
800 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] corrupt data while reading colors "
802 __FILE__, __FUNCTION__, __LINE__,
813 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] corrupt data; bad ref colors tag at "
815 __FILE__, __FUNCTION__, __LINE__,
816 static_cast<int>( aFile.tellg() ) );
825 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] corrupt data: cannot find ref colors "
827 __FILE__, __FUNCTION__, __LINE__,
835 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] corrupt data: type is not SGCOLORS "
837 __FILE__, __FUNCTION__, __LINE__,
865 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] bad model; no vertices, vertex indices, "
867 __FILE__, __FUNCTION__, __LINE__ );
877 if(
nullptr == coords )
886 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] bad model; fewer than 3 vertices" ),
887 __FILE__, __FUNCTION__, __LINE__ );
896 int* lCIdx =
nullptr;
899 if( nCIdx < 3 || ( nCIdx % 3 > 0 ) )
901 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] bad model; no vertex indices or not "
903 __FILE__, __FUNCTION__, __LINE__ );
911 for(
size_t i = 0; i < nCIdx; ++i )
913 if( lCIdx[i] < 0 || lCIdx[i] >= (
int)nCoords )
915 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] bad model; vertex index out of "
917 __FILE__, __FUNCTION__, __LINE__ );
930 if(
nullptr == pNorms )
935 if( nNorms != nCoords )
937 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] bad model; number of normals (%ul) does "
938 "not match number of vertices (%ul)" ),
939 __FILE__, __FUNCTION__, __LINE__,
940 static_cast<unsigned long>( nNorms ),
941 static_cast<unsigned long>( nCoords ) );
951 if(
nullptr == pColors )
954 if(
nullptr != pColors )
982 if(
nullptr == coords || coords->
coords.empty() )
Define an RGB color set for a scenegraph object.
bool WriteCache(std::ostream &aFile, SGNODE *parentNode) override
Write this node's data to a binary cache file.
bool ReadCache(std::istream &aFile, SGNODE *parentNode) override
Reads binary format data from a cache file.
virtual bool SetParent(SGNODE *aParent, bool notify=true) override
Set the parent SGNODE of this object.
bool WriteVRML(std::ostream &aFile, bool aReuseFlag) override
Writes this node's data to a VRML file.
SGNODE * FindNode(const char *aNodeName, const SGNODE *aCaller) noexcept override
Search the tree of linked nodes and return a reference to the first node found with the given name.
bool GetColorList(size_t &aListSize, SGCOLOR *&aColorList)
void ReNameNodes(void) override
Rename a node and all its child nodes in preparation for write operations.
An object to maintain a coordinate index list.
void GatherCoordIndices(std::vector< int > &aIndexList)
Add all coordinate indices to the given list in preparation for a normals calculation.
Define a vertex coordinate set for a scenegraph object.
bool WriteCache(std::ostream &aFile, SGNODE *parentNode) override
Write this node's data to a binary cache file.
bool WriteVRML(std::ostream &aFile, bool aReuseFlag) override
Writes this node's data to a VRML file.
std::vector< SGPOINT > coords
bool ReadCache(std::istream &aFile, SGNODE *parentNode) override
Reads binary format data from a cache file.
SGNODE * FindNode(const char *aNodeName, const SGNODE *aCaller) noexcept override
Search the tree of linked nodes and return a reference to the first node found with the given name.
virtual bool SetParent(SGNODE *aParent, bool notify=true) override
Set the parent SGNODE of this object.
bool GetCoordsList(size_t &aListSize, SGPOINT *&aCoordsList)
void ReNameNodes(void) override
Rename a node and all its child nodes in preparation for write operations.
bool CalcNormals(SGFACESET *callingNode, SGNODE **aPtr=nullptr)
Calculate normals for this coordinate list and sets the normals list in the parent SGFACESET.
void GatherCoordIndices(std::vector< int > &aIndexList)
Add all internal coordinate indices to the given list in preparation for a normals calculation.
void unlinkRefNode(const SGNODE *aNode) override
Remove pointers to a referenced node.
SGCOORDINDEX * m_CoordIndices
SGNODE * FindNode(const char *aNodeName, const SGNODE *aCaller) override
Search the tree of linked nodes and return a reference to the first node found with the given name.
bool addNode(SGNODE *aNode, bool isChild)
bool CalcNormals(SGNODE **aPtr)
SGFACESET(SGNODE *aParent)
void ReNameNodes(void) override
Rename a node and all its child nodes in preparation for write operations.
virtual bool SetParent(SGNODE *aParent, bool notify=true) override
Set the parent SGNODE of this object.
void unlinkChildNode(const SGNODE *aNode) override
Remove references to an owned child.
void unlinkNode(const SGNODE *aNode, bool isChild)
bool AddRefNode(SGNODE *aNode) override
bool AddChildNode(SGNODE *aNode) override
bool WriteCache(std::ostream &aFile, SGNODE *parentNode) override
Write this node's data to a binary cache file.
bool WriteVRML(std::ostream &aFile, bool aReuseFlag) override
Writes this node's data to a VRML file.
bool ReadCache(std::istream &aFile, SGNODE *parentNode) override
Reads binary format data from a cache file.
bool GetIndices(size_t &nIndices, int *&aIndexList)
Retrieve the number of indices and a pointer to the list.
bool WriteVRML(std::ostream &aFile, bool aReuseFlag) override
Writes this node's data to a VRML file.
bool ReadCache(std::istream &aFile, SGNODE *parentNode) override
Reads binary format data from a cache file.
SGNODE * FindNode(const char *aNodeName, const SGNODE *aCaller) noexcept override
Search the tree of linked nodes and return a reference to the first node found with the given name.
void ReNameNodes(void) override
Rename a node and all its child nodes in preparation for write operations.
virtual bool SetParent(SGNODE *aParent, bool notify=true) override
Set the parent SGNODE of this object.
bool WriteCache(std::ostream &aFile, SGNODE *parentNode) override
Write this node's data to a binary cache file.
The base class of all Scene Graph nodes.
void SetName(const char *aName)
virtual bool WriteCache(std::ostream &aFile, SGNODE *parentNode)=0
Write this node's data to a binary cache file.
const char * GetName(void)
virtual SGNODE * FindNode(const char *aNodeName, const SGNODE *aCaller)=0
Search the tree of linked nodes and return a reference to the first node found with the given name.
bool isWritten(void) noexcept
Return true if the object had already been written to a cache file or VRML file.
SGNODE * GetParent(void) const noexcept
Returns a pointer to the parent SGNODE of this object or NULL if the object has no parent (ie.
S3D::SGTYPES GetNodeType(void) const noexcept
Return the type of this node instance.
virtual bool AddChildNode(SGNODE *aNode)=0
SGNODE * m_Parent
Pointer to parent node; may be NULL for top level transform.
std::string m_Name
name to use for referencing the entity by name.
void addNodeRef(SGNODE *aNode)
Add a pointer to a node which references this node, but does not own.
virtual void unlinkChildNode(const SGNODE *aNode)=0
Remove references to an owned child.
void delNodeRef(const SGNODE *aNode)
Remove a pointer to a node which references this node, but does not own.
bool m_written
Set to true when the object has been written after a ReNameNodes().
S3D::SGTYPES m_SGtype
Type of Scene Graph node.
bool SwapParent(SGNODE *aNewParent)
Swap the ownership with the given parent.
Define a set of vertex normals for a scene graph object.
virtual bool SetParent(SGNODE *aParent, bool notify=true) override
Set the parent SGNODE of this object.
void ReNameNodes(void) override
Rename a node and all its child nodes in preparation for write operations.
bool WriteCache(std::ostream &aFile, SGNODE *parentNode) override
Write this node's data to a binary cache file.
bool GetNormalList(size_t &aListSize, SGVECTOR *&aNormalList)
bool WriteVRML(std::ostream &aFile, bool aReuseFlag) override
Writes this node's data to a VRML file.
bool ReadCache(std::istream &aFile, SGNODE *parentNode) override
Reads binary format data from a cache file.
SGNODE * FindNode(const char *aNodeName, const SGNODE *aCaller) noexcept override
Search the tree of linked nodes and return a reference to the first node found with the given name.
std::vector< SGVECTOR > norms
S3D::SGTYPES ReadTag(std::istream &aFile, std::string &aName)
Read the text tag of a binary cache file which is the NodeTag and unique ID number combined.
Define a number of macros to aid in repetitious code which is probably best expressed as a preprocess...