52        wxLogTrace( MASK_3D_SG, wxT( 
"%s:%s:%d * [BUG] inappropriate parent to SGSHAPE (type %d)" ),
 
   53                    __FILE__, __FUNCTION__, __LINE__, aParent->GetNodeType() );
 
   57        m_Parent->AddChildNode( this );
 
 
  107        if( 
nullptr == aParent )
 
 
  126    if( 
nullptr == aNodeName || 0 == aNodeName[0] )
 
  129    if( !
m_Name.compare( aNodeName ) )
 
  146        tmp = 
m_FaceSet->FindNode( aNodeName, 
this );
 
  158    return m_Parent->FindNode( aNodeName, 
this );
 
 
  164    if( 
nullptr == aNode )
 
  198    wxLogTrace( MASK_3D_SG, wxT( 
"%s:%s:%d * [BUG] unlinkNode() did not find its target" ),
 
  199                __FILE__, __FUNCTION__, __LINE__ );
 
 
  217    wxCHECK( aNode, 
false );
 
  225                wxLogTrace( MASK_3D_SG, wxT( 
"%s:%s:%d * [BUG] assigning multiple Appearance " 
  227                            __FILE__, __FUNCTION__, __LINE__ );
 
  255                wxLogTrace( MASK_3D_SG, wxT( 
"%s:%s:%d * [BUG] assigning multiple FaceSet nodes" ),
 
  256                            __FILE__, __FUNCTION__, __LINE__ );
 
  278    wxLogTrace( MASK_3D_SG, wxT( 
"%s:%s:%d * [BUG] object %s is not a valid type for this " 
 
  288    return addNode( aNode, 
false );
 
 
  327            aFile << 
"DEF " << 
GetName() << 
" Shape {\n";
 
  332            aFile << 
" USE " << 
GetName() << 
"\n";
 
  338        aFile << 
" Shape {\n";
 
  348        m_FaceSet->WriteVRML( aFile, aReuseFlag );
 
 
  361    if( 
nullptr == parentNode )
 
  379    wxCHECK( parentNode == 
m_Parent, 
false );
 
  383        wxLogTrace( MASK_3D_SG, wxT( 
"%s:%s:%d * [BUG] bad stream" ),
 
  384                    __FILE__, __FUNCTION__, __LINE__ );
 
  396    aFile << 
"[" << 
GetName() << 
"]";
 
  401    for( i = 0; i < 
NITEMS; ++i )
 
  424    for( 
int jj = 0; jj < 
NITEMS; ++jj )
 
  425        aFile.write( (
char*)&items[jj], 
sizeof(
bool) );
 
 
  455    for( 
int i = 0; i < 
NITEMS; ++i )
 
  456        aFile.read( (
char*)&items[i], 
sizeof(
bool) );
 
  458    if( ( items[0] && items[1] ) || ( items[2] && items[3] ) )
 
  460        wxLogTrace( MASK_3D_SG, wxT( 
"%s:%s:%d * [INFO] corrupt data; multiple item definitions " 
  462                    __FILE__, __FUNCTION__, __LINE__,
 
  463                    static_cast<unsigned long>( aFile.tellg() ) );
 
  474            wxLogTrace( MASK_3D_SG, wxT( 
"%s:%s:%d * [INFO] corrupt data; bad child appearance " 
  475                                         "tag at position %ul" ),
 
  476                        __FILE__, __FUNCTION__, __LINE__,
 
  477                        static_cast<unsigned long>( aFile.tellg() ) );
 
  487            wxLogTrace( MASK_3D_SG, wxT( 
"%s:%s:%d * [INFO] corrupt data while reading appearance " 
  489                        __FILE__, __FUNCTION__, __LINE__, 
name );
 
  499            wxLogTrace( MASK_3D_SG, wxT( 
"%s:%s:%d * [INFO] corrupt data; bad ref appearance tag " 
  501                        __FILE__, __FUNCTION__, __LINE__,
 
  502                        static_cast<unsigned long>( aFile.tellg() ) );
 
  511            wxLogTrace( MASK_3D_SG, wxT( 
"%s:%s:%d * [INFO] corrupt data: cannot find ref " 
  513                        __FILE__, __FUNCTION__, __LINE__,
 
  521            wxLogTrace( MASK_3D_SG, wxT( 
"%s:%s:%d * [INFO] corrupt data: type is not " 
  522                                         "SGAPPEARANCE '%s'" ),
 
  523                        __FILE__, __FUNCTION__, __LINE__,
 
  537            wxLogTrace( MASK_3D_SG, wxT( 
"%s:%s:%d * [INFO] corrupt data; bad child face set tag " 
  539                        __FILE__, __FUNCTION__, __LINE__,
 
  540                        static_cast<unsigned long>( aFile.tellg() ) );
 
  548        if( !
m_FaceSet->ReadCache( aFile, 
this ) )
 
  550            wxLogTrace( MASK_3D_SG, wxT( 
"%s:%s:%d * [INFO] corrupt data while reading face set " 
  552                        __FILE__, __FUNCTION__, __LINE__, 
name );
 
  562            wxLogTrace( MASK_3D_SG, wxT( 
"%s:%s:%d * [INFO] corrupt data; bad ref face set tag at " 
  564                        __FILE__, __FUNCTION__, __LINE__,
 
  565                        static_cast<unsigned long>( aFile.tellg() ) );
 
  574            wxLogTrace( MASK_3D_SG, wxT( 
"%s:%s:%d * [INFO] corrupt data: cannot find ref face " 
  576                        __FILE__, __FUNCTION__, __LINE__,
 
  584            wxLogTrace( MASK_3D_SG, wxT( 
"%s:%s:%d * [INFO] corrupt data: type is not SGFACESET " 
  586                        __FILE__, __FUNCTION__, __LINE__,
 
 
  604                       std::vector< SMESH >& meshes )
 
  624        wxLogTrace( MASK_3D_SG, wxT( 
"%s:%s:%d * [INFO] bad model; inconsistent data" ),
 
  625                    __FILE__, __FUNCTION__, __LINE__ );
 
  675        if( nColors < nCoords )
 
  677            wxLogTrace( MASK_3D_SG, wxT( 
"%s:%s:%d * [INFO] bad model; not enough colors per " 
  678                                         "vertex (%ul vs %ul)" ),
 
  679                        __FILE__, __FUNCTION__, __LINE__, 
static_cast<unsigned long>( nColors ),
 
  680                        static_cast<unsigned long>( nCoords ) );
 
  692    std::vector< int > vertices;            
 
  693    std::map< int, unsigned int > indexmap; 
 
  694    std::map< int, unsigned int >::iterator mit;
 
  696    for( 
unsigned int i = 0; i < nvidx; ++i )
 
  698        mit = indexmap.find( lv[i] );
 
  700        if( mit == indexmap.end() )
 
  702            indexmap.emplace( lv[i], vertices.size() );
 
  703            vertices.push_back( lv[i] );
 
  707    if( vertices.size() < 3 )
 
  709        wxLogTrace( MASK_3D_SG, wxT( 
"%s:%s:%d * [INFO] bad model; not enough vertices" ),
 
  710                    __FILE__, __FUNCTION__, __LINE__ );
 
  722        lColors = 
new SFVEC3F[vertices.size()];
 
  728        for( 
size_t i = 0; i < vertices.size(); ++i )
 
  731            glm::dvec4 pt( pCoords[ti].x, pCoords[ti].y, pCoords[ti].z, 1.0 );
 
  732            pt = (*aTransform) * pt;
 
  733            pColors[ti].
GetColor( lColors[i].x, lColors[i].y, lColors[i].z );
 
  734            lCoords[i] = 
SFVEC3F( pt.x, pt.y, pt.z );
 
  739        for( 
size_t i = 0; i < vertices.size(); ++i )
 
  742            glm::dvec4 pt( pCoords[ti].x, pCoords[ti].y, pCoords[ti].z, 1.0 );
 
  743            pt = (*aTransform) * pt;
 
  744            lCoords[i] = 
SFVEC3F( pt.x, pt.y, pt.z );
 
  750    unsigned int* lvidx = 
new unsigned int[ nvidx ];
 
  752    for( 
unsigned int i = 0; i < nvidx; ++i )
 
  754        mit = indexmap.find( lv[i] );
 
  756        if( mit != indexmap.end() )
 
  757            lvidx[i] = mit->second;
 
  771    for( 
size_t i = 0; i < vertices.size(); ++i )
 
  775        glm::dvec4 pt( x, y, z, 0.0 );
 
  776        pt = (*aTransform) * pt;
 
  778        lNorms[i] = 
SFVEC3F( pt.x, pt.y, pt.z );
 
  782    meshes.push_back( m );
 
 
Defines the generic material appearance of a scenegraph object.
 
Define an RGB color set for a scenegraph object.
 
bool GetColorList(size_t &aListSize, SGCOLOR *&aColorList)
 
void GetColor(float &aRedVal, float &aGreenVal, float &aBlueVal) const noexcept
 
An object to maintain a coordinate index list.
 
Define a vertex coordinate set for a scenegraph object.
 
bool GetCoordsList(size_t &aListSize, SGPOINT *&aCoordsList)
 
Define an indexed face set for a scenegraph.
 
SGCOORDINDEX * m_CoordIndices
 
bool GetIndices(size_t &nIndices, int *&aIndexList)
Retrieve the number of indices and a pointer to the list.
 
virtual bool WriteCache(std::ostream &aFile, SGNODE *parentNode)=0
Write this node's data to a binary cache file.
 
const char * GetName(void)
 
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.
 
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 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.
 
Define a set of vertex normals for a scene graph object.
 
bool GetNormalList(size_t &aListSize, SGVECTOR *&aNormalList)
 
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 WriteVRML(std::ostream &aFile, bool aReuseFlag) override
Writes this node's data to a VRML file.
 
virtual bool SetParent(SGNODE *aParent, bool notify=true) override
Set the parent SGNODE of this object.
 
bool AddChildNode(SGNODE *aNode) override
 
void unlinkRefNode(const SGNODE *aNode) override
Remove pointers to a referenced node.
 
void unlinkNode(const SGNODE *aNode, bool isChild)
 
bool Prepare(const glm::dmat4 *aTransform, S3D::MATLIST &materials, std::vector< SMESH > &meshes)
 
bool AddRefNode(SGNODE *aNode) override
 
void ReNameNodes(void) override
Rename a node and all its child nodes in preparation for write operations.
 
bool addNode(SGNODE *aNode, bool isChild)
 
void unlinkChildNode(const SGNODE *aNode) override
Remove references to an owned child.
 
bool WriteCache(std::ostream &aFile, SGNODE *parentNode) override
Write this node's data to a binary cache file.
 
SGAPPEARANCE * m_RAppearance
 
bool ReadCache(std::istream &aFile, SGNODE *parentNode) override
Reads binary format data from a cache file.
 
SGAPPEARANCE * m_Appearance
 
void GetVector(double &aXVal, double &aYVal, double &aZVal) const noexcept
 
void INIT_SMESH(SMESH &aMesh) noexcept
 
bool GetMatIndex(MATLIST &aList, SGNODE *aNode, int &aIndex)
 
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...
 
Per-vertex normal/color/texcoors structure.
 
unsigned int * m_FaceIdx
Triangle Face Indexes.
 
SFVEC3F * m_Normals
Vertex normals array.
 
unsigned int m_MaterialIdx
Material Index to be used in this mesh (must be < m_MaterialsSize )
 
unsigned int m_VertexSize
Number of vertex in the arrays.
 
unsigned int m_FaceIdxSize
Number of elements of the m_FaceIdx array.
 
SFVEC3F * m_Color
Vertex color array, can be NULL.
 
SFVEC3F * m_Positions
Vertex position array.