ViewportInfo
Represents a viewing frustum.
Inheritance Hierarchy
System.Object
Rhino.Runtime.CommonObject
Rhino.DocObjects.ViewportInfo
Namespace: Rhino.DocObjects
Assembly: RhinoCommon (in RhinoCommon.dll)
Syntax
[SerializableAttribute]public sealed class ViewportInfo : CommonObject
The ViewportInfo type exposes the following members.
Constructors
Name
Description
Public Method
ViewportInfo.
Initializes a new instance.
Public Method
ViewportInfo(RhinoViewport)
Copies all of the ViewportInfo data from an existing RhinoViewport.
Public Method
ViewportInfo(ViewportInfo)
Initializes a new instance by copying values from another instance.
Properties
Name
Description
Public Property
Camera35mmLensLength
This property assumes the camera is horizontal and crop the film rather than the image when the aspect of the frustum is not 36/24. (35mm film is 36mm wide and 24mm high.) Setting preserves camera location, changes the frustum, but maintains the frustum’s aspect.
Public Property
CameraAngle
Gets or sets the 1/2 smallest angle. See
GetCameraAngles(Double., Double., Double.)
for more information.Public Property
CameraDirection
Gets the direction that the camera faces.
Public Property
CameraLocation
Gets the camera location (position) point.
Public Property
CameraUp
Gets the camera up vector.
Public Property
CameraX
Gets the unit “to the right” vector.
Public Property
CameraY
Gets the unit “up” vector.
Public Property
CameraZ
Gets the unit vector in -CameraDirection.
Public Property
Static Member
DefaultCameraDirection
Default z=up perspective camera direction
Public Property
Disposed
Indicates if this object has been disposed or the document it originally belonged to has been disposed.
(Inherited from CommonObject.)
Public Property
FrustumAspect
Setting FrustumAspect changes the larger of the frustum’s width/height so that the resulting value of width/height matches the requested aspect. The camera angle is not changed. If you change the shape of the view port with a call SetScreenPort(), then you generally want to call SetFrustumAspect() with the value returned by GetScreenPortAspect().
Public Property
FrustumBottom
Gets the frustum bottom value. This is -top if the frustum has a horizontal symmetry axis.
This number is usually negative.
Public Property
FrustumBottomPlane
Gets the frustum bottom plane that separates visible from off-screen.
Public Property
FrustumCenter
Gets the frustum center point.
Public Property
FrustumFar
Gets the frustum far-cutting value.
Public Property
FrustumFarPlane
Gets far clipping plane if camera and frustum are valid. The plane’s frame is the same as the camera’s frame. The origin is located at the intersection of the camera direction ray and the far clipping plane. The plane’s normal points into the frustum towards the camera location.
Public Property
FrustumHeight
Gets the frustum height. This is
FrustumTop
-FrustumBottom
.Public Property
FrustumLeft
Gets the frustum left value. This is -right if the frustum has a vertical symmetry axis.
This number is usually negative.
Public Property
FrustumLeftPlane
Gets the frustum left plane that separates visible from off-screen.
Public Property
FrustumMaximumDiameter
Gets the frustum maximum diameter, or the maximum between
FrustumWidth
andFrustumHeight
.Public Property
FrustumMinimumDiameter
Gets the frustum minimum diameter, or the minimum between
FrustumWidth
andFrustumHeight
.Public Property
FrustumNear
Gets the frustum near-cutting value.
Public Property
FrustumNearPlane
Gets near clipping plane if camera and frustum are valid. The plane’s frame is the same as the camera’s frame. The origin is located at the intersection of the camera direction ray and the near clipping plane. The plane’s normal points out of the frustum towards the camera location.
Public Property
FrustumRight
Gets the frustum right value. This is -left if the frustum has a vertical symmetry axis.
This number is usually positive.
Public Property
FrustumRightPlane
Gets the frustum right plane that separates visible from off-screen.
Public Property
FrustumTop
Gets the frustum top value. This is -bottom if the frustum has a horizontal symmetry axis.
This number is usually positive.
Public Property
FrustumTopPlane
Gets the frustum top plane that separates visible from off-screen.
Public Property
FrustumWidth
Gets the frustum width. This is
FrustumRight
-FrustumLeft
.Public Property
HasUserData
Gets true if this class has any custom information attached to it through UserData.
(Inherited from CommonObject.)
Public Property
Id
Sets the viewport’s id to the value used to uniquely identify this viewport. There is no approved way to change the viewport id once it is set in order to maintain consistency across multiple viewports and those routines that manage them.
Public Property
IsCameraDirectionLocked
Gets or sets a value that indicates whether the direction that the camera faces is unmodifiable.
Public Property
IsCameraLocationLocked
Gets or sets a value that indicates whether the camera location is unmodifiable.
Public Property
IsCameraUpLocked
Gets or sets a value that indicates whether the camera up vector is unmodifiable.
Public Property
IsDocumentControlled
If true this object may not be modified. Any properties or functions that attempt to modify this object when it is set to “IsReadOnly” will throw a NotSupportedException.
(Inherited from CommonObject.)
Public Property
IsFrustumLeftRightSymmetric
Gets or sets a value that indicates whether the camera frustum has a vertical symmetry axis.
Public Property
IsFrustumTopBottomSymmetric
Gets or sets a value that indicates whether the camera frustum has a horizontal symmetry axis.
Public Property
IsParallelProjection
Get or set whether this projection is parallel.
Public Property
IsPerspectiveProjection
Get or set whether this projection is perspective.
Public Property
IsTwoPointPerspectiveProjection
Gets a value that indicates whether this projection is a two-point perspective.
Public Property
IsValid
Tests an object to see if it is valid.
(Inherited from CommonObject.)
Public Property
IsValidCamera
Gets a value that indicates whether the camera is valid.
Public Property
IsValidFrustum
Gets a value that indicates whether the frustum is valid.
Public Property
PerspectiveMinNearDist
Expert user function to control the minimum value of near when perspective projections are being used.
Public Property
PerspectiveMinNearOverFar
Expert user function to control the minimum ratio of near/far when perspective projections are begin used.
Public Property
ScreenPort
Get or set the screen port.
SetScreenPort(Rectangle)
andPublic Property
ScreenPortAspect
Gets the screen aspect ratio.
This is width / height.
Public Property
TargetPoint
The current value of the target point. This point does not play a role in the view projection calculations. It can be used as a fixed point when changing the camera so the visible regions of the before and after frustums both contain the region of interest. The default constructor sets this point on ON_3dPoint::UnsetPoint. You must explicitly call one SetTargetPoint() functions to set the target point.
Public Property
UserData
List of custom information that is attached to this class.
(Inherited from CommonObject.)
Public Property
UserDictionary
Dictionary of custom information attached to this class. The dictionary is actually user data provided as an easy to use shareable set of information.
(Inherited from CommonObject.)
Public Property
ViewScale
Applies scaling factors to parallel projection clipping coordinates by setting the m_clip_mod transformation. If you want to compress the view projection across the viewing plane, then set x = 0.5, y = 1.0, and z = 1.0.
Methods
Name
Description
Public Method
Static Member
CalculateCameraRotationAngle
Calculates the camera rotation angle.
Public Method
Static Member
CalculateCameraUpDirection
Calculates the camera up direction.
Public Method
ChangeToParallelProjection
Use this function to change projections of valid viewports from parallel to perspective. It will make common additional adjustments to the frustum and camera location so the resulting views are similar. The camera direction and target point are not be changed. If the current projection is parallel and symmetricFrustum, FrustumIsLeftRightSymmetric() and FrustumIsTopBottomSymmetric() are all equal, then no changes are made and true is returned.
Public Method
ChangeToPerspectiveProjection
Use this function to change projections of valid viewports from parallel to perspective. It will make common additional adjustments to the frustum and camera location so the resulting views are similar. The camera direction and target point are not changed. If the current projection is perspective and symmetricFrustum, IsFrustumIsLeftRightSymmetric, and IsFrustumIsTopBottomSymmetric are all equal, then no changes are made and true is returned.
Public Method
ChangeToSymmetricFrustum
If needed, adjusts the current frustum so it has the specified symmetries and adjust the camera location so the target plane remains visible.
Public Method
ChangeToTwoPointPerspectiveProjection
Changes projections of valid viewports to a two point perspective. It will make common additional adjustments to the frustum and camera location and direction so the resulting views are similar. If the current projection is perspective and IsFrustumIsLeftRightSymmetric is true and IsFrustumIsTopBottomSymmetric is false, then no changes are made and true is returned.
Public Method
Dispose.
Actively reclaims unmanaged resources that this instance uses.
(Inherited from CommonObject.)
Public Method
DollyCamera
DollyCamera() does not update the frustum’s clipping planes. To update the frustum’s clipping planes call DollyFrustum(d) with d = dollyVector o cameraFrameZ. To convert screen locations into a dolly vector, use GetDollyCameraVector(). Does not update frustum. To update frustum use DollyFrustum(d) with d = dollyVector o cameraFrameZ.
Public Method
DollyExtents(BoundingBox, Double)
Dolly the camera location and so that the view frustum contains all of the document objects that can be seen in view. If the projection is perspective, the camera angle is not changed.
Public Method
DollyExtents(IEnumerable.GeometryBase., Double)
Dolly the camera location and so that the view frustum contains all of the document objects that can be seen in view. If the projection is perspective, the camera angle is not changed.
Public Method
DollyFrustum
Moves the frustum clipping planes.
Public Method
EnsurePrivateCopy
If you want to keep a copy of this class around by holding onto it in a variable after a command completes, call EnsurePrivateCopy to make sure that this class is not tied to the document. You can call this function as many times as you want.
(Inherited from CommonObject.)
Public Method
Equals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public Method
Extents(Double, BoundingBox)
Extends this viewport view to include a bounding box.
Use Extents() as a quick way to set a viewport to so that bounding volume is inside of a viewports frustum. The view angle is used to determine the position of the camera.
Public Method
Extents(Double, Sphere)
Extends this viewport view to include a sphere.
Use Extents() as a quick way to set a viewport to so that bounding volume is inside of a viewports frustum. The view angle is used to determine the position of the camera.
Public Method
FrustumCenterPoint
Return a point on the central axis of the view frustum. This point is a good choice for a general purpose target point.
Public Method
GetBoundingBoxDepth
Gets near and far clipping distances of a bounding box. This function ignores the current value of the viewport’s near and far settings. If the viewport is a perspective projection, the it intersects the semi infinite frustum volume with the bounding box and returns the near and far distances of the intersection. If the viewport is a parallel projection, it intersects the infinite view region with the bounding box and returns the near and far distances of the projection.
Public Method
GetCameraAngles
Gets the field of view angles.
Public Method
GetCameraFrame
Gets location and vectors of this camera.
Public Method
GetDollyCameraVector(Point, Point, Double)
Gets a world coordinate dolly vector that can be passed to DollyCamera().
Public Method
GetDollyCameraVector(Int32, Int32, Int32, Int32, Double)
Gets a world coordinate dolly vector that can be passed to DollyCamera().
Public Method
GetFarPlaneCorners
Gets the corners of far clipping plane rectangle. 4 points are returned in the order of bottom left, bottom right, top left, top right.
Public Method
GetFramePlaneCorners
Gets the corners of the frame plane rectangle at specified depth. 4 points are returned in the order of bottom left, bottom right, top left, top right.
Public Method
GetFrustum
Gets the view frustum.
Public Method
GetFrustumLine(Point)
Gets the world coordinate line in the view frustum that projects to a point on the screen.
Public Method
GetFrustumLine(PointF)
Gets the world coordinate line in the view frustum that projects to a point on the screen.
Public Method
GetFrustumLine(Double, Double)
Gets the world coordinate line in the view frustum that projects to a point on the screen.
Public Method
GetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public Method
GetNearPlaneCorners
Gets the corners of near clipping plane rectangle. 4 points are returned in the order of bottom left, bottom right, top left, top right.
Public Method
GetObjectData
Populates a System.Runtime.Serialization.SerializationInfo with the data needed to serialize the target object.
(Inherited from CommonObject.)
Public Method
GetPointDepth
Gets the clipping distance of a point. This function ignores the current value of the viewport’s near and far settings. If the viewport is a perspective projection, then it intersects the semi infinite frustum volume with the bounding box and returns the near and far distances of the intersection. If the viewport is a parallel projection, it intersects the infinite view region with the bounding box and returns the near and far distances of the projection.
Public Method
GetScreenPort.
Gets the location of viewport in pixels. See documentation for
SetScreenPort
.Public Method
GetScreenPort(Int32., Int32.)
Gets the location of viewport in pixels.
See value meanings in
SetScreenPort
.Public Method
GetScreenPortLocation
Get the location of viewport in pixels (non System.Drawing version of GetScreenPort)
Public Method
GetSphereDepth
Gets near and far clipping distances of a bounding sphere.
Public Method
GetType
Gets the Type of the current instance.
(Inherited from Object.)
Public Method
GetViewScale
Get scaling applied to this viewport projection. Reflected ceiling projections will return the values 1,1,-1
Public Method
GetWorldToScreenScale
Gets the scale factor from point in frustum to screen scale.
Public Method
GetXform
Computes a transform from a coordinate system to another.
Public Method
IsValidWithLog
Determines if an object is valid. Also provides a report on errors if this object happens not to be valid.
(Inherited from CommonObject.)
Public Method
RotateCamera
Rotates the view camera.
Public Method
SetCameraDirection
Sets the direction that the camera faces.
Public Method
SetCameraLocation
Sets the camera location (position) point.
Public Method
SetCameraUp
Sets the camera up vector.
Public Method
SetFrustum
Sets the view frustum. If FrustumSymmetryIsLocked() is true and left != -right or bottom != -top, then they will be adjusted so the resulting frustum is symmetric.
Public Method
SetFrustumNearFar(BoundingBox)
Sets the frustum near and far using a bounding box.
Public Method
SetFrustumNearFar(Double, Double)
Sets the frustum near and far distances using two values.
Public Method
SetFrustumNearFar(Point3d, Double)
Sets the frustum near and far using a center point and radius.
Public Method
SetFrustumNearFar(Double, Double, Double, Double, Double)
Sets near and far clipping distance subject to constraints.
Public Method
SetScreenPort(Rectangle)
Gets the location of viewport in pixels.
See value meanings in
SetScreenPort
.Public Method
SetScreenPort(Rectangle, Int32, Int32)
Gets the location of viewport in pixels.
See value meanings in
SetScreenPort
.Public Method
SetScreenPort(Int32, Int32, Int32, Int32, Int32, Int32)
Location of viewport in pixels. These are provided so you can set the port you are using and get the appropriate transformations to and from screen space. // For a Windows window / int width = width of window client area in pixels; / int height = height of window client area in pixels; / port_left = 0; / port_right = width; / port_top = 0; / port_bottom = height; / port_near = 0; / port_far = 1; / SetScreenPort( port_left, port_right, / port_bottom, port_top, / port_near, port_far );
Public Method
SetViewScale
Set scaling applied for this viewport projection. For reflected projections, call with values 1,1,-1
Public Method
TargetDistance
Gets the distance from the target point to the camera plane. Note that if the frustum is not symmetric, then this distance is shorter than the distance from the target to the camera location.
Public Method
ToJSON
Create a JSON string representation of this object
(Inherited from CommonObject.)
Public Method
ToString
Returns a string that represents the current object.
(Inherited from Object.)
Public Method
TransformCamera
Transforms the view camera location, direction, and up.
Public Method
UnlockCamera
Unlocks the camera vectors and location.
Public Method
UnlockFrustumSymmetry
Unlocks frustum horizontal and vertical symmetries.
Public Method
ZoomToScreenRect(Rectangle)
Zooms to a screen zone.
View changing from screen input points. Handy for using a mouse to manipulate a view. ZoomToScreenRect() may change camera and frustum settings.
Public Method
ZoomToScreenRect(Int32, Int32, Int32, Int32)
Zooms to a screen zone.
View changing from screen input points. Handy for using a mouse to manipulate a view. ZoomToScreenRect() may change camera and frustum settings.