EgtGraphics 1.5d5 :
- Gestione materiali - Facce con front e back diversificati per materiale - HiddenLine.
This commit is contained in:
+39
-15
@@ -91,7 +91,7 @@ Scene::SetMark( Color colMark)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::DrawGroup( int nId, int nParentMode, int nParentStat, int nParentMark)
|
||||
Scene::DrawGroup( int nId, int nPass, MdStMk cParent)
|
||||
{
|
||||
// creo un iteratore
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGeomDB)) ;
|
||||
@@ -103,12 +103,12 @@ Scene::DrawGroup( int nId, int nParentMode, int nParentStat, int nParentMark)
|
||||
return false ;
|
||||
|
||||
// eseguo il disegno
|
||||
return DrawGroup( *pIter, nParentMode, nParentStat, nParentMark) ;
|
||||
return DrawGroup( *pIter, nPass, cParent) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::DrawGroup( const IGdbIterator& iIter, int nParentMode, int nParentStat, int nParentMark)
|
||||
Scene::DrawGroup( const IGdbIterator& iIter, int nPass, MdStMk cParent)
|
||||
{
|
||||
// recupero il riferimento del gruppo
|
||||
Frame3d frFrame ;
|
||||
@@ -121,34 +121,35 @@ Scene::DrawGroup( const IGdbIterator& iIter, int nParentMode, int nParentStat, i
|
||||
double Matrix[OGLMAT_DIM] ;
|
||||
if ( FrameToOpenGlMatrix( frFrame, Matrix))
|
||||
glMultMatrixd( Matrix) ;
|
||||
}
|
||||
}
|
||||
// creo un iteratore
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGeomDB)) ;
|
||||
if ( ! ::IsValid( pIter))
|
||||
return false ;
|
||||
// scandisco il gruppo
|
||||
bool bNext = pIter->GoToFirstInGroup( iIter) ;
|
||||
while ( bNext) {
|
||||
for ( bool bNext = pIter->GoToFirstInGroup( iIter) ;
|
||||
bNext ;
|
||||
bNext = pIter->GoToNext()) {
|
||||
// leggo il tipo di oggetto
|
||||
int nGdbType = pIter->GetGdbType() ;
|
||||
// recupero e aggiorno il modo dell'oggetto
|
||||
int nMode = GDB_MD_STD ;
|
||||
pIter->GetMode( nMode) ;
|
||||
nMode = ::CalcMode( nMode, nParentMode) ;
|
||||
nMode = ::CalcMode( nMode, cParent.nMode) ;
|
||||
// recupero e aggiorno lo stato dell'oggetto
|
||||
int nStat = GDB_ST_ON ;
|
||||
pIter->GetStatus( nStat) ;
|
||||
nStat = ::CalcStatus( nStat, nParentStat) ;
|
||||
nStat = ::CalcStatus( nStat, cParent.nStat) ;
|
||||
nStat = ::AdjustStatusWithMode( nStat, nMode) ;
|
||||
// recupero e aggiorno la marcatura dell'oggetto
|
||||
int nMark = GDB_MK_OFF ;
|
||||
pIter->GetMark( nMark) ;
|
||||
nMark = ::CalcMark( nMark, nParentMark) ;
|
||||
nMark = ::CalcMark( nMark, cParent.nMark) ;
|
||||
// se oggetto geometrico
|
||||
if ( nGdbType == GDB_TY_GEO) {
|
||||
// se non nascosto, lo disegno
|
||||
if ( nStat != GDB_ST_OFF) {
|
||||
if ( ! DrawGeoObj( *pIter, nStat, nMark))
|
||||
if ( ! DrawGeoObj( *pIter, nPass, MdStMk( nMode, nStat, nMark)))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
@@ -156,12 +157,10 @@ Scene::DrawGroup( const IGdbIterator& iIter, int nParentMode, int nParentStat, i
|
||||
else if ( nGdbType == GDB_TY_GROUP) {
|
||||
// se non nascosto, lo disegno
|
||||
if ( nStat != GDB_ST_OFF) {
|
||||
if ( ! DrawGroup( *pIter, nMode, nStat, nMark))
|
||||
if ( ! DrawGroup( *pIter, nPass, MdStMk( nMode, nStat, nMark)))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// passo al successivo
|
||||
bNext = pIter->GoToNext() ;
|
||||
}
|
||||
// se necessario, ripristino lo stack delle matrici
|
||||
if ( bMatrix)
|
||||
@@ -172,7 +171,7 @@ Scene::DrawGroup( const IGdbIterator& iIter, int nParentMode, int nParentStat, i
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::DrawGeoObj( const IGdbIterator& iIter, int nObjStat, int nObjMark)
|
||||
Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, MdStMk siObj)
|
||||
{
|
||||
// recupero l'oggetto geometrico
|
||||
IGeoObj* pGeoObj = (const_cast<IGdbIterator*>(&iIter))->GetGeoObj() ;
|
||||
@@ -260,6 +259,14 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nObjStat, int nObjMark)
|
||||
// impostazioni iniziali
|
||||
pGraphics->Clear() ;
|
||||
pGraphics->AddColor( cCol) ;
|
||||
pGraphics->AddMaterial( cCol, cCol, Color( 192, 192, 192, 50)) ;
|
||||
Color colBack ;
|
||||
float fLum = ( cCol.GetRed() + cCol.GetGreen() + cCol.GetBlue()) / 3 ;
|
||||
colBack.Set( 0.4 * fLum + 0.2 * cCol.GetRed(),
|
||||
0.4 * fLum + 0.2 * cCol.GetGreen(),
|
||||
0.4 * fLum + 0.2 * cCol.GetBlue(),
|
||||
cCol.GetAlpha()) ;
|
||||
pGraphics->AddBackMaterial( colBack) ;
|
||||
pGraphics->StartTriangles( pSTM->GetTriangleNum()) ;
|
||||
// ciclo sui triangoli della superficie
|
||||
Triangle3d Tria ;
|
||||
@@ -274,8 +281,25 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nObjStat, int nObjMark)
|
||||
}
|
||||
}
|
||||
|
||||
// se hiddenline
|
||||
if ( m_nShowMode == SM_HIDDENLINE) {
|
||||
// in prima passata disegno solo le superfici
|
||||
if ( nPass == 1 && ( pGeoObj->GetType() & GEO_SURF) == 0)
|
||||
return true ;
|
||||
}
|
||||
|
||||
// se shading
|
||||
if ( m_nShowMode == SM_SHADING) {
|
||||
// in prima passata disegno solo le superfici
|
||||
if ( nPass == 1 && ( pGeoObj->GetType() & GEO_SURF) == 0)
|
||||
return true ;
|
||||
// in seconda passata disegno solo dimensioni 0 e curve
|
||||
if ( nPass == 2 && ( pGeoObj->GetType() & GEO_SURF) != 0)
|
||||
return true ;
|
||||
}
|
||||
|
||||
// visualizzo la grafica associata
|
||||
return pGraphics->Draw( nObjStat, nObjMark) ;
|
||||
return pGraphics->Draw( siObj.nStat, siObj.nMark) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user