EgtGraphics :
- migliorato calcolo centro di vista in Zwin utilizzando GetPixelZ.
This commit is contained in:
@@ -246,6 +246,7 @@ class Scene : public IEGrScene
|
||||
bool MyDraw( bool bSwapBF) ;
|
||||
bool Background( void) ;
|
||||
bool Prepare( void) ;
|
||||
bool GetPixelZ( const Point3d& ptWin, double& dWinZ) ;
|
||||
// Camera
|
||||
bool VerifyCamera( bool bUseOrizzOffsCamera = false) ;
|
||||
bool CalcDirUp( bool bUseOrizzOffsCamera = false) ;
|
||||
|
||||
@@ -941,6 +941,24 @@ Scene::UnProject( const Point3d& ptView, Point3d& ptWorld) const
|
||||
return ( nRes == GL_TRUE) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::GetPixelZ( const Point3d& ptWin, double& dWinZ)
|
||||
{
|
||||
glGetError() ;
|
||||
GLint Viewport[ 4] ;
|
||||
glGetIntegerv( GL_VIEWPORT, Viewport) ;
|
||||
float dZ ;
|
||||
glReadBuffer( GL_FRONT) ;
|
||||
glReadPixels( int( ptWin.x), Viewport[3] - int( ptWin.y), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &dZ) ;
|
||||
if ( glGetError() == GL_NO_ERROR && dZ > 0.001 && dZ < 0.999) {
|
||||
dWinZ = dZ ;
|
||||
return true ;
|
||||
}
|
||||
dWinZ = GetProjectedCenter().z ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
Scene::Destroy( void)
|
||||
|
||||
+5
-1
@@ -525,8 +525,12 @@ Scene::ZoomChange( double dCoeff)
|
||||
bool
|
||||
Scene::ZoomOnPoint( const Point3d& ptWin, double dCoeff)
|
||||
{
|
||||
// leggo Z del pixel
|
||||
double dWinZ ;
|
||||
GetPixelZ( ptWin, dWinZ) ;
|
||||
|
||||
// porto il punto in coordinate mondo
|
||||
Point3d ptView( ptWin.x, ptWin.y, GetProjectedCenter().z) ;
|
||||
Point3d ptView( ptWin.x, ptWin.y, dWinZ) ;
|
||||
Point3d ptWorld ;
|
||||
if ( ! UnProject( ptView, ptWorld))
|
||||
return false ;
|
||||
|
||||
Reference in New Issue
Block a user