ViewportInfo

class rhino3dm.ViewportInfo
ViewportInfo()

ViewportInfo constructor

IsValidCameraFrame
isValidCamer
IsValidFrustum

bool: Gets a value that indicates whether the frustum is valid.

IsParallelProjection

bool: Get or set whether this projection is parallel.

IsPerspectiveProjection

bool: Get or set whether this projection is perspective.

IsTwoPointPerspectiveProjection

bool: Gets a value that indicates whether this projection is a two-point perspective.

CameraLocation

rhino3dm.Point3d: Gets the camera location (position) point.

CameraDirection

rhino3dm.Vector3d: Gets the direction that the camera faces.

CameraUp

rhino3dm.Vector3d: Gets the camera up vector.

CameraX

rhino3dm.Vector3d: Gets the unit “to the right” vector.

CameraY

rhino3dm.Vector3d: Gets the unit “up” vector.

CameraZ

rhino3dm.Vector3d: Gets the unit vector in -CameraDirection.

ScreenPortAspect

float: Gets the screen aspect ratio. This is width / height.

CameraAngle

float: Gets or sets the 1/2 smallest angle. See for more information.

Camera35mmLensLength

float: 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.

Id

Guid: 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.

static DefaultTop()

[todo] add documentation

static DefaultPerspective()

[todo] add documentation

ChangeToParallelProjection(symmetricFrustum)

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.

Parameters:symmetricFrustum (bool) – True if you want the resulting frustum to be symmetric.
Returns:True if the operation succeeded; otherwise, false.
Return type:bool
ChangeToPerspectiveProjection(targetDistance, symmetricFrustum, lensLength)

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.

Parameters:
  • targetDistance (float) – If RhinoMath.UnsetValue this parameter is ignored. Otherwise it must be > 0 and indicates which plane in the current view frustum should be preserved.
  • symmetricFrustum (bool) – True if you want the resulting frustum to be symmetric.
  • lensLength (float) – (pass 50.0 when in doubt) 35 mm lens length to use when changing from parallel to perspective projections. If the current projection is perspective or lens_length is <= 0.0, then this parameter is ignored.
Returns:

True if the operation succeeded; otherwise, false.

Return type:

bool

ChangeToTwoPointPerspectiveProjection(targetDistance, up, lensLength)

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.

Parameters:
  • targetDistance (float) – If RhinoMath.UnsetValue this parameter is ignored. Otherwise it must be > 0 and indicates which plane in the current view frustum should be preserved.
  • up (rhino3dm.Vector3d) – The locked up direction. Pass Vector3d.Zero if you want to use the world axis direction that is closest to the current up direction. Pass CameraY() if you want to preserve the current up direction.
  • lensLength (float) – (pass 50.0 when in doubt) 35 mm lens length to use when changing from parallel to perspective projections. If the current projection is perspective or lens_length is <= 0.0, then this parameter is ignored.
Returns:

True if the operation succeeded; otherwise, false.

Return type:

bool

SetCameraLocation(location)

Sets the camera location (position) point.

Returns:True if the operation succeeded; otherwise, false.
Return type:bool
SetCameraDirection(direction)

Sets the direction that the camera faces.

Parameters:direction (rhino3dm.Vector3d) – A new direction.
Returns:True if the direction was set; otherwise false.
Return type:bool
SetCameraUp(up)

Sets the camera up vector.

Parameters:up (rhino3dm.Vector3d) – A new direction.
Returns:True if the direction was set; otherwise false.
Return type:bool
SetFrustum(left, right, bottom, top, near, far)

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.

Parameters:
  • left (float) – A new left value.
  • right (float) – A new right value.
  • bottom (float) – A new bottom value.
  • top (float) – A new top value.
  • nearDistance (float) – A new near distance value.
  • farDistance (float) – A new far distance value.
Returns:

True if operation succeeded; otherwise, false.

Return type:

bool

GetFrustum()

[todo] add documentation

SetScreenPort()

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 );

Parameters:
  • left (int) – A left value.
  • right (int) – A left value. (port_left != port_right)
  • bottom (int) – A bottom value.
  • top (int) – A top value. (port_top != port_bottom)
  • near (int) – A near value.
  • far (int) – A far value.
Returns:

True if input is valid.

Return type:

bool

GetScreenPort()

Gets the location of viewport in pixels. See documentation for SetScreenPort.

Returns:The rectangle, or Empty rectangle on error.
Return type:System.Drawing.Rectangle
GetXform(sourceCoordinateSystem, destinationCoordinateSystem)

Computes a transform from a coordinate system to another.

Parameters:
  • sourceSystem (CoordinateSystem) – The coordinate system to map from.
  • destinationSystem (CoordinateSystem) – The coordinate system to map into.
Returns:

The 4x4 transformation matrix (acts on the left).

Return type:

Transform

Extents(halfViewAngleRadians, worldBbox)

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.

Parameters:
  • halfViewAngleRadians (float) – 1/2 smallest subtended view angle in radians.
  • bbox (rhino3dm.BoundingBox) – A bounding box in 3d world coordinates.
Returns:

True if the operation succeeded; otherwise, false.

Return type:

bool

DollyExtents(bbox, border)

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.

Returns:True if successful.
Return type:bool
FrustumCenterPoint(targetDistance)

Return a point on the central axis of the view frustum. This point is a good choice for a general purpose target point.

Parameters:targetDistance (float) – If targetDistance > 0.0, then the distance from the returned point to the camera plane will be targetDistance. Note that if the frustum is not symmetric, the distance from the returned point to the camera location will be larger than targetDistance. If targetDistance == ON_UNSET_VALUE and the frustum is valid with near > 0.0, then 0.5*(near + far) will be used as the targetDistance.
Returns:A point on the frustum’s central axis. If the viewport or input is not valid, then ON_3dPoint::UnsetPoint is returned.
Return type:rhino3dm.Point3d
TargetDistance(useFrustumCenterFallback)

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.

Parameters:useFrustumCenterFallback (bool) – If bUseFrustumCenterFallback is False and the target point is not valid, then ON_UNSET_VALUE is returned. If bUseFrustumCenterFallback is True and the frustum is valid and current target point is not valid or is behind the camera, then 0.5*(near + far) is returned.
Returns:Shortest signed distance from camera plane to target point. If the target point is on the visible side of the camera, a positive value is returned. ON_UNSET_VALUE is returned when the input of view is not valid.
Return type:float