EgtGraphics 2.7b3 :
- in vista prospettica con zoom standard introdotto valore massimo per fov.
This commit is contained in:
Binary file not shown.
@@ -401,3 +401,5 @@ class Scene : public IEGrScene
|
||||
//----------------------------------------------------------------------------
|
||||
static const double PERSPECTIVE_NEAR_PLANE = 10 ;
|
||||
static const double PERSPECTIVE_STD_FOV = 45 ;
|
||||
static const double PERSPECTIVE_MAX_FOV = 100 ;
|
||||
static const double PERSPECTIVE_TAN_MAX_FOV = tan( 0.5 * PERSPECTIVE_MAX_FOV * DEGTORAD) ;
|
||||
|
||||
+13
-3
@@ -701,10 +701,20 @@ Scene::Prepare( void)
|
||||
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 ;
|
||||
double dRatio = m_dHalfWidth / m_dHalfHeight ;
|
||||
if ( m_nPerspZoomType == ZT_STD) {
|
||||
// verifico che il fov non superi il valore massimo consentito
|
||||
if ( m_dHalfHeight / m_dDistCamera > PERSPECTIVE_TAN_MAX_FOV) {
|
||||
dFov = PERSPECTIVE_MAX_FOV ;
|
||||
// aggiusto i valori di HalfHeight e HalfWidth
|
||||
m_dHalfHeight = m_dDistCamera * PERSPECTIVE_TAN_MAX_FOV ;
|
||||
m_dHalfWidth = dRatio * m_dHalfHeight ;
|
||||
}
|
||||
else
|
||||
dFov = 2 * atan2( m_dHalfHeight, m_dDistCamera) * RADTODEG ;
|
||||
}
|
||||
|
||||
gluPerspective( abs( dFov), m_dHalfWidth / m_dHalfHeight, m_dZNear, m_dZFar) ;
|
||||
gluPerspective( abs( dFov), dRatio, m_dZNear, m_dZFar) ;
|
||||
}
|
||||
|
||||
// imposto matrice modello/vista
|
||||
|
||||
+24
-15
@@ -391,10 +391,8 @@ Scene::ZoomAll( void)
|
||||
m_dDistCamera = m_dHalfHeight / tan( PERSPECTIVE_STD_FOV * 0.5 * DEGTORAD) + ( m_b3ExtView.GetMax().z - m_b3ExtView.GetMin().z) * 0.5 ;
|
||||
}
|
||||
else {
|
||||
// verifico di non finire dentro l'oggetto
|
||||
double dDiam ; m_b3ExtView.GetDiameter( dDiam) ;
|
||||
if ( m_dDistCamera < dDiam * 0.5)
|
||||
m_dDistCamera = dDiam * 0.5 ;
|
||||
// aggiusto la distanza della camera
|
||||
m_b3ExtView.GetDiameter( m_dDistCamera) ;
|
||||
|
||||
// il valore di m_dHalfHeight calcolato dal box non garantisce che l'oggetto sia interamente contenuto nel frustum
|
||||
// perchè è il valore in corrispondenza della faccia del box davanti alla camera. Per il calcolo del fov m_dHalfHeight
|
||||
@@ -537,19 +535,30 @@ Scene::ZoomOnPoint( const Point3d& ptWin, double dCoeff)
|
||||
Point3d ptOldCen = m_ptCenter ;
|
||||
Point3d ptNewCen = ptWorld + ( m_ptCenter - ptWorld) * dCoeff ;
|
||||
SetCenter( ptNewCen) ;
|
||||
|
||||
// nel caso di dolly verifico se il nuovo zoom fa entrare negli oggetti
|
||||
if ( ! m_bOrthographic && m_nPerspZoomType == ZT_DOLLY) {
|
||||
double dMinDist = CalcMinCameraDistance() ;
|
||||
if ( m_dDistCamera * dCoeff < dMinDist) {
|
||||
// adatto il coefficiente di zoom e ricalcolo il centro
|
||||
dCoeff = dMinDist / m_dDistCamera ;
|
||||
Point3d ptNewCenter = ptWorld + ( ptOldCen - ptWorld) * dCoeff ;
|
||||
SetCenter( ptNewCenter) ;
|
||||
}
|
||||
}
|
||||
m_bDistOk = true ;
|
||||
|
||||
if ( ! m_bOrthographic) {
|
||||
if ( m_nPerspZoomType == ZT_DOLLY) {
|
||||
// nel caso di dolly verifico se il nuovo zoom fa entrare negli oggetti
|
||||
double dMinDist = CalcMinCameraDistance() ;
|
||||
if ( m_dDistCamera * dCoeff < dMinDist) {
|
||||
// adatto il coefficiente di zoom e ricalcolo il centro
|
||||
dCoeff = dMinDist / m_dDistCamera ;
|
||||
Point3d ptNewCenter = ptWorld + ( ptOldCen - ptWorld) * dCoeff ;
|
||||
SetCenter( ptNewCenter) ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// nel caso standard verifico se il nuovo fov supera il valore massimo
|
||||
if ( m_dHalfHeight * dCoeff / m_dDistCamera > PERSPECTIVE_TAN_MAX_FOV) {
|
||||
// adatto il coefficiente di zoom e ricalcolo il centro
|
||||
dCoeff = PERSPECTIVE_TAN_MAX_FOV * m_dDistCamera / m_dHalfHeight ;
|
||||
Point3d ptNewCenter = ptWorld + ( ptOldCen - ptWorld) * dCoeff ;
|
||||
SetCenter( ptNewCenter) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ZoomChange( dCoeff) ;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user