diff --git a/EgtGraphics.rc b/EgtGraphics.rc index 2a12b9d..8339764 100644 Binary files a/EgtGraphics.rc and b/EgtGraphics.rc differ diff --git a/SceneGeom.cpp b/SceneGeom.cpp index afa1abf..3e26c77 100644 --- a/SceneGeom.cpp +++ b/SceneGeom.cpp @@ -174,14 +174,19 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj) // nuova modalità grafica solo per superfici con molti triangoli const int N_MIN_TRIA_NEWWAY = 100 ; bool bNewWay = false ; - if ( m_bNewWay && ( nGeoType & GEO_SURF) != 0) { - const ISurfTriMesh* pSTM = nullptr ; - switch ( nGeoType) { - case SRF_TRIMESH : pSTM = GetSurfTriMesh( pGeoObj) ; break ; - case SRF_FLATRGN : pSTM = GetSurfFlatRegion( pGeoObj)->GetAuxSurf() ; break ; - } - if ( pSTM != nullptr && pSTM->GetTriangleCount() > N_MIN_TRIA_NEWWAY) + if ( m_bNewWay) { + if (( nGeoType & GEO_SURF) != 0) { + const ISurfTriMesh* pSTM = nullptr ; + switch ( nGeoType) { + case SRF_TRIMESH : pSTM = GetSurfTriMesh( pGeoObj) ; break ; + case SRF_FLATRGN : pSTM = GetSurfFlatRegion( pGeoObj)->GetAuxSurf() ; break ; + } + if ( pSTM != nullptr && pSTM->GetTriangleCount() > N_MIN_TRIA_NEWWAY) + bNewWay = true ; + } + else if (( nGeoType & GEO_VOLUME) != 0) { bNewWay = true ; + } } ObjEGrGraphics* pGraphics = CreateObjEGrGraphics( bNewWay) ; if ( pGraphics == nullptr) @@ -324,27 +329,32 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj) const IVolZmap* pZmap = GetVolZmap( pGeoObj) ; if ( pZmap == nullptr) return false ; - // calcolo la grafica + // recupero il materiale + Material mMat ; + if ( ! iIter.GetCalcMaterial( mMat)) + mMat.Set( m_colDef) ; + // impostazioni iniziali pGraphics->Clear() ; - pGraphics->AddColor( BLUE) ; - POLYLINELIST lstPL ; - for ( int i = 0 ; ; ++ i) { - bool bOutBreak = false ; - for ( int j = 0 ; ; ++ j) { - if ( pZmap->GetDexelLines( 1, j, i, lstPL)) { - for ( const auto& PL : lstPL) - pGraphics->AddPolyLine( PL) ; - } - else { - if ( j == 0) - bOutBreak = true ; - break ; - } - } - if ( bOutBreak) - break ; - } - + pGraphics->AddColor( siObj.colObj) ; // per wireframe + pGraphics->AddMaterial( mMat.GetAmbient(), mMat.GetDiffuse(), + mMat.GetSpecular(), mMat.GetShininess()) ; + pGraphics->AddBackMaterial( GetSurfBackColor( mMat.GetDiffuse())) ; + // recupero la geometria + TRIA3DLIST lstTria ; + pZmap->GetAllTriangles( lstTria) ; + // passo i triangoli alla grafica + pGraphics->StartTriangles( int( lstTria.size())) ; + for ( const auto& Tria : lstTria) { + TriFlags3d TFlags ; + TriNormals3d TNrms ; + for ( int i = 0 ; i < 3 ; ++i) { + // i triangoli sono sempre parte di un quadrilatero -> terzo lato da non visualizzare + TFlags.bFlag[i] = ( i != 2 ? true : false) ; + TNrms.vtN[i] = Tria.GetN() ; + } + pGraphics->AddTriangle( Tria, TFlags, TNrms) ; + } + pGraphics->EndTriangles() ; } // se testo else if ( nGeoType == EXT_TEXT) { @@ -381,7 +391,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj) // se hiddenline e non selezione if ( m_nShowMode == SM_HIDDENLINE && ! m_bSelect) { // in prima passata disegno solo le superfici opache - if ( nPass == 1 && ( ( nGeoType & GEO_SURF) == 0 || nAlpha <= ALPHA_LIM)) + if ( nPass == 1 && ( ( nGeoType & ( GEO_SURF | GEO_VOLUME)) == 0 || nAlpha <= ALPHA_LIM)) return true ; } @@ -390,7 +400,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj) if ( m_nShowMode == SM_SHADING && ! m_bSelect) { // in prima passata disegno solo le superfici opache e metto in un vettore quelle semitrasparenti if ( nPass == 1) { - if ( ( nGeoType & GEO_SURF) == 0) + if ( ( nGeoType & ( GEO_SURF | GEO_VOLUME)) == 0) return true ; else { if ( nAlpha > ALPHA_LIM) @@ -413,7 +423,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj) } } // in seconda passata disegno solo dimensioni 0 e curve - if ( nPass == 2 && ( nGeoType & GEO_SURF) != 0) + if ( nPass == 2 && ( nGeoType & ( GEO_SURF | GEO_VOLUME)) != 0) return true ; }