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

3d_viewer fix translation and rotation issues (patch from Mario Luzeiro)

parent 34b645da
...@@ -424,7 +424,7 @@ void EDA_3D_CANVAS::Redraw() ...@@ -424,7 +424,7 @@ void EDA_3D_CANVAS::Redraw()
// Initialize Projection Matrix for Ortographic View // Initialize Projection Matrix for Ortographic View
glOrtho( -size.x / orthoReductionFactor, size.x / orthoReductionFactor, glOrtho( -size.x / orthoReductionFactor, size.x / orthoReductionFactor,
-size.y / orthoReductionFactor, size.y / orthoReductionFactor, 1, 100 ); -size.y / orthoReductionFactor, size.y / orthoReductionFactor, 1, 10 );
} }
else else
{ {
...@@ -432,7 +432,7 @@ void EDA_3D_CANVAS::Redraw() ...@@ -432,7 +432,7 @@ void EDA_3D_CANVAS::Redraw()
double ratio_HV = (double) size.x / size.y; double ratio_HV = (double) size.x / size.y;
// Initialize Projection Matrix for Perspective View // Initialize Projection Matrix for Perspective View
gluPerspective( 45.0 * g_Parm_3D_Visu.m_Zoom, ratio_HV, 1, 100 ); gluPerspective( 45.0 * g_Parm_3D_Visu.m_Zoom, ratio_HV, 1, 10 );
} }
// position viewer // position viewer
...@@ -979,7 +979,7 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList) ...@@ -979,7 +979,7 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
if( g_Parm_3D_Visu.IsRealisticMode() ) if( g_Parm_3D_Visu.IsRealisticMode() )
{ {
SetGLEpoxyColor( 0.9 ); SetGLEpoxyColor( 1.0 );
if( g_Parm_3D_Visu.HightQualityMode() ) if( g_Parm_3D_Visu.HightQualityMode() )
{ {
SetGLTexture( m_text_pcb, 35.0f ); SetGLTexture( m_text_pcb, 35.0f );
...@@ -1400,7 +1400,7 @@ void EDA_3D_CANVAS::CreateDrawGL_List() ...@@ -1400,7 +1400,7 @@ void EDA_3D_CANVAS::CreateDrawGL_List()
m_glLists[GL_ID_BOARD] = glGenLists( 1 ); m_glLists[GL_ID_BOARD] = glGenLists( 1 );
m_glLists[GL_ID_BODY] = glGenLists( 1 ); m_glLists[GL_ID_BODY] = glGenLists( 1 );
BuildBoard3DView(m_glLists[GL_ID_BOARD], m_glLists[GL_ID_BODY]); BuildBoard3DView(m_glLists[GL_ID_BOARD], m_glLists[GL_ID_BODY]);
CheckGLError( __FILE__, __LINE__ );
} }
if( ! m_glLists[GL_ID_TECH_LAYERS] ) if( ! m_glLists[GL_ID_TECH_LAYERS] )
...@@ -1409,6 +1409,7 @@ void EDA_3D_CANVAS::CreateDrawGL_List() ...@@ -1409,6 +1409,7 @@ void EDA_3D_CANVAS::CreateDrawGL_List()
glNewList( m_glLists[GL_ID_TECH_LAYERS], GL_COMPILE ); glNewList( m_glLists[GL_ID_TECH_LAYERS], GL_COMPILE );
BuildTechLayers3DView(); BuildTechLayers3DView();
glEndList(); glEndList();
CheckGLError( __FILE__, __LINE__ );
} }
if( ! m_glLists[GL_ID_AUX_LAYERS] ) if( ! m_glLists[GL_ID_AUX_LAYERS] )
...@@ -1417,9 +1418,9 @@ void EDA_3D_CANVAS::CreateDrawGL_List() ...@@ -1417,9 +1418,9 @@ void EDA_3D_CANVAS::CreateDrawGL_List()
glNewList( m_glLists[GL_ID_AUX_LAYERS], GL_COMPILE ); glNewList( m_glLists[GL_ID_AUX_LAYERS], GL_COMPILE );
BuildBoard3DAuxLayers(); BuildBoard3DAuxLayers();
glEndList(); glEndList();
CheckGLError( __FILE__, __LINE__ );
} }
// draw modules 3D shapes // draw modules 3D shapes
if( ! m_glLists[GL_ID_3DSHAPES_SOLID_FRONT] && g_Parm_3D_Visu.GetFlag( FL_MODULE ) ) if( ! m_glLists[GL_ID_3DSHAPES_SOLID_FRONT] && g_Parm_3D_Visu.GetFlag( FL_MODULE ) )
{ {
...@@ -1434,14 +1435,16 @@ void EDA_3D_CANVAS::CreateDrawGL_List() ...@@ -1434,14 +1435,16 @@ void EDA_3D_CANVAS::CreateDrawGL_List()
BuildFootprintShape3DList( m_glLists[GL_ID_3DSHAPES_SOLID_FRONT], BuildFootprintShape3DList( m_glLists[GL_ID_3DSHAPES_SOLID_FRONT],
m_glLists[GL_ID_3DSHAPES_TRANSP_FRONT], false ); m_glLists[GL_ID_3DSHAPES_TRANSP_FRONT], false );
CheckGLError( __FILE__, __LINE__ );
m_glLists[GL_ID_SHADOW_FRONT] = glGenLists( 1 ); m_glLists[GL_ID_SHADOW_FRONT] = glGenLists( 1 );
m_glLists[GL_ID_SHADOW_BACK] = glGenLists( 1 ); m_glLists[GL_ID_SHADOW_BACK] = glGenLists( 1 );
m_glLists[GL_ID_SHADOW_BOARD] = glGenLists( 1 ); m_glLists[GL_ID_SHADOW_BOARD] = glGenLists( 1 );
BuildShadowList(m_glLists[GL_ID_SHADOW_FRONT], m_glLists[GL_ID_SHADOW_BACK], m_glLists[GL_ID_SHADOW_BOARD]); BuildShadowList(m_glLists[GL_ID_SHADOW_FRONT], m_glLists[GL_ID_SHADOW_BACK], m_glLists[GL_ID_SHADOW_BOARD]);
}
// Test for errors
CheckGLError( __FILE__, __LINE__ ); CheckGLError( __FILE__, __LINE__ );
}
#ifdef PRINT_CALCULATION_TIME #ifdef PRINT_CALCULATION_TIME
unsigned endtime = GetRunningMicroSecs(); unsigned endtime = GetRunningMicroSecs();
......
...@@ -51,12 +51,12 @@ static void CALLBACK tessCPolyPt2Vertex( const GLvoid* data ); ...@@ -51,12 +51,12 @@ static void CALLBACK tessCPolyPt2Vertex( const GLvoid* data );
// 2 helper functions to set the current normal vector for gle items // 2 helper functions to set the current normal vector for gle items
static inline void SetNormalZpos() static inline void SetNormalZpos()
{ {
glNormal3f( 0.0, 0.0, 1.0 ); //glNormal3f( 0.0, 0.0, 1.0 );
} }
static inline void SetNormalZneg() static inline void SetNormalZneg()
{ {
glNormal3f( 0.0, 0.0, -1.0 ); //glNormal3f( 0.0, 0.0, -1.0 );
} }
void TransfertToGLlist( std::vector< S3D_VERTEX >& aVertices, double aBiuTo3DUnits ); void TransfertToGLlist( std::vector< S3D_VERTEX >& aVertices, double aBiuTo3DUnits );
...@@ -185,6 +185,10 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList, ...@@ -185,6 +185,10 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList,
startContour = 0; startContour = 0;
} }
// https://www.opengl.org/sdk/docs/man2/xhtml/gluTessNormal.xml
gluTessNormal( tess, 0.0, 0.0, 0.0 );
v_data[0] = polylist.GetX( ii ) * aBiuTo3DUnits; v_data[0] = polylist.GetX( ii ) * aBiuTo3DUnits;
v_data[1] = -polylist.GetY( ii ) * aBiuTo3DUnits; v_data[1] = -polylist.GetY( ii ) * aBiuTo3DUnits;
// gluTessVertex store pointers on data, not data, so do not store // gluTessVertex store pointers on data, not data, so do not store
...@@ -193,6 +197,7 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList, ...@@ -193,6 +197,7 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList,
// before calling gluDeleteTess // before calling gluDeleteTess
gluTessVertex( tess, v_data, &polylist[ii] ); gluTessVertex( tess, v_data, &polylist[ii] );
if( polylist.IsEndContour( ii ) ) if( polylist.IsEndContour( ii ) )
{ {
gluTessEndContour( tess ); gluTessEndContour( tess );
...@@ -215,7 +220,9 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList, ...@@ -215,7 +220,9 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList,
gluDeleteTess( tess ); gluDeleteTess( tess );
if( aThickness == 0 ) if( aThickness == 0 )
{
return; return;
}
// Build the 3D data : vertical side // Build the 3D data : vertical side
Draw3D_VerticalPolygonalCylinder( polylist, aThickness, aZpos - (aThickness / 2.0), false, aBiuTo3DUnits ); Draw3D_VerticalPolygonalCylinder( polylist, aThickness, aZpos - (aThickness / 2.0), false, aBiuTo3DUnits );
......
...@@ -54,10 +54,10 @@ S3D_MATERIAL::S3D_MATERIAL( S3D_MASTER* father, const wxString& name ) : ...@@ -54,10 +54,10 @@ S3D_MATERIAL::S3D_MATERIAL( S3D_MASTER* father, const wxString& name ) :
void SetOpenGlDefaultMaterial() void SetOpenGlDefaultMaterial()
{ {
glm::vec4 ambient( 0.2, 0.2, 0.2, 1.0 ); glm::vec4 ambient( 0.15, 0.15, 0.15, 1.0 );
glm::vec4 specular( 0.1, 0.1, 0.1, 1.0 ); glm::vec4 specular( 0.1, 0.1, 0.1, 1.0 );
glm::vec4 emissive( 0.1, 0.1, 0.1, 1.0 ); glm::vec4 emissive( 0.1, 0.1, 0.1, 1.0 );
GLint shininess_value = 100; GLint shininess_value = 80;
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
//glColor4f( 1.0, 1.0, 1.0, 1.0 ); //glColor4f( 1.0, 1.0, 1.0, 1.0 );
......
...@@ -57,6 +57,8 @@ S3D_MESH::~S3D_MESH() ...@@ -57,6 +57,8 @@ S3D_MESH::~S3D_MESH()
void S3D_MESH::openGL_RenderAllChilds() void S3D_MESH::openGL_RenderAllChilds()
{ {
//DBG( printf( "openGL_RenderAllChilds") );
glPushMatrix(); glPushMatrix();
glTranslatef( m_translation.x, m_translation.y, m_translation.z ); glTranslatef( m_translation.x, m_translation.y, m_translation.z );
glRotatef( m_rotation[3], m_rotation[0], m_rotation[1], m_rotation[2] ); glRotatef( m_rotation[3], m_rotation[0], m_rotation[1], m_rotation[2] );
...@@ -76,12 +78,13 @@ void S3D_MESH::openGL_RenderAllChilds() ...@@ -76,12 +78,13 @@ void S3D_MESH::openGL_RenderAllChilds()
SetOpenGlDefaultMaterial(); SetOpenGlDefaultMaterial();
glPopMatrix(); glPopMatrix();
} }
void S3D_MESH::openGL_Render() void S3D_MESH::openGL_Render()
{ {
//DBG( printf( " render\n" ) ); //DBG( printf( "openGL_Render" ) );
if( m_Materials ) if( m_Materials )
{ {
...@@ -90,6 +93,7 @@ void S3D_MESH::openGL_Render() ...@@ -90,6 +93,7 @@ void S3D_MESH::openGL_Render()
if( m_CoordIndex.size() == 0) if( m_CoordIndex.size() == 0)
{ {
return; return;
} }
...@@ -134,7 +138,7 @@ void S3D_MESH::openGL_Render() ...@@ -134,7 +138,7 @@ void S3D_MESH::openGL_Render()
{ {
for(unsigned int ii = 0; ii < m_CoordIndex[idx].size(); ii++ ) for(unsigned int ii = 0; ii < m_CoordIndex[idx].size(); ii++ )
{ {
glm::vec3 normal = m_PerVertexNormalsNormalized[m_CoordIndex[idx][ii]]; glm::vec3 normal = m_PerVertexNormalsNormalized[m_NormalIndex[idx][ii]];
glNormal3fv( &normal.x ); glNormal3fv( &normal.x );
glm::vec3 point = m_Point[m_CoordIndex[idx][ii]]; glm::vec3 point = m_Point[m_CoordIndex[idx][ii]];
...@@ -176,6 +180,8 @@ void S3D_MESH::openGL_Render() ...@@ -176,6 +180,8 @@ void S3D_MESH::openGL_Render()
void S3D_MESH::calcPointNormalized () void S3D_MESH::calcPointNormalized ()
{ {
//DBG( printf( "calcPointNormalized\n" ) );
if( isPointNormalizedComputed == true ) if( isPointNormalizedComputed == true )
{ {
return; return;
...@@ -221,8 +227,11 @@ bool IsClockwise(glm::vec3 v0, glm::vec3 v1, glm::vec3 v2) ...@@ -221,8 +227,11 @@ bool IsClockwise(glm::vec3 v0, glm::vec3 v1, glm::vec3 v2)
void S3D_MESH::calcPerFaceNormals () void S3D_MESH::calcPerFaceNormals ()
{ {
//DBG( printf( "calcPerFaceNormals" ) );
if( isPerFaceNormalsComputed == true ) if( isPerFaceNormalsComputed == true )
{ {
return; return;
} }
isPerFaceNormalsComputed = true; isPerFaceNormalsComputed = true;
...@@ -230,6 +239,7 @@ void S3D_MESH::calcPerFaceNormals () ...@@ -230,6 +239,7 @@ void S3D_MESH::calcPerFaceNormals ()
if( m_PerVertexNormalsNormalized.size() > 0 ) if( m_PerVertexNormalsNormalized.size() > 0 )
{ {
return; return;
} }
...@@ -317,12 +327,15 @@ void S3D_MESH::calcPerFaceNormals () ...@@ -317,12 +327,15 @@ void S3D_MESH::calcPerFaceNormals ()
} }
} }
} }
// http://www.bytehazard.com/code/vertnorm.html // http://www.bytehazard.com/code/vertnorm.html
// http://www.emeyex.com/site/tuts/VertexNormals.pdf // http://www.emeyex.com/site/tuts/VertexNormals.pdf
void S3D_MESH::calcPerPointNormals () void S3D_MESH::calcPerPointNormals ()
{ {
//DBG( printf( "calcPerPointNormals" ) );
if( isPerPointNormalsComputed == true ) if( isPerPointNormalsComputed == true )
{ {
return; return;
......
...@@ -66,6 +66,7 @@ public: ...@@ -66,6 +66,7 @@ public:
// Point and index list // Point and index list
std::vector< glm::vec3 > m_Point; std::vector< glm::vec3 > m_Point;
std::vector< std::vector<int> > m_CoordIndex; std::vector< std::vector<int> > m_CoordIndex;
std::vector< std::vector<int> > m_NormalIndex;
std::vector< glm::vec3 > m_PerFaceNormalsNormalized; std::vector< glm::vec3 > m_PerFaceNormalsNormalized;
std::vector< glm::vec3 > m_PerVertexNormalsNormalized; std::vector< glm::vec3 > m_PerVertexNormalsNormalized;
......
...@@ -167,6 +167,7 @@ private: ...@@ -167,6 +167,7 @@ private:
int read_IndexedFaceSet(); int read_IndexedFaceSet();
int read_Coordinate(); int read_Coordinate();
int read_Normal(); int read_Normal();
int read_NormalIndex();
int read_Color(); int read_Color();
int read_coordIndex(); int read_coordIndex();
int read_colorIndex(); int read_colorIndex();
......
...@@ -68,6 +68,9 @@ void VRML1_MODEL_PARSER::Load( const wxString aFilename ) ...@@ -68,6 +68,9 @@ void VRML1_MODEL_PARSER::Load( const wxString aFilename )
glShadeModel( GL_SMOOTH ); glShadeModel( GL_SMOOTH );
glEnable( GL_NORMALIZE ); glEnable( GL_NORMALIZE );
float vrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits * UNITS3D_TO_UNITSPCB;
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, GetMaster()->m_MatScale.z );
glm::vec3 matRot( GetMaster()->m_MatRotation.x, GetMaster()->m_MatRotation.y, GetMaster()->m_MatRotation.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 ); glm::vec3 matPos( GetMaster()->m_MatPosition.x, GetMaster()->m_MatPosition.y, GetMaster()->m_MatPosition.z );
...@@ -78,15 +81,12 @@ void VRML1_MODEL_PARSER::Load( const wxString aFilename ) ...@@ -78,15 +81,12 @@ void VRML1_MODEL_PARSER::Load( const wxString aFilename )
//glPushMatrix(); //glPushMatrix();
glTranslatef( matPos.x * SCALE_3D_CONV, matPos.y * SCALE_3D_CONV, matPos.z * SCALE_3D_CONV ); glTranslatef( matPos.x * SCALE_3D_CONV, matPos.y * SCALE_3D_CONV, matPos.z * SCALE_3D_CONV );
glRotatef( matRot.z, 0.0f, 0.0f, 1.0f ); glRotatef(-matRot.z, 0.0f, 0.0f, 1.0f );
glRotatef( matRot.y, 0.0f, 1.0f, 0.0f ); glRotatef(-matRot.y, 0.0f, 1.0f, 0.0f );
glRotatef( matRot.x, 1.0f, 0.0f, 0.0f ); glRotatef(-matRot.x, 1.0f, 0.0f, 0.0f );
glScalef( matScale.x, matScale.y, matScale.z ); glScalef( matScale.x, matScale.y, matScale.z );
float vrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits * UNITS3D_TO_UNITSPCB;
glScalef( vrmlunits_to_3Dunits, vrmlunits_to_3Dunits, vrmlunits_to_3Dunits );
// Switch the locale to standard C (needed to print floating point numbers like 1.3) // Switch the locale to standard C (needed to print floating point numbers like 1.3)
SetLocaleTo_C_standard(); SetLocaleTo_C_standard();
......
...@@ -70,6 +70,9 @@ void VRML2_MODEL_PARSER::Load( const wxString aFilename ) ...@@ -70,6 +70,9 @@ void VRML2_MODEL_PARSER::Load( const wxString aFilename )
glShadeModel(GL_SMOOTH); glShadeModel(GL_SMOOTH);
glEnable(GL_NORMALIZE); glEnable(GL_NORMALIZE);
float vrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits * UNITS3D_TO_UNITSPCB;
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, GetMaster()->m_MatScale.z );
glm::vec3 matRot( GetMaster()->m_MatRotation.x, GetMaster()->m_MatRotation.y, GetMaster()->m_MatRotation.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 ); glm::vec3 matPos( GetMaster()->m_MatPosition.x, GetMaster()->m_MatPosition.y, GetMaster()->m_MatPosition.z );
...@@ -80,15 +83,12 @@ void VRML2_MODEL_PARSER::Load( const wxString aFilename ) ...@@ -80,15 +83,12 @@ void VRML2_MODEL_PARSER::Load( const wxString aFilename )
//glPushMatrix(); //glPushMatrix();
glTranslatef( matPos.x * SCALE_3D_CONV, matPos.y * SCALE_3D_CONV, matPos.z * SCALE_3D_CONV ); glTranslatef( matPos.x * SCALE_3D_CONV, matPos.y * SCALE_3D_CONV, matPos.z * SCALE_3D_CONV );
glRotatef( matRot.z, 0.0f, 0.0f, 1.0f ); glRotatef(-matRot.z, 0.0f, 0.0f, 1.0f );
glRotatef( matRot.y, 0.0f, 1.0f, 0.0f ); glRotatef(-matRot.y, 0.0f, 1.0f, 0.0f );
glRotatef( matRot.x, 1.0f, 0.0f, 0.0f ); glRotatef(-matRot.x, 1.0f, 0.0f, 0.0f );
glScalef( matScale.x, matScale.y, matScale.z ); glScalef( matScale.x, matScale.y, matScale.z );
float vrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits * UNITS3D_TO_UNITSPCB;
glScalef( vrmlunits_to_3Dunits, vrmlunits_to_3Dunits, vrmlunits_to_3Dunits );
// Switch the locale to standard C (needed to print floating point numbers like 1.3) // Switch the locale to standard C (needed to print floating point numbers like 1.3)
SetLocaleTo_C_standard(); SetLocaleTo_C_standard();
...@@ -546,12 +546,10 @@ int VRML2_MODEL_PARSER::read_IndexedFaceSet() ...@@ -546,12 +546,10 @@ int VRML2_MODEL_PARSER::read_IndexedFaceSet()
read_Coordinate(); read_Coordinate();
} else if( strcmp( text, "Normal" ) == 0 ) } else if( strcmp( text, "Normal" ) == 0 )
{ {
//read_Normal(); read_Normal();
read_NotImplemented( m_file, '}' );
} else if( strcmp( text, "normalIndex" ) == 0 ) } else if( strcmp( text, "normalIndex" ) == 0 )
{ {
//DBG( printf( " normalIndex NotImplemented\n" ) ); read_NormalIndex();
read_NotImplemented( m_file, ']' );
} else if( strcmp( text, "Color" ) == 0 ) } else if( strcmp( text, "Color" ) == 0 )
{ {
read_Color(); read_Color();
...@@ -606,6 +604,38 @@ int VRML2_MODEL_PARSER::read_colorIndex() ...@@ -606,6 +604,38 @@ int VRML2_MODEL_PARSER::read_colorIndex()
} }
int VRML2_MODEL_PARSER::read_NormalIndex()
{
//DBG( printf( " read_NormalIndex\n" ) );
m_model->m_NormalIndex.clear();
glm::ivec3 coord;
int dummy; // should be -1
std::vector<int> coord_list;
coord_list.clear();
while( fscanf (m_file, "%d, ", &dummy ) == 1 )
{
if( dummy == -1 )
{
m_model->m_NormalIndex.push_back( coord_list );
//DBG( printf( " size: %lu ", coord_list.size()) );
coord_list.clear();
} else
{
coord_list.push_back( dummy );
//DBG( printf( "%d ", dummy) );
}
}
//DBG( printf( " m_NormalIndex.size: %ld\n", m_model->m_NormalIndex.size() ) );
return 0;
}
int VRML2_MODEL_PARSER::read_coordIndex() int VRML2_MODEL_PARSER::read_coordIndex()
{ {
//DBG( printf( " read_coordIndex\n" ) ); //DBG( printf( " read_coordIndex\n" ) );
......
...@@ -64,7 +64,7 @@ void VRML_MODEL_PARSER::Load( const wxString aFilename ) ...@@ -64,7 +64,7 @@ void VRML_MODEL_PARSER::Load( const wxString aFilename )
char line[12]; char line[12];
FILE* file; FILE* file;
// DBG( printf( "Load %s\n", static_cast<const char*>(aFilename.mb_str()) ) ); //DBG( printf( "Load %s", static_cast<const char*>(aFilename.mb_str()) ) );
file = wxFopen( aFilename, wxT( "rt" ) ); file = wxFopen( aFilename, wxT( "rt" ) );
......
...@@ -69,17 +69,22 @@ void X3D_MODEL_PARSER::Load( const wxString aFilename ) ...@@ -69,17 +69,22 @@ void X3D_MODEL_PARSER::Load( const wxString aFilename )
glShadeModel(GL_SMOOTH); glShadeModel(GL_SMOOTH);
glEnable(GL_NORMALIZE); glEnable(GL_NORMALIZE);
glm::vec3 matScale(GetMaster()->m_MatScale.x, GetMaster()->m_MatScale.y, GetMaster()->m_MatScale.z ); float vrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits * UNITS3D_TO_UNITSPCB;
glm::vec3 matRot(GetMaster()->m_MatRotation.x, GetMaster()->m_MatRotation.y, GetMaster()->m_MatRotation.z ); glScalef( vrmlunits_to_3Dunits, vrmlunits_to_3Dunits, vrmlunits_to_3Dunits );
glm::vec3 matPos(GetMaster()->m_MatPosition.x, GetMaster()->m_MatPosition.y, GetMaster()->m_MatPosition.z );
glm::vec3 matScale( GetMaster()->m_MatScale.x, GetMaster()->m_MatScale.y, GetMaster()->m_MatScale.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)
//glPushMatrix(); //glPushMatrix();
glTranslatef( matPos.x, matPos.y, matPos.z); glTranslatef( matPos.x * SCALE_3D_CONV, matPos.y * SCALE_3D_CONV, matPos.z * SCALE_3D_CONV );
glRotatef( matRot.z, 0.0f, 0.0f, 1.0f); glRotatef(-matRot.z, 0.0f, 0.0f, 1.0f );
glRotatef( matRot.y, 0.0f, 1.0f, 0.0f); glRotatef(-matRot.y, 0.0f, 1.0f, 0.0f );
glRotatef( matRot.x, 1.0f, 0.0f, 0.0f); glRotatef(-matRot.x, 1.0f, 0.0f, 0.0f );
glScalef( matScale.x, matScale.y, matScale.z ); glScalef( matScale.x, matScale.y, matScale.z );
...@@ -502,9 +507,6 @@ void X3D_MODEL_PARSER::readIndexedFaceSet( wxXmlNode* aFaceNode, ...@@ -502,9 +507,6 @@ void X3D_MODEL_PARSER::readIndexedFaceSet( wxXmlNode* aFaceNode,
//triplets.push_back(point); //triplets.push_back(point);
double vrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits * UNITS3D_TO_UNITSPCB;
point *= vrmlunits_to_3Dunits;
m_model->m_Point.push_back( point ); m_model->m_Point.push_back( point );
// VRML // VRML
......
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