EgtGraphics :
- modifiche per colore più scuro in wireframe superfici (se sfondo chiaro).
This commit is contained in:
+37
-16
@@ -22,8 +22,6 @@
|
||||
|
||||
|
||||
//--------------------------- Macro e Costanti -------------------------------
|
||||
// Per funzioni glew dipendenti dal context
|
||||
//#define glewGetContext() (( m_pScene != nullptr) ? m_pScene->glewGetContext() : nullptr)
|
||||
// Dimensioni flag per edge di triangoli
|
||||
const size_t SIZEFLAG = sizeof( unsigned char) ;
|
||||
// Dimensioni record del buffer ( vertice + normale + flag)
|
||||
@@ -48,7 +46,7 @@ void
|
||||
ObjNewGraphics::Clear( void)
|
||||
{
|
||||
DeleteVaoVbo() ;
|
||||
m_ngaList.clear() ;
|
||||
m_ngaVect.clear() ;
|
||||
m_bValid = false ;
|
||||
m_nCurrMode = GL_NONE ;
|
||||
}
|
||||
@@ -240,7 +238,7 @@ ObjNewGraphics::AddTriangle( const Triangle3d& Tria, const TriFlags3d& TFlags, c
|
||||
if ( m_nCurrMode != GL_TRIANGLES)
|
||||
return false ;
|
||||
// recupero il conteggio dei vertici
|
||||
int nCount = m_ngaList.back().m_nCount ;
|
||||
int nCount = m_ngaVect.back().m_nCount ;
|
||||
// emetto i vertici, le normali e i flag del triangolo
|
||||
#pragma pack( push, 1)
|
||||
struct VnfBuf {
|
||||
@@ -258,7 +256,7 @@ ObjNewGraphics::AddTriangle( const Triangle3d& Tria, const TriFlags3d& TFlags, c
|
||||
glBufferSubData( GL_ARRAY_BUFFER, nCount * SIZEVNF, 3 * SIZEVNF, Buffer) ;
|
||||
// aggiorno il conteggio
|
||||
nCount += 3 ;
|
||||
m_ngaList.back().m_nCount = nCount ;
|
||||
m_ngaVect.back().m_nCount = nCount ;
|
||||
// aggiorno bbox
|
||||
for ( int i = 0 ; i < 3 ; ++ i)
|
||||
m_b3Loc.Add( Tria.GetP( i)) ;
|
||||
@@ -291,6 +289,23 @@ ObjNewGraphics::EndTriangles( void)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static float*
|
||||
AdjustColor( float fCol[4], bool bDark)
|
||||
{
|
||||
if ( ! bDark) {
|
||||
return fCol ;
|
||||
}
|
||||
else {
|
||||
static float fDarkCol[4] = { fCol[0], fCol[1], fCol[2], fCol[3]} ;
|
||||
fDarkCol[0] = fCol[0] * 0.6f ;
|
||||
fDarkCol[1] = fCol[1] * 0.6f ;
|
||||
fDarkCol[2] = fCol[2] * 0.6f ;
|
||||
fDarkCol[3] = fCol[3] * 0.6f ;
|
||||
return fDarkCol ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ObjNewGraphics::Draw( int nStat, int nMark, bool bSurfSha, int nAlpha, bool bShowAux)
|
||||
@@ -299,7 +314,7 @@ ObjNewGraphics::Draw( int nStat, int nMark, bool bSurfSha, int nAlpha, bool bSho
|
||||
return false ;
|
||||
|
||||
// se vuoto non faccio alcunché
|
||||
if ( m_ngaList.size() == 0)
|
||||
if ( m_ngaVect.size() == 0)
|
||||
return true ;
|
||||
|
||||
// gestione stato di visualizzazione
|
||||
@@ -317,7 +332,7 @@ ObjNewGraphics::Draw( int nStat, int nMark, bool bSurfSha, int nAlpha, bool bSho
|
||||
if ( bSurfSha) {
|
||||
if ( nMark == GDB_MK_ON) {
|
||||
bStdCol = false ;
|
||||
Color colMark = ( ( GetScene() != nullptr) ? GetScene()->GetMark() : Color( 192, 192, 0)) ;
|
||||
Color colMark = m_pScene->GetMark() ;
|
||||
colMark.SetAlpha( nAlpha) ;
|
||||
colMark.GetFloat( fSelMarkCol) ;
|
||||
Color colMarkBack = GetSurfBackColor( colMark) ;
|
||||
@@ -326,7 +341,7 @@ ObjNewGraphics::Draw( int nStat, int nMark, bool bSurfSha, int nAlpha, bool bSho
|
||||
}
|
||||
else if ( nStat == GDB_ST_SEL) {
|
||||
bStdCol = false ;
|
||||
Color colSelSurf = ( ( GetScene() != nullptr) ? GetScene()->GetSelSurf() : Color( 255, 255, 192)) ;
|
||||
Color colSelSurf = m_pScene->GetSelSurf() ;
|
||||
colSelSurf.SetAlpha( nAlpha) ;
|
||||
colSelSurf.GetFloat( fSelMarkCol) ;
|
||||
Color colSelSurfBack = GetSurfBackColor( colSelSurf) ;
|
||||
@@ -335,9 +350,17 @@ ObjNewGraphics::Draw( int nStat, int nMark, bool bSurfSha, int nAlpha, bool bSho
|
||||
}
|
||||
}
|
||||
|
||||
// determino se devo scurire il colore wireframe
|
||||
bool bDark = false ;
|
||||
if ( bStdCol && ! bSurfSha) {
|
||||
Color colBT, colBB ;
|
||||
m_pScene->GetBackground( colBT, colBB) ;
|
||||
int nColMid = ( colBT.GetIntIntensity() + colBB.GetIntIntensity()) / 2 ;
|
||||
bDark = ( nColMid > 127) ;
|
||||
}
|
||||
|
||||
// ciclo di disegno
|
||||
NGALIST::iterator iIter ;
|
||||
for ( iIter = m_ngaList.begin() ; iIter != m_ngaList.end() ; ++ iIter) {
|
||||
for ( auto iIter = m_ngaVect.begin() ; iIter != m_ngaVect.end() ; ++ iIter) {
|
||||
switch ( iIter->m_nType) {
|
||||
case NgAtom::VERTS :
|
||||
if ( iIter->m_nCount > 0 && iIter->m_nVaoId != 0) {
|
||||
@@ -354,7 +377,7 @@ ObjNewGraphics::Draw( int nStat, int nMark, bool bSurfSha, int nAlpha, bool bSho
|
||||
}
|
||||
break ;
|
||||
case NgAtom::COLOR :
|
||||
glColor4fv( ( bStdCol ? iIter->m_fCol : fSelMarkCol)) ;
|
||||
glColor4fv( ( bStdCol ? AdjustColor( iIter->m_fCol, bDark) : fSelMarkCol)) ;
|
||||
break ;
|
||||
case NgAtom::MAT_A :
|
||||
glMaterialfv( GL_FRONT, GL_AMBIENT, ( bStdCol ? iIter->m_fCol : fSelMarkCol)) ;
|
||||
@@ -384,12 +407,11 @@ ObjNewGraphics::Draw( int nStat, int nMark, bool bSurfSha, int nAlpha, bool bSho
|
||||
glLineWidth( (float) m_pScene->GetMarkLineWidth()) ;
|
||||
|
||||
// colore di marcatura
|
||||
Color colMark = ( ( GetScene() != nullptr) ? GetScene()->GetMark() : Color( 192, 192, 0)) ;
|
||||
Color colMark = m_pScene->GetMark() ;
|
||||
glColor4f( colMark.GetRed(), colMark.GetGreen(), colMark.GetBlue(), colMark.GetAlpha()) ;
|
||||
|
||||
// ciclo di disegno
|
||||
NGALIST::iterator iIter ;
|
||||
for ( iIter = m_ngaList.begin() ; iIter != m_ngaList.end() ; ++ iIter) {
|
||||
for ( auto iIter = m_ngaVect.begin() ; iIter != m_ngaVect.end() ; ++ iIter) {
|
||||
switch ( iIter->m_nType) {
|
||||
case NgAtom::VERTS :
|
||||
if ( iIter->m_nCount > 0 && iIter->m_nVaoId != 0) {
|
||||
@@ -429,8 +451,7 @@ ObjNewGraphics::DeleteVaoVbo( void)
|
||||
return false ;
|
||||
|
||||
// ciclo di cancellazione VAO/VBO
|
||||
NGALIST::iterator iIter ;
|
||||
for ( iIter = m_ngaList.begin() ; iIter != m_ngaList.end() ; ++ iIter) {
|
||||
for ( auto iIter = m_ngaVect.begin() ; iIter != m_ngaVect.end() ; ++ iIter) {
|
||||
if ( iIter->m_nType == NgAtom::VERTS && iIter->m_nCount > 0) {
|
||||
glBindBuffer( GL_ARRAY_BUFFER, 0) ;
|
||||
glDeleteBuffers( 1, &iIter->m_nVboId) ;
|
||||
|
||||
Reference in New Issue
Block a user