52 std::ostringstream ostr;
53 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
54 ostr <<
" * [BUG] inappropriate parent to SGSHAPE (type ";
56 wxLogTrace( MASK_3D_SG,
"%s\n", ostr.str().c_str() );
115 if( NULL == aParent )
134 if( NULL == aNodeName || 0 == aNodeName[0] )
137 if( !
m_Name.compare( aNodeName ) )
208 std::ostringstream ostr;
209 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
210 ostr <<
" * [BUG] unlinkNode() did not find its target";
211 wxLogTrace( MASK_3D_SG,
"%s\n", ostr.str().c_str() );
238 std::ostringstream ostr;
239 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
240 ostr <<
" * [BUG] NULL pointer passed for aNode";
241 wxLogTrace( MASK_3D_SG,
"%s\n", ostr.str().c_str() );
254 std::ostringstream ostr;
255 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
256 ostr <<
" * [BUG] assigning multiple Appearance nodes";
257 wxLogTrace( MASK_3D_SG,
"%s\n", ostr.str().c_str() );
287 std::ostringstream ostr;
288 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
289 ostr <<
" * [BUG] assigning multiple FaceSet nodes";
290 wxLogTrace( MASK_3D_SG,
"%s\n", ostr.str().c_str() );
315 std::ostringstream ostr;
316 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
317 ostr <<
" * [BUG] object '" << aNode->
GetName();
318 ostr <<
"' is not a valid type for this object (" << aNode->
GetNodeType() <<
")";
319 wxLogTrace( MASK_3D_SG,
"%s\n", ostr.str().c_str() );
329 return addNode( aNode,
false );
371 aFile <<
"DEF " <<
GetName() <<
" Shape {\n";
376 aFile <<
" USE " <<
GetName() <<
"\n";
382 aFile <<
" Shape {\n";
405 if( NULL == parentNode )
410 std::ostringstream ostr;
411 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
412 ostr <<
" * [BUG] corrupt data; m_aParent is NULL";
413 wxLogTrace( MASK_3D_SG,
"%s\n", ostr.str().c_str() );
436 std::ostringstream ostr;
437 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
438 ostr <<
" * [BUG] corrupt data; parentNode != m_aParent";
439 wxLogTrace( MASK_3D_SG,
"%s\n", ostr.str().c_str() );
448 std::ostringstream ostr;
449 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
450 ostr <<
" * [INFO] bad stream";
451 wxLogTrace( MASK_3D_SG,
"%s\n", ostr.str().c_str() );
464 aFile <<
"[" <<
GetName() <<
"]";
488 for(
int jj = 0; jj <
NITEMS; ++jj )
489 aFile.write( (
char*)&items[jj],
sizeof(
bool) );
516 std::ostringstream ostr;
517 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
518 ostr <<
" * [BUG] non-empty node";
519 wxLogTrace( MASK_3D_SG,
"%s\n", ostr.str().c_str() );
529 aFile.read( (
char*)&items[
i],
sizeof(
bool) );
531 if( ( items[0] && items[1] ) || ( items[2] && items[3] ) )
534 std::ostringstream ostr;
535 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
536 ostr <<
" * [INFO] corrupt data; multiple item definitions at position ";
537 ostr << aFile.tellg();
538 wxLogTrace( MASK_3D_SG,
"%s\n", ostr.str().c_str() );
551 std::ostringstream ostr;
552 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
553 ostr <<
" * [INFO] corrupt data; bad child apperance tag at position ";
554 ostr << aFile.tellg();
555 wxLogTrace( MASK_3D_SG,
"%s\n", ostr.str().c_str() );
567 std::ostringstream ostr;
568 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
569 ostr <<
" * [INFO] corrupt data while reading appearance '";
571 wxLogTrace( MASK_3D_SG,
"%s\n", ostr.str().c_str() );
583 std::ostringstream ostr;
584 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
585 ostr <<
" * [INFO] corrupt data; bad ref appearance tag at position ";
586 ostr << aFile.tellg();
587 wxLogTrace( MASK_3D_SG,
"%s\n", ostr.str().c_str() );
598 std::ostringstream ostr;
599 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
600 ostr <<
" * [INFO] corrupt data: cannot find ref appearance '";
602 wxLogTrace( MASK_3D_SG,
"%s\n", ostr.str().c_str() );
611 std::ostringstream ostr;
612 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
613 ostr <<
" * [INFO] corrupt data: type is not SGAPPEARANCE '";
615 wxLogTrace( MASK_3D_SG,
"%s\n", ostr.str().c_str() );
630 std::ostringstream ostr;
631 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
632 ostr <<
" * [INFO] corrupt data; bad child face set tag at position ";
633 ostr << aFile.tellg();
634 wxLogTrace( MASK_3D_SG,
"%s\n", ostr.str().c_str() );
646 std::ostringstream ostr;
647 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
648 ostr <<
" * [INFO] corrupt data while reading face set '";
650 wxLogTrace( MASK_3D_SG,
"%s\n", ostr.str().c_str() );
662 std::ostringstream ostr;
663 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
664 ostr <<
" * [INFO] corrupt data; bad ref face set tag at position ";
665 ostr << aFile.tellg();
666 wxLogTrace( MASK_3D_SG,
"%s\n", ostr.str().c_str() );
677 std::ostringstream ostr;
678 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
679 ostr <<
" * [INFO] corrupt data: cannot find ref face set '";
681 wxLogTrace( MASK_3D_SG,
"%s\n", ostr.str().c_str() );
690 std::ostringstream ostr;
691 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
692 ostr <<
" * [INFO] corrupt data: type is not SGFACESET '";
694 wxLogTrace( MASK_3D_SG,
"%s\n", ostr.str().c_str() );
733 std::ostringstream ostr;
734 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
735 ostr <<
" * [INFO] bad model; inconsistent data";
736 wxLogTrace( MASK_3D_SG,
"%s\n", ostr.str().c_str() );
786 if( nColors < nCoords )
789 std::ostringstream ostr;
790 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
791 ostr <<
" * [INFO] bad model; not enough colors per vertex (";
792 ostr << nColors <<
" vs " << nCoords <<
")";
793 wxLogTrace( MASK_3D_SG,
"%s\n", ostr.str().c_str() );
805 std::vector< int > vertices;
806 std::map< int, unsigned int > indexmap;
807 std::map< int, unsigned int >::iterator mit;
809 for(
unsigned int i = 0;
i < nvidx; ++
i )
811 mit = indexmap.find( lv[
i] );
813 if( mit == indexmap.end() )
815 indexmap.insert( std::pair< int, unsigned int >( lv[
i], vertices.size() ) );
816 vertices.push_back( lv[
i] );
820 if( vertices.size() < 3 )
823 std::ostringstream ostr;
824 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
825 ostr <<
" * [INFO] bad model; not enough vertices";
826 wxLogTrace( MASK_3D_SG,
"%s\n", ostr.str().c_str() );
838 lColors =
new SFVEC3F[vertices.size()];
845 for(
size_t i = 0;
i < vertices.size(); ++
i )
848 glm::dvec4 pt( pCoords[ti].x, pCoords[ti].y, pCoords[ti].z, 1.0 );
849 pt = (*aTransform) * pt;
850 pColors[ti].
GetColor( lColors[
i].x, lColors[
i].y, lColors[
i].z );
851 lCoords[
i] =
SFVEC3F( pt.x, pt.y, pt.z );
856 for(
size_t i = 0;
i < vertices.size(); ++
i )
859 glm::dvec4 pt( pCoords[ti].x, pCoords[ti].y, pCoords[ti].z, 1.0 );
860 pt = (*aTransform) * pt;
861 lCoords[
i] =
SFVEC3F( pt.x, pt.y, pt.z );
867 unsigned int* lvidx =
new unsigned int[ nvidx ];
869 for(
unsigned int i = 0;
i < nvidx; ++
i )
871 mit = indexmap.find( lv[
i] );
872 lvidx[
i] = mit->second;
886 for(
size_t i = 0;
i < vertices.size(); ++
i )
890 glm::dvec4 pt( x, y, z, 0.0 );
891 pt = (*aTransform) * pt;
893 lNorms[
i] =
SFVEC3F( pt.x, pt.y, pt.z );
897 meshes.push_back( m );
SFVEC3F * m_Normals
Vertex normals array.
defines a vertex coordinate set for a scenegraph object
void addNodeRef(SGNODE *aNode)
Function addNodeRef adds a pointer to a node which references, but does not own, this node.
SGCOORDINDEX * m_CoordIndices
bool ReadCache(std::istream &aFile, SGNODE *parentNode) override
Function ReadCache Reads binary format data from a cache file.
Class SGCOORDINDEX is a class which maintains a coordinate index list.
void unlinkChildNode(const SGNODE *aNode) override
Function unlinkChild removes references to an owned child; it is invoked by the child upon destructio...
SGNODE * FindNode(const char *aNodeName, const SGNODE *aCaller) override
Function FindNode searches the tree of linked nodes and returns a reference to the first node found w...
bool ReadCache(std::istream &aFile, SGNODE *parentNode) override
Function ReadCache Reads binary format data from a cache file.
bool GetColorList(size_t &aListSize, SGCOLOR *&aColorList)
SGNODE * GetParent(void) const
Function GetParent returns a pointer to the parent SGNODE of this object or NULL if the object has no...
defines a set of vertex normals for a scene graph object
void unlinkNode(const SGNODE *aNode, bool isChild)
bool GetMatIndex(MATLIST &aList, SGNODE *aNode, int &aIndex)
bool WriteVRML(std::ostream &aFile, bool aReuseFlag) override
Function WriteVRML writes this node's data to a VRML file; this includes all data of child and refere...
bool addNode(SGNODE *aNode, bool isChild)
bool WriteCache(std::ostream &aFile, SGNODE *parentNode) override
Function WriteCache write's this node's data to a binary cache file; the data includes all data of ch...
bool GetCoordsList(size_t &aListSize, SGPOINT *&aCoordsList)
virtual bool SetParent(SGNODE *aParent, bool notify=true) override
Function SetParent sets the parent SGNODE of this object.
Class SGNODE represents the base class of all Scene Graph nodes.
SFVEC3F * m_Positions
Vertex position array.
void delNodeRef(const SGNODE *aNode)
Function delNodeRef removes a pointer to a node which references, but does not own,...
bool Prepare(const glm::dmat4 *aTransform, S3D::MATLIST &materials, std::vector< SMESH > &meshes)
bool WriteCache(std::ostream &aFile, SGNODE *parentNode) override
Function WriteCache write's this node's data to a binary cache file; the data includes all data of ch...
Per-vertex normal/color/texcoors structure.
void ReNameNodes(void) override
Function ReNameNodes renames a node and all its child nodes in preparation for Write() operations.
bool ReadCache(std::istream &aFile, SGNODE *parentNode) override
Function ReadCache Reads binary format data from a cache file.
unsigned int m_FaceIdxSize
Number of elements of the m_FaceIdx array.
void ReNameNodes(void) override
Function ReNameNodes renames a node and all its child nodes in preparation for Write() operations.
SGNODE * FindNode(const char *aNodeName, const SGNODE *aCaller) override
Function FindNode searches the tree of linked nodes and returns a reference to the first node found w...
unsigned int m_VertexSize
Number of vertex in the arrays.
const char * GetName(void)
defines the generic material appearance of a scenegraph object
SGAPPEARANCE * m_Appearance
defines a complex 3D shape for a scenegraph object
bool AddRefNode(SGNODE *aNode) override
S3D::SGTYPES ReadTag(std::istream &aFile, std::string &aName)
Function ReadTag reads the text tag of a binary cache file which is the NodeTag and unique ID number ...
virtual void unlinkChildNode(const SGNODE *aNode)=0
Function unlinkChild removes references to an owned child; it is invoked by the child upon destructio...
defines an coordinate index set for a scenegraph object
bool GetIndices(size_t &nIndices, int *&aIndexList)
Function GetIndices retrieves the number of indices and a pointer to the list.
bool SwapParent(SGNODE *aNewParent)
Function SwapParent swaps the ownership with the given parent.
S3D::SGTYPES GetNodeType(void) const
Function GetNodeType returns the type of this node instance.
void ReNameNodes(void) override
Function ReNameNodes renames a node and all its child nodes in preparation for Write() operations.
SFVEC3F * m_Color
Vertex color array, can be NULL.
void GetVector(double &aXVal, double &aYVal, double &aZVal) const
defines an indexed face set for a scenegraph
virtual SGNODE * FindNode(const char *aNodeName, const SGNODE *aCaller)=0
Function FindNode searches the tree of linked nodes and returns a reference to the first node found w...
SGNODE * FindNode(const char *aNodeName, const SGNODE *aCaller) override
Function FindNode searches the tree of linked nodes and returns a reference to the first node found w...
void SetName(const char *aName)
virtual bool SetParent(SGNODE *aParent, bool notify=true) override
Function SetParent sets the parent SGNODE of this object.
virtual bool WriteCache(std::ostream &aFile, SGNODE *parentNode)=0
Function WriteCache write's this node's data to a binary cache file; the data includes all data of ch...
bool WriteVRML(std::ostream &aFile, bool aReuseFlag) override
Function WriteVRML writes this node's data to a VRML file; this includes all data of child and refere...
void GetColor(float &aRedVal, float &aGreenVal, float &aBlueVal) const
void INIT_SMESH(SMESH &aMesh)
defines an RGB color set for a scenegraph object
unsigned int m_MaterialIdx
Material Index to be used in this mesh (must be < m_MaterialsSize )
bool WriteVRML(std::ostream &aFile, bool aReuseFlag) override
Function WriteVRML writes this node's data to a VRML file; this includes all data of child and refere...
bool AddChildNode(SGNODE *aNode) override
virtual bool AddChildNode(SGNODE *aNode)=0
SGAPPEARANCE * m_RAppearance
defines a number of macro functions to aid in repetitious code which is probably best expressed as a ...
unsigned int * m_FaceIdx
Triangle Face Indexes.
bool WriteCache(std::ostream &aFile, SGNODE *parentNode) override
Function WriteCache write's this node's data to a binary cache file; the data includes all data of ch...
void unlinkRefNode(const SGNODE *aNode) override
Function unlinkRef removes pointers to a referenced node; it is invoked by the referenced node upon d...
bool GetNormalList(size_t &aListSize, SGVECTOR *&aNormalList)
bool isWritten(void)
Function IsWritten returns true if the object had already been written to a cache file or VRML file; ...
virtual bool SetParent(SGNODE *aParent, bool notify=true) override
Function SetParent sets the parent SGNODE of this object.