EgtGraphics 2.7a2 :
- aggiunta vista prospettica con due modalità di zoom ( standard e dolly).
This commit is contained in:
+34
-13
@@ -57,12 +57,14 @@ Scene::Scene( void)
|
||||
SetCamera( 0, 0, 0) ;
|
||||
m_nViewportW = 0 ;
|
||||
m_nViewportH = 0 ;
|
||||
m_bOrthographic = true ;
|
||||
m_nPerspZoomType = ZT_STD ;
|
||||
// Textures
|
||||
m_TextMgr.SetScene( this) ;
|
||||
// Sfondo
|
||||
m_colBackTop.Set( 176, 176, 176) ;
|
||||
m_colBackBottom.Set( 176, 176, 176) ;
|
||||
// Modalità di visualizzazione
|
||||
// Modalità di visualizzazione
|
||||
m_nShowMode = SM_WIREFRAME ;
|
||||
m_bShowCurveDirection = false ;
|
||||
m_bShowTriaAdvanced = true ;
|
||||
@@ -138,7 +140,7 @@ Scene::Init( IGeomDB* pGeomDB)
|
||||
bool
|
||||
Scene::CreateContext( HDC hDC, int nDriver, bool b2Buff, int nColorBits, int nDepthBits)
|
||||
{
|
||||
// verifico validità Device Context
|
||||
// verifico validità Device Context
|
||||
if ( hDC == nullptr)
|
||||
return false ;
|
||||
m_hDC = hDC ;
|
||||
@@ -215,7 +217,7 @@ Scene::CreateContext( HDC hDC, int nDriver, bool b2Buff, int nColorBits, int nDe
|
||||
LOG_INFO( GetEGrLogger(), "WGL_ARB_create_context missing !")
|
||||
}
|
||||
|
||||
// verifico validità Rendering Context
|
||||
// verifico validità Rendering Context
|
||||
if ( m_hRC == nullptr)
|
||||
return false ;
|
||||
|
||||
@@ -226,7 +228,7 @@ Scene::CreateContext( HDC hDC, int nDriver, bool b2Buff, int nColorBits, int nDe
|
||||
if ( GlewInitResult != GLEW_OK)
|
||||
LOG_INFO( GetEGrLogger(), "GLEW is not initialized !")
|
||||
|
||||
// verifico se posso lavorare in modalità nuova
|
||||
// verifico se posso lavorare in modalità nuova
|
||||
m_bNewWay = ( nDriver == OD_NEW && glewIsSupported( "GL_VERSION_3_0") == 1) ;
|
||||
if ( ! m_bNewWay)
|
||||
LOG_INFO( GetEGrLogger(), "OpenGL old way rendering !")
|
||||
@@ -288,11 +290,11 @@ Scene::ChooseGenPixelFormat( int nPfd, bool b2Buff, int nColorBits, int nDepthBi
|
||||
bool
|
||||
Scene::MakeCurrent( void) const
|
||||
{
|
||||
// se RC della scena non è definito, errore
|
||||
// se RC della scena non è definito, errore
|
||||
if ( m_hRC == nullptr)
|
||||
return false ;
|
||||
|
||||
// se RC della scena è quello corrente, ok
|
||||
// se RC della scena è quello corrente, ok
|
||||
HGLRC hRC = wglGetCurrentContext() ;
|
||||
if ( m_hRC == hRC)
|
||||
return true ;
|
||||
@@ -419,7 +421,7 @@ Scene::SetExtension( const BBox3d& b3Ext)
|
||||
bool
|
||||
Scene::CalcExtView( void)
|
||||
{
|
||||
// verifico se il calcolo è necessario
|
||||
// verifico se il calcolo è necessario
|
||||
if ( m_bExtViewOk && m_bUpOk)
|
||||
return true ;
|
||||
// calcolo direzione camera Up
|
||||
@@ -515,8 +517,14 @@ Scene::CalcClippingPlanesFromExtView( void)
|
||||
// ricavo la posizione dei piani di clipping sull'asse Z di vista
|
||||
const double EXP_COEFF = 1.1 ;
|
||||
double dExtent = max( ( EXP_COEFF * vtExtent.z), MIN_ZCLIP_EXT) ;
|
||||
m_dZNear = - ( ptCenter.z + dExtent) ;
|
||||
m_dZFar = - ( ptCenter.z - dExtent) ;
|
||||
if ( m_bOrthographic) {
|
||||
m_dZNear = - ( ptCenter.z + dExtent) ;
|
||||
m_dZFar = - ( ptCenter.z - dExtent) ;
|
||||
}
|
||||
else {
|
||||
m_dZNear = PERSPECTIVE_NEAR_PLANE ;
|
||||
m_dZFar = abs( ptCenter.z - dExtent) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -673,6 +681,9 @@ Scene::Prepare( void)
|
||||
|
||||
// eventuale ricalcolo parametri di vista
|
||||
CalcDirUp() ;
|
||||
CalcDistCamera() ;
|
||||
if ( ! m_bOrthographic)
|
||||
m_bDistOk = false ; // resetto il flag per le prossime operazioni
|
||||
|
||||
// imposto matrice di proiezione
|
||||
glMatrixMode( GL_PROJECTION) ;
|
||||
@@ -684,7 +695,17 @@ Scene::Prepare( void)
|
||||
// imposto area di pick
|
||||
gluPickMatrix( m_ptSelCent.x, ( Viewport[3] - m_ptSelCent.y), m_nSelW, m_nSelH, Viewport) ;
|
||||
}
|
||||
glOrtho( - m_dHalfWidth, m_dHalfWidth, - m_dHalfHeight, m_dHalfHeight, m_dZNear, m_dZFar) ;
|
||||
|
||||
if ( m_bOrthographic)
|
||||
glOrtho( - m_dHalfWidth, m_dHalfWidth, - m_dHalfHeight, m_dHalfHeight, m_dZNear, m_dZFar) ;
|
||||
else {
|
||||
// calcolo del fov : se dolly è costante, se zoom standard deve adattarsi alla vista
|
||||
double dFov = PERSPECTIVE_STD_FOV ;
|
||||
if ( m_nPerspZoomType == ZT_STD)
|
||||
dFov = 2 * atan2( m_dHalfHeight, m_dDistCamera) * RADTODEG ;
|
||||
|
||||
gluPerspective( abs( dFov), m_dHalfWidth / m_dHalfHeight, m_dZNear, m_dZFar) ;
|
||||
}
|
||||
|
||||
// imposto matrice modello/vista
|
||||
glMatrixMode( GL_MODELVIEW) ;
|
||||
@@ -731,12 +752,12 @@ Scene::MyDraw( bool bSwapBF)
|
||||
if ( m_pGeomDB != nullptr)
|
||||
m_pGeomDB->GetDefaultMaterial( m_colDef) ;
|
||||
|
||||
// impostazioni dipendenti dalla modalità di visualizzazione
|
||||
// impostazioni dipendenti dalla modalità di visualizzazione
|
||||
switch ( m_nShowMode) {
|
||||
case SM_WIREFRAME :
|
||||
// disabilito illuminazione
|
||||
glDisable( GL_LIGHTING) ;
|
||||
// disegno griglia senza illuminazione (già impostato)
|
||||
// disegno griglia senza illuminazione (già impostato)
|
||||
DrawGrid() ;
|
||||
// imposto dati standard per punti e linee
|
||||
glPointSize( (float) GetPointSize()) ;
|
||||
@@ -749,7 +770,7 @@ Scene::MyDraw( bool bSwapBF)
|
||||
case SM_HIDDENLINE :
|
||||
// disabilito illuminazione
|
||||
glDisable( GL_LIGHTING) ;
|
||||
// disegno griglia senza illuminazione (già impostato)
|
||||
// disegno griglia senza illuminazione (già impostato)
|
||||
DrawGrid() ;
|
||||
// imposto dati standard per punti e linee
|
||||
glPointSize( (float) GetPointSize()) ;
|
||||
|
||||
Reference in New Issue
Block a user