Commit 34dfbc33 authored by unknown's avatar unknown Committed by jean-pierre charras

3D viewer: fix an issue introduced in previous commit. Add an improvement.

parent c0518db7
...@@ -526,7 +526,7 @@ void EDA_3D_CANVAS::Redraw() ...@@ -526,7 +526,7 @@ void EDA_3D_CANVAS::Redraw()
{ {
glEnable( GL_BLEND ); glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glColor4f( 1.0, 1.0, 1.0, 0.85f ); glColor4f( 1.0, 1.0, 1.0, 0.75f );
glEnable( GL_CULL_FACE ); glEnable( GL_CULL_FACE );
glDisable( GL_COLOR_MATERIAL ); glDisable( GL_COLOR_MATERIAL );
glEnable( GL_TEXTURE_2D ); glEnable( GL_TEXTURE_2D );
......
...@@ -262,6 +262,32 @@ void S3D_MESH::openGL_Render( bool aIsRenderingJustNonTransparentObjects, ...@@ -262,6 +262,32 @@ void S3D_MESH::openGL_Render( bool aIsRenderingJustNonTransparentObjects,
} }
} }
/*
#if defined(DEBUG)
// Debug Normals
glColor4f( 1.0, 0.0, 1.0, 1.0 );
for( unsigned int ii = 0; ii < m_CoordIndex[idx].size(); ii++ )
{
// Flat
if( m_PerFaceNormalsNormalized.size() > 0 )
{
S3D_VERTEX normal = m_PerFaceNormalsNormalized[idx];
glNormal3fv( &normal.x );
for( unsigned int ii = 0; ii < m_CoordIndex[idx].size(); ii++ )
{
glBegin( GL_LINES );
glm::vec3 point = m_Point[m_CoordIndex[idx][ii]];
glVertex3fv( &point.x );
point += normal;
glVertex3fv( &point.x );
glEnd();
}
}
}
#endif
*/
switch( m_CoordIndex[idx].size() ) switch( m_CoordIndex[idx].size() )
{ {
case 3: case 3:
......
...@@ -222,6 +222,8 @@ private: ...@@ -222,6 +222,8 @@ private:
int m_counter_DEF_GROUP; ///< Counts the number of DEF * GROUPS used int m_counter_DEF_GROUP; ///< Counts the number of DEF * GROUPS used
int m_counter_USE_GROUP; ///< Counts the number of USE * used, in the end, if m_counter_DEF_GROUP > 0 and m_counter_USE_GROUP == 0 then it will add the first group with childs int m_counter_USE_GROUP; ///< Counts the number of USE * used, in the end, if m_counter_DEF_GROUP > 0 and m_counter_USE_GROUP == 0 then it will add the first group with childs
bool m_discardLastGeometry; ///< If true, it should not store the latest loaded geometry (used to discard IndexedLineSet, but load it)
}; };
......
...@@ -277,6 +277,7 @@ int VRML2_MODEL_PARSER::loadFileModel( S3D_MESH *aTransformationModel ) ...@@ -277,6 +277,7 @@ int VRML2_MODEL_PARSER::loadFileModel( S3D_MESH *aTransformationModel )
{ {
for( VRML2_DEF_GROUP_MAP::iterator groupIt = m_defGroupMap.begin(); groupIt!=m_defGroupMap.end(); ++groupIt ) for( VRML2_DEF_GROUP_MAP::iterator groupIt = m_defGroupMap.begin(); groupIt!=m_defGroupMap.end(); ++groupIt )
{ {
wxString groupName = groupIt->first;
S3D_MESH* ptrModel = groupIt->second; S3D_MESH* ptrModel = groupIt->second;
...@@ -288,6 +289,7 @@ int VRML2_MODEL_PARSER::loadFileModel( S3D_MESH *aTransformationModel ) ...@@ -288,6 +289,7 @@ int VRML2_MODEL_PARSER::loadFileModel( S3D_MESH *aTransformationModel )
} }
else else
{ {
wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "loadFileModel: forced added %s group" ), groupName );
m_ModelParser->childs.push_back( ptrModel ); m_ModelParser->childs.push_back( ptrModel );
} }
} }
...@@ -470,6 +472,8 @@ int VRML2_MODEL_PARSER::read_Transform() ...@@ -470,6 +472,8 @@ int VRML2_MODEL_PARSER::read_Transform()
S3D_MESH* save_ptr = m_model; S3D_MESH* save_ptr = m_model;
if( read_Shape() == 0 ) if( read_Shape() == 0 )
{
if( m_discardLastGeometry == false )
{ {
m_model = save_ptr; m_model = save_ptr;
...@@ -490,6 +494,13 @@ int VRML2_MODEL_PARSER::read_Transform() ...@@ -490,6 +494,13 @@ int VRML2_MODEL_PARSER::read_Transform()
} }
} }
else else
{
delete m_model;
wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_Transform: Shape, discard child." ) );
}
}
else
{ {
delete m_model; delete m_model;
} }
...@@ -692,7 +703,10 @@ int VRML2_MODEL_PARSER::read_DEF_Coordinate() ...@@ -692,7 +703,10 @@ int VRML2_MODEL_PARSER::read_DEF_Coordinate()
int retVal = read_CoordinateDef(); int retVal = read_CoordinateDef();
if( retVal == 0 ) if( retVal == 0 )
{
m_defCoordinateMap.insert( std::make_pair( coordinateName, m_model->m_Point ) ); m_defCoordinateMap.insert( std::make_pair( coordinateName, m_model->m_Point ) );
wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_DEF_Coordinate insert %s" ), coordinateName );
}
debug_exit(); debug_exit();
return retVal; return retVal;
...@@ -801,6 +815,7 @@ int VRML2_MODEL_PARSER::read_DEF() ...@@ -801,6 +815,7 @@ int VRML2_MODEL_PARSER::read_DEF()
} }
else if( strcmp( text, "IndexedFaceSet" ) == 0 ) else if( strcmp( text, "IndexedFaceSet" ) == 0 )
{ {
m_discardLastGeometry = false;
read_IndexedFaceSet(); read_IndexedFaceSet();
} }
else if( strcmp( text, "Group" ) == 0 ) else if( strcmp( text, "Group" ) == 0 )
...@@ -882,11 +897,13 @@ int VRML2_MODEL_PARSER::read_IndexedFaceSet_USE() ...@@ -882,11 +897,13 @@ int VRML2_MODEL_PARSER::read_IndexedFaceSet_USE()
if( coordinate == m_defCoordinateMap.end() ) if( coordinate == m_defCoordinateMap.end() )
{ {
debug_exit(); debug_exit();
wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "USE: coordinate %s not previously defined " wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_IndexedFaceSet_USE: coordinate %s not previously defined "
"in a DEF section." ), text ); "in a DEF section." ), text );
return -1; return -1;
} }
wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_IndexedFaceSet_USE %s" ), text );
m_model->m_Point = coordinate->second; m_model->m_Point = coordinate->second;
debug_exit(); debug_exit();
return 0; return 0;
...@@ -924,10 +941,12 @@ int VRML2_MODEL_PARSER::read_Shape() ...@@ -924,10 +941,12 @@ int VRML2_MODEL_PARSER::read_Shape()
} }
else if( strcmp( text, "IndexedFaceSet" ) == 0 ) else if( strcmp( text, "IndexedFaceSet" ) == 0 )
{ {
m_discardLastGeometry = false;
read_IndexedFaceSet(); read_IndexedFaceSet();
} }
else if( strcmp( text, "IndexedLineSet" ) == 0 ) else if( strcmp( text, "IndexedLineSet" ) == 0 )
{ {
m_discardLastGeometry = true;
read_IndexedLineSet(); read_IndexedLineSet();
} }
else else
...@@ -977,11 +996,20 @@ int VRML2_MODEL_PARSER::read_geometry() ...@@ -977,11 +996,20 @@ int VRML2_MODEL_PARSER::read_geometry()
} }
else if( strcmp( text, "IndexedFaceSet" ) == 0 ) else if( strcmp( text, "IndexedFaceSet" ) == 0 )
{ {
m_discardLastGeometry = false;
int ret = read_IndexedFaceSet(); int ret = read_IndexedFaceSet();
debug_exit(); debug_exit();
wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_geometry exit, after IndexedFaceSet" ) ); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_geometry exit, after IndexedFaceSet" ) );
return ret; return ret;
} }
else if( strcmp( text, "IndexedLineSet" ) == 0 )
{
m_discardLastGeometry = true;
int ret = read_IndexedLineSet();
debug_exit();
wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_geometry exit, after IndexedLineSet" ) );
return ret;
}
else else
{ {
wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_geometry: %s NotImplemented" ), text ); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_geometry: %s NotImplemented" ), text );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment