EgtGraphics 1.6b5 :
- modifiche per gestione superfici trasparenti - migliorata gestione colore da padre.
This commit is contained in:
+10
@@ -46,3 +46,13 @@ FrameToOpenGlMatrix( const Frame3d& frFrame, double Matrix[OGLMAT_DIM])
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline bool
|
||||
OpenGlMatrixToFrame( const double Matrix[OGLMAT_DIM], Frame3d& frFrame)
|
||||
{
|
||||
return frFrame.Set( Point3d( Matrix[12], Matrix[13], Matrix[14]),
|
||||
Vector3d( Matrix[0], Matrix[1], Matrix[2]),
|
||||
Vector3d( Matrix[4], Matrix[5], Matrix[6]),
|
||||
Vector3d( Matrix[8], Matrix[9], Matrix[10])) ;
|
||||
}
|
||||
|
||||
Binary file not shown.
+2
-1
@@ -42,7 +42,8 @@ class ObjEGrGraphics : public IObjGraphics
|
||||
virtual bool StartTriangles( int nNum, bool bAux = false) = 0 ;
|
||||
virtual bool AddTriangle( const Triangle3d& Tria, const TriFlags3d& TFlags, const TriNormals3d& TNrms) = 0 ;
|
||||
virtual bool EndTriangles( void) = 0 ;
|
||||
virtual bool Draw( int nStat, int nMark, bool bSurfSha, bool ShowAux) = 0 ;
|
||||
virtual bool Draw( int nStat, int nMark, bool bSurfSha, int nAlpha, bool ShowAux) = 0 ;
|
||||
virtual bool GetLocalBBox( BBox3d& b3Loc) = 0 ;
|
||||
} ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
+10
-2
@@ -105,6 +105,7 @@ ObjNewGraphics::AddPoint( const Point3d& ptP, bool bAux)
|
||||
glBufferData( GL_ARRAY_BUFFER, 1 * SIZEV3F, NULL, GL_STATIC_DRAW) ;
|
||||
Vert3f v3V( ptP) ;
|
||||
glBufferSubData( GL_ARRAY_BUFFER, 0, SIZEV3F, &v3V) ;
|
||||
m_b3Loc.Add( ptP) ;
|
||||
int nCount = 1 ;
|
||||
glVertexPointer( 3, GL_FLOAT, 0, ((void*)(0))) ;
|
||||
glEnableClientState( GL_VERTEX_ARRAY) ;
|
||||
@@ -143,6 +144,7 @@ ObjNewGraphics::AddLines( const PNTVECTOR& vPnt, bool bAux)
|
||||
for ( int i = 0 ; i < nCount ; ++ i) {
|
||||
v3V.Set( vPnt[i]) ;
|
||||
glBufferSubData( GL_ARRAY_BUFFER, i * SIZEV3F, SIZEV3F, &v3V) ;
|
||||
m_b3Loc.Add( vPnt[i]) ;
|
||||
}
|
||||
glVertexPointer( 3, GL_FLOAT, 0, ((void*)(0))) ;
|
||||
glEnableClientState( GL_VERTEX_ARRAY) ;
|
||||
@@ -182,6 +184,7 @@ ObjNewGraphics::AddPolyLine( const PolyLine& PL, bool bAux)
|
||||
for ( bool bFound = PL.GetFirstPoint( ptP) ; bFound ; bFound = PL.GetNextPoint( ptP)) {
|
||||
v3V.Set( ptP) ;
|
||||
glBufferSubData( GL_ARRAY_BUFFER, nCount * SIZEV3F, SIZEV3F, &v3V) ;
|
||||
m_b3Loc.Add( ptP) ;
|
||||
++ nCount ;
|
||||
}
|
||||
glVertexPointer( 3, GL_FLOAT, 0, ((void*)(0))) ;
|
||||
@@ -238,10 +241,11 @@ ObjNewGraphics::AddTriangle( const Triangle3d& Tria, const TriFlags3d& TFlags, c
|
||||
return false ;
|
||||
// recupero il conteggio dei vertici
|
||||
int nCount = m_ngaList.back().m_nCount ;
|
||||
// emetto i vertici e le normali del triangolo
|
||||
// emetto i flag, le normali e i vertici del triangolo + aggiorno bbox
|
||||
for ( int i = 0 ; i < 3 ; ++ i) {
|
||||
Vert3f v3V( Tria.GetP( i)) ;
|
||||
glBufferSubData( GL_ARRAY_BUFFER, nCount * SIZEVNF, SIZEV3F, &v3V) ;
|
||||
m_b3Loc.Add( Tria.GetP( i)) ;
|
||||
Vert3f v3N( TNrms.vtN[i]) ;
|
||||
glBufferSubData( GL_ARRAY_BUFFER, nCount * SIZEVNF + SIZEV3F, SIZEV3F, &v3N) ;
|
||||
unsigned char cFlag = ( TFlags.bFlag[i] ? 1 : 0) ;
|
||||
@@ -280,7 +284,7 @@ ObjNewGraphics::EndTriangles( void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ObjNewGraphics::Draw( int nStat, int nMark, bool bSurfSha, bool bShowAux)
|
||||
ObjNewGraphics::Draw( int nStat, int nMark, bool bSurfSha, int nAlpha, bool bShowAux)
|
||||
{
|
||||
if ( ! m_bValid || m_pScene == nullptr || ! m_pScene->MakeCurrent())
|
||||
return false ;
|
||||
@@ -305,15 +309,19 @@ ObjNewGraphics::Draw( int nStat, int nMark, bool bSurfSha, bool bShowAux)
|
||||
if ( nMark == GDB_MK_ON) {
|
||||
bStdCol = false ;
|
||||
Color colMark = ( ( GetScene() != nullptr) ? GetScene()->GetMark() : Color( 192, 192, 0)) ;
|
||||
colMark.SetAlpha( nAlpha) ;
|
||||
colMark.GetFloat( fSelMarkCol) ;
|
||||
Color colMarkBack = GetSurfBackColor( colMark) ;
|
||||
colMarkBack.SetAlpha( nAlpha) ;
|
||||
colMarkBack.GetFloat( fSelMarkBackCol) ;
|
||||
}
|
||||
else if ( nStat == GDB_ST_SEL) {
|
||||
bStdCol = false ;
|
||||
Color colSelSurf = ( ( GetScene() != nullptr) ? GetScene()->GetSelSurf() : Color( 255, 255, 192)) ;
|
||||
colSelSurf.SetAlpha( nAlpha) ;
|
||||
colSelSurf.GetFloat( fSelMarkCol) ;
|
||||
Color colSelSurfBack = GetSurfBackColor( colSelSurf) ;
|
||||
colSelSurfBack.SetAlpha( nAlpha) ;
|
||||
colSelSurfBack.GetFloat( fSelMarkBackCol) ;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -76,7 +76,9 @@ class ObjNewGraphics : public ObjEGrGraphics
|
||||
virtual bool StartTriangles( int nNum, bool bAux = false) ;
|
||||
virtual bool AddTriangle( const Triangle3d& Tria, const TriFlags3d& TFlags, const TriNormals3d& TNrms) ;
|
||||
virtual bool EndTriangles( void) ;
|
||||
virtual bool Draw( int nStat, int nMark, bool bSurfSha, bool bShowAux) ;
|
||||
virtual bool Draw( int nStat, int nMark, bool bSurfSha, int nAlpha, bool bShowAux) ;
|
||||
virtual bool GetLocalBBox( BBox3d& b3Loc)
|
||||
{ b3Loc = m_b3Loc ; return ! m_b3Loc.IsEmpty() ; }
|
||||
|
||||
public :
|
||||
ObjNewGraphics( void) : m_pScene( nullptr), m_bValid( false) {}
|
||||
@@ -109,6 +111,7 @@ class ObjNewGraphics : public ObjEGrGraphics
|
||||
bool m_bValid ; // flag
|
||||
int m_nCurrMode ; // modo corrente
|
||||
NGALIST m_ngaList ; // liste di atomi per nuova grafica
|
||||
BBox3d m_b3Loc ; // BoundingBox locale
|
||||
} ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
+17
-6
@@ -83,6 +83,8 @@ ObjOldGraphics::AddPoint( const Point3d& ptP, bool bAux)
|
||||
AddStart( GL_POINTS, bAux) ;
|
||||
// inserisco il nuovo vertice
|
||||
AddVert3f( ptP) ;
|
||||
// aggiorno bbox
|
||||
m_b3Loc.Add( ptP) ;
|
||||
// fine
|
||||
AddEnd() ;
|
||||
// dichiaro valida la grafica
|
||||
@@ -100,9 +102,11 @@ ObjOldGraphics::AddLines( const PNTVECTOR& vPnt, bool bAux)
|
||||
return false ;
|
||||
// start
|
||||
AddStart( GL_LINES, bAux) ;
|
||||
// inserisco i vertici
|
||||
for ( int i = 0 ; i < int( vPnt.size()) ; ++ i)
|
||||
// inserisco i vertici + aggiorno bbox
|
||||
for ( int i = 0 ; i < int( vPnt.size()) ; ++ i) {
|
||||
AddVert3f( vPnt[i]) ;
|
||||
m_b3Loc.Add( vPnt[i]) ;
|
||||
}
|
||||
// fine
|
||||
AddEnd() ;
|
||||
// dichiaro valida la grafica
|
||||
@@ -120,10 +124,12 @@ ObjOldGraphics::AddPolyLine( const PolyLine& PL, bool bAux)
|
||||
return false ;
|
||||
// start
|
||||
AddStart( GL_LINE_STRIP, bAux) ;
|
||||
// inserisco i nuovi vertici
|
||||
// inserisco i nuovi vertici + aggiorno bbox
|
||||
Point3d ptP ;
|
||||
for ( bool bFound = PL.GetFirstPoint( ptP) ; bFound ; bFound = PL.GetNextPoint( ptP))
|
||||
for ( bool bFound = PL.GetFirstPoint( ptP) ; bFound ; bFound = PL.GetNextPoint( ptP)) {
|
||||
AddVert3f( ptP) ;
|
||||
m_b3Loc.Add( ptP) ;
|
||||
}
|
||||
// fine
|
||||
AddEnd() ;
|
||||
// dichiaro valida la grafica
|
||||
@@ -152,11 +158,12 @@ ObjOldGraphics::AddTriangle( const Triangle3d& Tria, const TriFlags3d& TFlags, c
|
||||
// modo corrente deve essere triangoli
|
||||
if ( m_nCurrMode != GL_TRIANGLES)
|
||||
return false ;
|
||||
// emetto le normali e i vertici del triangolo
|
||||
// emetto i flag, le normali e i vertici del triangolo + aggiorno bbox
|
||||
for ( int i = 0 ; i < 3 ; ++ i) {
|
||||
AddBndFlag( TFlags.bFlag[i]) ;
|
||||
AddNormal3f( TNrms.vtN[i]) ;
|
||||
AddVert3f( Tria.GetP( i)) ;
|
||||
m_b3Loc.Add( Tria.GetP( i)) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
@@ -179,7 +186,7 @@ ObjOldGraphics::EndTriangles( void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ObjOldGraphics::Draw( int nStat, int nMark, bool bSurfSha, bool bShowAux)
|
||||
ObjOldGraphics::Draw( int nStat, int nMark, bool bSurfSha, int nAlpha, bool bShowAux)
|
||||
{
|
||||
// se vuoto non faccio alcunché
|
||||
if ( m_ogaList.size() == 0)
|
||||
@@ -201,15 +208,19 @@ ObjOldGraphics::Draw( int nStat, int nMark, bool bSurfSha, bool bShowAux)
|
||||
if ( nMark == GDB_MK_ON) {
|
||||
bStdCol = false ;
|
||||
Color colMark = ( ( GetScene() != nullptr) ? GetScene()->GetMark() : Color( 255, 255, 0)) ;
|
||||
colMark.SetAlpha( nAlpha) ;
|
||||
colMark.GetFloat( fSelMarkCol) ;
|
||||
Color colMarkBack = GetSurfBackColor( colMark) ;
|
||||
colMarkBack.SetAlpha( nAlpha) ;
|
||||
colMarkBack.GetFloat( fSelMarkBackCol) ;
|
||||
}
|
||||
else if ( nStat == GDB_ST_SEL) {
|
||||
bStdCol = false ;
|
||||
Color colSelSurf = ( ( GetScene() != nullptr) ? GetScene()->GetSelSurf() : Color( 255, 255, 192)) ;
|
||||
colSelSurf.SetAlpha( nAlpha) ;
|
||||
colSelSurf.GetFloat( fSelMarkCol) ;
|
||||
Color colSelSurfBack = GetSurfBackColor( colSelSurf) ;
|
||||
colSelSurfBack.SetAlpha( nAlpha) ;
|
||||
colSelSurfBack.GetFloat( fSelMarkBackCol) ;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -80,7 +80,9 @@ class ObjOldGraphics : public ObjEGrGraphics
|
||||
virtual bool StartTriangles( int nNum, bool bAux = false) ;
|
||||
virtual bool AddTriangle( const Triangle3d& Tria, const TriFlags3d& TFlags, const TriNormals3d& TNrms) ;
|
||||
virtual bool EndTriangles( void) ;
|
||||
virtual bool Draw( int nStat, int nMark, bool bSurfSha, bool bShowAux) ;
|
||||
virtual bool Draw( int nStat, int nMark, bool bSurfSha, int nAlpha, bool bShowAux) ;
|
||||
virtual bool GetLocalBBox( BBox3d& b3Loc)
|
||||
{ b3Loc = m_b3Loc ; return ! m_b3Loc.IsEmpty() ; }
|
||||
|
||||
public :
|
||||
ObjOldGraphics( void) : m_pScene( nullptr), m_nCurrMode( GL_NONE), m_bValid( false) {}
|
||||
@@ -130,6 +132,7 @@ class ObjOldGraphics : public ObjEGrGraphics
|
||||
bool m_bValid ; // flag
|
||||
int m_nCurrMode ; // modo corrente
|
||||
OGALIST m_ogaList ; // lista di atomi per vecchia grafica
|
||||
BBox3d m_b3Loc ; // BoundingBox locale
|
||||
} ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -20,17 +20,17 @@
|
||||
|
||||
class IGdbIterator ;
|
||||
class ICurve ;
|
||||
class ObjEGrGraphics ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class MdStMk
|
||||
struct MdStMkCol
|
||||
{
|
||||
public :
|
||||
MdStMk( int nMd, int nSt, int nMk) : nMode( nMd), nStat( nSt), nMark( nMk) {}
|
||||
|
||||
public :
|
||||
int nMode ;
|
||||
int nStat ;
|
||||
int nMark ;
|
||||
int nMode ;
|
||||
int nStat ;
|
||||
int nMark ;
|
||||
Color colObj ;
|
||||
MdStMkCol( int nMd, int nSt, int nMk, Color colC)
|
||||
: nMode( nMd), nStat( nSt), nMark( nMk), colObj( colC) {}
|
||||
} ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -41,6 +41,19 @@ struct SelRec { // record di selezione per OpenGL (buffer di GLuint)
|
||||
GLuint nId ; // nome dell'oggetto
|
||||
} ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
struct AlphaSurf {
|
||||
ObjEGrGraphics* pGraph ;
|
||||
int nStat ;
|
||||
int nMark ;
|
||||
int nAlpha ;
|
||||
bool bShowAux ;
|
||||
double dZmin ;
|
||||
double dZmax ;
|
||||
AlphaSurf( ObjEGrGraphics* pG, int nS, int nM, int nA, bool bSA, double dZm, double dZM)
|
||||
: pGraph( pG), nStat( nS), nMark( nM), nAlpha( nA), bShowAux( bSA), dZmin( dZm), dZmax( dZM) {}
|
||||
} ;
|
||||
typedef std::vector<AlphaSurf> ASURFVECTOR ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class Scene : public IEGrScene
|
||||
@@ -167,9 +180,10 @@ class Scene : public IEGrScene
|
||||
bool CalcDirUp( void) ;
|
||||
bool CalcCameraFrame( Frame3d& frView) ;
|
||||
// Geometry
|
||||
bool DrawGroup( int nId, int nPass, MdStMk siParent) ;
|
||||
bool DrawGroup( const IGdbIterator& iIter, int nPass, MdStMk siParent) ;
|
||||
bool DrawGeoObj( const IGdbIterator& iIter, int nPass, MdStMk siObj) ;
|
||||
bool DrawGroup( int nId, int nPass, const MdStMkCol& siParent) ;
|
||||
bool DrawGroup( const IGdbIterator& iIter, int nPass, const MdStMkCol& siParent) ;
|
||||
bool DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj) ;
|
||||
bool DrawAlphaSurfVector( void) ;
|
||||
bool DeleteObjGraphicsGroup( int nId) ;
|
||||
// Grid
|
||||
const Frame3d& GetGridFrame( void)
|
||||
@@ -233,7 +247,9 @@ class Scene : public IEGrScene
|
||||
IGeomDB* m_pGeomDB ; // puntatore al DB geometrico
|
||||
Color m_colDef ; // colore di default
|
||||
Color m_colMark ; // colore per marcatura
|
||||
Color m_colSelSurf ; // colore di superficie selezionata
|
||||
Color m_colSelSurf ; // colore di superficie selezionata
|
||||
// Superfici semitrasparenti
|
||||
ASURFVECTOR m_vAlphaSurf ; // vettore temporaneo di superfici semitrasparenti
|
||||
// Extension
|
||||
BBox3d m_b3ExtWorld ; // estensione della geometria nel riferimento globale (mondo)
|
||||
BBox3d m_b3ExtView ; // estensione nel riferimento di vista
|
||||
|
||||
+26
-6
@@ -70,6 +70,8 @@ Scene::Scene( void)
|
||||
m_colDef.Set( 0, 0, 0) ;
|
||||
m_colMark.Set( 255, 255, 0) ;
|
||||
m_colSelSurf.Set( 255, 255, 192) ;
|
||||
// Superfici semitrasparenti
|
||||
m_vAlphaSurf.reserve( 100) ;
|
||||
// Extension
|
||||
SetExtension( BBox3d( -MIN_EXTENSION, -MIN_EXTENSION, -MIN_EXTENSION,
|
||||
MIN_EXTENSION, MIN_EXTENSION, MIN_EXTENSION)) ;
|
||||
@@ -685,7 +687,7 @@ Scene::Draw( void)
|
||||
// imposto disegno wireframe anche per poligoni
|
||||
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE) ;
|
||||
// disegno le geometrie del DB in una sola passata
|
||||
DrawGroup( GDB_ID_ROOT, 1, MdStMk( GDB_MD_STD, GDB_ST_ON, GDB_MK_OFF)) ;
|
||||
DrawGroup( GDB_ID_ROOT, 1, MdStMkCol( GDB_MD_STD, GDB_ST_ON, GDB_MK_OFF, m_colDef)) ;
|
||||
break ;
|
||||
case SM_HIDDENLINE :
|
||||
// disabilito illuminazione
|
||||
@@ -696,14 +698,14 @@ Scene::Draw( void)
|
||||
glEnable( GL_POLYGON_OFFSET_FILL) ;
|
||||
glPolygonOffset( 1.0, 1.0) ;
|
||||
glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE) ;
|
||||
DrawGroup( GDB_ID_ROOT, 1, MdStMk( GDB_MD_STD, GDB_ST_ON, GDB_MK_OFF)) ;
|
||||
DrawGroup( GDB_ID_ROOT, 1, MdStMkCol( GDB_MD_STD, GDB_ST_ON, GDB_MK_OFF, m_colDef)) ;
|
||||
glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE) ;
|
||||
glDisable( GL_POLYGON_OFFSET_FILL) ;
|
||||
// disegno griglia senza illuminazione (già impostato)
|
||||
DrawGrid() ;
|
||||
// seconda passata per tutto in forma 0dim e curve
|
||||
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE) ;
|
||||
DrawGroup( GDB_ID_ROOT, 2, MdStMk( GDB_MD_STD, GDB_ST_ON, GDB_MK_OFF)) ;
|
||||
DrawGroup( GDB_ID_ROOT, 2, MdStMkCol( GDB_MD_STD, GDB_ST_ON, GDB_MK_OFF, m_colDef)) ;
|
||||
break ;
|
||||
case SM_SHADING :
|
||||
// disegno griglia senza illuminazione
|
||||
@@ -730,16 +732,34 @@ Scene::Draw( void)
|
||||
glLightfv( GL_LIGHT1, GL_POSITION, Light1Pos) ;
|
||||
glEnable( GL_LIGHT1) ;
|
||||
// disegno le geometrie del DB
|
||||
// prima passata per superfici con illuminazione abilitata
|
||||
// annullo vettore superfici traslucide
|
||||
m_vAlphaSurf.clear() ;
|
||||
// prima passata per superfici completamente opache con illuminazione abilitata
|
||||
glEnable( GL_POLYGON_OFFSET_FILL) ;
|
||||
glPolygonOffset( 0.75, 0.75) ;
|
||||
glEnable( GL_LIGHTING) ;
|
||||
DrawGroup( GDB_ID_ROOT, 1, MdStMk( GDB_MD_STD, GDB_ST_ON, GDB_MK_OFF)) ;
|
||||
DrawGroup( GDB_ID_ROOT, 1, MdStMkCol( GDB_MD_STD, GDB_ST_ON, GDB_MK_OFF, m_colDef)) ;
|
||||
glDisable( GL_POLYGON_OFFSET_FILL) ;
|
||||
// seconda passata per 0dim e curve con illuminazione disabilitata
|
||||
glDisable( GL_LIGHTING) ;
|
||||
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE) ;
|
||||
DrawGroup( GDB_ID_ROOT, 2, MdStMk( GDB_MD_STD, GDB_ST_ON, GDB_MK_OFF)) ;
|
||||
DrawGroup( GDB_ID_ROOT, 2, MdStMkCol( GDB_MD_STD, GDB_ST_ON, GDB_MK_OFF, m_colDef)) ;
|
||||
// terza passata su vettore di superfici trasparenti con :
|
||||
// illuminazione abilitata, blend abilitato e Zdepth solo in lettura
|
||||
if ( m_vAlphaSurf.size() > 0) {
|
||||
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL) ;
|
||||
glEnable( GL_POLYGON_OFFSET_FILL) ;
|
||||
glPolygonOffset( 0.75, 0.75) ;
|
||||
glEnable( GL_LIGHTING) ;
|
||||
glEnable( GL_BLEND) ;
|
||||
glDepthMask( GL_FALSE) ;
|
||||
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ;
|
||||
DrawAlphaSurfVector() ;
|
||||
m_vAlphaSurf.clear() ;
|
||||
glDepthMask( GL_TRUE) ;
|
||||
glDisable( GL_BLEND) ;
|
||||
glDisable( GL_POLYGON_OFFSET_FILL) ;
|
||||
}
|
||||
break ;
|
||||
}
|
||||
|
||||
|
||||
+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 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
+1
-1
@@ -87,7 +87,7 @@ Scene::Select( const Point3d& ptSelCenter, int nW, int nH, int& nSel)
|
||||
glDisable( GL_LIGHTING) ;
|
||||
// non imposto glPolygonMode secondo il tipo di rendering perchè ignorato in selezione
|
||||
// disegno le geometrie del DB in una sola passata
|
||||
DrawGroup( GDB_ID_ROOT, 1, MdStMk( GDB_MD_STD, GDB_ST_ON, GDB_MK_OFF)) ;
|
||||
DrawGroup( GDB_ID_ROOT, 1, MdStMkCol( GDB_MD_STD, GDB_ST_ON, GDB_MK_OFF, m_colDef)) ;
|
||||
|
||||
// pulisco stack nomi
|
||||
glPopName() ;
|
||||
|
||||
Reference in New Issue
Block a user