Loading 3d-viewer/3d_draw.cpp +11 −8 Original line number Diff line number Diff line Loading @@ -424,7 +424,7 @@ void EDA_3D_CANVAS::Redraw() // Initialize Projection Matrix for Ortographic View glOrtho( -size.x / orthoReductionFactor, size.x / orthoReductionFactor, -size.y / orthoReductionFactor, size.y / orthoReductionFactor, 1, 100 ); -size.y / orthoReductionFactor, size.y / orthoReductionFactor, 1, 10 ); } else { Loading @@ -432,7 +432,7 @@ void EDA_3D_CANVAS::Redraw() double ratio_HV = (double) size.x / size.y; // 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 Loading Loading @@ -979,7 +979,7 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList) if( g_Parm_3D_Visu.IsRealisticMode() ) { SetGLEpoxyColor( 0.9 ); SetGLEpoxyColor( 1.0 ); if( g_Parm_3D_Visu.HightQualityMode() ) { SetGLTexture( m_text_pcb, 35.0f ); Loading Loading @@ -1400,7 +1400,7 @@ void EDA_3D_CANVAS::CreateDrawGL_List() m_glLists[GL_ID_BOARD] = glGenLists( 1 ); m_glLists[GL_ID_BODY] = glGenLists( 1 ); BuildBoard3DView(m_glLists[GL_ID_BOARD], m_glLists[GL_ID_BODY]); CheckGLError( __FILE__, __LINE__ ); } if( ! m_glLists[GL_ID_TECH_LAYERS] ) Loading @@ -1409,6 +1409,7 @@ void EDA_3D_CANVAS::CreateDrawGL_List() glNewList( m_glLists[GL_ID_TECH_LAYERS], GL_COMPILE ); BuildTechLayers3DView(); glEndList(); CheckGLError( __FILE__, __LINE__ ); } if( ! m_glLists[GL_ID_AUX_LAYERS] ) Loading @@ -1417,9 +1418,9 @@ void EDA_3D_CANVAS::CreateDrawGL_List() glNewList( m_glLists[GL_ID_AUX_LAYERS], GL_COMPILE ); BuildBoard3DAuxLayers(); glEndList(); CheckGLError( __FILE__, __LINE__ ); } // draw modules 3D shapes if( ! m_glLists[GL_ID_3DSHAPES_SOLID_FRONT] && g_Parm_3D_Visu.GetFlag( FL_MODULE ) ) { Loading @@ -1434,14 +1435,16 @@ void EDA_3D_CANVAS::CreateDrawGL_List() BuildFootprintShape3DList( m_glLists[GL_ID_3DSHAPES_SOLID_FRONT], m_glLists[GL_ID_3DSHAPES_TRANSP_FRONT], false ); CheckGLError( __FILE__, __LINE__ ); m_glLists[GL_ID_SHADOW_FRONT] = glGenLists( 1 ); m_glLists[GL_ID_SHADOW_BACK] = 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]); } // Test for errors CheckGLError( __FILE__, __LINE__ ); } #ifdef PRINT_CALCULATION_TIME unsigned endtime = GetRunningMicroSecs(); Loading 3d-viewer/3d_draw_basic_functions.cpp +9 −2 Original line number Diff line number Diff line Loading @@ -51,12 +51,12 @@ static void CALLBACK tessCPolyPt2Vertex( const GLvoid* data ); // 2 helper functions to set the current normal vector for gle items static inline void SetNormalZpos() { glNormal3f( 0.0, 0.0, 1.0 ); //glNormal3f( 0.0, 0.0, 1.0 ); } 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 ); Loading Loading @@ -185,6 +185,10 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList, 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[1] = -polylist.GetY( ii ) * aBiuTo3DUnits; // gluTessVertex store pointers on data, not data, so do not store Loading @@ -193,6 +197,7 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList, // before calling gluDeleteTess gluTessVertex( tess, v_data, &polylist[ii] ); if( polylist.IsEndContour( ii ) ) { gluTessEndContour( tess ); Loading @@ -215,7 +220,9 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList, gluDeleteTess( tess ); if( aThickness == 0 ) { return; } // Build the 3D data : vertical side Draw3D_VerticalPolygonalCylinder( polylist, aThickness, aZpos - (aThickness / 2.0), false, aBiuTo3DUnits ); Loading 3d-viewer/3d_material.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -54,10 +54,10 @@ S3D_MATERIAL::S3D_MATERIAL( S3D_MASTER* father, const wxString& name ) : 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 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 ); //glColor4f( 1.0, 1.0, 1.0, 1.0 ); Loading 3d-viewer/3d_mesh_model.cpp +15 −2 Original line number Diff line number Diff line Loading @@ -57,6 +57,8 @@ S3D_MESH::~S3D_MESH() void S3D_MESH::openGL_RenderAllChilds() { //DBG( printf( "openGL_RenderAllChilds") ); glPushMatrix(); glTranslatef( m_translation.x, m_translation.y, m_translation.z ); glRotatef( m_rotation[3], m_rotation[0], m_rotation[1], m_rotation[2] ); Loading @@ -76,12 +78,13 @@ void S3D_MESH::openGL_RenderAllChilds() SetOpenGlDefaultMaterial(); glPopMatrix(); } void S3D_MESH::openGL_Render() { //DBG( printf( " render\n" ) ); //DBG( printf( "openGL_Render" ) ); if( m_Materials ) { Loading @@ -90,6 +93,7 @@ void S3D_MESH::openGL_Render() if( m_CoordIndex.size() == 0) { return; } Loading Loading @@ -134,7 +138,7 @@ void S3D_MESH::openGL_Render() { 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 ); glm::vec3 point = m_Point[m_CoordIndex[idx][ii]]; Loading Loading @@ -176,6 +180,8 @@ void S3D_MESH::openGL_Render() void S3D_MESH::calcPointNormalized () { //DBG( printf( "calcPointNormalized\n" ) ); if( isPointNormalizedComputed == true ) { return; Loading Loading @@ -221,8 +227,11 @@ bool IsClockwise(glm::vec3 v0, glm::vec3 v1, glm::vec3 v2) void S3D_MESH::calcPerFaceNormals () { //DBG( printf( "calcPerFaceNormals" ) ); if( isPerFaceNormalsComputed == true ) { return; } isPerFaceNormalsComputed = true; Loading @@ -230,6 +239,7 @@ void S3D_MESH::calcPerFaceNormals () if( m_PerVertexNormalsNormalized.size() > 0 ) { return; } Loading Loading @@ -317,12 +327,15 @@ void S3D_MESH::calcPerFaceNormals () } } } // http://www.bytehazard.com/code/vertnorm.html // http://www.emeyex.com/site/tuts/VertexNormals.pdf void S3D_MESH::calcPerPointNormals () { //DBG( printf( "calcPerPointNormals" ) ); if( isPerPointNormalsComputed == true ) { return; Loading 3d-viewer/3d_mesh_model.h +1 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ public: // Point and index list std::vector< glm::vec3 > m_Point; 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_PerVertexNormalsNormalized; Loading Loading
3d-viewer/3d_draw.cpp +11 −8 Original line number Diff line number Diff line Loading @@ -424,7 +424,7 @@ void EDA_3D_CANVAS::Redraw() // Initialize Projection Matrix for Ortographic View glOrtho( -size.x / orthoReductionFactor, size.x / orthoReductionFactor, -size.y / orthoReductionFactor, size.y / orthoReductionFactor, 1, 100 ); -size.y / orthoReductionFactor, size.y / orthoReductionFactor, 1, 10 ); } else { Loading @@ -432,7 +432,7 @@ void EDA_3D_CANVAS::Redraw() double ratio_HV = (double) size.x / size.y; // 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 Loading Loading @@ -979,7 +979,7 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList) if( g_Parm_3D_Visu.IsRealisticMode() ) { SetGLEpoxyColor( 0.9 ); SetGLEpoxyColor( 1.0 ); if( g_Parm_3D_Visu.HightQualityMode() ) { SetGLTexture( m_text_pcb, 35.0f ); Loading Loading @@ -1400,7 +1400,7 @@ void EDA_3D_CANVAS::CreateDrawGL_List() m_glLists[GL_ID_BOARD] = glGenLists( 1 ); m_glLists[GL_ID_BODY] = glGenLists( 1 ); BuildBoard3DView(m_glLists[GL_ID_BOARD], m_glLists[GL_ID_BODY]); CheckGLError( __FILE__, __LINE__ ); } if( ! m_glLists[GL_ID_TECH_LAYERS] ) Loading @@ -1409,6 +1409,7 @@ void EDA_3D_CANVAS::CreateDrawGL_List() glNewList( m_glLists[GL_ID_TECH_LAYERS], GL_COMPILE ); BuildTechLayers3DView(); glEndList(); CheckGLError( __FILE__, __LINE__ ); } if( ! m_glLists[GL_ID_AUX_LAYERS] ) Loading @@ -1417,9 +1418,9 @@ void EDA_3D_CANVAS::CreateDrawGL_List() glNewList( m_glLists[GL_ID_AUX_LAYERS], GL_COMPILE ); BuildBoard3DAuxLayers(); glEndList(); CheckGLError( __FILE__, __LINE__ ); } // draw modules 3D shapes if( ! m_glLists[GL_ID_3DSHAPES_SOLID_FRONT] && g_Parm_3D_Visu.GetFlag( FL_MODULE ) ) { Loading @@ -1434,14 +1435,16 @@ void EDA_3D_CANVAS::CreateDrawGL_List() BuildFootprintShape3DList( m_glLists[GL_ID_3DSHAPES_SOLID_FRONT], m_glLists[GL_ID_3DSHAPES_TRANSP_FRONT], false ); CheckGLError( __FILE__, __LINE__ ); m_glLists[GL_ID_SHADOW_FRONT] = glGenLists( 1 ); m_glLists[GL_ID_SHADOW_BACK] = 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]); } // Test for errors CheckGLError( __FILE__, __LINE__ ); } #ifdef PRINT_CALCULATION_TIME unsigned endtime = GetRunningMicroSecs(); Loading
3d-viewer/3d_draw_basic_functions.cpp +9 −2 Original line number Diff line number Diff line Loading @@ -51,12 +51,12 @@ static void CALLBACK tessCPolyPt2Vertex( const GLvoid* data ); // 2 helper functions to set the current normal vector for gle items static inline void SetNormalZpos() { glNormal3f( 0.0, 0.0, 1.0 ); //glNormal3f( 0.0, 0.0, 1.0 ); } 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 ); Loading Loading @@ -185,6 +185,10 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList, 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[1] = -polylist.GetY( ii ) * aBiuTo3DUnits; // gluTessVertex store pointers on data, not data, so do not store Loading @@ -193,6 +197,7 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList, // before calling gluDeleteTess gluTessVertex( tess, v_data, &polylist[ii] ); if( polylist.IsEndContour( ii ) ) { gluTessEndContour( tess ); Loading @@ -215,7 +220,9 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList, gluDeleteTess( tess ); if( aThickness == 0 ) { return; } // Build the 3D data : vertical side Draw3D_VerticalPolygonalCylinder( polylist, aThickness, aZpos - (aThickness / 2.0), false, aBiuTo3DUnits ); Loading
3d-viewer/3d_material.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -54,10 +54,10 @@ S3D_MATERIAL::S3D_MATERIAL( S3D_MASTER* father, const wxString& name ) : 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 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 ); //glColor4f( 1.0, 1.0, 1.0, 1.0 ); Loading
3d-viewer/3d_mesh_model.cpp +15 −2 Original line number Diff line number Diff line Loading @@ -57,6 +57,8 @@ S3D_MESH::~S3D_MESH() void S3D_MESH::openGL_RenderAllChilds() { //DBG( printf( "openGL_RenderAllChilds") ); glPushMatrix(); glTranslatef( m_translation.x, m_translation.y, m_translation.z ); glRotatef( m_rotation[3], m_rotation[0], m_rotation[1], m_rotation[2] ); Loading @@ -76,12 +78,13 @@ void S3D_MESH::openGL_RenderAllChilds() SetOpenGlDefaultMaterial(); glPopMatrix(); } void S3D_MESH::openGL_Render() { //DBG( printf( " render\n" ) ); //DBG( printf( "openGL_Render" ) ); if( m_Materials ) { Loading @@ -90,6 +93,7 @@ void S3D_MESH::openGL_Render() if( m_CoordIndex.size() == 0) { return; } Loading Loading @@ -134,7 +138,7 @@ void S3D_MESH::openGL_Render() { 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 ); glm::vec3 point = m_Point[m_CoordIndex[idx][ii]]; Loading Loading @@ -176,6 +180,8 @@ void S3D_MESH::openGL_Render() void S3D_MESH::calcPointNormalized () { //DBG( printf( "calcPointNormalized\n" ) ); if( isPointNormalizedComputed == true ) { return; Loading Loading @@ -221,8 +227,11 @@ bool IsClockwise(glm::vec3 v0, glm::vec3 v1, glm::vec3 v2) void S3D_MESH::calcPerFaceNormals () { //DBG( printf( "calcPerFaceNormals" ) ); if( isPerFaceNormalsComputed == true ) { return; } isPerFaceNormalsComputed = true; Loading @@ -230,6 +239,7 @@ void S3D_MESH::calcPerFaceNormals () if( m_PerVertexNormalsNormalized.size() > 0 ) { return; } Loading Loading @@ -317,12 +327,15 @@ void S3D_MESH::calcPerFaceNormals () } } } // http://www.bytehazard.com/code/vertnorm.html // http://www.emeyex.com/site/tuts/VertexNormals.pdf void S3D_MESH::calcPerPointNormals () { //DBG( printf( "calcPerPointNormals" ) ); if( isPerPointNormalsComputed == true ) { return; Loading
3d-viewer/3d_mesh_model.h +1 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ public: // Point and index list std::vector< glm::vec3 > m_Point; 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_PerVertexNormalsNormalized; Loading