Point Cloud Library (PCL) 1.12.1
opennurbs_viewport.h
1/* $NoKeywords: $ */
2/*
3//
4// Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
5// OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6// McNeel & Associates.
7//
8// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10// MERCHANTABILITY ARE HEREBY DISCLAIMED.
11//
12// For complete openNURBS copyright information see <http://www.opennurbs.org>.
13//
14////////////////////////////////////////////////////////////////
15*/
16
17////////////////////////////////////////////////////////////////
18//
19// defines ON_Viewport
20//
21////////////////////////////////////////////////////////////////
22
23#if !defined(OPENNURBS_VIEWPORT_INC_)
24#define OPENNURBS_VIEWPORT_INC_
25
26///////////////////////////////////////////////////////////////////////////////
27// Class ON_Viewport
28//
29// This object represents a viewing frustum
30///////////////////////////////////////////////////////////////////////////////
31class ON_CLASS ON_Viewport : public ON_Geometry
32{
33 ON_OBJECT_DECLARE( ON_Viewport );
34public:
35
36 // Default z=up perspective camera direction
38
39 // Construction
43
44 bool IsValidCamera() const;
45 bool IsValidFrustum() const;
46
47 // ON_Object overrides //////////////////////////////////////////////////////
48 //
49
50 /*
51 Description:
52 Test for a valid camera, frustum, and screen port.
53 Parameters:
54 text_log - [in] if the object is not valid and text_log
55 is not NULL, then a brief englis description of the
56 reason the object is not valid is appened to the log.
57 The information appended to text_log is suitable for
58 low-level debugging purposes by programmers and is
59 not intended to be useful as a high level user
60 interface tool.
61 Returns:
62 @untitled table
63 true camera, frustum, and screen port are valid.
64 false camera, frustum, or screen port is invalid.
65 Remarks:
66 Overrides virtual ON_Object::IsValid
67 See Also:
68 IsValidCamera, IsValidFrustum
69 */
70 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
71
72 // Description:
73 // Dumps debugging text description to a text log.
74 //
75 // Parameters:
76 // dump_target - [in] text log
77 //
78 // Remarks:
79 // This overrides the virtual ON_Object::Dump() function.
80 void Dump(
81 ON_TextLog& // dump_target
82 ) const;
83
84 // Description:
85 // Writes ON_Viewport defintion from a binary archive.
86 //
87 // Parameters:
88 // binary_archive - [in] open binary archive
89 //
90 // Returns:
91 // true if successful.
92 //
93 // Remarks:
94 // This overrides the virtual ON_Object::Write() function.
95 ON_BOOL32 Write(
96 ON_BinaryArchive& // binary_archive
97 ) const;
98
99
100 // Description:
101 // Reads ON_Viewport defintion from a binary archive.
102 //
103 // Parameters:
104 // binary_archive - [in] open binary archive
105 //
106 // Returns:
107 // true if successful.
108 //
109 // Remarks:
110 // This overrides the virtual ON_Object::Read() function.
111 ON_BOOL32 Read(
112 ON_BinaryArchive& // binary_archive
113 );
114
115
116 // ON_Geometry overrides //////////////////////////////////////////////////////
117 //
118
119 // Description:
120 // The dimension of a camera view frustum is 3.
121 //
122 // Returns:
123 // 3
124 //
125 // Remarks:
126 // This is virtual ON_Geometry function.
127 int Dimension() const;
128
129 // Description:
130 // Gets bounding box of viewing frustum.
131 //
132 // Parameters:
133 // boxmin - [in/out] array of Dimension() doubles
134 // boxmax - [in/out] array of Dimension() doubles
135 // bGrowBox - [in] (default=false)
136 // If true, then the union of the input bbox and the
137 // object's bounding box is returned in bbox.
138 // If false, the object's bounding box is returned in bbox.
139 //
140 // Returns:
141 // @untitled table
142 // true Valid frustum and bounding box returned.
143 // false Invalid camera or frustum. No bounding box returned.
144 //
145 // Remarks:
146 // This overrides the virtual ON_Geometry::GetBBox() function.
147 ON_BOOL32 GetBBox( // returns true if successful
148 double*, // boxmin
149 double*, // boxmax
150 ON_BOOL32 = false // bGrowBox
151 ) const;
152
153 // Description:
154 // Transforms the view camera location, direction, and up.
155 //
156 // Parameters:
157 // xform - [in] transformation to apply to camera.
158 //
159 // Returns:
160 // @untitled table
161 // true Valid camera was transformed.
162 // false Invalid camera, frustum, or transformation.
163 //
164 // Remarks:
165 // This overrides the virtual ON_Geometry::Transform() function.
166 ON_BOOL32 Transform(
167 const ON_Xform& // xform
168 );
169
170 // Interface /////////////////////////////////////////////////////////////////
171 //
173
174 ON::view_projection Projection() const;
175
176 /*
177 Description:
178 Unconditionally set the projection.
179 Parameters:
180 projection - [in]
181 See Also:
182 ON_Viewport::SetParallelProjection
183 ON_Viewport::SetPerpectiveProjection
184 ON_Viewport::SetTwoPointPerspectiveProjection
185 */
186 bool SetProjection( ON::view_projection projection );
187
188 /*
189 Description:
190 Use this function to change projections of valid viewports
191 from persective to parallel. It will make common additional
192 adjustments to the frustum so the resulting views are similar.
193 The camera location and direction will not be changed.
194 Parameters:
195 bSymmetricFrustum - [in]
196 True if you want the resulting frustum to be symmetric.
197 Remarks:
198 If the current projection is parallel and bSymmetricFrustum,
199 FrustumIsLeftRightSymmetric() and FrustumIsTopBottomSymmetric()
200 are all equal, then no changes are made and true is returned.
201 */
202 bool ChangeToParallelProjection( bool bSymmetricFrustum );
203
204 /*
205 Description:
206 Use this function to change projections of valid viewports
207 from parallel to perspective. It will make common additional
208 adjustments to the frustum and camera location so the resulting
209 views are similar. The camera direction and target point are
210 not be changed.
211 Parameters:
212 target_distance - [in]
213 If ON_UNSET_VALUE this parameter is ignored. Otherwise
214 it must be > 0 and indicates which plane in the current
215 view frustum should be perserved.
216 bSymmetricFrustum - [in]
217 True if you want the resulting frustum to be symmetric.
218 lens_length - [in] (pass 50.0 when in doubt)
219 35 mm lens length to use when changing from parallel
220 to perspective projections. If the current projection
221 is perspective or lens_length is <= 0.0,
222 then this parameter is ignored.
223 Remarks:
224 If the current projection is perspective and bSymmetricFrustum,
225 FrustumIsLeftRightSymmetric() and FrustumIsTopBottomSymmetric()
226 are all equal, then no changes are made and true is returned.
227 */
229 double target_distance,
230 bool bSymmetricFrustum,
231 double lens_length
232 );
233
234 /*
235 Description:
236 Use this function to change projections of valid viewports
237 to a two point perspective. It will make common additional
238 adjustments to the frustum and camera location and direction
239 so the resulting views are similar.
240 Parameters:
241 target_distance - [in]
242 If ON_UNSET_VALUE this parameter is ignored. Otherwise
243 it must be > 0 and indicates which plane in the current
244 view frustum should be perserved.
245 up - [in]
246 This direction will be the locked up direction. Pass
247 ON_3dVector::ZeroVector if you want to use the world axis
248 direction that is closest to the current up direction.
249 Pass CameraY() if you want to preserve the current up direction.
250 lens_length - [in] (pass 50.0 when in doubt)
251 35 mm lens length to use when changing from parallel
252 to perspective projections. If the current projection
253 is perspective or lens_length is <= 0.0,
254 then this parameter is ignored.
255 Remarks:
256 If the current projection is perspective and
257 FrustumIsLeftRightSymmetric() is true and
258 FrustumIsTopBottomSymmetric() is false, then no changes are
259 made and true is returned.
260 */
262 double target_distance,
263 ON_3dVector up,
264 double lens_length
265 );
266
267 /*
268 Returns:
269 True if the projection is ON::perspective_view.
270 */
272
273 /*
274 Returns
275 IsPerspectiveProjection()
276 && CameraUpIsLocked()
277 && FrustumIsLeftRightSymmetric
278 && !FrustumIsTopBottomSymmetric
279 */
281
282 /*
283 Returns:
284 True if the projection is ON::parallel_view.
285 */
287
288 // These return true if the current direction and up are not zero and not
289 // parallel so the camera position is well defined.
292 bool SetCameraUp( const ON_3dVector& );
293
297
300 bool CameraUpIsLocked() const;
303
304 void SetCameraLocationLock( bool bLockCameraLocation );
305 void SetCameraDirectionLock( bool bLockCameraDirection ) ;
306 void SetCameraUpLock( bool bLockCameraUp );
307 void SetFrustumLeftRightSymmetry( bool bForceLeftRightSymmetry );
308 void SetFrustumTopBottomSymmetry( bool bForceTopBottomSymmetry );
309 void UnlockCamera(); // sets all camera locks to false
310 void UnlockFrustumSymmetry(); // sets all frustum symmetry locks to false
311
312 // returns true if current camera orientation is valid
314 double*, // CameraLocation[3]
315 double*, // CameraX[3]
316 double*, // CameraY[3]
317 double* // CameraZ[3]
318 ) const;
319
320 // these do not check for a valid camera orientation
321 ON_3dVector CameraX() const; // unit to right vector
322 ON_3dVector CameraY() const; // unit up vector
323 ON_3dVector CameraZ() const; // unit vector in -CameraDirection
324
325
327 // Returns true if the camera direction = some world axis.
328 // The indices report which axes are used. For a "twisted"
329 // plan view it is possible to have zero x and y indices.
330 // This function returns true if and only if the "z" index
331 // is non-zero.
332 //
333 // Indices are +/-1 = world +/-x, +/-2 = world +/-y, +/-3 = world +/-z,
334 int*, // if true and plan is axis aligned, view x index, else 0
335 int*, // if true and plan is axis aligned, view y index, else 0
336 int* // if true, view z index, else 0
337 );
338
340 // returns bounding box in camera coordinates - this is useful information
341 // for setting view frustrums to include the point list
342 int, // count = number of 3d points
343 int, // stride = number of doubles to skip between points (>=3)
344 const double*, // 3d points in world coordinates
345 ON_BoundingBox& cambbox, // bounding box in camera coordinates
346 int bGrowBox = false // set to true if you want to enlarge an existing camera coordinate box
347 ) const;
348
350 // returns bounding box in camera coordinates - this is useful information
351 // for setting view frustrums to include the point list
352 const ON_BoundingBox&, // world coordinate bounding box
353 ON_BoundingBox& cambbox, // bounding box in camera coordinates
354 int bGrowBox = false // set to true if you want to enlarge an existing camera coordinate box
355 ) const;
356
358 // returns bounding box in camera coordinates - this is useful information
359 // for setting view frustrums to include the point list
360 ON_3dPoint&, // world coordinate bounding sphere center
361 double, // world coordinate bounding sphere radius
362 ON_BoundingBox& cambox, // bounding box in camera coordinates
363 int bGrowBox = false // set to true if you want to enlarge an existing camera coordinate box
364 ) const;
365
366 /*
367 Description:
368 Set the view frustum. If FrustumSymmetryIsLocked() is true
369 and left != -right or bottom != -top, then they will be
370 adjusted so the resulting frustum is symmetric.
371 */
373 double left, //
374 double right, // ( left < right )
375 double bottom, //
376 double top, // ( bottom < top )
377 double near_dist, //
378 double far_dist // ( 0 < near_dist < far_dist ) // ignored by Rhino version 1.0
379 );
381 double* left, //
382 double* right, // (left < right)
383 double* bottom, //
384 double* top, // (bottom < top)
385 double* near_dist = NULL, //
386 double* far_dist = NULL // (0 < near_dist < far_dist)
387 ) const;
388
389 // SetFrustumAspect() changes the larger of the frustum's widht/height
390 // so that the resulting value of width/height matches the requested
391 // aspect. The camera angle is not changed. If you change the shape
392 // of the view port with a call SetScreenPort(), then you generally
393 // want to call SetFrustumAspect() with the value returned by
394 // GetScreenPortAspect().
395 bool SetFrustumAspect( double );
396
397 // Returns frustum's width/height
398 bool GetFrustumAspect( double& ) const;
399
400 // Returns world coordinates of frustum's center
401 bool GetFrustumCenter( double* ) const;
402
403 // The near clipping plane stored in the Rhino 1.0 file is frequently very
404 // small and useless for high quality z-buffer based rendering. The far
405 // clipping value is not stored in the file. Use these functions to set
406 // the frustum's near and far clipping planes to appropriate values.
407 double FrustumLeft() const;
408 double FrustumRight() const;
409 double FrustumBottom() const;
410 double FrustumTop() const;
411 double FrustumNear() const;
412 double FrustumFar() const;
413
414 /*
415 Returns:
416 frustum right - frustum left
417 */
418 double FrustumWidth() const; // right - left
419
420 /*
421 Returns:
422 frustum right - frustum left
423 */
424 double FrustumHeight() const; // top - bottom
425
426 /*
427 Returns:
428 Minimum of fabs(FrustumWidth()) and fabs(FrustumHeight())
429 */
431
432 /*
433 Returns:
434 Maximum of fabs(FrustumWidth()) and fabs(FrustumHeight())
435 */
437
438
440 const double* bboxmin, // 3d bounding box min
441 const double* bboxmax // 3d bounding box max
442 );
444 const double* center, // 3d bounding sphere center
445 double radius // 3d bounding sphere radius
446 );
448 double near_dist, // ( > 0 )
449 double far_dist //
450 );
451
452 /*
453 Description:
454 If needed, adjust the current frustum so it has the
455 specified symmetries and adjust the camera location
456 so the target plane remains visible.
457 Parameters:
458 bLeftRightSymmetric - [in]
459 If true, the frustum will be adjusted so left = -right.
460 bTopBottomSymmetric - [in]
461 If true, the frustum will be adjusted so top = -bottom.
462 target_distance - [in]
463 If projection is not perspective or target_distance
464 is ON_UNSET_VALUE, this this parameter is ignored.
465 If the projection is perspective and target_distance
466 is not ON_UNSET_VALUE, then it must be > 0.0 and
467 it is used to determine which plane in the old
468 frustum will appear unchanged in the new frustum.
469 bool
470 Returns true if the returned viewport has a frustum
471 with the specified symmetries.
472 */
474 bool bLeftRightSymmetric,
475 bool bTopBottomSymmetric,
476 double target_distance
477 );
478
479 /*
480 Description:
481 Get near and far clipping distances of a point
482 Parameters:
483 point - [in]
484 near_dist - [out]
485 near distance of the point (can be < 0)
486 far_dist - [out]
487 far distance of the point (can be equal to near_dist)
488 bGrowNearFar - [in]
489 If true and input values of near_dist and far_dist
490 are not ON_UNSET_VALUE, the near_dist and far_dist
491 are enlarged to include bbox.
492 Returns:
493 True if the point is ing the view frustum and
494 near_dist/far_dist were set.
495 False if the bounding box does not intesect the
496 view frustum.
497 */
499 ON_3dPoint point,
500 double* near_dist,
501 double* far_dist,
502 bool bGrowNearFar=false
503 ) const;
504
505 /*
506 Description:
507 Get the view plane depth of a point
508 Parameters:
509 point - [in]
510 view_plane_depth - [out]
511 positive values are in front of the camera and negative
512 values are behind the camera.
513 If 0 <= point_depth < FrustumNear(), the point's view
514 plane is between the camera and the frustum's near plane.
515 If point_depth > FrustumFar(), the point's view
516 plane is farther from the camera and the frustum's far plane.
517 Returns:
518 True if the point is ing the view frustum and
519 near_dist/far_dist were set.
520 False if the bounding box does not intesect the
521 view frustum.
522 */
524 ON_3dPoint point,
525 double* view_plane_depth
526 ) const;
527
528 /*
529 Description:
530 Get near and far clipping distances of a bounding box.
531 Parameters:
532 bbox - [in]
533 bounding box
534 near_dist - [out]
535 near distance of the box
536 This value can be zero or negative when the camera
537 location is inside bbox.
538 far_dist - [out]
539 far distance of the box
540 This value can be equal to near_dist, zero or negative
541 when the camera location is in front of the bounding box.
542 bGrowNearFar - [in]
543 If true and input values of near_dist and far_dist
544 are not ON_UNSET_VALUE, the near_dist and far_dist
545 are enlarged to include bbox.
546 Returns:
547 True if the bounding box intersects the view frustum and
548 near_dist/far_dist were set.
549 False if the bounding box does not intesect the view frustum.
550 Remarks:
551 This function ignores the current value of the viewport's
552 near and far settings. If the viewport is a perspective
553 projection, the it intersects the semi infinite frustum
554 volume with the bounding box and returns the near and far
555 distances of the intersection. If the viewport is a parallel
556 projection, it instersects the infinte view region with the
557 bounding box and returns the near and far distances of the
558 projection.
559 */
561 ON_BoundingBox bbox,
562 double* near_dist,
563 double* far_dist,
564 bool bGrowNearFar=false
565 ) const;
566
567 /*
568 Description:
569 Get near and far clipping distances of a bounding sphere.
570 Parameters:
571 sphere - [in]
572 bounding sphere
573 near_dist - [out]
574 near distance of the sphere (can be < 0)
575 far_dist - [out]
576 far distance of the sphere (can be equal to near_dist)
577 bGrowNearFar - [in]
578 If true and input values of near_dist and far_dist
579 are not ON_UNSET_VALUE, the near_dist and far_dist
580 are enlarged to include bbox.
581 Returns:
582 True if the sphere intersects the view frustum and
583 near_dist/far_dist were set.
584 False if the sphere does not intesect the view frustum.
585 */
587 ON_Sphere sphere,
588 double* near_dist,
589 double* far_dist,
590 bool bGrowNearFar=false
591 ) const;
592
593 /*
594 Description:
595 Set near and far clipping distance subject to constraints.
596 Parameters:
597 near_dist - [in] (>0) desired near clipping distance
598 far_dist - [in] (>near_dist) desired near clipping distance
599 min_near_dist - [in]
600 If min_near_dist <= 0.0, it is ignored.
601 If min_near_dist > 0 and near_dist < min_near_dist,
602 then the frustum's near_dist will be increased to
603 min_near_dist.
604 min_near_over_far - [in]
605 If min_near_over_far <= 0.0, it is ignored.
606 If near_dist < far_dist*min_near_over_far, then
607 near_dist is increased and/or far_dist is decreased
608 so that near_dist = far_dist*min_near_over_far.
609 If near_dist < target_dist < far_dist, then near_dist
610 near_dist is increased and far_dist is decreased so that
611 projection precision will be good at target_dist.
612 Otherwise, near_dist is simply set to
613 far_dist*min_near_over_far.
614 target_dist - [in]
615 If target_dist <= 0.0, it is ignored.
616 If target_dist > 0, it is used as described in the
617 description of the min_near_over_far parameter.
618 relative_depth_bias - [in]
619 If relative_depth_bias <= 0.0, it is ignored.
620 If relative_depth_bias > 0, it is assumed that
621 the requested near_dist and far_dist were calculated
622 assuming no depth bias and the values will be
623 appropriately adjusted to ensure the frustum's
624 near and far clipping planes will not clip biased
625 objects.
626 */
628 double near_dist,
629 double far_dist,
630 double min_near_dist,
631 double min_near_over_far,
632 double target_dist
633 );
634
636 double near_dist,
637 double far_dist,
638 double min_near_dist,
639 double min_near_over_far,
640 double target_dist,
641 double relative_depth_bias
642 );
643
644 // Description:
645 // Get near clipping plane.
646 //
647 // near_plane - [out] near clipping plane if camera and frustum
648 // are valid. The plane's frame is the same as the camera's
649 // frame. The origin is located at the intersection of the
650 // camera direction ray and the near clipping plane. The plane's
651 // normal points out of the frustum towards the camera
652 // location.
653 //
654 // Returns:
655 // true if camera and frustum are valid.
657 ON_Plane& near_plane
658 ) const;
659
661 ON_PlaneEquation& near_plane_equation
662 ) const;
663
664 // Description:
665 // Get far clipping plane.
666 //
667 // far_plane - [out] far clipping plane if camera and frustum
668 // are valid. The plane's frame is the same as the camera's
669 // frame. The origin is located at the intersection of the
670 // camera direction ray and the far clipping plane. The plane's
671 // normal points into the frustum towards the camera location.
672 //
673 // Returns:
674 // true if camera and frustum are valid.
676 ON_Plane& far_plane
677 ) const;
678
680 ON_PlaneEquation& far_plane_equation
681 ) const;
682
683 /*
684 Description:
685 Get the plane that is a specified distance from the camera.
686 This plane is parallel to the frustum's near and far planes.
687 Parameters:
688 view_plane_depth - [in]
689 The distance from the camera location to the view plane.
690 Positive distances are in front of the camera and
691 negative distances are behind the camera.
692 A value of FrustumNear() will return the frustum's
693 near plane and a valud of FrustumFar() will return
694 the frustum's far plane.
695 view_plane - [out]
696 View plane
697 view_plane_equation - [out]
698 Equation of the view plane.
699 Returns:
700 True if the camera and frustum are valid and view_plane
701 was calculated. False otherwise.
702 */
704 double view_plane_depth,
705 ON_Plane& view_plane
706 ) const;
707
709 double view_plane_depth,
710 ON_PlaneEquation& view_plane_equation
711 ) const;
712
713 /*
714 Description:
715 Get left world frustum clipping plane.
716 Parameters:
717 left_plane - [out]
718 frustum left side clipping plane. The normal points
719 into the visible region of the frustum. If the projection
720 is perspective, the origin is at the camera location,
721 otherwise the origin isthe point on the plane that is
722 closest to the camera location.
723 Returns:
724 True if camera and frustum are valid and plane was set.
725 */
727 ON_Plane& left_plane
728 ) const;
729
731 ON_PlaneEquation& left_plane_equation
732 ) const;
733
734 /*
735 Description:
736 Get right world frustum clipping plane.
737 Parameters:
738 right_plane - [out]
739 frustum right side clipping plane. The normal points
740 into the visible region of the frustum. If the projection
741 is perspective, the origin is at the camera location,
742 otherwise the origin isthe point on the plane that is
743 closest to the camera location.
744 Returns:
745 True if camera and frustum are valid and plane was set.
746 */
748 ON_Plane& right_plane
749 ) const;
750
752 ON_PlaneEquation& right_plane_equation
753 ) const;
754
755 /*
756 Description:
757 Get right world frustum clipping plane.
758 Parameters:
759 right_plane - [out]
760 frustum bottom side clipping plane. The normal points
761 into the visible region of the frustum. If the projection
762 is perspective, the origin is at the camera location,
763 otherwise the origin isthe point on the plane that is
764 closest to the camera location.
765 Returns:
766 True if camera and frustum are valid and plane was set.
767 */
769 ON_Plane& bottom_plane
770 ) const;
771
773 ON_PlaneEquation& bottom_plane_equation
774 ) const;
775 /*
776 Description:
777 Get right world frustum clipping plane.
778 Parameters:
779 top_plane - [out]
780 frustum top side clipping plane. The normal points
781 into the visible region of the frustum. If the projection
782 is perspective, the origin is at the camera location,
783 otherwise the origin isthe point on the plane that is
784 closest to the camera location.
785 Returns:
786 True if camera and frustum are valid and plane was set.
787 */
789 ON_Plane& top_plane
790 ) const;
791
793 ON_PlaneEquation& top_plane_equation
794 ) const;
795
796 // Description:
797 // Get corners of near clipping plane rectangle.
798 //
799 // Parameters:
800 // left_bottom - [out]
801 // right_bottom - [out]
802 // left_top - [out]
803 // right_top - [out]
804 //
805 // Returns:
806 // true if camera and frustum are valid.
808 ON_3dPoint& left_bottom,
809 ON_3dPoint& right_bottom,
810 ON_3dPoint& left_top,
811 ON_3dPoint& right_top
812 ) const;
813
814 // Description:
815 // Get corners of far clipping plane rectangle.
816 //
817 // Parameters:
818 // left_bottom - [out]
819 // right_bottom - [out]
820 // left_top - [out]
821 // right_top - [out]
822 //
823 // Returns:
824 // true if camera and frustum are valid.
826 ON_3dPoint& left_bottom,
827 ON_3dPoint& right_bottom,
828 ON_3dPoint& left_top,
829 ON_3dPoint& right_top
830 ) const;
831
832 /*
833 Description:
834 Get the world coordinate corners of the rectangle of
835 a view plane that is a specified distance from the camera.
836 This rectangle is parallel to the frustum's near and far planes.
837 Parameters:
838 view_plane_depth - [in]
839 The distance from the camera location to the view plane.
840 Positive distances are in front of the camera and
841 negative distances are behind the camera.
842 A value of FrustumNear() will return the frustum's
843 near rectangle and a valud of FrustumFar() will return
844 the frustum's far rectangle.
845 left_bottom - [out]
846 right_bottom - [out]
847 left_top - [out]
848 right_top - [out]
849 Returns:
850 True if the camera and frustum are valid and view_plane
851 was calculated. False otherwise.
852 */
854 double view_plane_depth,
855 ON_3dPoint& left_bottom,
856 ON_3dPoint& right_bottom,
857 ON_3dPoint& left_top,
858 ON_3dPoint& right_top
859 ) const;
860
861
862 /*
863 Description:
864 Location of viewport in pixels.
865 These are provided so you can set the port you are using
866 and get the appropriate transformations to and from
867 screen space.
868 Parameters:
869 port_left - [in]
870 port_right - [in] (port_left != port_right)
871 port_bottom - [in]
872 port_top - [in] (port_top != port_bottom)
873 port_near - [in]
874 port_far - [in]
875 Example:
876
877 // For a Windows window
878 int width = width of window client area in pixels;
879 int height = height of window client area in pixels;
880 port_left = 0;
881 port_right = width;
882 port_top = 0;
883 port_bottom = height;
884 port_near = 0;
885 port_far = 1;
886 SetScreenPort( port_left, port_right,
887 port_bottom, port_top,
888 port_near, port_far );
889
890 Returns:
891 true if input is valid.
892 See Also:
893 ON_Viewport::GetScreenPort
894 */
896 int port_left,
897 int port_right,
898 int port_bottom,
899 int port_top,
900 int port_near = 0,
901 int port_far = 0
902 );
903
905 int* left,
906 int* right, //( port_left != port_right )
907 int* port_bottom,
908 int* port_top, //( port_bottom != port_top)
909 int* port_near=NULL,
910 int* port_far=NULL
911 ) const;
912
913 /*
914 Returns:
915 abs(port_right - port_left)
916 */
917 int ScreenPortWidth() const;
918
919 /*
920 Returns:
921 abs(port_bottom - port_top)
922 */
923 int ScreenPortHeight() const;
924
925 bool GetScreenPortAspect( double& ) const; // port's |width/height|
926
928 double* half_diagonal_angle, // 1/2 of diagonal subtended angle
929 double* half_vertical_angle, // 1/2 of vertical subtended angle
930 double* half_horizontal_angle // 1/2 of horizontal subtended angle
931 ) const;
933 double* half_smallest_angle // 1/2 of smallest subtended view angle
934 ) const;
936 double half_smallest_angle // 1/2 of smallest subtended view angle
937 // 0 < angle < pi/2
938 );
939
940 // These functions assume the camera is horizontal and crop the
941 // film rather than the image when the aspect of the frustum
942 // is not 36/24. (35mm film is 36mm wide and 24mm high.)
943 //
944 // The SetCamera35mmLensLength() preserves camera location,
945 // changes the frustum, but maintains the frsutrum's aspect.
947 double* lens_length
948 ) const;
950 double lens_length
951 );
952
953 // Same as GetCamera35mmLensLength() with "lens" misspelled.
955 double* lens_length
956 ) const;
957
958 // Same as SetCamera35mmLensLength() with "lens" misspelled.
960 double lens_length
961 );
962
963 bool GetXform(
964 ON::coordinate_system srcCS,
965 ON::coordinate_system destCS,
966 ON_Xform& matrix // 4x4 transformation matrix (acts on the left)
967 ) const;
968
969 /*
970 Description:
971 Get the world coordinate line in the view frustum
972 that projects to a point on the screen.
973 Parameters:
974 screenx - [in]
975 screeny - [in] (screenx,screeny) = screen location
976 world_line - [out] 3d world coordinate line segment
977 starting on the near clipping plane and ending
978 on the far clipping plane.
979 Returns:
980 true if successful.
981 false if view projection or frustum is invalid.
982 */
984 double screenx,
985 double screeny,
986 ON_Line& world_line
987 ) const;
988
989 // display tools
991 const ON_3dPoint& point_in_frustum, // [in] point in viewing frustum.
992 double* pixels_per_unit // [out] scale = number of pixels per world unit at the 3d point
993 ) const;
994
996 int, // size in pixels of coordinate sprite axes
997 int, int, // screen (x,y) for sprite origin
998 int[3], // returns depth order for axes
999 double [3][2] // screen coords for axes ends
1000 ) const;
1001
1002 // Use Extents() as a quick way to set a viewport to so that bounding
1003 // volume is inside of a viewports frusmtrum.
1004 // The view angle is used to determine the position of the camera.
1005 bool Extents(
1006 double half_view_angle, // 1/2 smallest subtended view angle
1007 // (0 < angle < pi/2)
1008 const ON_BoundingBox& world_bbox// 3d world coordinate bounding box
1009 );
1010 bool Extents(
1011 double half_view_angle, // 1/2 smallest subtended view angle
1012 // (0 < angle < pi/2)
1013 const ON_3dPoint& center, // 3d world coordinate bounding sphere center
1014 double radius // 3d sphere radius
1015 );
1016
1017 ////////////////////////////////////////////////////////////////////////
1018 // View changing from screen input points. Handy for
1019 // using a mouse to manipulate a view.
1020 //
1021
1022 //////////
1023 // ZoomToScreenRect() may change camera and frustum settings
1025 int screen_x0,
1026 int screen_y0, // (x,y) screen coords of a rectangle corner
1027 int screen_x1,
1028 int screen_y1 // (x,y) screen coords of opposite rectangle corner
1029 );
1030
1031 //////////
1032 // DollyCamera() does not update the frustum's clipping planes.
1033 // To update the frustum's clipping planes call DollyFrustum(d)
1034 // with d = dollyVector o cameraFrameZ. To convert screen locations
1035 // into a dolly vector, use GetDollyCameraVector().
1036 bool DollyCamera( // Does not update frustum. To update frustum use
1037 // DollyFrustum(d) with d = dollyVector o cameraFrameZ
1038 const ON_3dVector& dolly_vector // dolly vector in world coordinates
1039 );
1040
1041 //////////
1042 // Gets a world coordinate dolly vector that can be passed to
1043 // DollyCamera().
1045 int screen_x0,
1046 int screen_y0, // (x,y) screen coords of start point
1047 int screen_x1,
1048 int screen_y1, // (x,y) screen coords of end point
1049 double proj_plane_dist, // distance of projection plane from camera.
1050 // When in doubt, use 0.5*(frus_near+frus_far).
1051 ON_3dVector& dolly_vector // world coordinate dolly vector returned here
1052 ) const;
1053
1054 //////////
1055 // Moves frustum's clipping planes
1057 double dolly_distance // distance to move in camera direction
1058 );
1059
1060 /*
1061 Description:
1062 Apply scaling factors to parallel projection clipping coordinates
1063 by setting the m_clip_mod transformation.
1064 Parameters:
1065 x - [in] x > 0
1066 y - [in] y > 0
1067 Example:
1068 If you want to compress the view projection across the viewing
1069 plane, then set x = 0.5, y = 1.0, and z = 1.0.
1070 Returns:
1071 True if successful.
1072 False if input is invalid or the view is a perspective view.
1073 */
1074 bool SetViewScale( double x, double y );
1075 void GetViewScale( double* x, double* y ) const;
1076
1077 /*
1078 Description:
1079 Gets the m_clip_mod transformation;
1080 Returns:
1081 value of the m_clip_mod transformation.
1082 */
1084
1085 /*
1086 Description:
1087 Gets the m_clip_mod_inverse transformation;
1088 Returns:
1089 value of the m_clip_mod_inverse transformation.
1090 */
1092
1093 /*
1094 Returns:
1095 True if clip mod xform is identity.
1096 */
1098
1099 /*
1100 Description:
1101 Return a point on the central axis of the view frustum.
1102 This point is a good choice for a general purpose target point.
1103 Parameters:
1104 target_distance - [in]
1105 If target_distance > 0.0, then the distance from the returned
1106 point to the camera plane will be target_distance. Note that
1107 if the frustum is not symmetric, the distance from the
1108 returned point to the camera location will be larger than
1109 target_distanct.
1110 If target_distance == ON_UNSET_VALUE and the frustum
1111 is valid with near > 0.0, then 0.5*(near + far) will be used
1112 as the target_distance.
1113 Returns:
1114 A point on the frustum's central axis. If the viewport or input
1115 is not valid, then ON_3dPoint::UnsetPoint is returned.
1116 */
1117 ON_3dPoint FrustumCenterPoint( double target_distance ) const;
1118
1119 /*
1120 Returns:
1121 The current value of the target point. This point does not play
1122 a role in the view projection calculations. It can be used as a
1123 fixed point when changing the camera so the visible regions of the
1124 before and after frustums both contain the region of interest.
1125 Remarks:
1126 The default constructor sets this point on ON_3dPoint::UnsetPoint.
1127 You must explicitly call one SetTargetPoint() functions to set
1128 the target point.
1129 */
1131
1132 /*
1133 Description:
1134 Set the target point.
1135 Parameters:
1136 target_point - [in]
1137 When in doubt, the point returned by FrustumCenterPoint(ON_UNSET_VALUE)
1138 is a good choice.
1139 Remarks:
1140 The default constructor sets this point on ON_3dPoint::UnsetPoint.
1141 You must explicitly call one SetTargetPoint() functions to set
1142 the target point.
1143 */
1144 bool SetTargetPoint( ON_3dPoint target_point );
1145
1146 /*
1147 Description:
1148 Get the distance from the target point to the camera plane.
1149 Note that if the frustum is not symmetric, then this distance
1150 is shorter than the distance from the target to the camera location.
1151 Parameters:
1152 bUseFrustumCenterFallback - [in]
1153 If bUseFrustumCenterFallback is false and the target point is
1154 not valid, then ON_UNSET_VALUE is returned.
1155 If bUseFrustumCenterFallback is true and the frustum is valid
1156 and current target point is not valid or is behind the camera,
1157 then 0.5*(near + far) is returned.
1158 Returns:
1159 Shortest signed distance from camera plane to target point.
1160 If the target point is on the visible side of the camera,
1161 a positive value is returned. ON_UNSET_VALUE is returned
1162 when the input of view is not valid.
1163 */
1164 double TargetDistance( bool bUseFrustumCenterFallback ) const;
1165
1166 /*
1167 Description:
1168 Get suggested values for setting the perspective minimum
1169 near distance and minimum near/far ratio.
1170 Parameters:
1171 camera_location - [in]
1172 depth_buffer_bit_depth - [in]
1173 typically 32, 24, 16 or 8, but any positive value can be
1174 passed in.
1175 min_near_dist - [out]
1176 Suggest value for passing to SetPerspectiveMinNearDist().
1177 min_near_over_far - [out]
1178 Suggest value for passing to SetPerspectiveMinNearOverFar().
1179 */
1181 ON_3dPoint camera_location,
1182 unsigned int depth_buffer_bit_depth,
1183 double* min_near_dist,
1184 double* min_near_over_far
1185 );
1186
1187 /*
1188 Description:
1189 Calculate the value to add to homogeneous "z" clipping coordinate
1190 that corresponds to moving the corresponding euclidean camera
1191 coordinate by relative_depth_bias*(far - near).
1192 Parameters:
1193 relative_depth_bias - [in]
1194 signed relative bias.
1195 = 0: no bias,
1196 > 0: bias towards frustum's near clipping plane
1197 < 0: bias towards frustum's far clipping plane
1198 When you have curves and points that are "on" shaded objects,
1199 values around 1/256 work well to move the wire objects
1200 in front of or behind shaded objects.
1201 clip_z [-in]
1202 clip_w [-in]
1203 clip_z and clip_w are the homogeneous "w" and "w" coordinates
1204 of a homogeneous clipping coordinate point.
1205 Returns:
1206 The clipping coordinate depth bias to add to the z-clipping
1207 coordinate that corresponds to adding cam_depth_bias
1208 to the z camera coordinate.
1209 Remarks:
1210 For perspective views, this bias is largest in the vicinity
1211 of the frustum's near clipping plane and smallest in the
1212 vicinity of the frustum's far clipping plane.
1213 For orthographic projectsions, this bias is constant.
1214 */
1216 double relative_depth_bias,
1217 double clip_z,
1218 double clip_w
1219 ) const;
1220
1221 /*
1222 Description:
1223 Calculate a transformation to apply to clipping coordinates to
1224 bias their depth.
1225
1226 Parameters:
1227 relative_depth_bias - [in]
1228 signed relative bias.
1229 = 0: no bias,
1230 > 0: bias towards frustum's near clipping plane
1231 < 0: bias towards frustum's far clipping plane
1232 When you have curves and points that are "on" shaded objects,
1233 values around 1/512 work well to move the wire objects
1234 in front of or behind shaded objects.
1235
1236 clip_bias - [out]
1237 clip_bias = cam2clip * delta * clip2cam,
1238 where delta = 1 0 0 0
1239 0 1 0 0
1240 0 0 1 D
1241 0 0 0 1
1242 and D = relative_depth_bias*(far-near).
1243
1244 Returns:
1245 True if the function worked. False if the frustum settings
1246 are not valild, in which cate the identity matrix is returned.
1247
1248 Remarks:
1249 The inverse of the transformations returned by
1250 GetClipCoordDepthBiasXform(+r,...) is the transformation
1251 returned by GetClipCoordDepthBiasXform(-r,...).
1252 */
1254 double relative_depth_bias,
1255 ON_Xform& clip_bias
1256 ) const;
1257
1258 /*
1259 Description:
1260 Set suggested the perspective minimum near distance and
1261 minimum near/far ratio to the suggested values returned
1262 by GetPerspectiveClippingPlaneConstraints().
1263 Parameters:
1264 depth_buffer_bit_depth - [in]
1265 typically 32, 24, 16 or 8, but any positive value can be
1266 passed in.
1267 */
1269 unsigned int depth_buffer_bit_depth
1270 );
1271
1272 /*
1273 Description:
1274 Expert user function to control the minimum
1275 ratio of near/far when perspective projections
1276 are begin used.
1277 Parameters:
1278 min_near_over_far - [in]
1279 Remarks:
1280 This is a runtime setting and is not saved in 3dm files.
1281 */
1282 void SetPerspectiveMinNearOverFar(double min_near_over_far);
1283
1284 /*
1285 Description:
1286 Expert user function to get the minimum runtime
1287 value of near/far when perspective projections
1288 are begin used.
1289 Returns:
1290 The minimum permitted value of near/far when perspective
1291 projections are begin used.
1292 Remarks:
1293 This is a runtime setting and is not saved in 3dm files.
1294 */
1296
1297 /*
1298 Description:
1299 Expert user function to control the minimum
1300 value of near when perspective projections
1301 are begin used.
1302 Parameters:
1303 min_near_dist - [in]
1304 Remarks:
1305 This is a runtime setting and is not saved in 3dm files.
1306 */
1307 void SetPerspectiveMinNearDist(double min_near_dist);
1308
1309 /*
1310 Description:
1311 Expert user function to get the minimum
1312 value of near when perspective projections
1313 are begin used.
1314 Returns:
1315 The minimum permitted value of near when perspective
1316 projections are begin used.
1317 Remarks:
1318 This is a runtime setting and is not saved in 3dm files.
1319 */
1321
1322 /*
1323 Description:
1324 Sets the viewport's id to the value used to
1325 uniquely identify this viewport.
1326 Parameters:
1327 viewport_id - [in]
1328 Returns:
1329 True if the viewport's id was successfully set
1330 and false otherwise (ie. the viewport uuid has
1331 already been set).
1332 Remarks:
1333 There is no approved way to change the viewport
1334 id once it is set in order to maintain consistency
1335 across multiple viewports and those routines that
1336 manage them.
1337 */
1338 bool SetViewportId(const ON_UUID& viewport_id );
1339
1340 ON_UUID ViewportId(void) const;
1341
1342 /*
1343 Description:
1344 EXPERT USER function to change the viewport's id.
1345 If you change the id, you risk damaging display
1346 and visibility relationships in the model.
1347 Parameters:
1348 viewport_id - [in]
1349 */
1350 void ChangeViewportId(const ON_UUID& viewport_id);
1351
1352protected:
1353
1354 // These boolean status flags are set to true when
1355 // the associated fields contain valid values.
1359 unsigned char m_reserved1;
1360
1361 // Camera Settings: ///////////////////////////////////////////////
1362
1363 // perspective or parallel projection
1364 ON::view_projection m_projection;
1365
1366 // Camera location, direction and orientation (in world coordinates).
1367 // These values are used to set the camera frame vectors CamX, CamY,
1368 // CamZ. If bValidCamera is true, then the CamX, CamY and CamZ
1369 // vectors are properly initialized and should be used
1370 // instead of CamDir[] and CamUp[]. The frame vectors CamX, CamY, CamZ
1371 // are always a right handed orthonormal frame. The CamDir
1372 // and CamUp vectors contain the values passed to SetViewCamera().
1373
1374 // If true and the camera is valid, then the corresponding camera
1375 // parameter will not be changed by view editing functions. This
1376 // permits user interface to easily preserve important camera
1377 // features without having to perform excessive calculations.
1381 unsigned char m_frustum_symmetry_flags; // 0 != (flags & 1) top/bottom symmetry enforced
1382 // 0 != (flags & 2) left/right symmetry enforced.
1383 ON_3dPoint m_CamLoc; // camera location
1384 ON_3dVector m_CamDir; // from camera towards view (nonzero and not parallel to m_CamUp)
1385 ON_3dVector m_CamUp; // (nonzero and not parallel to m_CamDir)
1386
1387 // The camera frame vectors are properly initialized by SetCamera()
1391
1392 // View Frustum Settings: ///////////////////////////////////////
1393 // left, right are camera X coords on near clipping plane
1394 // bottom, top are camera Y coords on near clipping plane
1395 // near = distance from camera to near clipping plane
1396 // far = distance from camera to far clipping plane
1397 double m_frus_left, m_frus_right; // frus_left < frus_right
1398 double m_frus_bottom, m_frus_top; // frus_bottom < frus_top
1399 double m_frus_near, m_frus_far; // frus_near < frus_far
1400 // in perspective, 0 < frus_near
1401
1402
1403 // Device View Port Box Settings: ( in display device coordinates ) ////
1404 // The point (left,bottom,-near), in camera coordinates, of the view
1405 // frustum is mapped to pixel coordinate (port_left,port_bottom,port_near).
1406 // The point (right,top,-far), in camera coordinates, of the view frustum
1407 // is mapped to pixel coordinate (port_right,port_top,port_far).
1408 int m_port_left, m_port_right; // port_left != port_right
1409 int m_port_bottom, m_port_top; // port_bottom != port_top
1410 // In many situations including Windows,
1411 // port_left = 0,
1412 // port_right = viewport width-1,
1413 // port_top = 0,
1414 // port_bottom = viewport height-1.
1415 int m_port_near, m_port_far; // (If you want an 8 bit z-buffer with
1416 // z=255 being "in front of" z=0, then
1417 // set port_near = 255 and port_far = 0.)
1418
1419
1420 // The location of this point has no impact on the
1421 // view projection. It is simply a suggestion for a
1422 // fixed point when views are rotated or the isometric
1423 // depth when perpsective views are dollied. The default
1424 // is ON_UNSET_POINT.
1426
1427private:
1428 // When this id matches the viewport id saved in an ON_DisplayMaterialRef
1429 // list in ON_3dmObjectAttributes, then the the display material is used
1430 // for that object in this view.
1431 ON_UUID m_viewport_id;
1432
1433 bool SetCameraFrame(); // used to set m_CamX, m_CamY, m_CamZ
1434
1435 // This transform is used to tweak the clipping
1436 // coordinates. The default is the identity.
1437 // Modify this transformation when you need to do
1438 // things like z-buffer bias, non-uniform viewplane
1439 // scaling, and so on.
1440
1441 /*
1442 Description:
1443 Sets the m_clip_mod transformation;
1444 Parameters:
1445 clip_mod_xform - [in] invertable transformation
1446 */
1447 bool SetClipModXform( ON_Xform clip_mod_xform );
1448 ON_Xform m_clip_mods;
1449 ON_Xform m_clip_mods_inverse;
1450
1451 // Runtime values that depend on the graphics hardware being used.
1452 // These values are not saved in 3dm files.
1453 double m__MIN_NEAR_DIST;
1454 double m__MIN_NEAR_OVER_FAR;
1455
1456public:
1457 static const double DefaultNearDist; // 0.005
1458 static const double DefaultFarDist; // 1000.0
1459 static const double DefaultMinNearDist; // 0.0001
1460 static const double DefaultMinNearOverFar; // 0.0001
1461};
1462
1463ON_DECL
1464bool
1465ON_GetViewportRotationAngles(
1466 const ON_3dVector&, // X, // X,Y,Z must be a right handed orthonormal basis
1467 const ON_3dVector&, // Y,
1468 const ON_3dVector&, // Z,
1469 double*, // angle1, // returns rotation about world Z
1470 double*, // angle2, // returns rotation about world X ( 0 <= a2 <= pi )
1471 double* // angle3 // returns rotation about world Z
1472 );
1473
1474ON_DECL
1475bool
1476ON_ViewportFromRhinoView( // create ON_Viewport from legacy Rhino projection info
1477 ON::view_projection, // projection,
1478 const ON_3dPoint&, // rhvp_target, // 3d point
1479 double, // rhvp_angle1 in radians
1480 double, // rhvp_angle2 in radians
1481 double, // rhvp_angle3 in radians
1482 double, // rhvp_viewsize, // > 0
1483 double, // rhvp_cameradist, // > 0
1484 int, // screen_width,
1485 int, // screen_height,
1487 );
1488
1489/*
1490Description:
1491 Calculate the corners of the polygon that is the
1492 intersection of a view frustum with and infinte plane.
1493Parameters:
1494 vp - [in] defines view frustum
1495 plane_equation - [in] defined infinte plane
1496 points - [out] corners of the polygon.
1497 If true is returned and points.Count() is zero, then
1498 the plane missed the frustum. Note that the start/end
1499 point is not duplicated in the list.
1500Returns:
1501 True if input was valid, false otherwise. Note that
1502 even when true is returned, the returned points.Count()
1503 may be zero if the plane and frustum do not intersect.
1504*/
1505ON_DECL
1506bool
1507ON_IntersectViewFrustumPlane(
1508 const ON_Viewport& vp,
1509 const ON_PlaneEquation& plane_equation,
1511 );
1512
1513#endif
1514
ON_3dPoint m_target_point
bool SetCameraAngle(double half_smallest_angle)
ON_3dPoint FrustumCenterPoint(double target_distance) const
double FrustumTop() const
bool IsCameraFrameWorldPlan(int *, int *, int *)
ON_BOOL32 IsValid(ON_TextLog *text_log=NULL) const
void SetFrustumTopBottomSymmetry(bool bForceTopBottomSymmetry)
bool GetCameraExtents(int, int, const double *, ON_BoundingBox &cambbox, int bGrowBox=false) const
double FrustumFar() const
bool GetCameraExtents(const ON_BoundingBox &, ON_BoundingBox &cambbox, int bGrowBox=false) const
bool GetFrustumCenter(double *) const
bool SetFrustumNearFar(double near_dist, double far_dist, double min_near_dist, double min_near_over_far, double target_dist, double relative_depth_bias)
bool GetClipCoordDepthBiasXform(double relative_depth_bias, ON_Xform &clip_bias) const
ON_UUID ViewportId(void) const
static const double DefaultMinNearOverFar
void SetCameraLocationLock(bool bLockCameraLocation)
bool Extents(double half_view_angle, const ON_3dPoint &center, double radius)
bool IsTwoPointPerspectiveProjection() const
bool GetFarRect(ON_3dPoint &left_bottom, ON_3dPoint &right_bottom, ON_3dPoint &left_top, ON_3dPoint &right_top) const
bool GetPointDepth(ON_3dPoint point, double *view_plane_depth) const
bool GetNearPlane(ON_Plane &near_plane) const
ON_3dVector m_CamDir
double PerspectiveMinNearOverFar() const
ON_BOOL32 Write(ON_BinaryArchive &) const
int Dimension() const
bool GetFrustumTopPlaneEquation(ON_PlaneEquation &top_plane_equation) const
ON::view_projection m_projection
ON_3dVector m_CamX
bool GetCameraAngle(double *half_diagonal_angle, double *half_vertical_angle, double *half_horizontal_angle) const
double FrustumWidth() const
double FrustumLeft() const
bool ChangeToPerspectiveProjection(double target_distance, bool bSymmetricFrustum, double lens_length)
double FrustumBottom() const
bool GetFrustumBottomPlaneEquation(ON_PlaneEquation &bottom_plane_equation) const
ON_3dVector CameraUp() const
ON_3dPoint m_CamLoc
unsigned char m_reserved1
double FrustumNear() const
static const double DefaultFarDist
ON_Viewport & operator=(const ON_Viewport &)
bool ChangeToTwoPointPerspectiveProjection(double target_distance, ON_3dVector up, double lens_length)
bool GetNearPlaneEquation(ON_PlaneEquation &near_plane_equation) const
bool IsValidCamera() const
bool SetFrustum(double left, double right, double bottom, double top, double near_dist, double far_dist)
ON_BOOL32 Transform(const ON_Xform &)
bool SetFrustumNearFar(const double *center, double radius)
ON_3dVector m_CamY
bool GetFrustumAspect(double &) const
ON_3dVector m_CamZ
bool GetViewPlaneEquation(double view_plane_depth, ON_PlaneEquation &view_plane_equation) const
bool GetPointDepth(ON_3dPoint point, double *near_dist, double *far_dist, bool bGrowNearFar=false) const
bool GetCamera35mmLensLength(double *lens_length) const
bool GetScreenPort(int *left, int *right, int *port_bottom, int *port_top, int *port_near=NULL, int *port_far=NULL) const
double FrustumHeight() const
static const double DefaultNearDist
bool GetFrustum(double *left, double *right, double *bottom, double *top, double *near_dist=NULL, double *far_dist=NULL) const
ON_3dVector CameraX() const
bool GetWorldToScreenScale(const ON_3dPoint &point_in_frustum, double *pixels_per_unit) const
bool SetCameraDirection(const ON_3dVector &)
bool GetFarPlane(ON_Plane &far_plane) const
ON_Xform ClipModXform() const
ON_3dVector CameraDirection() const
bool GetBoundingBoxDepth(ON_BoundingBox bbox, double *near_dist, double *far_dist, bool bGrowNearFar=false) const
bool CameraLocationIsLocked() const
double PerspectiveMinNearDist() const
bool SetScreenPort(int port_left, int port_right, int port_bottom, int port_top, int port_near=0, int port_far=0)
bool GetCoordinateSprite(int, int, int, int[3], double[3][2]) const
bool ChangeToSymmetricFrustum(bool bLeftRightSymmetric, bool bTopBottomSymmetric, double target_distance)
bool ZoomToScreenRect(int screen_x0, int screen_y0, int screen_x1, int screen_y1)
bool GetViewPlane(double view_plane_depth, ON_Plane &view_plane) const
bool SetViewportId(const ON_UUID &viewport_id)
bool GetFrustumLine(double screenx, double screeny, ON_Line &world_line) const
ON_3dVector CameraY() const
ON_BOOL32 GetBBox(double *, double *, ON_BOOL32=false) const
unsigned char m_frustum_symmetry_flags
bool GetFrustumRightPlaneEquation(ON_PlaneEquation &right_plane_equation) const
void Initialize()
bool IsParallelProjection() const
int ScreenPortWidth() const
bool SetViewScale(double x, double y)
void GetViewScale(double *x, double *y) const
ON_3dVector CameraZ() const
bool ChangeToParallelProjection(bool bSymmetricFrustum)
void UnlockCamera()
double ClipCoordDepthBias(double relative_depth_bias, double clip_z, double clip_w) const
bool GetDollyCameraVector(int screen_x0, int screen_y0, int screen_x1, int screen_y1, double proj_plane_dist, ON_3dVector &dolly_vector) const
bool SetFrustumAspect(double)
bool GetScreenPortAspect(double &) const
bool GetCameraExtents(ON_3dPoint &, double, ON_BoundingBox &cambox, int bGrowBox=false) const
bool GetNearRect(ON_3dPoint &left_bottom, ON_3dPoint &right_bottom, ON_3dPoint &left_top, ON_3dPoint &right_top) const
bool SetCamera35mmLenseLength(double lens_length)
bool GetCameraAngle(double *half_smallest_angle) const
ON_3dVector m_CamUp
void SetPerspectiveMinNearOverFar(double min_near_over_far)
bool IsValidFrustum() const
bool GetXform(ON::coordinate_system srcCS, ON::coordinate_system destCS, ON_Xform &matrix) const
double FrustumMaximumDiameter() const
bool GetCameraFrame(double *, double *, double *, double *) const
bool SetCameraLocation(const ON_3dPoint &)
bool SetFrustumNearFar(const double *bboxmin, const double *bboxmax)
bool SetCameraUp(const ON_3dVector &)
bool FrustumIsLeftRightSymmetric() const
bool GetFrustumLeftPlane(ON_Plane &left_plane) const
ON_BOOL32 Read(ON_BinaryArchive &)
bool DollyFrustum(double dolly_distance)
bool GetViewPlaneRect(double view_plane_depth, ON_3dPoint &left_bottom, ON_3dPoint &right_bottom, ON_3dPoint &left_top, ON_3dPoint &right_top) const
static const ON_3dVector Default3dCameraDirection
int ScreenPortHeight() const
bool GetFrustumTopPlane(ON_Plane &top_plane) const
bool IsPerspectiveProjection() const
void SetCameraUpLock(bool bLockCameraUp)
bool GetSphereDepth(ON_Sphere sphere, double *near_dist, double *far_dist, bool bGrowNearFar=false) const
double FrustumRight() const
bool ClipModXformIsIdentity() const
bool SetFrustumNearFar(double near_dist, double far_dist)
bool SetCamera35mmLensLength(double lens_length)
bool DollyCamera(const ON_3dVector &dolly_vector)
static const double DefaultMinNearDist
bool SetProjection(ON::view_projection projection)
bool SetFrustumNearFar(double near_dist, double far_dist, double min_near_dist, double min_near_over_far, double target_dist)
void SetFrustumLeftRightSymmetry(bool bForceLeftRightSymmetry)
bool GetFrustumRightPlane(ON_Plane &right_plane) const
bool FrustumIsTopBottomSymmetric() const
bool GetFrustumLeftPlaneEquation(ON_PlaneEquation &left_plane_equation) const
ON_3dPoint CameraLocation() const
bool SetTargetPoint(ON_3dPoint target_point)
bool Extents(double half_view_angle, const ON_BoundingBox &world_bbox)
void UnlockFrustumSymmetry()
bool CameraDirectionIsLocked() const
double FrustumMinimumDiameter() const
void SetCameraDirectionLock(bool bLockCameraDirection)
ON::view_projection Projection() const
void Dump(ON_TextLog &) const
bool GetFrustumBottomPlane(ON_Plane &bottom_plane) const
void ChangeViewportId(const ON_UUID &viewport_id)
void SetPerspectiveClippingPlaneConstraints(unsigned int depth_buffer_bit_depth)
bool GetCamera35mmLenseLength(double *lens_length) const
static void GetPerspectiveClippingPlaneConstraints(ON_3dPoint camera_location, unsigned int depth_buffer_bit_depth, double *min_near_dist, double *min_near_over_far)
ON_Xform ClipModInverseXform() const
ON_3dPoint TargetPoint() const
bool CameraUpIsLocked() const
bool GetFarPlaneEquation(ON_PlaneEquation &far_plane_equation) const
void SetPerspectiveMinNearDist(double min_near_dist)
double TargetDistance(bool bUseFrustumCenterFallback) const