00001 /* $NoKeywords: $ */ 00002 /* 00003 // 00004 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved. 00005 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert 00006 // McNeel & Associates. 00007 // 00008 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. 00009 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF 00010 // MERCHANTABILITY ARE HEREBY DISCLAIMED. 00011 // 00012 // For complete openNURBS copyright information see <http://www.opennurbs.org>. 00013 // 00015 */ 00016 00018 // 00019 // defines ON_Viewport 00020 // 00022 00023 #if !defined(OPENNURBS_VIEWPORT_INC_) 00024 #define OPENNURBS_VIEWPORT_INC_ 00025 00027 // Class ON_Viewport 00028 // 00029 // This object represents a viewing frustum 00031 class ON_CLASS ON_Viewport : public ON_Geometry 00032 { 00033 ON_OBJECT_DECLARE( ON_Viewport ); 00034 public: 00035 00036 // Default z=up perspective camera direction 00037 static const ON_3dVector Default3dCameraDirection; 00038 00039 // Construction 00040 ON_Viewport(); 00041 ~ON_Viewport(); 00042 ON_Viewport& operator=( const ON_Viewport& ); 00043 00044 bool IsValidCamera() const; 00045 bool IsValidFrustum() const; 00046 00047 // ON_Object overrides ////////////////////////////////////////////////////// 00048 // 00049 00050 /* 00051 Description: 00052 Test for a valid camera, frustum, and screen port. 00053 Parameters: 00054 text_log - [in] if the object is not valid and text_log 00055 is not NULL, then a brief englis description of the 00056 reason the object is not valid is appened to the log. 00057 The information appended to text_log is suitable for 00058 low-level debugging purposes by programmers and is 00059 not intended to be useful as a high level user 00060 interface tool. 00061 Returns: 00062 @untitled table 00063 true camera, frustum, and screen port are valid. 00064 false camera, frustum, or screen port is invalid. 00065 Remarks: 00066 Overrides virtual ON_Object::IsValid 00067 See Also: 00068 IsValidCamera, IsValidFrustum 00069 */ 00070 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const; 00071 00072 // Description: 00073 // Dumps debugging text description to a text log. 00074 // 00075 // Parameters: 00076 // dump_target - [in] text log 00077 // 00078 // Remarks: 00079 // This overrides the virtual ON_Object::Dump() function. 00080 void Dump( 00081 ON_TextLog& // dump_target 00082 ) const; 00083 00084 // Description: 00085 // Writes ON_Viewport defintion from a binary archive. 00086 // 00087 // Parameters: 00088 // binary_archive - [in] open binary archive 00089 // 00090 // Returns: 00091 // true if successful. 00092 // 00093 // Remarks: 00094 // This overrides the virtual ON_Object::Write() function. 00095 ON_BOOL32 Write( 00096 ON_BinaryArchive& // binary_archive 00097 ) const; 00098 00099 00100 // Description: 00101 // Reads ON_Viewport defintion from a binary archive. 00102 // 00103 // Parameters: 00104 // binary_archive - [in] open binary archive 00105 // 00106 // Returns: 00107 // true if successful. 00108 // 00109 // Remarks: 00110 // This overrides the virtual ON_Object::Read() function. 00111 ON_BOOL32 Read( 00112 ON_BinaryArchive& // binary_archive 00113 ); 00114 00115 00116 // ON_Geometry overrides ////////////////////////////////////////////////////// 00117 // 00118 00119 // Description: 00120 // The dimension of a camera view frustum is 3. 00121 // 00122 // Returns: 00123 // 3 00124 // 00125 // Remarks: 00126 // This is virtual ON_Geometry function. 00127 int Dimension() const; 00128 00129 // Description: 00130 // Gets bounding box of viewing frustum. 00131 // 00132 // Parameters: 00133 // boxmin - [in/out] array of Dimension() doubles 00134 // boxmax - [in/out] array of Dimension() doubles 00135 // bGrowBox - [in] (default=false) 00136 // If true, then the union of the input bbox and the 00137 // object's bounding box is returned in bbox. 00138 // If false, the object's bounding box is returned in bbox. 00139 // 00140 // Returns: 00141 // @untitled table 00142 // true Valid frustum and bounding box returned. 00143 // false Invalid camera or frustum. No bounding box returned. 00144 // 00145 // Remarks: 00146 // This overrides the virtual ON_Geometry::GetBBox() function. 00147 ON_BOOL32 GetBBox( // returns true if successful 00148 double*, // boxmin 00149 double*, // boxmax 00150 ON_BOOL32 = false // bGrowBox 00151 ) const; 00152 00153 // Description: 00154 // Transforms the view camera location, direction, and up. 00155 // 00156 // Parameters: 00157 // xform - [in] transformation to apply to camera. 00158 // 00159 // Returns: 00160 // @untitled table 00161 // true Valid camera was transformed. 00162 // false Invalid camera, frustum, or transformation. 00163 // 00164 // Remarks: 00165 // This overrides the virtual ON_Geometry::Transform() function. 00166 ON_BOOL32 Transform( 00167 const ON_Xform& // xform 00168 ); 00169 00170 // Interface ///////////////////////////////////////////////////////////////// 00171 // 00172 void Initialize(); 00173 00174 ON::view_projection Projection() const; 00175 00176 /* 00177 Description: 00178 Unconditionally set the projection. 00179 Parameters: 00180 projection - [in] 00181 See Also: 00182 ON_Viewport::SetParallelProjection 00183 ON_Viewport::SetPerpectiveProjection 00184 ON_Viewport::SetTwoPointPerspectiveProjection 00185 */ 00186 bool SetProjection( ON::view_projection projection ); 00187 00188 /* 00189 Description: 00190 Use this function to change projections of valid viewports 00191 from persective to parallel. It will make common additional 00192 adjustments to the frustum so the resulting views are similar. 00193 The camera location and direction will not be changed. 00194 Parameters: 00195 bSymmetricFrustum - [in] 00196 True if you want the resulting frustum to be symmetric. 00197 Remarks: 00198 If the current projection is parallel and bSymmetricFrustum, 00199 FrustumIsLeftRightSymmetric() and FrustumIsTopBottomSymmetric() 00200 are all equal, then no changes are made and true is returned. 00201 */ 00202 bool ChangeToParallelProjection( bool bSymmetricFrustum ); 00203 00204 /* 00205 Description: 00206 Use this function to change projections of valid viewports 00207 from parallel to perspective. It will make common additional 00208 adjustments to the frustum and camera location so the resulting 00209 views are similar. The camera direction and target point are 00210 not be changed. 00211 Parameters: 00212 target_distance - [in] 00213 If ON_UNSET_VALUE this parameter is ignored. Otherwise 00214 it must be > 0 and indicates which plane in the current 00215 view frustum should be perserved. 00216 bSymmetricFrustum - [in] 00217 True if you want the resulting frustum to be symmetric. 00218 lens_length - [in] (pass 50.0 when in doubt) 00219 35 mm lens length to use when changing from parallel 00220 to perspective projections. If the current projection 00221 is perspective or lens_length is <= 0.0, 00222 then this parameter is ignored. 00223 Remarks: 00224 If the current projection is perspective and bSymmetricFrustum, 00225 FrustumIsLeftRightSymmetric() and FrustumIsTopBottomSymmetric() 00226 are all equal, then no changes are made and true is returned. 00227 */ 00228 bool ChangeToPerspectiveProjection( 00229 double target_distance, 00230 bool bSymmetricFrustum, 00231 double lens_length 00232 ); 00233 00234 /* 00235 Description: 00236 Use this function to change projections of valid viewports 00237 to a two point perspective. It will make common additional 00238 adjustments to the frustum and camera location and direction 00239 so the resulting views are similar. 00240 Parameters: 00241 target_distance - [in] 00242 If ON_UNSET_VALUE this parameter is ignored. Otherwise 00243 it must be > 0 and indicates which plane in the current 00244 view frustum should be perserved. 00245 up - [in] 00246 This direction will be the locked up direction. Pass 00247 ON_3dVector::ZeroVector if you want to use the world axis 00248 direction that is closest to the current up direction. 00249 Pass CameraY() if you want to preserve the current up direction. 00250 lens_length - [in] (pass 50.0 when in doubt) 00251 35 mm lens length to use when changing from parallel 00252 to perspective projections. If the current projection 00253 is perspective or lens_length is <= 0.0, 00254 then this parameter is ignored. 00255 Remarks: 00256 If the current projection is perspective and 00257 FrustumIsLeftRightSymmetric() is true and 00258 FrustumIsTopBottomSymmetric() is false, then no changes are 00259 made and true is returned. 00260 */ 00261 bool ChangeToTwoPointPerspectiveProjection( 00262 double target_distance, 00263 ON_3dVector up, 00264 double lens_length 00265 ); 00266 00267 /* 00268 Returns: 00269 True if the projection is ON::perspective_view. 00270 */ 00271 bool IsPerspectiveProjection() const; 00272 00273 /* 00274 Returns 00275 IsPerspectiveProjection() 00276 && CameraUpIsLocked() 00277 && FrustumIsLeftRightSymmetric 00278 && !FrustumIsTopBottomSymmetric 00279 */ 00280 bool IsTwoPointPerspectiveProjection() const; 00281 00282 /* 00283 Returns: 00284 True if the projection is ON::parallel_view. 00285 */ 00286 bool IsParallelProjection() const; 00287 00288 // These return true if the current direction and up are not zero and not 00289 // parallel so the camera position is well defined. 00290 bool SetCameraLocation( const ON_3dPoint& ); 00291 bool SetCameraDirection( const ON_3dVector& ); 00292 bool SetCameraUp( const ON_3dVector& ); 00293 00294 ON_3dPoint CameraLocation() const; 00295 ON_3dVector CameraDirection() const; 00296 ON_3dVector CameraUp() const; 00297 00298 bool CameraLocationIsLocked() const; 00299 bool CameraDirectionIsLocked() const; 00300 bool CameraUpIsLocked() const; 00301 bool FrustumIsLeftRightSymmetric() const; 00302 bool FrustumIsTopBottomSymmetric() const; 00303 00304 void SetCameraLocationLock( bool bLockCameraLocation ); 00305 void SetCameraDirectionLock( bool bLockCameraDirection ) ; 00306 void SetCameraUpLock( bool bLockCameraUp ); 00307 void SetFrustumLeftRightSymmetry( bool bForceLeftRightSymmetry ); 00308 void SetFrustumTopBottomSymmetry( bool bForceTopBottomSymmetry ); 00309 void UnlockCamera(); // sets all camera locks to false 00310 void UnlockFrustumSymmetry(); // sets all frustum symmetry locks to false 00311 00312 // returns true if current camera orientation is valid 00313 bool GetCameraFrame( 00314 double*, // CameraLocation[3] 00315 double*, // CameraX[3] 00316 double*, // CameraY[3] 00317 double* // CameraZ[3] 00318 ) const; 00319 00320 // these do not check for a valid camera orientation 00321 ON_3dVector CameraX() const; // unit to right vector 00322 ON_3dVector CameraY() const; // unit up vector 00323 ON_3dVector CameraZ() const; // unit vector in -CameraDirection 00324 00325 00326 bool IsCameraFrameWorldPlan( 00327 // Returns true if the camera direction = some world axis. 00328 // The indices report which axes are used. For a "twisted" 00329 // plan view it is possible to have zero x and y indices. 00330 // This function returns true if and only if the "z" index 00331 // is non-zero. 00332 // 00333 // Indices are +/-1 = world +/-x, +/-2 = world +/-y, +/-3 = world +/-z, 00334 int*, // if true and plan is axis aligned, view x index, else 0 00335 int*, // if true and plan is axis aligned, view y index, else 0 00336 int* // if true, view z index, else 0 00337 ); 00338 00339 bool GetCameraExtents( 00340 // returns bounding box in camera coordinates - this is useful information 00341 // for setting view frustrums to include the point list 00342 int, // count = number of 3d points 00343 int, // stride = number of doubles to skip between points (>=3) 00344 const double*, // 3d points in world coordinates 00345 ON_BoundingBox& cambbox, // bounding box in camera coordinates 00346 int bGrowBox = false // set to true if you want to enlarge an existing camera coordinate box 00347 ) const; 00348 00349 bool GetCameraExtents( 00350 // returns bounding box in camera coordinates - this is useful information 00351 // for setting view frustrums to include the point list 00352 const ON_BoundingBox&, // world coordinate bounding box 00353 ON_BoundingBox& cambbox, // bounding box in camera coordinates 00354 int bGrowBox = false // set to true if you want to enlarge an existing camera coordinate box 00355 ) const; 00356 00357 bool GetCameraExtents( 00358 // returns bounding box in camera coordinates - this is useful information 00359 // for setting view frustrums to include the point list 00360 ON_3dPoint&, // world coordinate bounding sphere center 00361 double, // world coordinate bounding sphere radius 00362 ON_BoundingBox& cambox, // bounding box in camera coordinates 00363 int bGrowBox = false // set to true if you want to enlarge an existing camera coordinate box 00364 ) const; 00365 00366 /* 00367 Description: 00368 Set the view frustum. If FrustumSymmetryIsLocked() is true 00369 and left != -right or bottom != -top, then they will be 00370 adjusted so the resulting frustum is symmetric. 00371 */ 00372 bool SetFrustum( 00373 double left, // 00374 double right, // ( left < right ) 00375 double bottom, // 00376 double top, // ( bottom < top ) 00377 double near_dist, // 00378 double far_dist // ( 0 < near_dist < far_dist ) // ignored by Rhino version 1.0 00379 ); 00380 bool GetFrustum( 00381 double* left, // 00382 double* right, // (left < right) 00383 double* bottom, // 00384 double* top, // (bottom < top) 00385 double* near_dist = NULL, // 00386 double* far_dist = NULL // (0 < near_dist < far_dist) 00387 ) const; 00388 00389 // SetFrustumAspect() changes the larger of the frustum's widht/height 00390 // so that the resulting value of width/height matches the requested 00391 // aspect. The camera angle is not changed. If you change the shape 00392 // of the view port with a call SetScreenPort(), then you generally 00393 // want to call SetFrustumAspect() with the value returned by 00394 // GetScreenPortAspect(). 00395 bool SetFrustumAspect( double ); 00396 00397 // Returns frustum's width/height 00398 bool GetFrustumAspect( double& ) const; 00399 00400 // Returns world coordinates of frustum's center 00401 bool GetFrustumCenter( double* ) const; 00402 00403 // The near clipping plane stored in the Rhino 1.0 file is frequently very 00404 // small and useless for high quality z-buffer based rendering. The far 00405 // clipping value is not stored in the file. Use these functions to set 00406 // the frustum's near and far clipping planes to appropriate values. 00407 double FrustumLeft() const; 00408 double FrustumRight() const; 00409 double FrustumBottom() const; 00410 double FrustumTop() const; 00411 double FrustumNear() const; 00412 double FrustumFar() const; 00413 00414 /* 00415 Returns: 00416 frustum right - frustum left 00417 */ 00418 double FrustumWidth() const; // right - left 00419 00420 /* 00421 Returns: 00422 frustum right - frustum left 00423 */ 00424 double FrustumHeight() const; // top - bottom 00425 00426 /* 00427 Returns: 00428 Minimum of fabs(FrustumWidth()) and fabs(FrustumHeight()) 00429 */ 00430 double FrustumMinimumDiameter() const; 00431 00432 /* 00433 Returns: 00434 Maximum of fabs(FrustumWidth()) and fabs(FrustumHeight()) 00435 */ 00436 double FrustumMaximumDiameter() const; 00437 00438 00439 bool SetFrustumNearFar( 00440 const double* bboxmin, // 3d bounding box min 00441 const double* bboxmax // 3d bounding box max 00442 ); 00443 bool SetFrustumNearFar( 00444 const double* center, // 3d bounding sphere center 00445 double radius // 3d bounding sphere radius 00446 ); 00447 bool SetFrustumNearFar( 00448 double near_dist, // ( > 0 ) 00449 double far_dist // 00450 ); 00451 00452 /* 00453 Description: 00454 If needed, adjust the current frustum so it has the 00455 specified symmetries and adjust the camera location 00456 so the target plane remains visible. 00457 Parameters: 00458 bLeftRightSymmetric - [in] 00459 If true, the frustum will be adjusted so left = -right. 00460 bTopBottomSymmetric - [in] 00461 If true, the frustum will be adjusted so top = -bottom. 00462 target_distance - [in] 00463 If projection is not perspective or target_distance 00464 is ON_UNSET_VALUE, this this parameter is ignored. 00465 If the projection is perspective and target_distance 00466 is not ON_UNSET_VALUE, then it must be > 0.0 and 00467 it is used to determine which plane in the old 00468 frustum will appear unchanged in the new frustum. 00469 bool 00470 Returns true if the returned viewport has a frustum 00471 with the specified symmetries. 00472 */ 00473 bool ChangeToSymmetricFrustum( 00474 bool bLeftRightSymmetric, 00475 bool bTopBottomSymmetric, 00476 double target_distance 00477 ); 00478 00479 /* 00480 Description: 00481 Get near and far clipping distances of a point 00482 Parameters: 00483 point - [in] 00484 near_dist - [out] 00485 near distance of the point (can be < 0) 00486 far_dist - [out] 00487 far distance of the point (can be equal to near_dist) 00488 bGrowNearFar - [in] 00489 If true and input values of near_dist and far_dist 00490 are not ON_UNSET_VALUE, the near_dist and far_dist 00491 are enlarged to include bbox. 00492 Returns: 00493 True if the point is ing the view frustum and 00494 near_dist/far_dist were set. 00495 False if the bounding box does not intesect the 00496 view frustum. 00497 */ 00498 bool GetPointDepth( 00499 ON_3dPoint point, 00500 double* near_dist, 00501 double* far_dist, 00502 bool bGrowNearFar=false 00503 ) const; 00504 00505 /* 00506 Description: 00507 Get the view plane depth of a point 00508 Parameters: 00509 point - [in] 00510 view_plane_depth - [out] 00511 positive values are in front of the camera and negative 00512 values are behind the camera. 00513 If 0 <= point_depth < FrustumNear(), the point's view 00514 plane is between the camera and the frustum's near plane. 00515 If point_depth > FrustumFar(), the point's view 00516 plane is farther from the camera and the frustum's far plane. 00517 Returns: 00518 True if the point is ing the view frustum and 00519 near_dist/far_dist were set. 00520 False if the bounding box does not intesect the 00521 view frustum. 00522 */ 00523 bool GetPointDepth( 00524 ON_3dPoint point, 00525 double* view_plane_depth 00526 ) const; 00527 00528 /* 00529 Description: 00530 Get near and far clipping distances of a bounding box. 00531 Parameters: 00532 bbox - [in] 00533 bounding box 00534 near_dist - [out] 00535 near distance of the box 00536 This value can be zero or negative when the camera 00537 location is inside bbox. 00538 far_dist - [out] 00539 far distance of the box 00540 This value can be equal to near_dist, zero or negative 00541 when the camera location is in front of the bounding box. 00542 bGrowNearFar - [in] 00543 If true and input values of near_dist and far_dist 00544 are not ON_UNSET_VALUE, the near_dist and far_dist 00545 are enlarged to include bbox. 00546 Returns: 00547 True if the bounding box intersects the view frustum and 00548 near_dist/far_dist were set. 00549 False if the bounding box does not intesect the view frustum. 00550 Remarks: 00551 This function ignores the current value of the viewport's 00552 near and far settings. If the viewport is a perspective 00553 projection, the it intersects the semi infinite frustum 00554 volume with the bounding box and returns the near and far 00555 distances of the intersection. If the viewport is a parallel 00556 projection, it instersects the infinte view region with the 00557 bounding box and returns the near and far distances of the 00558 projection. 00559 */ 00560 bool GetBoundingBoxDepth( 00561 ON_BoundingBox bbox, 00562 double* near_dist, 00563 double* far_dist, 00564 bool bGrowNearFar=false 00565 ) const; 00566 00567 /* 00568 Description: 00569 Get near and far clipping distances of a bounding sphere. 00570 Parameters: 00571 sphere - [in] 00572 bounding sphere 00573 near_dist - [out] 00574 near distance of the sphere (can be < 0) 00575 far_dist - [out] 00576 far distance of the sphere (can be equal to near_dist) 00577 bGrowNearFar - [in] 00578 If true and input values of near_dist and far_dist 00579 are not ON_UNSET_VALUE, the near_dist and far_dist 00580 are enlarged to include bbox. 00581 Returns: 00582 True if the sphere intersects the view frustum and 00583 near_dist/far_dist were set. 00584 False if the sphere does not intesect the view frustum. 00585 */ 00586 bool GetSphereDepth( 00587 ON_Sphere sphere, 00588 double* near_dist, 00589 double* far_dist, 00590 bool bGrowNearFar=false 00591 ) const; 00592 00593 /* 00594 Description: 00595 Set near and far clipping distance subject to constraints. 00596 Parameters: 00597 near_dist - [in] (>0) desired near clipping distance 00598 far_dist - [in] (>near_dist) desired near clipping distance 00599 min_near_dist - [in] 00600 If min_near_dist <= 0.0, it is ignored. 00601 If min_near_dist > 0 and near_dist < min_near_dist, 00602 then the frustum's near_dist will be increased to 00603 min_near_dist. 00604 min_near_over_far - [in] 00605 If min_near_over_far <= 0.0, it is ignored. 00606 If near_dist < far_dist*min_near_over_far, then 00607 near_dist is increased and/or far_dist is decreased 00608 so that near_dist = far_dist*min_near_over_far. 00609 If near_dist < target_dist < far_dist, then near_dist 00610 near_dist is increased and far_dist is decreased so that 00611 projection precision will be good at target_dist. 00612 Otherwise, near_dist is simply set to 00613 far_dist*min_near_over_far. 00614 target_dist - [in] 00615 If target_dist <= 0.0, it is ignored. 00616 If target_dist > 0, it is used as described in the 00617 description of the min_near_over_far parameter. 00618 relative_depth_bias - [in] 00619 If relative_depth_bias <= 0.0, it is ignored. 00620 If relative_depth_bias > 0, it is assumed that 00621 the requested near_dist and far_dist were calculated 00622 assuming no depth bias and the values will be 00623 appropriately adjusted to ensure the frustum's 00624 near and far clipping planes will not clip biased 00625 objects. 00626 */ 00627 bool SetFrustumNearFar( 00628 double near_dist, 00629 double far_dist, 00630 double min_near_dist, 00631 double min_near_over_far, 00632 double target_dist 00633 ); 00634 00635 bool SetFrustumNearFar( 00636 double near_dist, 00637 double far_dist, 00638 double min_near_dist, 00639 double min_near_over_far, 00640 double target_dist, 00641 double relative_depth_bias 00642 ); 00643 00644 // Description: 00645 // Get near clipping plane. 00646 // 00647 // near_plane - [out] near clipping plane if camera and frustum 00648 // are valid. The plane's frame is the same as the camera's 00649 // frame. The origin is located at the intersection of the 00650 // camera direction ray and the near clipping plane. The plane's 00651 // normal points out of the frustum towards the camera 00652 // location. 00653 // 00654 // Returns: 00655 // true if camera and frustum are valid. 00656 bool GetNearPlane( 00657 ON_Plane& near_plane 00658 ) const; 00659 00660 bool GetNearPlaneEquation( 00661 ON_PlaneEquation& near_plane_equation 00662 ) const; 00663 00664 // Description: 00665 // Get far clipping plane. 00666 // 00667 // far_plane - [out] far clipping plane if camera and frustum 00668 // are valid. The plane's frame is the same as the camera's 00669 // frame. The origin is located at the intersection of the 00670 // camera direction ray and the far clipping plane. The plane's 00671 // normal points into the frustum towards the camera location. 00672 // 00673 // Returns: 00674 // true if camera and frustum are valid. 00675 bool GetFarPlane( 00676 ON_Plane& far_plane 00677 ) const; 00678 00679 bool GetFarPlaneEquation( 00680 ON_PlaneEquation& far_plane_equation 00681 ) const; 00682 00683 /* 00684 Description: 00685 Get the plane that is a specified distance from the camera. 00686 This plane is parallel to the frustum's near and far planes. 00687 Parameters: 00688 view_plane_depth - [in] 00689 The distance from the camera location to the view plane. 00690 Positive distances are in front of the camera and 00691 negative distances are behind the camera. 00692 A value of FrustumNear() will return the frustum's 00693 near plane and a valud of FrustumFar() will return 00694 the frustum's far plane. 00695 view_plane - [out] 00696 View plane 00697 view_plane_equation - [out] 00698 Equation of the view plane. 00699 Returns: 00700 True if the camera and frustum are valid and view_plane 00701 was calculated. False otherwise. 00702 */ 00703 bool GetViewPlane( 00704 double view_plane_depth, 00705 ON_Plane& view_plane 00706 ) const; 00707 00708 bool GetViewPlaneEquation( 00709 double view_plane_depth, 00710 ON_PlaneEquation& view_plane_equation 00711 ) const; 00712 00713 /* 00714 Description: 00715 Get left world frustum clipping plane. 00716 Parameters: 00717 left_plane - [out] 00718 frustum left side clipping plane. The normal points 00719 into the visible region of the frustum. If the projection 00720 is perspective, the origin is at the camera location, 00721 otherwise the origin isthe point on the plane that is 00722 closest to the camera location. 00723 Returns: 00724 True if camera and frustum are valid and plane was set. 00725 */ 00726 bool GetFrustumLeftPlane( 00727 ON_Plane& left_plane 00728 ) const; 00729 00730 bool GetFrustumLeftPlaneEquation( 00731 ON_PlaneEquation& left_plane_equation 00732 ) const; 00733 00734 /* 00735 Description: 00736 Get right world frustum clipping plane. 00737 Parameters: 00738 right_plane - [out] 00739 frustum right side clipping plane. The normal points 00740 into the visible region of the frustum. If the projection 00741 is perspective, the origin is at the camera location, 00742 otherwise the origin isthe point on the plane that is 00743 closest to the camera location. 00744 Returns: 00745 True if camera and frustum are valid and plane was set. 00746 */ 00747 bool GetFrustumRightPlane( 00748 ON_Plane& right_plane 00749 ) const; 00750 00751 bool GetFrustumRightPlaneEquation( 00752 ON_PlaneEquation& right_plane_equation 00753 ) const; 00754 00755 /* 00756 Description: 00757 Get right world frustum clipping plane. 00758 Parameters: 00759 right_plane - [out] 00760 frustum bottom side clipping plane. The normal points 00761 into the visible region of the frustum. If the projection 00762 is perspective, the origin is at the camera location, 00763 otherwise the origin isthe point on the plane that is 00764 closest to the camera location. 00765 Returns: 00766 True if camera and frustum are valid and plane was set. 00767 */ 00768 bool GetFrustumBottomPlane( 00769 ON_Plane& bottom_plane 00770 ) const; 00771 00772 bool GetFrustumBottomPlaneEquation( 00773 ON_PlaneEquation& bottom_plane_equation 00774 ) const; 00775 /* 00776 Description: 00777 Get right world frustum clipping plane. 00778 Parameters: 00779 top_plane - [out] 00780 frustum top side clipping plane. The normal points 00781 into the visible region of the frustum. If the projection 00782 is perspective, the origin is at the camera location, 00783 otherwise the origin isthe point on the plane that is 00784 closest to the camera location. 00785 Returns: 00786 True if camera and frustum are valid and plane was set. 00787 */ 00788 bool GetFrustumTopPlane( 00789 ON_Plane& top_plane 00790 ) const; 00791 00792 bool GetFrustumTopPlaneEquation( 00793 ON_PlaneEquation& top_plane_equation 00794 ) const; 00795 00796 // Description: 00797 // Get corners of near clipping plane rectangle. 00798 // 00799 // Parameters: 00800 // left_bottom - [out] 00801 // right_bottom - [out] 00802 // left_top - [out] 00803 // right_top - [out] 00804 // 00805 // Returns: 00806 // true if camera and frustum are valid. 00807 bool GetNearRect( 00808 ON_3dPoint& left_bottom, 00809 ON_3dPoint& right_bottom, 00810 ON_3dPoint& left_top, 00811 ON_3dPoint& right_top 00812 ) const; 00813 00814 // Description: 00815 // Get corners of far clipping plane rectangle. 00816 // 00817 // Parameters: 00818 // left_bottom - [out] 00819 // right_bottom - [out] 00820 // left_top - [out] 00821 // right_top - [out] 00822 // 00823 // Returns: 00824 // true if camera and frustum are valid. 00825 bool GetFarRect( 00826 ON_3dPoint& left_bottom, 00827 ON_3dPoint& right_bottom, 00828 ON_3dPoint& left_top, 00829 ON_3dPoint& right_top 00830 ) const; 00831 00832 /* 00833 Description: 00834 Get the world coordinate corners of the rectangle of 00835 a view plane that is a specified distance from the camera. 00836 This rectangle is parallel to the frustum's near and far planes. 00837 Parameters: 00838 view_plane_depth - [in] 00839 The distance from the camera location to the view plane. 00840 Positive distances are in front of the camera and 00841 negative distances are behind the camera. 00842 A value of FrustumNear() will return the frustum's 00843 near rectangle and a valud of FrustumFar() will return 00844 the frustum's far rectangle. 00845 left_bottom - [out] 00846 right_bottom - [out] 00847 left_top - [out] 00848 right_top - [out] 00849 Returns: 00850 True if the camera and frustum are valid and view_plane 00851 was calculated. False otherwise. 00852 */ 00853 bool GetViewPlaneRect( 00854 double view_plane_depth, 00855 ON_3dPoint& left_bottom, 00856 ON_3dPoint& right_bottom, 00857 ON_3dPoint& left_top, 00858 ON_3dPoint& right_top 00859 ) const; 00860 00861 00862 /* 00863 Description: 00864 Location of viewport in pixels. 00865 These are provided so you can set the port you are using 00866 and get the appropriate transformations to and from 00867 screen space. 00868 Parameters: 00869 port_left - [in] 00870 port_right - [in] (port_left != port_right) 00871 port_bottom - [in] 00872 port_top - [in] (port_top != port_bottom) 00873 port_near - [in] 00874 port_far - [in] 00875 Example: 00876 00877 // For a Windows window 00878 int width = width of window client area in pixels; 00879 int height = height of window client area in pixels; 00880 port_left = 0; 00881 port_right = width; 00882 port_top = 0; 00883 port_bottom = height; 00884 port_near = 0; 00885 port_far = 1; 00886 SetScreenPort( port_left, port_right, 00887 port_bottom, port_top, 00888 port_near, port_far ); 00889 00890 Returns: 00891 true if input is valid. 00892 See Also: 00893 ON_Viewport::GetScreenPort 00894 */ 00895 bool SetScreenPort( 00896 int port_left, 00897 int port_right, 00898 int port_bottom, 00899 int port_top, 00900 int port_near = 0, 00901 int port_far = 0 00902 ); 00903 00904 bool GetScreenPort( 00905 int* left, 00906 int* right, //( port_left != port_right ) 00907 int* port_bottom, 00908 int* port_top, //( port_bottom != port_top) 00909 int* port_near=NULL, 00910 int* port_far=NULL 00911 ) const; 00912 00913 /* 00914 Returns: 00915 abs(port_right - port_left) 00916 */ 00917 int ScreenPortWidth() const; 00918 00919 /* 00920 Returns: 00921 abs(port_bottom - port_top) 00922 */ 00923 int ScreenPortHeight() const; 00924 00925 bool GetScreenPortAspect( double& ) const; // port's |width/height| 00926 00927 bool GetCameraAngle( 00928 double* half_diagonal_angle, // 1/2 of diagonal subtended angle 00929 double* half_vertical_angle, // 1/2 of vertical subtended angle 00930 double* half_horizontal_angle // 1/2 of horizontal subtended angle 00931 ) const; 00932 bool GetCameraAngle( 00933 double* half_smallest_angle // 1/2 of smallest subtended view angle 00934 ) const; 00935 bool SetCameraAngle( 00936 double half_smallest_angle // 1/2 of smallest subtended view angle 00937 // 0 < angle < pi/2 00938 ); 00939 00940 // These functions assume the camera is horizontal and crop the 00941 // film rather than the image when the aspect of the frustum 00942 // is not 36/24. (35mm film is 36mm wide and 24mm high.) 00943 // 00944 // The SetCamera35mmLensLength() preserves camera location, 00945 // changes the frustum, but maintains the frsutrum's aspect. 00946 bool GetCamera35mmLensLength( 00947 double* lens_length 00948 ) const; 00949 bool SetCamera35mmLensLength( 00950 double lens_length 00951 ); 00952 00953 // Same as GetCamera35mmLensLength() with "lens" misspelled. 00954 bool GetCamera35mmLenseLength( 00955 double* lens_length 00956 ) const; 00957 00958 // Same as SetCamera35mmLensLength() with "lens" misspelled. 00959 bool SetCamera35mmLenseLength( 00960 double lens_length 00961 ); 00962 00963 bool GetXform( 00964 ON::coordinate_system srcCS, 00965 ON::coordinate_system destCS, 00966 ON_Xform& matrix // 4x4 transformation matrix (acts on the left) 00967 ) const; 00968 00969 /* 00970 Description: 00971 Get the world coordinate line in the view frustum 00972 that projects to a point on the screen. 00973 Parameters: 00974 screenx - [in] 00975 screeny - [in] (screenx,screeny) = screen location 00976 world_line - [out] 3d world coordinate line segment 00977 starting on the near clipping plane and ending 00978 on the far clipping plane. 00979 Returns: 00980 true if successful. 00981 false if view projection or frustum is invalid. 00982 */ 00983 bool GetFrustumLine( 00984 double screenx, 00985 double screeny, 00986 ON_Line& world_line 00987 ) const; 00988 00989 // display tools 00990 bool GetWorldToScreenScale( 00991 const ON_3dPoint& point_in_frustum, // [in] point in viewing frustum. 00992 double* pixels_per_unit // [out] scale = number of pixels per world unit at the 3d point 00993 ) const; 00994 00995 bool GetCoordinateSprite( 00996 int, // size in pixels of coordinate sprite axes 00997 int, int, // screen (x,y) for sprite origin 00998 int[3], // returns depth order for axes 00999 double [3][2] // screen coords for axes ends 01000 ) const; 01001 01002 // Use Extents() as a quick way to set a viewport to so that bounding 01003 // volume is inside of a viewports frusmtrum. 01004 // The view angle is used to determine the position of the camera. 01005 bool Extents( 01006 double half_view_angle, // 1/2 smallest subtended view angle 01007 // (0 < angle < pi/2) 01008 const ON_BoundingBox& world_bbox// 3d world coordinate bounding box 01009 ); 01010 bool Extents( 01011 double half_view_angle, // 1/2 smallest subtended view angle 01012 // (0 < angle < pi/2) 01013 const ON_3dPoint& center, // 3d world coordinate bounding sphere center 01014 double radius // 3d sphere radius 01015 ); 01016 01018 // View changing from screen input points. Handy for 01019 // using a mouse to manipulate a view. 01020 // 01021 01023 // ZoomToScreenRect() may change camera and frustum settings 01024 bool ZoomToScreenRect( 01025 int screen_x0, 01026 int screen_y0, // (x,y) screen coords of a rectangle corner 01027 int screen_x1, 01028 int screen_y1 // (x,y) screen coords of opposite rectangle corner 01029 ); 01030 01032 // DollyCamera() does not update the frustum's clipping planes. 01033 // To update the frustum's clipping planes call DollyFrustum(d) 01034 // with d = dollyVector o cameraFrameZ. To convert screen locations 01035 // into a dolly vector, use GetDollyCameraVector(). 01036 bool DollyCamera( // Does not update frustum. To update frustum use 01037 // DollyFrustum(d) with d = dollyVector o cameraFrameZ 01038 const ON_3dVector& dolly_vector // dolly vector in world coordinates 01039 ); 01040 01042 // Gets a world coordinate dolly vector that can be passed to 01043 // DollyCamera(). 01044 bool GetDollyCameraVector( 01045 int screen_x0, 01046 int screen_y0, // (x,y) screen coords of start point 01047 int screen_x1, 01048 int screen_y1, // (x,y) screen coords of end point 01049 double proj_plane_dist, // distance of projection plane from camera. 01050 // When in doubt, use 0.5*(frus_near+frus_far). 01051 ON_3dVector& dolly_vector // world coordinate dolly vector returned here 01052 ) const; 01053 01055 // Moves frustum's clipping planes 01056 bool DollyFrustum( 01057 double dolly_distance // distance to move in camera direction 01058 ); 01059 01060 /* 01061 Description: 01062 Apply scaling factors to parallel projection clipping coordinates 01063 by setting the m_clip_mod transformation. 01064 Parameters: 01065 x - [in] x > 0 01066 y - [in] y > 0 01067 Example: 01068 If you want to compress the view projection across the viewing 01069 plane, then set x = 0.5, y = 1.0, and z = 1.0. 01070 Returns: 01071 True if successful. 01072 False if input is invalid or the view is a perspective view. 01073 */ 01074 bool SetViewScale( double x, double y ); 01075 void GetViewScale( double* x, double* y ) const; 01076 01077 /* 01078 Description: 01079 Gets the m_clip_mod transformation; 01080 Returns: 01081 value of the m_clip_mod transformation. 01082 */ 01083 ON_Xform ClipModXform() const; 01084 01085 /* 01086 Description: 01087 Gets the m_clip_mod_inverse transformation; 01088 Returns: 01089 value of the m_clip_mod_inverse transformation. 01090 */ 01091 ON_Xform ClipModInverseXform() const; 01092 01093 /* 01094 Returns: 01095 True if clip mod xform is identity. 01096 */ 01097 bool ClipModXformIsIdentity() const; 01098 01099 /* 01100 Description: 01101 Return a point on the central axis of the view frustum. 01102 This point is a good choice for a general purpose target point. 01103 Parameters: 01104 target_distance - [in] 01105 If target_distance > 0.0, then the distance from the returned 01106 point to the camera plane will be target_distance. Note that 01107 if the frustum is not symmetric, the distance from the 01108 returned point to the camera location will be larger than 01109 target_distanct. 01110 If target_distance == ON_UNSET_VALUE and the frustum 01111 is valid with near > 0.0, then 0.5*(near + far) will be used 01112 as the target_distance. 01113 Returns: 01114 A point on the frustum's central axis. If the viewport or input 01115 is not valid, then ON_3dPoint::UnsetPoint is returned. 01116 */ 01117 ON_3dPoint FrustumCenterPoint( double target_distance ) const; 01118 01119 /* 01120 Returns: 01121 The current value of the target point. This point does not play 01122 a role in the view projection calculations. It can be used as a 01123 fixed point when changing the camera so the visible regions of the 01124 before and after frustums both contain the region of interest. 01125 Remarks: 01126 The default constructor sets this point on ON_3dPoint::UnsetPoint. 01127 You must explicitly call one SetTargetPoint() functions to set 01128 the target point. 01129 */ 01130 ON_3dPoint TargetPoint() const; 01131 01132 /* 01133 Description: 01134 Set the target point. 01135 Parameters: 01136 target_point - [in] 01137 When in doubt, the point returned by FrustumCenterPoint(ON_UNSET_VALUE) 01138 is a good choice. 01139 Remarks: 01140 The default constructor sets this point on ON_3dPoint::UnsetPoint. 01141 You must explicitly call one SetTargetPoint() functions to set 01142 the target point. 01143 */ 01144 bool SetTargetPoint( ON_3dPoint target_point ); 01145 01146 /* 01147 Description: 01148 Get the distance from the target point to the camera plane. 01149 Note that if the frustum is not symmetric, then this distance 01150 is shorter than the distance from the target to the camera location. 01151 Parameters: 01152 bUseFrustumCenterFallback - [in] 01153 If bUseFrustumCenterFallback is false and the target point is 01154 not valid, then ON_UNSET_VALUE is returned. 01155 If bUseFrustumCenterFallback is true and the frustum is valid 01156 and current target point is not valid or is behind the camera, 01157 then 0.5*(near + far) is returned. 01158 Returns: 01159 Shortest signed distance from camera plane to target point. 01160 If the target point is on the visible side of the camera, 01161 a positive value is returned. ON_UNSET_VALUE is returned 01162 when the input of view is not valid. 01163 */ 01164 double TargetDistance( bool bUseFrustumCenterFallback ) const; 01165 01166 /* 01167 Description: 01168 Get suggested values for setting the perspective minimum 01169 near distance and minimum near/far ratio. 01170 Parameters: 01171 camera_location - [in] 01172 depth_buffer_bit_depth - [in] 01173 typically 32, 24, 16 or 8, but any positive value can be 01174 passed in. 01175 min_near_dist - [out] 01176 Suggest value for passing to SetPerspectiveMinNearDist(). 01177 min_near_over_far - [out] 01178 Suggest value for passing to SetPerspectiveMinNearOverFar(). 01179 */ 01180 static void GetPerspectiveClippingPlaneConstraints( 01181 ON_3dPoint camera_location, 01182 unsigned int depth_buffer_bit_depth, 01183 double* min_near_dist, 01184 double* min_near_over_far 01185 ); 01186 01187 /* 01188 Description: 01189 Calculate the value to add to homogeneous "z" clipping coordinate 01190 that corresponds to moving the corresponding euclidean camera 01191 coordinate by relative_depth_bias*(far - near). 01192 Parameters: 01193 relative_depth_bias - [in] 01194 signed relative bias. 01195 = 0: no bias, 01196 > 0: bias towards frustum's near clipping plane 01197 < 0: bias towards frustum's far clipping plane 01198 When you have curves and points that are "on" shaded objects, 01199 values around 1/256 work well to move the wire objects 01200 in front of or behind shaded objects. 01201 clip_z [-in] 01202 clip_w [-in] 01203 clip_z and clip_w are the homogeneous "w" and "w" coordinates 01204 of a homogeneous clipping coordinate point. 01205 Returns: 01206 The clipping coordinate depth bias to add to the z-clipping 01207 coordinate that corresponds to adding cam_depth_bias 01208 to the z camera coordinate. 01209 Remarks: 01210 For perspective views, this bias is largest in the vicinity 01211 of the frustum's near clipping plane and smallest in the 01212 vicinity of the frustum's far clipping plane. 01213 For orthographic projectsions, this bias is constant. 01214 */ 01215 double ClipCoordDepthBias( 01216 double relative_depth_bias, 01217 double clip_z, 01218 double clip_w 01219 ) const; 01220 01221 /* 01222 Description: 01223 Calculate a transformation to apply to clipping coordinates to 01224 bias their depth. 01225 01226 Parameters: 01227 relative_depth_bias - [in] 01228 signed relative bias. 01229 = 0: no bias, 01230 > 0: bias towards frustum's near clipping plane 01231 < 0: bias towards frustum's far clipping plane 01232 When you have curves and points that are "on" shaded objects, 01233 values around 1/512 work well to move the wire objects 01234 in front of or behind shaded objects. 01235 01236 clip_bias - [out] 01237 clip_bias = cam2clip * delta * clip2cam, 01238 where delta = 1 0 0 0 01239 0 1 0 0 01240 0 0 1 D 01241 0 0 0 1 01242 and D = relative_depth_bias*(far-near). 01243 01244 Returns: 01245 True if the function worked. False if the frustum settings 01246 are not valild, in which cate the identity matrix is returned. 01247 01248 Remarks: 01249 The inverse of the transformations returned by 01250 GetClipCoordDepthBiasXform(+r,...) is the transformation 01251 returned by GetClipCoordDepthBiasXform(-r,...). 01252 */ 01253 bool GetClipCoordDepthBiasXform( 01254 double relative_depth_bias, 01255 ON_Xform& clip_bias 01256 ) const; 01257 01258 /* 01259 Description: 01260 Set suggested the perspective minimum near distance and 01261 minimum near/far ratio to the suggested values returned 01262 by GetPerspectiveClippingPlaneConstraints(). 01263 Parameters: 01264 depth_buffer_bit_depth - [in] 01265 typically 32, 24, 16 or 8, but any positive value can be 01266 passed in. 01267 */ 01268 void SetPerspectiveClippingPlaneConstraints( 01269 unsigned int depth_buffer_bit_depth 01270 ); 01271 01272 /* 01273 Description: 01274 Expert user function to control the minimum 01275 ratio of near/far when perspective projections 01276 are begin used. 01277 Parameters: 01278 min_near_over_far - [in] 01279 Remarks: 01280 This is a runtime setting and is not saved in 3dm files. 01281 */ 01282 void SetPerspectiveMinNearOverFar(double min_near_over_far); 01283 01284 /* 01285 Description: 01286 Expert user function to get the minimum runtime 01287 value of near/far when perspective projections 01288 are begin used. 01289 Returns: 01290 The minimum permitted value of near/far when perspective 01291 projections are begin used. 01292 Remarks: 01293 This is a runtime setting and is not saved in 3dm files. 01294 */ 01295 double PerspectiveMinNearOverFar() const; 01296 01297 /* 01298 Description: 01299 Expert user function to control the minimum 01300 value of near when perspective projections 01301 are begin used. 01302 Parameters: 01303 min_near_dist - [in] 01304 Remarks: 01305 This is a runtime setting and is not saved in 3dm files. 01306 */ 01307 void SetPerspectiveMinNearDist(double min_near_dist); 01308 01309 /* 01310 Description: 01311 Expert user function to get the minimum 01312 value of near when perspective projections 01313 are begin used. 01314 Returns: 01315 The minimum permitted value of near when perspective 01316 projections are begin used. 01317 Remarks: 01318 This is a runtime setting and is not saved in 3dm files. 01319 */ 01320 double PerspectiveMinNearDist() const; 01321 01322 /* 01323 Description: 01324 Sets the viewport's id to the value used to 01325 uniquely identify this viewport. 01326 Parameters: 01327 viewport_id - [in] 01328 Returns: 01329 True if the viewport's id was successfully set 01330 and false otherwise (ie. the viewport uuid has 01331 already been set). 01332 Remarks: 01333 There is no approved way to change the viewport 01334 id once it is set in order to maintain consistency 01335 across multiple viewports and those routines that 01336 manage them. 01337 */ 01338 bool SetViewportId(const ON_UUID& viewport_id ); 01339 01340 ON_UUID ViewportId(void) const; 01341 01342 /* 01343 Description: 01344 EXPERT USER function to change the viewport's id. 01345 If you change the id, you risk damaging display 01346 and visibility relationships in the model. 01347 Parameters: 01348 viewport_id - [in] 01349 */ 01350 void ChangeViewportId(const ON_UUID& viewport_id); 01351 01352 protected: 01353 01354 // These boolean status flags are set to true when 01355 // the associated fields contain valid values. 01356 bool m_bValidCamera; 01357 bool m_bValidFrustum; 01358 bool m_bValidPort; 01359 unsigned char m_reserved1; 01360 01361 // Camera Settings: /////////////////////////////////////////////// 01362 01363 // perspective or parallel projection 01364 ON::view_projection m_projection; 01365 01366 // Camera location, direction and orientation (in world coordinates). 01367 // These values are used to set the camera frame vectors CamX, CamY, 01368 // CamZ. If bValidCamera is true, then the CamX, CamY and CamZ 01369 // vectors are properly initialized and should be used 01370 // instead of CamDir[] and CamUp[]. The frame vectors CamX, CamY, CamZ 01371 // are always a right handed orthonormal frame. The CamDir 01372 // and CamUp vectors contain the values passed to SetViewCamera(). 01373 01374 // If true and the camera is valid, then the corresponding camera 01375 // parameter will not be changed by view editing functions. This 01376 // permits user interface to easily preserve important camera 01377 // features without having to perform excessive calculations. 01378 bool m_bLockCamUp; 01379 bool m_bLockCamDir; 01380 bool m_bLockCamLoc; 01381 unsigned char m_frustum_symmetry_flags; // 0 != (flags & 1) top/bottom symmetry enforced 01382 // 0 != (flags & 2) left/right symmetry enforced. 01383 ON_3dPoint m_CamLoc; // camera location 01384 ON_3dVector m_CamDir; // from camera towards view (nonzero and not parallel to m_CamUp) 01385 ON_3dVector m_CamUp; // (nonzero and not parallel to m_CamDir) 01386 01387 // The camera frame vectors are properly initialized by SetCamera() 01388 ON_3dVector m_CamX; 01389 ON_3dVector m_CamY; 01390 ON_3dVector m_CamZ; 01391 01392 // View Frustum Settings: /////////////////////////////////////// 01393 // left, right are camera X coords on near clipping plane 01394 // bottom, top are camera Y coords on near clipping plane 01395 // near = distance from camera to near clipping plane 01396 // far = distance from camera to far clipping plane 01397 double m_frus_left, m_frus_right; // frus_left < frus_right 01398 double m_frus_bottom, m_frus_top; // frus_bottom < frus_top 01399 double m_frus_near, m_frus_far; // frus_near < frus_far 01400 // in perspective, 0 < frus_near 01401 01402 01403 // Device View Port Box Settings: ( in display device coordinates ) //// 01404 // The point (left,bottom,-near), in camera coordinates, of the view 01405 // frustum is mapped to pixel coordinate (port_left,port_bottom,port_near). 01406 // The point (right,top,-far), in camera coordinates, of the view frustum 01407 // is mapped to pixel coordinate (port_right,port_top,port_far). 01408 int m_port_left, m_port_right; // port_left != port_right 01409 int m_port_bottom, m_port_top; // port_bottom != port_top 01410 // In many situations including Windows, 01411 // port_left = 0, 01412 // port_right = viewport width-1, 01413 // port_top = 0, 01414 // port_bottom = viewport height-1. 01415 int m_port_near, m_port_far; // (If you want an 8 bit z-buffer with 01416 // z=255 being "in front of" z=0, then 01417 // set port_near = 255 and port_far = 0.) 01418 01419 01420 // The location of this point has no impact on the 01421 // view projection. It is simply a suggestion for a 01422 // fixed point when views are rotated or the isometric 01423 // depth when perpsective views are dollied. The default 01424 // is ON_UNSET_POINT. 01425 ON_3dPoint m_target_point; 01426 01427 private: 01428 // When this id matches the viewport id saved in an ON_DisplayMaterialRef 01429 // list in ON_3dmObjectAttributes, then the the display material is used 01430 // for that object in this view. 01431 ON_UUID m_viewport_id; 01432 01433 bool SetCameraFrame(); // used to set m_CamX, m_CamY, m_CamZ 01434 01435 // This transform is used to tweak the clipping 01436 // coordinates. The default is the identity. 01437 // Modify this transformation when you need to do 01438 // things like z-buffer bias, non-uniform viewplane 01439 // scaling, and so on. 01440 01441 /* 01442 Description: 01443 Sets the m_clip_mod transformation; 01444 Parameters: 01445 clip_mod_xform - [in] invertable transformation 01446 */ 01447 bool SetClipModXform( ON_Xform clip_mod_xform ); 01448 ON_Xform m_clip_mods; 01449 ON_Xform m_clip_mods_inverse; 01450 01451 // Runtime values that depend on the graphics hardware being used. 01452 // These values are not saved in 3dm files. 01453 double m__MIN_NEAR_DIST; 01454 double m__MIN_NEAR_OVER_FAR; 01455 01456 public: 01457 static const double DefaultNearDist; // 0.005 01458 static const double DefaultFarDist; // 1000.0 01459 static const double DefaultMinNearDist; // 0.0001 01460 static const double DefaultMinNearOverFar; // 0.0001 01461 }; 01462 01463 ON_DECL 01464 bool 01465 ON_GetViewportRotationAngles( 01466 const ON_3dVector&, // X, // X,Y,Z must be a right handed orthonormal basis 01467 const ON_3dVector&, // Y, 01468 const ON_3dVector&, // Z, 01469 double*, // angle1, // returns rotation about world Z 01470 double*, // angle2, // returns rotation about world X ( 0 <= a2 <= pi ) 01471 double* // angle3 // returns rotation about world Z 01472 ); 01473 01474 ON_DECL 01475 bool 01476 ON_ViewportFromRhinoView( // create ON_Viewport from legacy Rhino projection info 01477 ON::view_projection, // projection, 01478 const ON_3dPoint&, // rhvp_target, // 3d point 01479 double, // rhvp_angle1 in radians 01480 double, // rhvp_angle2 in radians 01481 double, // rhvp_angle3 in radians 01482 double, // rhvp_viewsize, // > 0 01483 double, // rhvp_cameradist, // > 0 01484 int, // screen_width, 01485 int, // screen_height, 01486 ON_Viewport& 01487 ); 01488 01489 /* 01490 Description: 01491 Calculate the corners of the polygon that is the 01492 intersection of a view frustum with and infinte plane. 01493 Parameters: 01494 vp - [in] defines view frustum 01495 plane_equation - [in] defined infinte plane 01496 points - [out] corners of the polygon. 01497 If true is returned and points.Count() is zero, then 01498 the plane missed the frustum. Note that the start/end 01499 point is not duplicated in the list. 01500 Returns: 01501 True if input was valid, false otherwise. Note that 01502 even when true is returned, the returned points.Count() 01503 may be zero if the plane and frustum do not intersect. 01504 */ 01505 ON_DECL 01506 bool 01507 ON_IntersectViewFrustumPlane( 01508 const ON_Viewport& vp, 01509 const ON_PlaneEquation& plane_equation, 01510 ON_SimpleArray<ON_3dPoint>& points 01511 ); 01512 01513 #endif 01514