public class SbViewVolume extends Inventor
The view volume used for rendering can be queried from an SoCamera
node using its getViewVolume() method.
See also:
SbVec3f
, SbVec2f
, SbBox3f
, SbMatrix
, SbRotation
, SoViewVolumeElement
Modifier and Type | Class and Description |
---|---|
static class |
SbViewVolume.Matrices |
static class |
SbViewVolume.ProjectionTypes
Projection type.
|
static class |
SbViewVolume.StereoModes
Stereo Modes.
|
Inventor.ConstructorCommand
Modifier and Type | Field and Description |
---|---|
static int |
LEFT_VIEW
Deprecated.
Use
SbViewVolume.StereoModes.LEFT_VIEW instead. |
static int |
MONOSCOPIC
Deprecated.
Use
SbViewVolume.StereoModes.MONOSCOPIC instead. |
static int |
ORTHOGRAPHIC
Deprecated.
Use
SbViewVolume.ProjectionTypes.ORTHOGRAPHIC instead. |
static int |
PERSPECTIVE
Deprecated.
Use
SbViewVolume.ProjectionTypes.PERSPECTIVE instead. |
static int |
RIGHT_VIEW
Deprecated.
Use
SbViewVolume.StereoModes.RIGHT_VIEW instead. |
VERBOSE_LEVEL, ZeroHandle
Constructor and Description |
---|
SbViewVolume()
Default constructor.
|
SbViewVolume(SbViewVolume copyFrom) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(SbViewVolume v,
float tolerance)
Equality comparison within given tolerance.
|
SbRotation |
getAlignRotation()
Calls getAlignRotation(false).
|
SbRotation |
getAlignRotation(boolean rightAngleOnly)
Returns a rotation that would align a viewed object so that its positive x-axis (of its object space) is to the right in the view and its positive y-axis is up.
|
float |
getBalanceAdjustment()
Queries the parallax balance.
|
SbMatrix |
getCameraSpaceMatrix()
Returns a matrix that transforms the view volume into camera space: it translates the view volume so the viewpoint is at the origin, and rotates it so the view direction is along the negative z axis.
|
float |
getDepth()
Returns depth of viewing frustum.
|
float |
getHeight()
Returns height of viewing frustum.
|
SbViewVolume.Matrices |
getMatrices()
Returns two matrices corresponding to the view volume.
|
SbMatrix |
getMatrix()
Like the method above, but returns the affine and projection parts together in one matrix (i.e., affine.multRight(proj) ).
|
float |
getNearDist()
Returns distance from projection point to near plane.
|
SbPlane |
getPlane(float distFromEye)
Returns a plane parallel to the near (or far) plane of the view volume at a given distance from the projection point (eye).
|
SbVec3f |
getPlanePoint(float distFromEye,
SbVec2f normPoint)
Maps a 2D point in normalized screen coordinates (0 <= x,y <= 1) to a 3D world coordinates point on the plane parallel to the near plane that is at
distFromEye units from the eye.
|
SbBox3f |
getProjectedBbox(SbBox3f box)
Projects the given 3D bounding box onto the near plane and returns it (in normalized screen coordinates).
|
SbBox3f |
getProjectedBbox(SbMatrix affineProj,
SbBox3f box)
Same as getProjectedBbox but takes a matrix (containing affine and projection parts) to use instead of the one returned by getMatrix.
|
SbVec3f |
getProjectionDirection()
Returns projection direction.
|
SbVec3f |
getProjectionPoint()
Returns projection point.
|
SbViewVolume.ProjectionTypes |
getProjectionType()
Returns projection type.
|
SbVec3f |
getSightPoint(float distFromEye)
Returns the point along the line of sight at the given distance from the projection point (eye).
|
float |
getStereoAdjustment()
Queries the stereo offset.
|
SbViewVolume.StereoModes |
getStereoMode()
Queries the stereo mode.
|
float |
getWidth()
Returns width of viewing frustum.
|
float |
getWorldToScreenScale(SbVec3f worldCenter,
float normRadius)
Returns a scale factor that would scale a unit sphere centered at worldCenter so that it would appear to have the given radius in normalized screen coordinates when projected onto the near plane.
|
boolean |
isBalanceNearFraction()
Returns true if the stereo balance adjustement is defined as a fraction of the camera near distance.
|
boolean |
isStereoAbsoluteAdjustments()
Returns true if the stereo adjustments are absolute.
|
SbViewVolume |
narrow(float left,
float bottom,
float right,
float top)
Given a view volume, narrows the view to the given sub-rectangle of the near plane.
|
SbViewVolume |
narrow(SbBox3f box)
Narrows a view volume by the given box.
|
void |
ortho(float left,
float right,
float bottom,
float top,
float nearPlane,
float farPlane)
Sets up an orthographic view volume with the given sides.
|
void |
perspective(float fovy,
float aspect,
float nearPlane,
float farPlane)
Sets up a perspective view volume with the given field of view and aspect ratio.
|
SbVec2f |
projectBox(SbBox3f box)
Projects the given 3D bounding box onto the near plane and returns the size (in normalized screen coordinates) of the rectangular region that encloses it.
|
SbVec3f |
projectFromScreen(SbVec3f src)
Maps a 3D point in normalized screen coordinates (0 <= x,y,z <= 1) to a 3D world point.
|
SbLine |
projectPointToLine(SbVec2f pt)
Maps a 2D point (in 0 <= x,y <= 1) to a 3D line.
|
SbVec3f |
projectToScreen(SbVec3f src)
Maps a 3D point in world coordinates to a 2D point in normalized screen coordinates (0 <= x,y,z <= 1).
|
void |
rotateCamera(SbRotation q)
Rotate the camera view direction.
|
void |
scale(float factor)
Scales width and height of view volume by given factor.
|
void |
scaleHeight(float ratio)
Scales view volume to be the given ratio of its current height, leaving the resulting view volume centered about the same point (in the near plane) as the current one.
|
void |
scaleWidth(float ratio)
Scales view volume to be the given ratio of its current width, leaving the resulting view volume centered about the same point (in the near plane) as the current one.
|
void |
setBalanceAdjustment(float adjustment)
Calls setBalanceAdjustment(adjustment, (boolean)false).
|
void |
setBalanceAdjustment(float adjustment,
boolean nearFrac)
Sets the stereo balance (the position of the zero parallax plane) and specifies whether the balance value is defined as a fraction of the camera near distance.
|
void |
setStereoAbsoluteAdjustments(boolean absolute)
Specifies if stereo adjustments are absolute.
|
void |
setStereoAdjustment(float adjustment)
Sets the stereo offset (the distance of each eye from the camera position).
|
void |
setStereoMode(SbViewVolume.StereoModes mode)
Sets the stereo mode.
|
void |
setValue(SbViewVolume copyFrom) |
static SbViewVolume[] |
toArray(long nativeArray,
long length) |
void |
translateCamera(SbVec3f v)
Translate the camera viewpoint.
|
SbViewVolume |
zNarrow(float nearPlane,
float farPlane)
Returns a narrowed view volume which contains as tightly as possible the given interval on the z axis (in eye space).
|
SbVec3f |
zVector()
Returns the positive z axis in eye space.
|
dispose, getAddress, getNativeResourceHandle, startInternalThreads, stopInternalThreads
@Deprecated public static final int ORTHOGRAPHIC
SbViewVolume.ProjectionTypes.ORTHOGRAPHIC
instead.@Deprecated public static final int PERSPECTIVE
SbViewVolume.ProjectionTypes.PERSPECTIVE
instead.@Deprecated public static final int MONOSCOPIC
SbViewVolume.StereoModes.MONOSCOPIC
instead.@Deprecated public static final int LEFT_VIEW
SbViewVolume.StereoModes.LEFT_VIEW
instead.@Deprecated public static final int RIGHT_VIEW
SbViewVolume.StereoModes.RIGHT_VIEW
instead.public SbViewVolume(SbViewVolume copyFrom)
public SbViewVolume()
public SbRotation getAlignRotation()
public void setBalanceAdjustment(float adjustment)
public boolean equals(SbViewVolume v, float tolerance)
public SbViewVolume.Matrices getMatrices()
Prior to release 2.6, the return value was a void, not a float.
public void setValue(SbViewVolume copyFrom)
public SbViewVolume narrow(float left, float bottom, float right, float top)
public static SbViewVolume[] toArray(long nativeArray, long length)
public SbViewVolume narrow(SbBox3f box)
public SbBox3f getProjectedBbox(SbMatrix affineProj, SbBox3f box)
public SbBox3f getProjectedBbox(SbBox3f box)
public SbPlane getPlane(float distFromEye)
public float getNearDist()
public SbVec3f zVector()
public SbVec3f getProjectionDirection()
public float getWorldToScreenScale(SbVec3f worldCenter, float normRadius)
public float getHeight()
public void translateCamera(SbVec3f v)
public float getWidth()
public SbVec3f projectFromScreen(SbVec3f src)
projectToScreen()
. See also getPlanePoint()
.
Note: This is a convenience function that calls the getMatrix()
method and apply inverse() on it, then transforms the point. The getMatrix()
and inverse() calls are somewhat expensive, so if you need to project a large number of points you should call the getMatrix()
and inverse() methods just once and apply the matrix to each point using SbMatrix.multVecMatrix()
.
public void scaleWidth(float ratio)
public SbVec3f getPlanePoint(float distFromEye, SbVec2f normPoint)
projectFromScreen()
.)public void scale(float factor)
public SbRotation getAlignRotation(boolean rightAngleOnly)
public void scaleHeight(float ratio)
public SbVec3f getSightPoint(float distFromEye)
public SbVec3f getProjectionPoint()
public SbViewVolume zNarrow(float nearPlane, float farPlane)
zVector()
: this means that near > far must hold.public SbViewVolume.ProjectionTypes getProjectionType()
public float getBalanceAdjustment()
public void perspective(float fovy, float aspect, float nearPlane, float farPlane)
public void setBalanceAdjustment(float adjustment, boolean nearFrac)
Default balance is 1.0. The default can be set using the OIV_STEREO_BALANCE environment variable. Default nearFrac is false. The default can be set using the OIV_STEREO_BALANCE_NEAR_FRAC environment variable.
public SbMatrix getCameraSpaceMatrix()
public boolean isBalanceNearFraction()
public void ortho(float left, float right, float bottom, float top, float nearPlane, float farPlane)
public SbViewVolume.StereoModes getStereoMode()
public SbMatrix getMatrix()
SbVec3f
(0.5f,0.5f,0.5f));public void setStereoMode(SbViewVolume.StereoModes mode)
public void setStereoAbsoluteAdjustments(boolean absolute)
The default non-absolute mode allows the stereo settings to be valid over a range of different view volume settings. If you chose absolute mode, you are responsible for modifying the stereo settings (if necessary) when the view volume changes.
When absolute mode is true, stereo offset and balance for the right eye view are used as in the following pseudo-code:
The left eye view is symmetric.StereoCameraOffset = getStereoAdjustment(); FrustumAsymmetry = getBalanceAdjustment(); glTranslated (-StereoCameraOffset, 0, 0); glFrustum (FrustumLeft + FrustumAsymmetry, FrustumRight + FrustumAsymmetry, FrustumBottom, FrustumTop, NearClipDistance, FarClipDistance);
When absolute mode is false, stereo offset and balance for the right eye view are used as in the following pseudo-code:
Xrange is right minus left (i.e., first two arguments of glFrustum) and multiply that difference by the ratio of the distance to the desired plane of zero parallax to the near clipping plane distance.
The left eye view is symmetric.StereoCameraOffset = Xrange * 0.035 * getStereoAdjustment(); FrustumAsymmetry = -StereoCameraOffset * getBalanceAdjustment(); ZeroParallaxDistance = (NearClipDistance + FarClipDistance)/0.5; FrustumAsymmetry *= NearClipDistance / ZeroParallaxDistance; glTranslated (-StereoCameraOffset, 0, 0); glFrustum (FrustumLeft + FrustumAsymmetry, FrustumRight + FrustumAsymmetry, FrustumBottom, FrustumTop, NearClipDistance, FarClipDistance);
public boolean isStereoAbsoluteAdjustments()
public float getDepth()
public SbVec3f projectToScreen(SbVec3f src)
NOTE: This is a convenience function that calls the getMatrix()
method, then transforms the point. The getMatrix()
call is somewhat expensive, so if you need to project a large number of points you should call the getMatrix()
method just once and apply the matrix to each point using SbMatrix.multVecMatrix()
.
However be aware that this matrix transforms world coordinates into normalized clip space, -1 to 1,
not directly to normalized screen coordinates, 0 to 1. To convert the result to normalized screen coordinates: dst.multiply(0.5f); dst.plus(new SbVec3f
(0.5f,0.5f,0.5f));
public void rotateCamera(SbRotation q)
public float getStereoAdjustment()
public SbVec2f projectBox(SbBox3f box)
public void setStereoAdjustment(float adjustment)
Generated on January 23, 2025, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com