public abstract class SoCamera extends SoNode
You can also use a node kit to create a camera; see the reference page for SoCameraKit
.
Useful algorithms for manipulating a camera are provided in the SoCameraInteractor
class.
Compute the current view vector or up vector.
Compute the current focal point.SoCamera camera . . . SbRotation orientation = camera.orientation.getValue(); SbVec3f upVec = orientation.multVec( new SbVec3f(0,1,0) ); SbVec3f vwVec = orientation.multVec( new SbVec3f(0,0,-1) );
See also:SbRotation orientation = camera.orientation.getValue(); SbVec3f offset = orientation.multVec( new SbVec3f(0,0,-1) ); offset.multiply( camera.focalDistance.getValue() ); SbVec3f focalPt = camera.position.getValue().plus( offset );
SoOrthographicCamera
, SoPerspectiveCamera
, SoCameraKit
, SoCameraInteractor
Modifier and Type | Class and Description |
---|---|
static class |
SoCamera.StereoModes
Stereo mode
|
static class |
SoCamera.ViewportMappings
Viewport mapping.
|
SoNode.RenderModes
Inventor.ConstructorCommand
Modifier and Type | Field and Description |
---|---|
SoSFFloat |
aspectRatio
The ratio of camera viewing width to height.
|
SoSFFloat |
farDistance
The distance from the camera viewpoint to the far clipping plane.
|
SoSFFloat |
focalDistance
The distance from the viewpoint to the point of focus.
|
SoSFFloat |
nearDistance
The distance from the camera viewpoint to the near clipping plane.
|
SoSFRotation |
orientation
The orientation of the camera viewpoint, defined as a rotation of the viewing direction from its default (0,0,-1) vector.
|
SoSFVec3f |
position
The location of the camera viewpoint.
|
SoSFEnum<SoCamera.ViewportMappings> |
viewportMapping
Defines how to map the rendered image into the current viewport, when the aspect ratio of the camera differs from that of the viewport.
|
VERBOSE_LEVEL, ZeroHandle
Modifier and Type | Method and Description |
---|---|
void |
allowStereo(boolean name_9106)
Deprecated.
As of Open Inventor 9700 Use SoStereoCamera instead.
|
float |
getBalanceAdjustment()
Deprecated.
As of Open Inventor 9700 Use SoStereoCamera and balance field instead.
|
boolean |
getStereoAbsoluteAdjustment()
Deprecated.
As of Open Inventor 9700 Use SoStereoCamera and absoluteAdjustments field instead.
|
float |
getStereoAdjustment()
Deprecated.
As of Open Inventor 9700 Use SoStereoCamera and offset field instead.
|
SoCamera.StereoModes |
getStereoMode()
Queries the stereo mode.
|
SbViewportRegion |
getViewportBounds(SbViewportRegion region)
Returns the viewport region this camera would use to render into the given viewport region, accounting for cropping.
|
SbViewVolume |
getViewVolume()
Calls getViewVolume((float)0.0).
|
SbViewVolume |
getViewVolume(float useAspectRatio)
Returns a view volume object, based on the camera's viewing parameters.
|
SbViewVolume |
getViewVolume(float aspectRatio,
float nearDist,
float farDist,
SbVec3f position,
SbRotation rotation)
Computes a view volume from the given parameters.
|
boolean |
isBalanceAdjustmentNearFrac()
Deprecated.
As of Open Inventor 9700 Use SoStereoCamera and balanceNearFrac field instead.
|
void |
pointAt(SbVec3f targetPoint)
Sets the orientation of the camera so that it points toward the given target point while keeping the "up" direction of the camera parallel to the positive y-axis.
|
void |
scaleHeight(float scaleFactor)
Scales the height of the camera.
|
void |
setBalanceAdjustment(float adjustment)
Deprecated.
|
void |
setBalanceAdjustment(float adjustment,
boolean nearFrac)
Deprecated.
As of Open Inventor 9700 Use SoStereoCamera and balance / balanceNearFrac fields instead.
|
void |
setStereoAbsoluteAdjustments(boolean absolute)
Deprecated.
As of Open Inventor 9700 Use SoStereoCamera and absoluteAdjustments field instead.
|
void |
setStereoAdjustment(float adjustment)
Deprecated.
As of Open Inventor 9700 Use SoStereoCamera and offset field instead.
|
void |
setStereoMode(SoCamera.StereoModes mode)
Sets the stereo mode.
|
void |
viewAll(SbBox3f bbox,
SbViewportRegion vpRegion)
Sets the camera to view the region defined by the given bounding box.
|
void |
viewAll(SoNode sceneRoot,
SbViewportRegion vpRegion)
Calls viewAll(sceneRoot, vpRegion, (float)1.0).
|
void |
viewAll(SoNode sceneRoot,
SbViewportRegion vpRegion,
float slack)
Sets the camera to view the scene rooted by the given node.
|
void |
viewAll(SoPath path,
SbViewportRegion vpRegion)
Calls viewAll(path, vpRegion, (float)1.0).
|
void |
viewAll(SoPath path,
SbViewportRegion vpRegion,
float slack)
Sets the camera to view the scene defined by the given path.
|
affectsState, callback, copy, copy, distribute, doAction, getAlternateRep, getBoundingBox, getByName, getMatrix, getPrimitiveCount, getRenderEngineMode, getRenderUnitID, GLRender, GLRenderBelowPath, GLRenderInPath, GLRenderOffPath, grabEventsCleanup, grabEventsSetup, handleEvent, isBoundingBoxIgnoring, isOverride, pick, rayPick, search, setOverride, touch, write
copyFieldValues, copyFieldValues, enableNotify, fieldsAreEqual, get, getAllFields, getEventIn, getEventOut, getField, getFieldName, hasDefaultValues, isNotifyEnabled, set, setToDefaults
dispose, getName, isDisposable, isSynchronizable, setName, setSynchronizable
getNativeResourceHandle
public final SoSFEnum<SoCamera.ViewportMappings> viewportMapping
public final SoSFVec3f position
public final SoSFRotation orientation
public final SoSFFloat aspectRatio
public final SoSFFloat nearDistance
public final SoSFFloat farDistance
public final SoSFFloat focalDistance
public void viewAll(SoPath path, SbViewportRegion vpRegion)
public void viewAll(SoNode sceneRoot, SbViewportRegion vpRegion)
public SbViewVolume getViewVolume()
@Deprecated public void setBalanceAdjustment(float adjustment)
public SbViewVolume getViewVolume(float aspectRatio, float nearDist, float farDist, SbVec3f position, SbRotation rotation)
public void viewAll(SoNode sceneRoot, SbViewportRegion vpRegion, float slack)
The node applies an SoGetBoundingBoxAction
to the scene graph to get the bounding box of the entire scene. The bounding box will only include shapes that are actually traversed. For example the bounding box will not include shapes under an SoSwitch
with whichChild set to SO_SWITCH_NONE. The action does not consider the visibility of shapes that are traversed. In other words the bounding box will include shapes that are invisible (SoDrawStyle
), shapes that are clipped (SoClipPlane
), etc. Use an SoBBox
node to exclude shapes from the bounding box computation. Bounding boxes are automatically cached at SoSeparator
nodes, so getting the bounding box is very fast when the scene graph has not been changed.
public void viewAll(SoPath path, SbViewportRegion vpRegion, float slack)
See note about bounding boxes in the sceneRoot version of this method.
public SbViewVolume getViewVolume(float useAspectRatio)
If the useAspectRatio parameter is 0.0 (the default), the camera uses the current value of the aspectRatio
field to compute the view volume.
NOTE: In ADJUST_CAMERA mode (the default), the view volume returned when useAspectRatio = 0, is not (in general) the actual view volume used for rendering. Using this view volume to project points will not (in general) produce the correct results.
This is because, in ADJUST_CAMERA mode, Inventor automatically modifies the view volume to match the aspect ratio of the current viewport. This avoids the distortion that would be caused by "stretching" the view volume when it is mapped into the viewport. However the view volume values are not changed, only the values passed to OpenGL. In order to get the modified values (i.e., the actual view volume used for rendering) you must pass the actual viewport aspect ratio to getViewVolume. You can get the current viewport from the renderArea or viewer object that contains the Open Inventor window.
Also note that in ADJUST_CAMERA mode, when the viewport aspect ratio is less than 1, Open Inventor automatically scales the actual rendering view volume by the inverse of the aspect ratio (i.e. 1/aspect). The getViewVolume method does not automatically apply this adjustment. So a correct query of the actual rendering view volume can be done like this:
// Given a viewer object, get the actual rendering view volume SoCamera camera = viewer.getArea().getCamera(); float aspect = viewer.getArea().getViewportRegion().getViewportAspectRatio(); SbViewVolume viewVol = camera.getViewVolume( aspect ); if (aspect < 1) viewVol.scale( 1 / aspect );
@Deprecated public void allowStereo(boolean name_9106)
SoStereoCamera
instead. public void pointAt(SbVec3f targetPoint)
public void scaleHeight(float scaleFactor)
@Deprecated public float getBalanceAdjustment()
SoStereoCamera
and balance field instead. @Deprecated 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.Deprecated since Open Inventor 9700.
Use SoStereoCamera
and balance / balanceNearFrac fields instead.
@Deprecated public boolean isBalanceAdjustmentNearFrac()
SoStereoCamera
and balanceNearFrac field instead. public SoCamera.StereoModes getStereoMode()
public void setStereoMode(SoCamera.StereoModes mode)
@Deprecated public boolean getStereoAbsoluteAdjustment()
SoStereoCamera
and absoluteAdjustments field instead. public SbViewportRegion getViewportBounds(SbViewportRegion region)
public void viewAll(SbBox3f bbox, SbViewportRegion vpRegion)
See note about bounding boxes in the sceneRoot version of this method.
@Deprecated public void setStereoAdjustment(float adjustment)
SoStereoCamera
and offset field instead. @Deprecated 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 are used as shown in the following pseudo-code for the right eye view:
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 are used as shown in the following pseudo-code for the right eye view:
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);
Not virtual pure for compatiblity reasons.Deprecated since Open Inventor 9700.
Use SoStereoCamera
and absoluteAdjustments field instead.
@Deprecated public float getStereoAdjustment()
SoStereoCamera
and offset field instead. Generated on July 31, 2019, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com