Loading 3d-viewer/vrml_aux.cpp +63 −56 Original line number Original line Diff line number Diff line Loading @@ -56,8 +56,7 @@ char SkipGetChar ( FILE* File ) return EOF; return EOF; } } } } while( (c == ' ') || (c == '\t') || (c == '{') || (c == '[') ); while((c == ' ') || (c == '\t') || (c == '{') || (c == '[')); } } if( (c == '#') || (c == '\n') || (c == '\r') || (c == 0) || (c == ',') ) if( (c == '#') || (c == '\n') || (c == '\r') || (c == 0) || (c == ',') ) Loading @@ -72,8 +71,7 @@ char SkipGetChar ( FILE* File ) // DBG( printf( "EOF\n" ) ); // DBG( printf( "EOF\n" ) ); return EOF; return EOF; } } } } while( (c != '\n') && (c != '\r') && (c != 0) && (c != ',') ); while((c != '\n') && (c != '\r') && (c != 0) && (c != ',')); } } else else { { Loading @@ -94,27 +92,30 @@ char SkipGetChar ( FILE* File ) char* GetNextTag( FILE* File, char* tag ) char* GetNextTag( FILE* File, char* tag ) { { char c = SkipGetChar( File ); char c = SkipGetChar( File ); if( c == EOF ) if( c == EOF ) { { return NULL; return NULL; } } tag[0] = c; tag[0] = c; tag[1] = 0; tag[1] = 0; // DBG( printf( "tag[0] %c\n", tag[0] ) ); // DBG( printf( "tag[0] %c\n", tag[0] ) ); if( (c != '}') && (c != ']') ) if( (c != '}') && (c != ']') ) { { char* dst = &tag[1]; char* dst = &tag[1]; while( fscanf( File, "%c", dst ) ) while( fscanf( File, "%c", dst ) ) { { if( (*dst == ' ') || (*dst == '[') || (*dst == '{') || if( (*dst == ' ') || (*dst == '[') || (*dst == '{') (*dst == '\t') || (*dst == '\n')|| (*dst == '\r') ) || (*dst == '\t') || (*dst == '\n')|| (*dst == '\r') ) { { *dst = 0; *dst = 0; break; break; } } dst++; dst++; } } Loading @@ -136,6 +137,7 @@ char* GetNextTag( FILE* File, char* tag ) int read_NotImplemented( FILE* File, char closeChar ) int read_NotImplemented( FILE* File, char closeChar ) { { char c; char c; // DBG( printf( "look for %c\n", closeChar) ); // DBG( printf( "look for %c\n", closeChar) ); while( ( c = fgetc( File ) ) != EOF ) while( ( c = fgetc( File ) ) != EOF ) { { Loading @@ -143,18 +145,20 @@ int read_NotImplemented( FILE* File, char closeChar) { { // DBG( printf( "{\n") ); // DBG( printf( "{\n") ); read_NotImplemented( File, '}' ); read_NotImplemented( File, '}' ); } else if( c == '[' ) } else if( c == '[' ) { { // DBG( printf( "[\n") ); // DBG( printf( "[\n") ); read_NotImplemented( File, ']' ); read_NotImplemented( File, ']' ); } else if( c == closeChar ) } else if( c == closeChar ) { { // DBG( printf( "%c\n", closeChar) ); // DBG( printf( "%c\n", closeChar) ); return 0; return 0; } } } } DBG( printf( " NotImplemented failed\n" ) ); // DBG( printf( " NotImplemented failed\n" ) ); return -1; return -1; } } Loading @@ -166,6 +170,7 @@ int parseVertexList( FILE* File, std::vector< glm::vec3 > &dst_vector) dst_vector.clear(); dst_vector.clear(); glm::vec3 vertex; glm::vec3 vertex; while( parseVertex( File, vertex ) == 3 ) while( parseVertex( File, vertex ) == 3 ) { { dst_vector.push_back( vertex ); dst_vector.push_back( vertex ); Loading @@ -191,6 +196,7 @@ int parseVertex( FILE* File, glm::vec3 &dst_vertex ) // Puts again the read char in the buffer // Puts again the read char in the buffer ungetc( s, File ); ungetc( s, File ); } } // DBG( printf( "ret%d(%.9f,%.9f,%.9f)", ret, a,b,c) ); // DBG( printf( "ret%d(%.9f,%.9f,%.9f)", ret, a,b,c) ); return ret; return ret; Loading @@ -201,6 +207,7 @@ int parseFloat( FILE* File, float *dst_float ) { { float value; float value; int ret = fscanf( File, "%e", &value ); int ret = fscanf( File, "%e", &value ); *dst_float = value; *dst_float = value; return ret; return ret; Loading 3d-viewer/vrml_v1_modelparser.cpp +84 −78 Original line number Original line Diff line number Diff line Loading @@ -71,9 +71,12 @@ void VRML1_MODEL_PARSER::Load( const wxString aFilename ) float vrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits * UNITS3D_TO_UNITSPCB; float vrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits * UNITS3D_TO_UNITSPCB; glScalef( vrmlunits_to_3Dunits, vrmlunits_to_3Dunits, vrmlunits_to_3Dunits ); glScalef( vrmlunits_to_3Dunits, vrmlunits_to_3Dunits, vrmlunits_to_3Dunits ); glm::vec3 matScale( GetMaster()->m_MatScale.x, GetMaster()->m_MatScale.y, GetMaster()->m_MatScale.z ); glm::vec3 matScale( GetMaster()->m_MatScale.x, GetMaster()->m_MatScale.y, glm::vec3 matRot( GetMaster()->m_MatRotation.x, GetMaster()->m_MatRotation.y, GetMaster()->m_MatRotation.z ); GetMaster()->m_MatScale.z ); glm::vec3 matPos( GetMaster()->m_MatPosition.x, GetMaster()->m_MatPosition.y, GetMaster()->m_MatPosition.z ); glm::vec3 matRot( GetMaster()->m_MatRotation.x, GetMaster()->m_MatRotation.y, GetMaster()->m_MatRotation.z ); glm::vec3 matPos( GetMaster()->m_MatPosition.x, GetMaster()->m_MatPosition.y, GetMaster()->m_MatPosition.z ); #define SCALE_3D_CONV ( (IU_PER_MILS * 1000.0f) / UNITS3D_TO_UNITSPCB ) #define SCALE_3D_CONV ( (IU_PER_MILS * 1000.0f) / UNITS3D_TO_UNITSPCB ) Loading @@ -94,7 +97,6 @@ void VRML1_MODEL_PARSER::Load( const wxString aFilename ) while( GetNextTag( m_file, text ) ) while( GetNextTag( m_file, text ) ) { { if( ( text == NULL ) || ( *text == '}' ) || ( *text == ']' ) ) if( ( text == NULL ) || ( *text == '}' ) || ( *text == ']' ) ) { { continue; continue; Loading Loading @@ -123,6 +125,7 @@ void VRML1_MODEL_PARSER::Load( const wxString aFilename ) } } } } int VRML1_MODEL_PARSER::read_separator() int VRML1_MODEL_PARSER::read_separator() { { char text[128]; char text[128]; Loading @@ -131,7 +134,6 @@ int VRML1_MODEL_PARSER::read_separator() while( GetNextTag( m_file, text ) ) while( GetNextTag( m_file, text ) ) { { if( strcmp( text, "Material" ) == 0 ) if( strcmp( text, "Material" ) == 0 ) { { readMaterial(); readMaterial(); Loading Loading @@ -290,6 +292,7 @@ int VRML1_MODEL_PARSER::readIndexedFaceSet( ) return -1; return -1; } } int VRML1_MODEL_PARSER::readMaterial_ambientColor() int VRML1_MODEL_PARSER::readMaterial_ambientColor() { { // DBG( printf( " readMaterial_ambientColor\n" ) ); // DBG( printf( " readMaterial_ambientColor\n" ) ); Loading Loading @@ -408,6 +411,7 @@ int VRML1_MODEL_PARSER::readIndexedFaceSet_coordIndex() glm::ivec3 coord; glm::ivec3 coord; int dummy; // should be -1 int dummy; // should be -1 while( fscanf( m_file, "%d,%d,%d,%d,", &coord[0], &coord[1], &coord[2], &dummy ) ) while( fscanf( m_file, "%d,%d,%d,%d,", &coord[0], &coord[1], &coord[2], &dummy ) ) { { std::vector<int> coord_list; std::vector<int> coord_list; Loading @@ -417,9 +421,9 @@ int VRML1_MODEL_PARSER::readIndexedFaceSet_coordIndex() coord_list[1] = coord[1]; coord_list[1] = coord[1]; coord_list[2] = coord[2]; coord_list[2] = coord[2]; if( (coord[0] == coord[1]) || if( (coord[0] == coord[1]) (coord[0] == coord[2]) || || (coord[0] == coord[2]) (coord[2] == coord[1]) ) || (coord[2] == coord[1]) ) { { // DBG( printf( " invalid coordIndex at index %lu (%d, %d, %d, %d)\n", m_model->m_CoordIndex.size()+1,coord[0], coord[1], coord[2], dummy ) ); // DBG( printf( " invalid coordIndex at index %lu (%d, %d, %d, %d)\n", m_model->m_CoordIndex.size()+1,coord[0], coord[1], coord[2], dummy ) ); } } Loading @@ -428,6 +432,7 @@ int VRML1_MODEL_PARSER::readIndexedFaceSet_coordIndex() { { // DBG( printf( " Error at index %lu, -1 Expected, got %d\n", m_model->m_CoordIndex.size()+1, dummy ) ); // DBG( printf( " Error at index %lu, -1 Expected, got %d\n", m_model->m_CoordIndex.size()+1, dummy ) ); } } m_model->m_CoordIndex.push_back( coord_list ); m_model->m_CoordIndex.push_back( coord_list ); } } Loading @@ -444,6 +449,7 @@ int VRML1_MODEL_PARSER::readIndexedFaceSet_materialIndex() m_model->m_MaterialIndex.clear(); m_model->m_MaterialIndex.clear(); int index; int index; while( fscanf( m_file, "%d,", &index ) ) while( fscanf( m_file, "%d,", &index ) ) { { m_model->m_MaterialIndex.push_back( index ); m_model->m_MaterialIndex.push_back( index ); Loading 3d-viewer/vrml_v2_modelparser.cpp +145 −140 Original line number Original line Diff line number Diff line Loading @@ -98,7 +98,6 @@ void VRML2_MODEL_PARSER::Load( const wxString aFilename ) while( GetNextTag( m_file, text ) ) while( GetNextTag( m_file, text ) ) { { if( ( text == NULL ) || ( *text == '}' ) || ( *text == ']' ) ) if( ( text == NULL ) || ( *text == '}' ) || ( *text == ']' ) ) { { continue; continue; Loading @@ -110,7 +109,6 @@ void VRML2_MODEL_PARSER::Load( const wxString aFilename ) childs.push_back( m_model ); childs.push_back( m_model ); read_Transform(); read_Transform(); } } else if( strcmp( text, "DEF" ) == 0 ) else if( strcmp( text, "DEF" ) == 0 ) { { Loading Loading @@ -149,11 +147,13 @@ int VRML2_MODEL_PARSER::read_Transform() { { continue; continue; } } if( ( *text == '}' ) ) if( ( *text == '}' ) ) { { // DBG( printf( " } Exit Transform\n" ) ); // DBG( printf( " } Exit Transform\n" ) ); break; break; } } if( strcmp( text, "translation" ) == 0 ) if( strcmp( text, "translation" ) == 0 ) { { parseVertex( m_file, m_model->m_translation ); parseVertex( m_file, m_model->m_translation ); Loading Loading @@ -210,6 +210,7 @@ int VRML2_MODEL_PARSER::read_Transform() else if( strcmp( text, "whichChoice" ) == 0 ) else if( strcmp( text, "whichChoice" ) == 0 ) { { int dummy; int dummy; if( fscanf( m_file, "%d", &dummy ) != 1 ) if( fscanf( m_file, "%d", &dummy ) != 1 ) { { // !TODO: log errors // !TODO: log errors Loading @@ -236,7 +237,6 @@ int VRML2_MODEL_PARSER::read_Transform() read_Shape(); read_Shape(); m_model = parent; m_model = parent; } } else if( strcmp( text, "DEF" ) == 0 ) else if( strcmp( text, "DEF" ) == 0 ) { { Loading @@ -244,10 +244,11 @@ int VRML2_MODEL_PARSER::read_Transform() } } else else { { DBG( printf( " %s NotImplemented\n", text ) ); // DBG( printf( " %s NotImplemented\n", text ) ); read_NotImplemented( m_file, '}' ); read_NotImplemented( m_file, '}' ); } } } } return 0; return 0; } } Loading Loading @@ -276,7 +277,8 @@ int VRML2_MODEL_PARSER::read_DEF() if( strcmp( text, "Transform" ) == 0 ) if( strcmp( text, "Transform" ) == 0 ) { { return read_Transform(); return read_Transform(); } else if( strcmp( text, "children" ) == 0 ) } else if( strcmp( text, "children" ) == 0 ) { { // skip // skip } } Loading Loading @@ -304,7 +306,7 @@ int VRML2_MODEL_PARSER::read_DEF() } } } } DBG( printf( " DEF failed\n" ) ); // DBG( printf( " DEF failed\n" ) ); return -1; return -1; } } Loading Loading @@ -346,12 +348,12 @@ int VRML2_MODEL_PARSER::read_Shape() } } else else { { DBG( printf( " %s NotImplemented\n", text ) ); // DBG( printf( " %s NotImplemented\n", text ) ); read_NotImplemented( m_file, '}' ); read_NotImplemented( m_file, '}' ); } } } } DBG( printf( " Shape failed\n") ); // DBG( printf( " Shape failed\n" ) ); return -1; return -1; } } Loading Loading @@ -380,7 +382,7 @@ int VRML2_MODEL_PARSER::read_Appearance() } } } } DBG( printf( " Appearance failed\n") ); // DBG( printf( " Appearance failed\n" ) ); return -1; return -1; } } Loading Loading @@ -449,12 +451,13 @@ int VRML2_MODEL_PARSER::read_material() return 0; return 0; } } } } DBG( printf( " read_material error: material not found\n" ) ); DBG( printf( " read_material error: material not found\n" ) ); } } } } } } DBG( printf( " failed material\n") ); // DBG( printf( " failed material\n" ) ); return -1; return -1; } } Loading Loading @@ -484,10 +487,12 @@ int VRML2_MODEL_PARSER::read_Material() parseVertex( m_file, vertex ); parseVertex( m_file, vertex ); // DBG( printf( "\n") ); // DBG( printf( "\n") ); m_model->m_Materials->m_DiffuseColor.push_back( vertex ); m_model->m_Materials->m_DiffuseColor.push_back( vertex ); } else if( strcmp( text, "emissiveColor" ) == 0 ) } else if( strcmp( text, "emissiveColor" ) == 0 ) { { // DBG( printf( " emissiveColor") ); // DBG( printf( " emissiveColor") ); parseVertex( m_file, vertex ); parseVertex( m_file, vertex ); // DBG( printf( "\n") ); // DBG( printf( "\n") ); if( GetMaster()->m_use_modelfile_emissiveColor == true ) if( GetMaster()->m_use_modelfile_emissiveColor == true ) { { Loading @@ -513,7 +518,8 @@ int VRML2_MODEL_PARSER::read_Material() if( GetMaster()->m_use_modelfile_ambientIntensity == true ) if( GetMaster()->m_use_modelfile_ambientIntensity == true ) { { m_model->m_Materials->m_AmbientColor.push_back( glm::vec3( ambientIntensity, ambientIntensity, ambientIntensity ) ); m_model->m_Materials->m_AmbientColor.push_back( glm::vec3( ambientIntensity, ambientIntensity, ambientIntensity ) ); } } } } else if( strcmp( text, "transparency" ) == 0 ) else if( strcmp( text, "transparency" ) == 0 ) Loading Loading @@ -542,7 +548,7 @@ int VRML2_MODEL_PARSER::read_Material() } } } } DBG( printf( " Material failed\n") ); // DBG( printf( " Material failed\n" ) ); return -1; return -1; } } Loading Loading @@ -583,6 +589,7 @@ int VRML2_MODEL_PARSER::read_IndexedFaceSet() else if( strcmp( text, "colorPerVertex" ) == 0 ) else if( strcmp( text, "colorPerVertex" ) == 0 ) { { GetNextTag( m_file, text ); GetNextTag( m_file, text ); if( strcmp( text, "TRUE" ) ) if( strcmp( text, "TRUE" ) ) { { // DBG( printf( " colorPerVertex = true\n") ); // DBG( printf( " colorPerVertex = true\n") ); Loading @@ -592,7 +599,6 @@ int VRML2_MODEL_PARSER::read_IndexedFaceSet() { { colorPerVertex = false; colorPerVertex = false; } } } } else if( strcmp( text, "Coordinate" ) == 0 ) else if( strcmp( text, "Coordinate" ) == 0 ) { { Loading @@ -618,10 +624,9 @@ int VRML2_MODEL_PARSER::read_IndexedFaceSet() { { read_colorIndex(); read_colorIndex(); } } } } DBG( printf( " IndexedFaceSet failed %s\n", text) ); // DBG( printf( " IndexedFaceSet failed %s\n", text ) ); return -1; return -1; } } Loading @@ -636,6 +641,7 @@ int VRML2_MODEL_PARSER::read_colorIndex() { { int index; int index; int first_index; int first_index; while( fscanf( m_file, "%d, ", &index ) ) while( fscanf( m_file, "%d, ", &index ) ) { { if( index == -1 ) if( index == -1 ) Loading Loading @@ -677,6 +683,7 @@ int VRML2_MODEL_PARSER::read_NormalIndex() std::vector<int> coord_list; std::vector<int> coord_list; coord_list.clear(); coord_list.clear(); while( fscanf( m_file, "%d, ", &dummy ) == 1 ) while( fscanf( m_file, "%d, ", &dummy ) == 1 ) { { if( dummy == -1 ) if( dummy == -1 ) Loading Loading @@ -710,6 +717,7 @@ int VRML2_MODEL_PARSER::read_coordIndex() std::vector<int> coord_list; std::vector<int> coord_list; coord_list.clear(); coord_list.clear(); while( fscanf( m_file, "%d, ", &dummy ) == 1 ) while( fscanf( m_file, "%d, ", &dummy ) == 1 ) { { if( dummy == -1 ) if( dummy == -1 ) Loading Loading @@ -761,8 +769,6 @@ int VRML2_MODEL_PARSER::read_Color() } } int VRML2_MODEL_PARSER::read_Normal() int VRML2_MODEL_PARSER::read_Normal() { { char text[128]; char text[128]; Loading Loading @@ -828,4 +834,3 @@ int VRML2_MODEL_PARSER::read_Coordinate() return -1; return -1; } } 3d-viewer/vrmlmodelparser.cpp +8 −7 Original line number Original line Diff line number Diff line Loading @@ -79,6 +79,7 @@ void VRML_MODEL_PARSER::Load( const wxString aFilename ) return; return; } } fclose( file ); fclose( file ); Loading @@ -97,5 +98,5 @@ void VRML_MODEL_PARSER::Load( const wxString aFilename ) return; return; } } DBG( printf( "Unknown VRML file format: %s\n", line ) ); // DBG( printf( "Unknown VRML file format: %s\n", line ) ); } } 3d-viewer/x3dmodelparser.cpp +94 −88 Original line number Original line Diff line number Diff line Loading @@ -43,11 +43,13 @@ X3D_MODEL_PARSER::X3D_MODEL_PARSER( S3D_MASTER* aMaster ) : X3D_MODEL_PARSER::X3D_MODEL_PARSER( S3D_MASTER* aMaster ) : S3D_MODEL_PARSER( aMaster ) S3D_MODEL_PARSER( aMaster ) {} { } X3D_MODEL_PARSER::~X3D_MODEL_PARSER() X3D_MODEL_PARSER::~X3D_MODEL_PARSER() {} { } void X3D_MODEL_PARSER::Load( const wxString aFilename ) void X3D_MODEL_PARSER::Load( const wxString aFilename ) Loading Loading @@ -197,11 +199,13 @@ void X3D_MODEL_PARSER::GetNodeProperties( wxXmlNode* aNode, PROPERTY_MAP& aProps } } } } /* Private ----- */ /* Private ----- */ void X3D_MODEL_PARSER::readTransform( wxXmlNode* aTransformNode ) void X3D_MODEL_PARSER::readTransform( wxXmlNode* aTransformNode ) { { NODE_LIST childnodes; NODE_LIST childnodes; GetChildsByName( aTransformNode, wxT( "Material" ), childnodes ); GetChildsByName( aTransformNode, wxT( "Material" ), childnodes ); for( NODE_LIST::iterator node = childnodes.begin(); for( NODE_LIST::iterator node = childnodes.begin(); Loading Loading @@ -234,6 +238,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) glm::vec3 color; glm::vec3 color; PROPERTY_MAP properties; PROPERTY_MAP properties; GetNodeProperties( aMatNode, properties ); GetNodeProperties( aMatNode, properties ); // DEFine new Material named as value of DEF // DEFine new Material named as value of DEF Loading @@ -246,10 +251,9 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) m_model->m_Materials = material; m_model->m_Materials = material; if( !parseDoubleTriplet( properties[ wxT( "diffuseColor" ) ], if( !parseDoubleTriplet( properties[ wxT( "diffuseColor" ) ], color ) ) color ) ) { { DBG( printf("diffuseColor parsing error") ); // DBG( printf( "diffuseColor parsing error" ) ); } } else else { { Loading @@ -258,7 +262,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) if( !parseDoubleTriplet( properties[ wxT( "specularColor" ) ], color ) ) if( !parseDoubleTriplet( properties[ wxT( "specularColor" ) ], color ) ) { { DBG( printf("specularColor parsing error") ); // DBG( printf( "specularColor parsing error" ) ); } } else else { { Loading @@ -267,7 +271,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) if( !parseDoubleTriplet( properties[ wxT( "emissiveColor" ) ], color ) ) if( !parseDoubleTriplet( properties[ wxT( "emissiveColor" ) ], color ) ) { { DBG( printf("emissiveColor parsing error") ); // DBG( printf( "emissiveColor parsing error" ) ); } } else else { { Loading @@ -283,7 +287,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) } } else else { { DBG( printf( "ambienterror" ) ); // DBG( printf( "ambienterror" ) ); } } values.SetString( properties[ wxT( "shininess" ) ] ); values.SetString( properties[ wxT( "shininess" ) ] ); Loading @@ -296,7 +300,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) } } else else { { DBG( printf( "shininess error" ) ); // DBG( printf( "shininess error" ) ); } } values.SetString( properties[ wxT( "transparency" ) ] ); values.SetString( properties[ wxT( "transparency" ) ] ); Loading @@ -307,7 +311,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) } } else else { { DBG( printf( "trans error") ); // DBG( printf( "trans error" ) ); } } // VRML // VRML Loading @@ -321,7 +325,6 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) vrml_materials.push_back( vrml_material ); vrml_materials.push_back( vrml_material ); } } // USE existing material named by value of USE // USE existing material named by value of USE else if( properties.find( wxT( "USE" ) ) != properties.end() ) else if( properties.find( wxT( "USE" ) ) != properties.end() ) { { Loading Loading @@ -366,7 +369,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) } } } } DBG( printf( "ReadMaterial error: material not found\n" ) ); // DBG( printf( "ReadMaterial error: material not found\n" ) ); } } } } Loading @@ -378,9 +381,9 @@ bool X3D_MODEL_PARSER::parseDoubleTriplet( const wxString& aData, double x, y, z; double x, y, z; bool ret = tokens.GetNextToken().ToDouble( &x ) && bool ret = tokens.GetNextToken().ToDouble( &x ) tokens.GetNextToken().ToDouble( &y ) && && tokens.GetNextToken().ToDouble( &y ) tokens.GetNextToken().ToDouble( &z ); && tokens.GetNextToken().ToDouble( &z ); aResult.x = x; aResult.x = x; aResult.y = y; aResult.y = y; Loading Loading @@ -430,6 +433,7 @@ void X3D_MODEL_PARSER::readIndexedFaceSet( wxXmlNode* aFaceNode, * --------------------------- */ * --------------------------- */ S3D_VERTEX translation; S3D_VERTEX translation; parseDoubleTriplet( aTransformProps[ wxT( "translation" ) ], translation ); parseDoubleTriplet( aTransformProps[ wxT( "translation" ) ], translation ); S3D_VERTEX scale; S3D_VERTEX scale; Loading @@ -440,12 +444,13 @@ void X3D_MODEL_PARSER::readIndexedFaceSet( wxXmlNode* aFaceNode, wxStringTokenizer tokens( aTransformProps[ wxT( "rotation" ) ] ); wxStringTokenizer tokens( aTransformProps[ wxT( "rotation" ) ] ); double x, y, z; double x, y, z; if( !(tokens.GetNextToken().ToDouble( &x ) && tokens.GetNextToken().ToDouble( &y ) && if( !( tokens.GetNextToken().ToDouble( &x ) tokens.GetNextToken().ToDouble( &z ) && && tokens.GetNextToken().ToDouble( &y ) tokens.GetNextToken().ToDouble( &angle ) ) ) && tokens.GetNextToken().ToDouble( &z ) && tokens.GetNextToken().ToDouble( &angle ) ) ) { { DBG( printf("rotation read error") ); // DBG( printf( "rotation read error" ) ); } } else else { { Loading Loading @@ -482,7 +487,7 @@ void X3D_MODEL_PARSER::readIndexedFaceSet( wxXmlNode* aFaceNode, if( points.size() % 3 != 0 ) if( points.size() % 3 != 0 ) { { DBG( printf( "Number of points is incorrect" ) ); // DBG( printf( "Number of points is incorrect" ) ); return; return; } } Loading Loading @@ -549,13 +554,14 @@ void X3D_MODEL_PARSER::readIndexedFaceSet( wxXmlNode* aFaceNode, if( color_points.size() % 3 != 0 ) if( color_points.size() % 3 != 0 ) { { DBG( printf( "Number of points is incorrect" ) ); // DBG( printf( "Number of points is incorrect" ) ); return; return; } } /* Create 3D face color from 3 color points /* Create 3D face color from 3 color points */ */ m_model->m_Materials->m_DiffuseColor.clear(); m_model->m_Materials->m_DiffuseColor.clear(); for( unsigned id = 0; id < color_points.size() / 3; id++ ) for( unsigned id = 0; id < color_points.size() / 3; id++ ) { { m_model->m_MaterialIndex.push_back( id ); m_model->m_MaterialIndex.push_back( id ); Loading Loading
3d-viewer/vrml_aux.cpp +63 −56 Original line number Original line Diff line number Diff line Loading @@ -56,8 +56,7 @@ char SkipGetChar ( FILE* File ) return EOF; return EOF; } } } } while( (c == ' ') || (c == '\t') || (c == '{') || (c == '[') ); while((c == ' ') || (c == '\t') || (c == '{') || (c == '[')); } } if( (c == '#') || (c == '\n') || (c == '\r') || (c == 0) || (c == ',') ) if( (c == '#') || (c == '\n') || (c == '\r') || (c == 0) || (c == ',') ) Loading @@ -72,8 +71,7 @@ char SkipGetChar ( FILE* File ) // DBG( printf( "EOF\n" ) ); // DBG( printf( "EOF\n" ) ); return EOF; return EOF; } } } } while( (c != '\n') && (c != '\r') && (c != 0) && (c != ',') ); while((c != '\n') && (c != '\r') && (c != 0) && (c != ',')); } } else else { { Loading @@ -94,27 +92,30 @@ char SkipGetChar ( FILE* File ) char* GetNextTag( FILE* File, char* tag ) char* GetNextTag( FILE* File, char* tag ) { { char c = SkipGetChar( File ); char c = SkipGetChar( File ); if( c == EOF ) if( c == EOF ) { { return NULL; return NULL; } } tag[0] = c; tag[0] = c; tag[1] = 0; tag[1] = 0; // DBG( printf( "tag[0] %c\n", tag[0] ) ); // DBG( printf( "tag[0] %c\n", tag[0] ) ); if( (c != '}') && (c != ']') ) if( (c != '}') && (c != ']') ) { { char* dst = &tag[1]; char* dst = &tag[1]; while( fscanf( File, "%c", dst ) ) while( fscanf( File, "%c", dst ) ) { { if( (*dst == ' ') || (*dst == '[') || (*dst == '{') || if( (*dst == ' ') || (*dst == '[') || (*dst == '{') (*dst == '\t') || (*dst == '\n')|| (*dst == '\r') ) || (*dst == '\t') || (*dst == '\n')|| (*dst == '\r') ) { { *dst = 0; *dst = 0; break; break; } } dst++; dst++; } } Loading @@ -136,6 +137,7 @@ char* GetNextTag( FILE* File, char* tag ) int read_NotImplemented( FILE* File, char closeChar ) int read_NotImplemented( FILE* File, char closeChar ) { { char c; char c; // DBG( printf( "look for %c\n", closeChar) ); // DBG( printf( "look for %c\n", closeChar) ); while( ( c = fgetc( File ) ) != EOF ) while( ( c = fgetc( File ) ) != EOF ) { { Loading @@ -143,18 +145,20 @@ int read_NotImplemented( FILE* File, char closeChar) { { // DBG( printf( "{\n") ); // DBG( printf( "{\n") ); read_NotImplemented( File, '}' ); read_NotImplemented( File, '}' ); } else if( c == '[' ) } else if( c == '[' ) { { // DBG( printf( "[\n") ); // DBG( printf( "[\n") ); read_NotImplemented( File, ']' ); read_NotImplemented( File, ']' ); } else if( c == closeChar ) } else if( c == closeChar ) { { // DBG( printf( "%c\n", closeChar) ); // DBG( printf( "%c\n", closeChar) ); return 0; return 0; } } } } DBG( printf( " NotImplemented failed\n" ) ); // DBG( printf( " NotImplemented failed\n" ) ); return -1; return -1; } } Loading @@ -166,6 +170,7 @@ int parseVertexList( FILE* File, std::vector< glm::vec3 > &dst_vector) dst_vector.clear(); dst_vector.clear(); glm::vec3 vertex; glm::vec3 vertex; while( parseVertex( File, vertex ) == 3 ) while( parseVertex( File, vertex ) == 3 ) { { dst_vector.push_back( vertex ); dst_vector.push_back( vertex ); Loading @@ -191,6 +196,7 @@ int parseVertex( FILE* File, glm::vec3 &dst_vertex ) // Puts again the read char in the buffer // Puts again the read char in the buffer ungetc( s, File ); ungetc( s, File ); } } // DBG( printf( "ret%d(%.9f,%.9f,%.9f)", ret, a,b,c) ); // DBG( printf( "ret%d(%.9f,%.9f,%.9f)", ret, a,b,c) ); return ret; return ret; Loading @@ -201,6 +207,7 @@ int parseFloat( FILE* File, float *dst_float ) { { float value; float value; int ret = fscanf( File, "%e", &value ); int ret = fscanf( File, "%e", &value ); *dst_float = value; *dst_float = value; return ret; return ret; Loading
3d-viewer/vrml_v1_modelparser.cpp +84 −78 Original line number Original line Diff line number Diff line Loading @@ -71,9 +71,12 @@ void VRML1_MODEL_PARSER::Load( const wxString aFilename ) float vrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits * UNITS3D_TO_UNITSPCB; float vrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits * UNITS3D_TO_UNITSPCB; glScalef( vrmlunits_to_3Dunits, vrmlunits_to_3Dunits, vrmlunits_to_3Dunits ); glScalef( vrmlunits_to_3Dunits, vrmlunits_to_3Dunits, vrmlunits_to_3Dunits ); glm::vec3 matScale( GetMaster()->m_MatScale.x, GetMaster()->m_MatScale.y, GetMaster()->m_MatScale.z ); glm::vec3 matScale( GetMaster()->m_MatScale.x, GetMaster()->m_MatScale.y, glm::vec3 matRot( GetMaster()->m_MatRotation.x, GetMaster()->m_MatRotation.y, GetMaster()->m_MatRotation.z ); GetMaster()->m_MatScale.z ); glm::vec3 matPos( GetMaster()->m_MatPosition.x, GetMaster()->m_MatPosition.y, GetMaster()->m_MatPosition.z ); glm::vec3 matRot( GetMaster()->m_MatRotation.x, GetMaster()->m_MatRotation.y, GetMaster()->m_MatRotation.z ); glm::vec3 matPos( GetMaster()->m_MatPosition.x, GetMaster()->m_MatPosition.y, GetMaster()->m_MatPosition.z ); #define SCALE_3D_CONV ( (IU_PER_MILS * 1000.0f) / UNITS3D_TO_UNITSPCB ) #define SCALE_3D_CONV ( (IU_PER_MILS * 1000.0f) / UNITS3D_TO_UNITSPCB ) Loading @@ -94,7 +97,6 @@ void VRML1_MODEL_PARSER::Load( const wxString aFilename ) while( GetNextTag( m_file, text ) ) while( GetNextTag( m_file, text ) ) { { if( ( text == NULL ) || ( *text == '}' ) || ( *text == ']' ) ) if( ( text == NULL ) || ( *text == '}' ) || ( *text == ']' ) ) { { continue; continue; Loading Loading @@ -123,6 +125,7 @@ void VRML1_MODEL_PARSER::Load( const wxString aFilename ) } } } } int VRML1_MODEL_PARSER::read_separator() int VRML1_MODEL_PARSER::read_separator() { { char text[128]; char text[128]; Loading @@ -131,7 +134,6 @@ int VRML1_MODEL_PARSER::read_separator() while( GetNextTag( m_file, text ) ) while( GetNextTag( m_file, text ) ) { { if( strcmp( text, "Material" ) == 0 ) if( strcmp( text, "Material" ) == 0 ) { { readMaterial(); readMaterial(); Loading Loading @@ -290,6 +292,7 @@ int VRML1_MODEL_PARSER::readIndexedFaceSet( ) return -1; return -1; } } int VRML1_MODEL_PARSER::readMaterial_ambientColor() int VRML1_MODEL_PARSER::readMaterial_ambientColor() { { // DBG( printf( " readMaterial_ambientColor\n" ) ); // DBG( printf( " readMaterial_ambientColor\n" ) ); Loading Loading @@ -408,6 +411,7 @@ int VRML1_MODEL_PARSER::readIndexedFaceSet_coordIndex() glm::ivec3 coord; glm::ivec3 coord; int dummy; // should be -1 int dummy; // should be -1 while( fscanf( m_file, "%d,%d,%d,%d,", &coord[0], &coord[1], &coord[2], &dummy ) ) while( fscanf( m_file, "%d,%d,%d,%d,", &coord[0], &coord[1], &coord[2], &dummy ) ) { { std::vector<int> coord_list; std::vector<int> coord_list; Loading @@ -417,9 +421,9 @@ int VRML1_MODEL_PARSER::readIndexedFaceSet_coordIndex() coord_list[1] = coord[1]; coord_list[1] = coord[1]; coord_list[2] = coord[2]; coord_list[2] = coord[2]; if( (coord[0] == coord[1]) || if( (coord[0] == coord[1]) (coord[0] == coord[2]) || || (coord[0] == coord[2]) (coord[2] == coord[1]) ) || (coord[2] == coord[1]) ) { { // DBG( printf( " invalid coordIndex at index %lu (%d, %d, %d, %d)\n", m_model->m_CoordIndex.size()+1,coord[0], coord[1], coord[2], dummy ) ); // DBG( printf( " invalid coordIndex at index %lu (%d, %d, %d, %d)\n", m_model->m_CoordIndex.size()+1,coord[0], coord[1], coord[2], dummy ) ); } } Loading @@ -428,6 +432,7 @@ int VRML1_MODEL_PARSER::readIndexedFaceSet_coordIndex() { { // DBG( printf( " Error at index %lu, -1 Expected, got %d\n", m_model->m_CoordIndex.size()+1, dummy ) ); // DBG( printf( " Error at index %lu, -1 Expected, got %d\n", m_model->m_CoordIndex.size()+1, dummy ) ); } } m_model->m_CoordIndex.push_back( coord_list ); m_model->m_CoordIndex.push_back( coord_list ); } } Loading @@ -444,6 +449,7 @@ int VRML1_MODEL_PARSER::readIndexedFaceSet_materialIndex() m_model->m_MaterialIndex.clear(); m_model->m_MaterialIndex.clear(); int index; int index; while( fscanf( m_file, "%d,", &index ) ) while( fscanf( m_file, "%d,", &index ) ) { { m_model->m_MaterialIndex.push_back( index ); m_model->m_MaterialIndex.push_back( index ); Loading
3d-viewer/vrml_v2_modelparser.cpp +145 −140 Original line number Original line Diff line number Diff line Loading @@ -98,7 +98,6 @@ void VRML2_MODEL_PARSER::Load( const wxString aFilename ) while( GetNextTag( m_file, text ) ) while( GetNextTag( m_file, text ) ) { { if( ( text == NULL ) || ( *text == '}' ) || ( *text == ']' ) ) if( ( text == NULL ) || ( *text == '}' ) || ( *text == ']' ) ) { { continue; continue; Loading @@ -110,7 +109,6 @@ void VRML2_MODEL_PARSER::Load( const wxString aFilename ) childs.push_back( m_model ); childs.push_back( m_model ); read_Transform(); read_Transform(); } } else if( strcmp( text, "DEF" ) == 0 ) else if( strcmp( text, "DEF" ) == 0 ) { { Loading Loading @@ -149,11 +147,13 @@ int VRML2_MODEL_PARSER::read_Transform() { { continue; continue; } } if( ( *text == '}' ) ) if( ( *text == '}' ) ) { { // DBG( printf( " } Exit Transform\n" ) ); // DBG( printf( " } Exit Transform\n" ) ); break; break; } } if( strcmp( text, "translation" ) == 0 ) if( strcmp( text, "translation" ) == 0 ) { { parseVertex( m_file, m_model->m_translation ); parseVertex( m_file, m_model->m_translation ); Loading Loading @@ -210,6 +210,7 @@ int VRML2_MODEL_PARSER::read_Transform() else if( strcmp( text, "whichChoice" ) == 0 ) else if( strcmp( text, "whichChoice" ) == 0 ) { { int dummy; int dummy; if( fscanf( m_file, "%d", &dummy ) != 1 ) if( fscanf( m_file, "%d", &dummy ) != 1 ) { { // !TODO: log errors // !TODO: log errors Loading @@ -236,7 +237,6 @@ int VRML2_MODEL_PARSER::read_Transform() read_Shape(); read_Shape(); m_model = parent; m_model = parent; } } else if( strcmp( text, "DEF" ) == 0 ) else if( strcmp( text, "DEF" ) == 0 ) { { Loading @@ -244,10 +244,11 @@ int VRML2_MODEL_PARSER::read_Transform() } } else else { { DBG( printf( " %s NotImplemented\n", text ) ); // DBG( printf( " %s NotImplemented\n", text ) ); read_NotImplemented( m_file, '}' ); read_NotImplemented( m_file, '}' ); } } } } return 0; return 0; } } Loading Loading @@ -276,7 +277,8 @@ int VRML2_MODEL_PARSER::read_DEF() if( strcmp( text, "Transform" ) == 0 ) if( strcmp( text, "Transform" ) == 0 ) { { return read_Transform(); return read_Transform(); } else if( strcmp( text, "children" ) == 0 ) } else if( strcmp( text, "children" ) == 0 ) { { // skip // skip } } Loading Loading @@ -304,7 +306,7 @@ int VRML2_MODEL_PARSER::read_DEF() } } } } DBG( printf( " DEF failed\n" ) ); // DBG( printf( " DEF failed\n" ) ); return -1; return -1; } } Loading Loading @@ -346,12 +348,12 @@ int VRML2_MODEL_PARSER::read_Shape() } } else else { { DBG( printf( " %s NotImplemented\n", text ) ); // DBG( printf( " %s NotImplemented\n", text ) ); read_NotImplemented( m_file, '}' ); read_NotImplemented( m_file, '}' ); } } } } DBG( printf( " Shape failed\n") ); // DBG( printf( " Shape failed\n" ) ); return -1; return -1; } } Loading Loading @@ -380,7 +382,7 @@ int VRML2_MODEL_PARSER::read_Appearance() } } } } DBG( printf( " Appearance failed\n") ); // DBG( printf( " Appearance failed\n" ) ); return -1; return -1; } } Loading Loading @@ -449,12 +451,13 @@ int VRML2_MODEL_PARSER::read_material() return 0; return 0; } } } } DBG( printf( " read_material error: material not found\n" ) ); DBG( printf( " read_material error: material not found\n" ) ); } } } } } } DBG( printf( " failed material\n") ); // DBG( printf( " failed material\n" ) ); return -1; return -1; } } Loading Loading @@ -484,10 +487,12 @@ int VRML2_MODEL_PARSER::read_Material() parseVertex( m_file, vertex ); parseVertex( m_file, vertex ); // DBG( printf( "\n") ); // DBG( printf( "\n") ); m_model->m_Materials->m_DiffuseColor.push_back( vertex ); m_model->m_Materials->m_DiffuseColor.push_back( vertex ); } else if( strcmp( text, "emissiveColor" ) == 0 ) } else if( strcmp( text, "emissiveColor" ) == 0 ) { { // DBG( printf( " emissiveColor") ); // DBG( printf( " emissiveColor") ); parseVertex( m_file, vertex ); parseVertex( m_file, vertex ); // DBG( printf( "\n") ); // DBG( printf( "\n") ); if( GetMaster()->m_use_modelfile_emissiveColor == true ) if( GetMaster()->m_use_modelfile_emissiveColor == true ) { { Loading @@ -513,7 +518,8 @@ int VRML2_MODEL_PARSER::read_Material() if( GetMaster()->m_use_modelfile_ambientIntensity == true ) if( GetMaster()->m_use_modelfile_ambientIntensity == true ) { { m_model->m_Materials->m_AmbientColor.push_back( glm::vec3( ambientIntensity, ambientIntensity, ambientIntensity ) ); m_model->m_Materials->m_AmbientColor.push_back( glm::vec3( ambientIntensity, ambientIntensity, ambientIntensity ) ); } } } } else if( strcmp( text, "transparency" ) == 0 ) else if( strcmp( text, "transparency" ) == 0 ) Loading Loading @@ -542,7 +548,7 @@ int VRML2_MODEL_PARSER::read_Material() } } } } DBG( printf( " Material failed\n") ); // DBG( printf( " Material failed\n" ) ); return -1; return -1; } } Loading Loading @@ -583,6 +589,7 @@ int VRML2_MODEL_PARSER::read_IndexedFaceSet() else if( strcmp( text, "colorPerVertex" ) == 0 ) else if( strcmp( text, "colorPerVertex" ) == 0 ) { { GetNextTag( m_file, text ); GetNextTag( m_file, text ); if( strcmp( text, "TRUE" ) ) if( strcmp( text, "TRUE" ) ) { { // DBG( printf( " colorPerVertex = true\n") ); // DBG( printf( " colorPerVertex = true\n") ); Loading @@ -592,7 +599,6 @@ int VRML2_MODEL_PARSER::read_IndexedFaceSet() { { colorPerVertex = false; colorPerVertex = false; } } } } else if( strcmp( text, "Coordinate" ) == 0 ) else if( strcmp( text, "Coordinate" ) == 0 ) { { Loading @@ -618,10 +624,9 @@ int VRML2_MODEL_PARSER::read_IndexedFaceSet() { { read_colorIndex(); read_colorIndex(); } } } } DBG( printf( " IndexedFaceSet failed %s\n", text) ); // DBG( printf( " IndexedFaceSet failed %s\n", text ) ); return -1; return -1; } } Loading @@ -636,6 +641,7 @@ int VRML2_MODEL_PARSER::read_colorIndex() { { int index; int index; int first_index; int first_index; while( fscanf( m_file, "%d, ", &index ) ) while( fscanf( m_file, "%d, ", &index ) ) { { if( index == -1 ) if( index == -1 ) Loading Loading @@ -677,6 +683,7 @@ int VRML2_MODEL_PARSER::read_NormalIndex() std::vector<int> coord_list; std::vector<int> coord_list; coord_list.clear(); coord_list.clear(); while( fscanf( m_file, "%d, ", &dummy ) == 1 ) while( fscanf( m_file, "%d, ", &dummy ) == 1 ) { { if( dummy == -1 ) if( dummy == -1 ) Loading Loading @@ -710,6 +717,7 @@ int VRML2_MODEL_PARSER::read_coordIndex() std::vector<int> coord_list; std::vector<int> coord_list; coord_list.clear(); coord_list.clear(); while( fscanf( m_file, "%d, ", &dummy ) == 1 ) while( fscanf( m_file, "%d, ", &dummy ) == 1 ) { { if( dummy == -1 ) if( dummy == -1 ) Loading Loading @@ -761,8 +769,6 @@ int VRML2_MODEL_PARSER::read_Color() } } int VRML2_MODEL_PARSER::read_Normal() int VRML2_MODEL_PARSER::read_Normal() { { char text[128]; char text[128]; Loading Loading @@ -828,4 +834,3 @@ int VRML2_MODEL_PARSER::read_Coordinate() return -1; return -1; } }
3d-viewer/vrmlmodelparser.cpp +8 −7 Original line number Original line Diff line number Diff line Loading @@ -79,6 +79,7 @@ void VRML_MODEL_PARSER::Load( const wxString aFilename ) return; return; } } fclose( file ); fclose( file ); Loading @@ -97,5 +98,5 @@ void VRML_MODEL_PARSER::Load( const wxString aFilename ) return; return; } } DBG( printf( "Unknown VRML file format: %s\n", line ) ); // DBG( printf( "Unknown VRML file format: %s\n", line ) ); } }
3d-viewer/x3dmodelparser.cpp +94 −88 Original line number Original line Diff line number Diff line Loading @@ -43,11 +43,13 @@ X3D_MODEL_PARSER::X3D_MODEL_PARSER( S3D_MASTER* aMaster ) : X3D_MODEL_PARSER::X3D_MODEL_PARSER( S3D_MASTER* aMaster ) : S3D_MODEL_PARSER( aMaster ) S3D_MODEL_PARSER( aMaster ) {} { } X3D_MODEL_PARSER::~X3D_MODEL_PARSER() X3D_MODEL_PARSER::~X3D_MODEL_PARSER() {} { } void X3D_MODEL_PARSER::Load( const wxString aFilename ) void X3D_MODEL_PARSER::Load( const wxString aFilename ) Loading Loading @@ -197,11 +199,13 @@ void X3D_MODEL_PARSER::GetNodeProperties( wxXmlNode* aNode, PROPERTY_MAP& aProps } } } } /* Private ----- */ /* Private ----- */ void X3D_MODEL_PARSER::readTransform( wxXmlNode* aTransformNode ) void X3D_MODEL_PARSER::readTransform( wxXmlNode* aTransformNode ) { { NODE_LIST childnodes; NODE_LIST childnodes; GetChildsByName( aTransformNode, wxT( "Material" ), childnodes ); GetChildsByName( aTransformNode, wxT( "Material" ), childnodes ); for( NODE_LIST::iterator node = childnodes.begin(); for( NODE_LIST::iterator node = childnodes.begin(); Loading Loading @@ -234,6 +238,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) glm::vec3 color; glm::vec3 color; PROPERTY_MAP properties; PROPERTY_MAP properties; GetNodeProperties( aMatNode, properties ); GetNodeProperties( aMatNode, properties ); // DEFine new Material named as value of DEF // DEFine new Material named as value of DEF Loading @@ -246,10 +251,9 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) m_model->m_Materials = material; m_model->m_Materials = material; if( !parseDoubleTriplet( properties[ wxT( "diffuseColor" ) ], if( !parseDoubleTriplet( properties[ wxT( "diffuseColor" ) ], color ) ) color ) ) { { DBG( printf("diffuseColor parsing error") ); // DBG( printf( "diffuseColor parsing error" ) ); } } else else { { Loading @@ -258,7 +262,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) if( !parseDoubleTriplet( properties[ wxT( "specularColor" ) ], color ) ) if( !parseDoubleTriplet( properties[ wxT( "specularColor" ) ], color ) ) { { DBG( printf("specularColor parsing error") ); // DBG( printf( "specularColor parsing error" ) ); } } else else { { Loading @@ -267,7 +271,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) if( !parseDoubleTriplet( properties[ wxT( "emissiveColor" ) ], color ) ) if( !parseDoubleTriplet( properties[ wxT( "emissiveColor" ) ], color ) ) { { DBG( printf("emissiveColor parsing error") ); // DBG( printf( "emissiveColor parsing error" ) ); } } else else { { Loading @@ -283,7 +287,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) } } else else { { DBG( printf( "ambienterror" ) ); // DBG( printf( "ambienterror" ) ); } } values.SetString( properties[ wxT( "shininess" ) ] ); values.SetString( properties[ wxT( "shininess" ) ] ); Loading @@ -296,7 +300,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) } } else else { { DBG( printf( "shininess error" ) ); // DBG( printf( "shininess error" ) ); } } values.SetString( properties[ wxT( "transparency" ) ] ); values.SetString( properties[ wxT( "transparency" ) ] ); Loading @@ -307,7 +311,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) } } else else { { DBG( printf( "trans error") ); // DBG( printf( "trans error" ) ); } } // VRML // VRML Loading @@ -321,7 +325,6 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) vrml_materials.push_back( vrml_material ); vrml_materials.push_back( vrml_material ); } } // USE existing material named by value of USE // USE existing material named by value of USE else if( properties.find( wxT( "USE" ) ) != properties.end() ) else if( properties.find( wxT( "USE" ) ) != properties.end() ) { { Loading Loading @@ -366,7 +369,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) } } } } DBG( printf( "ReadMaterial error: material not found\n" ) ); // DBG( printf( "ReadMaterial error: material not found\n" ) ); } } } } Loading @@ -378,9 +381,9 @@ bool X3D_MODEL_PARSER::parseDoubleTriplet( const wxString& aData, double x, y, z; double x, y, z; bool ret = tokens.GetNextToken().ToDouble( &x ) && bool ret = tokens.GetNextToken().ToDouble( &x ) tokens.GetNextToken().ToDouble( &y ) && && tokens.GetNextToken().ToDouble( &y ) tokens.GetNextToken().ToDouble( &z ); && tokens.GetNextToken().ToDouble( &z ); aResult.x = x; aResult.x = x; aResult.y = y; aResult.y = y; Loading Loading @@ -430,6 +433,7 @@ void X3D_MODEL_PARSER::readIndexedFaceSet( wxXmlNode* aFaceNode, * --------------------------- */ * --------------------------- */ S3D_VERTEX translation; S3D_VERTEX translation; parseDoubleTriplet( aTransformProps[ wxT( "translation" ) ], translation ); parseDoubleTriplet( aTransformProps[ wxT( "translation" ) ], translation ); S3D_VERTEX scale; S3D_VERTEX scale; Loading @@ -440,12 +444,13 @@ void X3D_MODEL_PARSER::readIndexedFaceSet( wxXmlNode* aFaceNode, wxStringTokenizer tokens( aTransformProps[ wxT( "rotation" ) ] ); wxStringTokenizer tokens( aTransformProps[ wxT( "rotation" ) ] ); double x, y, z; double x, y, z; if( !(tokens.GetNextToken().ToDouble( &x ) && tokens.GetNextToken().ToDouble( &y ) && if( !( tokens.GetNextToken().ToDouble( &x ) tokens.GetNextToken().ToDouble( &z ) && && tokens.GetNextToken().ToDouble( &y ) tokens.GetNextToken().ToDouble( &angle ) ) ) && tokens.GetNextToken().ToDouble( &z ) && tokens.GetNextToken().ToDouble( &angle ) ) ) { { DBG( printf("rotation read error") ); // DBG( printf( "rotation read error" ) ); } } else else { { Loading Loading @@ -482,7 +487,7 @@ void X3D_MODEL_PARSER::readIndexedFaceSet( wxXmlNode* aFaceNode, if( points.size() % 3 != 0 ) if( points.size() % 3 != 0 ) { { DBG( printf( "Number of points is incorrect" ) ); // DBG( printf( "Number of points is incorrect" ) ); return; return; } } Loading Loading @@ -549,13 +554,14 @@ void X3D_MODEL_PARSER::readIndexedFaceSet( wxXmlNode* aFaceNode, if( color_points.size() % 3 != 0 ) if( color_points.size() % 3 != 0 ) { { DBG( printf( "Number of points is incorrect" ) ); // DBG( printf( "Number of points is incorrect" ) ); return; return; } } /* Create 3D face color from 3 color points /* Create 3D face color from 3 color points */ */ m_model->m_Materials->m_DiffuseColor.clear(); m_model->m_Materials->m_DiffuseColor.clear(); for( unsigned id = 0; id < color_points.size() / 3; id++ ) for( unsigned id = 0; id < color_points.size() / 3; id++ ) { { m_model->m_MaterialIndex.push_back( id ); m_model->m_MaterialIndex.push_back( id ); Loading