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

This commit is contained in:
unknown 2015-03-29 18:13:58 +02:00 committed by jean-pierre charras
parent c0518db743
commit 34dfbc3306
4 changed files with 77 additions and 21 deletions

View File

@ -526,7 +526,7 @@ void EDA_3D_CANVAS::Redraw()
{
glEnable( GL_BLEND );
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 );
glDisable( GL_COLOR_MATERIAL );
glEnable( GL_TEXTURE_2D );

View File

@ -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() )
{
case 3:

View File

@ -222,6 +222,8 @@ private:
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
bool m_discardLastGeometry; ///< If true, it should not store the latest loaded geometry (used to discard IndexedLineSet, but load it)
};

View File

@ -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 )
{
wxString groupName = groupIt->first;
S3D_MESH* ptrModel = groupIt->second;
@ -288,6 +289,7 @@ int VRML2_MODEL_PARSER::loadFileModel( S3D_MESH *aTransformationModel )
}
else
{
wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "loadFileModel: forced added %s group" ), groupName );
m_ModelParser->childs.push_back( ptrModel );
}
}
@ -470,6 +472,8 @@ int VRML2_MODEL_PARSER::read_Transform()
S3D_MESH* save_ptr = m_model;
if( read_Shape() == 0 )
{
if( m_discardLastGeometry == false )
{
m_model = save_ptr;
@ -490,6 +494,13 @@ int VRML2_MODEL_PARSER::read_Transform()
}
}
else
{
delete m_model;
wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_Transform: Shape, discard child." ) );
}
}
else
{
delete m_model;
}
@ -692,7 +703,10 @@ int VRML2_MODEL_PARSER::read_DEF_Coordinate()
int retVal = read_CoordinateDef();
if( retVal == 0 )
{
m_defCoordinateMap.insert( std::make_pair( coordinateName, m_model->m_Point ) );
wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_DEF_Coordinate insert %s" ), coordinateName );
}
debug_exit();
return retVal;
@ -801,6 +815,7 @@ int VRML2_MODEL_PARSER::read_DEF()
}
else if( strcmp( text, "IndexedFaceSet" ) == 0 )
{
m_discardLastGeometry = false;
read_IndexedFaceSet();
}
else if( strcmp( text, "Group" ) == 0 )
@ -882,11 +897,13 @@ int VRML2_MODEL_PARSER::read_IndexedFaceSet_USE()
if( coordinate == m_defCoordinateMap.end() )
{
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 );
return -1;
}
wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_IndexedFaceSet_USE %s" ), text );
m_model->m_Point = coordinate->second;
debug_exit();
return 0;
@ -924,10 +941,12 @@ int VRML2_MODEL_PARSER::read_Shape()
}
else if( strcmp( text, "IndexedFaceSet" ) == 0 )
{
m_discardLastGeometry = false;
read_IndexedFaceSet();
}
else if( strcmp( text, "IndexedLineSet" ) == 0 )
{
m_discardLastGeometry = true;
read_IndexedLineSet();
}
else
@ -977,11 +996,20 @@ int VRML2_MODEL_PARSER::read_geometry()
}
else if( strcmp( text, "IndexedFaceSet" ) == 0 )
{
m_discardLastGeometry = false;
int ret = read_IndexedFaceSet();
debug_exit();
wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_geometry exit, after IndexedFaceSet" ) );
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
{
wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_geometry: %s NotImplemented" ), text );