EgtGraphics 1.6b5 :
- modifiche per gestione superfici trasparenti - migliorata gestione colore da padre.
This commit is contained in:
+68
-26
@@ -68,7 +68,7 @@ Scene::SetSelSurf( Color colSelSurf)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::DrawGroup( int nId, int nPass, MdStMk cParent)
|
||||
Scene::DrawGroup( int nId, int nPass, const MdStMkCol& cParent)
|
||||
{
|
||||
// creo un iteratore
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGeomDB)) ;
|
||||
@@ -85,7 +85,7 @@ Scene::DrawGroup( int nId, int nPass, MdStMk cParent)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::DrawGroup( const IGdbIterator& iIter, int nPass, MdStMk cParent)
|
||||
Scene::DrawGroup( const IGdbIterator& iIter, int nPass, const MdStMkCol& cParent)
|
||||
{
|
||||
// creo un iteratore
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGeomDB)) ;
|
||||
@@ -123,6 +123,9 @@ Scene::DrawGroup( const IGdbIterator& iIter, int nPass, MdStMk cParent)
|
||||
int nMark = GDB_MK_OFF ;
|
||||
pIter->GetMark( nMark) ;
|
||||
nMark = ::CalcMark( nMark, cParent.nMark) ;
|
||||
// recupero e aggiorno il colore dell'oggetto
|
||||
Color colObj = cParent.colObj ;
|
||||
pIter->GetMaterial( colObj) ;
|
||||
// se in modalità selezione, verifico sia selezionabile
|
||||
bool bSel = true ;
|
||||
if ( m_bSelect && UnselectableFind( pIter->GetId()))
|
||||
@@ -131,7 +134,7 @@ Scene::DrawGroup( const IGdbIterator& iIter, int nPass, MdStMk cParent)
|
||||
if ( nGdbType == GDB_TY_GEO) {
|
||||
// se non nascosto e selezionabile, lo disegno
|
||||
if ( nStat != GDB_ST_OFF && bSel) {
|
||||
if ( ! DrawGeoObj( *pIter, nPass, MdStMk( nMode, nStat, nMark)))
|
||||
if ( ! DrawGeoObj( *pIter, nPass, MdStMkCol( nMode, nStat, nMark, colObj)))
|
||||
bOk = false ;
|
||||
}
|
||||
}
|
||||
@@ -139,7 +142,7 @@ Scene::DrawGroup( const IGdbIterator& iIter, int nPass, MdStMk cParent)
|
||||
else if ( nGdbType == GDB_TY_GROUP) {
|
||||
// se non nascosto e selezionabile, lo disegno
|
||||
if ( nStat != GDB_ST_OFF && bSel) {
|
||||
if ( ! DrawGroup( *pIter, nPass, MdStMk( nMode, nStat, nMark)))
|
||||
if ( ! DrawGroup( *pIter, nPass, MdStMkCol( nMode, nStat, nMark, colObj)))
|
||||
bOk = false ;
|
||||
}
|
||||
}
|
||||
@@ -153,8 +156,11 @@ Scene::DrawGroup( const IGdbIterator& iIter, int nPass, MdStMk cParent)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, MdStMk siObj)
|
||||
Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
|
||||
{
|
||||
// valore limite di opacità oltre il quale è considerata completa
|
||||
const int ALPHA_LIM = 90 ;
|
||||
|
||||
// recupero l'oggetto geometrico e il suo tipo
|
||||
IGeoObj* pGeoObj = (const_cast<IGdbIterator*>(&iIter))->GetGeoObj() ;
|
||||
if ( pGeoObj == nullptr)
|
||||
@@ -181,10 +187,6 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, MdStMk siObj)
|
||||
// se la grafica associata non è valida la ricalcolo
|
||||
ObjEGrGraphics* pGraphics = GetObjEGrGraphics( pGeoObj) ;
|
||||
if ( ! pGraphics->IsValid()) {
|
||||
// recupero il colore
|
||||
Color cCol ;
|
||||
if ( ! iIter.GetCalcMaterial( cCol))
|
||||
cCol = m_colDef ;
|
||||
// se vettore
|
||||
if ( nGeoType == GEO_VECT3D) {
|
||||
// recupero il vettore
|
||||
@@ -195,7 +197,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, MdStMk siObj)
|
||||
PolyLine PL ;
|
||||
pVector->GetDrawWithArrowHead( 0.1, 10, PL) ;
|
||||
pGraphics->Clear() ;
|
||||
pGraphics->AddColor( cCol) ;
|
||||
pGraphics->AddColor( siObj.colObj) ;
|
||||
pGraphics->AddPolyLine( PL) ;
|
||||
}
|
||||
// se punto
|
||||
@@ -206,7 +208,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, MdStMk siObj)
|
||||
return false ;
|
||||
// calcolo la grafica
|
||||
pGraphics->Clear() ;
|
||||
pGraphics->AddColor( cCol) ;
|
||||
pGraphics->AddColor( siObj.colObj) ;
|
||||
pGraphics->AddPoint( pPoint->GetPoint()) ;
|
||||
}
|
||||
// se riferimento
|
||||
@@ -236,7 +238,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, MdStMk siObj)
|
||||
PolyLine PL ;
|
||||
pCurve->ApproxWithLines( 0.005, 5, PL) ;
|
||||
pGraphics->Clear() ;
|
||||
pGraphics->AddColor( cCol) ;
|
||||
pGraphics->AddColor( siObj.colObj) ;
|
||||
pGraphics->AddPolyLine( PL) ;
|
||||
// eventuali segni ausiliari (mark, frecce, ...)
|
||||
Vector3d vtRef ;
|
||||
@@ -275,7 +277,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, MdStMk siObj)
|
||||
mMat.Set( m_colDef) ;
|
||||
// impostazioni iniziali
|
||||
pGraphics->Clear() ;
|
||||
pGraphics->AddColor( cCol) ; // per wireframe
|
||||
pGraphics->AddColor( siObj.colObj) ; // per wireframe
|
||||
pGraphics->AddMaterial( mMat.GetAmbient(), mMat.GetDiffuse(),
|
||||
mMat.GetSpecular(), mMat.GetShininess()) ;
|
||||
pGraphics->AddBackMaterial( GetSurfBackColor( mMat.GetDiffuse())) ;
|
||||
@@ -313,29 +315,55 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, MdStMk siObj)
|
||||
POLYLINELIST lstPL ;
|
||||
pTXT->ApproxWithLines( 0.01, 5, lstPL) ;
|
||||
pGraphics->Clear() ;
|
||||
pGraphics->AddColor( cCol) ;
|
||||
pGraphics->AddColor( siObj.colObj) ;
|
||||
POLYLINELIST::iterator Iter ;
|
||||
for ( Iter = lstPL.begin() ; Iter != lstPL.end() ; ++ Iter)
|
||||
pGraphics->AddPolyLine( *Iter) ;
|
||||
}
|
||||
}
|
||||
|
||||
// se richiesto, visualizzo la grafica associata
|
||||
bool bShowAux = false ;
|
||||
if ( ( nGeoType & GEO_CURVE) != 0 && m_bShowCurveDirection)
|
||||
bShowAux = true ;
|
||||
|
||||
// recupero il valore di opacità (solo per le superfici può esserci trasparenza)
|
||||
int nAlpha = siObj.colObj.GetIntAlpha() ;
|
||||
|
||||
// se hiddenline e non selezione
|
||||
if ( m_nShowMode == SM_HIDDENLINE && ! m_bSelect) {
|
||||
// in prima passata disegno solo le superfici
|
||||
if ( nPass == 1 && ( nGeoType & GEO_SURF) == 0)
|
||||
// in prima passata disegno solo le superfici opache
|
||||
if ( nPass == 1 && ( ( nGeoType & GEO_SURF) == 0 || nAlpha <= ALPHA_LIM))
|
||||
return true ;
|
||||
}
|
||||
|
||||
// se shading e non modalità selezione
|
||||
bool bSurfSha = false ;
|
||||
if ( m_nShowMode == SM_SHADING && ! m_bSelect) {
|
||||
// in prima passata disegno solo le superfici
|
||||
if ( nPass == 1)
|
||||
if ( ( nGeoType & GEO_SURF) != 0)
|
||||
bSurfSha = true ;
|
||||
else
|
||||
// in prima passata disegno solo le superfici opache e metto in un vettore quelle semitrasparenti
|
||||
if ( nPass == 1) {
|
||||
if ( ( nGeoType & GEO_SURF) == 0)
|
||||
return true ;
|
||||
else {
|
||||
if ( nAlpha > ALPHA_LIM)
|
||||
bSurfSha = true ;
|
||||
else {
|
||||
// recupero matrice MODELVIEW corrente
|
||||
GLdouble ModelView[ OGLMAT_DIM] ;
|
||||
glGetDoublev( GL_MODELVIEW_MATRIX, ModelView) ;
|
||||
Frame3d frModView ;
|
||||
OpenGlMatrixToFrame( ModelView, frModView) ;
|
||||
// recupero il box dell'oggetto e lo porto nel riferimento MODELVIEW
|
||||
BBox3d b3Box ;
|
||||
pGraphics->GetLocalBBox( b3Box) ;
|
||||
b3Box.ToGlob( frModView) ;
|
||||
// inserisco i dati nel vettore
|
||||
m_vAlphaSurf.emplace_back( pGraphics, siObj.nStat, siObj.nMark, nAlpha, bShowAux,
|
||||
b3Box.GetMin().z, b3Box.GetMax().z) ;
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// in seconda passata disegno solo dimensioni 0 e curve
|
||||
if ( nPass == 2 && ( nGeoType & GEO_SURF) != 0)
|
||||
return true ;
|
||||
@@ -345,11 +373,25 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, MdStMk siObj)
|
||||
if ( m_bSelect)
|
||||
glLoadName( iIter.GetId()) ;
|
||||
|
||||
// se richiesto, visualizzo la grafica associata
|
||||
bool bShowAux = false ;
|
||||
if ( ( nGeoType & GEO_CURVE) != 0 && m_bShowCurveDirection)
|
||||
bShowAux = true ;
|
||||
return pGraphics->Draw( siObj.nStat, siObj.nMark, bSurfSha, bShowAux) ;
|
||||
// eseguo visualizzazione
|
||||
return pGraphics->Draw( siObj.nStat, siObj.nMark, bSurfSha, nAlpha, bShowAux) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::DrawAlphaSurfVector( void)
|
||||
{
|
||||
// ordino vettore in senso crescente secondo Zmin
|
||||
sort( m_vAlphaSurf.begin(), m_vAlphaSurf.end(),
|
||||
[]( const AlphaSurf& a, const AlphaSurf&b) { return a.dZmin < b.dZmin ; }) ;
|
||||
|
||||
// eseguo visualizzazione
|
||||
for ( int i = 0 ; i < int( m_vAlphaSurf.size()) ; ++i) {
|
||||
if ( ! m_vAlphaSurf[i].pGraph->Draw( m_vAlphaSurf[i].nStat, m_vAlphaSurf[i].nMark, true,
|
||||
m_vAlphaSurf[i].nAlpha, m_vAlphaSurf[i].bShowAux))
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user