EgtGraphics 1.5b5 :
- aggiunto ZoomWin - aggiunto DrawRectWin.
This commit is contained in:
@@ -191,6 +191,23 @@ Scene::CalcDirUp( void)
|
||||
return m_bUpOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::CalcCameraFrame( Frame3d& frView)
|
||||
{
|
||||
// verifico direzione camera Up
|
||||
if ( ! CalcDirUp())
|
||||
return false ;
|
||||
// eseguo il calcolo
|
||||
Vector3d vtZ = m_vtDirCamera ;
|
||||
Vector3d vtY = m_vtUp ;
|
||||
Vector3d vtX = vtY ^ vtZ ;
|
||||
if ( ! frView.Set( m_ptCenter + m_dDistCamera * vtZ, vtX, vtY, vtZ))
|
||||
return false ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::PanCamera( const Point3d& ptWinOld, const Point3d& ptWinNew)
|
||||
@@ -294,3 +311,38 @@ Scene::ZoomOnPoint( const Point3d& ptWin, double dCoeff)
|
||||
// eseguo lo zoom
|
||||
return ZoomChange( dCoeff) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::ZoomWin( const Point3d& ptWin1, const Point3d& ptWin2)
|
||||
{
|
||||
// porto i punti in coordinate mondo
|
||||
Point3d ptWorld1 ;
|
||||
if ( ! UnProject( Point3d( ptWin1.x, ptWin1.y, GetProjectedCenter().z), ptWorld1))
|
||||
return false ;
|
||||
Point3d ptWorld2 ;
|
||||
if ( ! UnProject( Point3d( ptWin2.x, ptWin2.y, GetProjectedCenter().z), ptWorld2))
|
||||
return false ;
|
||||
|
||||
// recupero il riferimento della camera (vista)
|
||||
Frame3d frView ;
|
||||
if ( ! CalcCameraFrame( frView))
|
||||
return false ;
|
||||
|
||||
// porto i punti in coordinate camera (vista)
|
||||
Point3d ptView1 = ptWorld1 ;
|
||||
ptView1.ToLoc( frView) ;
|
||||
Point3d ptView2 = ptWorld2 ;
|
||||
ptView2.ToLoc( frView) ;
|
||||
|
||||
// imposto il nuovo centro di vista
|
||||
Point3d ptNewCen = 0.5 * ( ptWorld1 + ptWorld2) ;
|
||||
SetCenter( ptNewCen) ;
|
||||
|
||||
// imposto il nuovo zoom
|
||||
double dHalfWidth = 0.5 * fabs( ptView1.x - ptView2.x) ;
|
||||
double dHalfHeight = 0.5 * fabs( ptView1.y - ptView2.y) ;
|
||||
|
||||
// adatto le dimensioni a quelle della vista
|
||||
return AdjustDimView( dHalfWidth, dHalfHeight) ;
|
||||
}
|
||||
Reference in New Issue
Block a user