本文整理汇总了C++中ON_Viewport::SetFrustum方法的典型用法代码示例。如果您正苦于以下问题:C++ ON_Viewport::SetFrustum方法的具体用法?C++ ON_Viewport::SetFrustum怎么用?C++ ON_Viewport::SetFrustum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ON_Viewport
的用法示例。
在下文中一共展示了ON_Viewport::SetFrustum方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DollyWindow
bool CCommandSampleZoomRotateWindow::DollyWindow( const CRhinoViewport& vport, CRect pick_rect, ON_3dPoint& target_point, ON_Viewport& vp_out )
{
const ON_Viewport& vp_in = vport.VP();
vp_out = vp_in;
// screen port values
int sleft, sright, stop, sbottom;
if( !vp_in.GetScreenPort(&sleft, &sright, &sbottom, &stop) )
return false;
// frustum values
double fleft, fright, ftop, fbottom, fnear, ffar;
if( !vp_in.GetFrustum(&fleft, &fright, &fbottom, &ftop, &fnear, &ffar) )
return false;
// camera coordinate system
ON_3dPoint cam_loc = vp_in.CameraLocation();
ON_3dVector cam_z = vp_in.CameraZ();
// capture Depth Buffer
CRect screen_rect( sleft, stop, sright, sbottom );
// user-specified rectangle
CRect zoom_rect;
zoom_rect.IntersectRect( &pick_rect, screen_rect );
CRhinoZBuffer zbuffer( vport );
zbuffer.ShowIsocurves( true );
zbuffer.ShowMeshWires( true );
zbuffer.ShowCurves( true );
zbuffer.ShowPoints( true );
zbuffer.ShowText( true );
zbuffer.ShowAnnotations( false );
bool bSeeThrough = ( vport.XrayShade() || vport.GhostedShade() );
if( bSeeThrough )
zbuffer.EnableShading( false );
bool rc = zbuffer.Capture( zoom_rect );
if( rc && bSeeThrough && 0 == zbuffer.HitCount() )
{
zbuffer.EnableShading( true );
zbuffer.ShowIsocurves( false );
zbuffer.ShowMeshWires( false );
zbuffer.ShowCurves( false );
zbuffer.ShowPoints( false );
zbuffer.ShowText( false );
rc = zbuffer.Capture( zoom_rect );
}
ON_Xform s2c;
if( rc )
rc = zbuffer.VP().GetXform( ON::screen_cs, ON::camera_cs, s2c );
if( rc )
{
// dolly sideways so zoom rectangle is centered
ON_3dPoint near_rect[4];
vp_in.GetNearRect( near_rect[0], near_rect[1], near_rect[2], near_rect[3] );
double port_dx = fabs( double(sright - sleft) );
double port_dy = fabs( double(stop - sbottom) );
ON_Interval lr( sleft, sright);
double nx = lr.NormalizedParameterAt( 0.5 * (pick_rect.left + pick_rect.right) );
ON_Interval bt( sbottom, stop);
double ny = bt.NormalizedParameterAt( 0.5 * (pick_rect.bottom + pick_rect.top) );
ON_3dPoint zoom_center = (1-nx) * (1-ny) * near_rect[0] +
nx * (1-ny) * near_rect[1] +
(1-nx) * ny * near_rect[2] +
nx *ny * near_rect[3];
ON_3dVector dolly_vec = zoom_center - cam_loc;
// dolly perpendicular to cam_z
dolly_vec -= dolly_vec * cam_z * cam_z;
vp_out.DollyCamera( dolly_vec );
double pick_rect_dx = fabs(double (pick_rect.right - pick_rect.left));
double pick_rect_dy = fabs(double(pick_rect.top - pick_rect.bottom));
// expand pick_rect to have the aspect ratio of the viewport
double d = 1.0;
if( pick_rect_dx/port_dx < pick_rect_dy/port_dy)
d = pick_rect_dy / port_dy;
else
d = pick_rect_dx / port_dx ;
fleft *= d;
fright *= d;
fbottom *= d;
ftop *=d ;
vp_out.SetFrustum( fleft, fright, fbottom, ftop, fnear, ffar );
// target point on plane perpendicular to cam_z
cam_loc = vp_out.CameraLocation();
target_point = cam_loc + (target_point - cam_loc) *cam_z * cam_z;
}
return rc;
//.........这里部分代码省略.........