Click or drag to resize
SoCameraGetViewVolume Method (Single)

Returns a view volume object, based on the camera's viewing parameters.

Namespace: OIV.Inventor.Nodes
Assembly: OIV.Inventor (in OIV.Inventor.dll) Version: 10.12.3.0 (10.12.3.0)
Syntax
public abstract SbViewVolume GetViewVolume(
	float useAspectRatio
)

Parameters

useAspectRatio
Type: SystemSingle

Return Value

Type: SbViewVolume
Remarks

This object can be used, for example, to get the view and projection matrices, to project 2D screen coordinates into 3D space and to project 3D coordinates into screen space.

If the useAspectRatio parameter is 0.0 (the default), the camera uses the current value of the OIV.Inventor.Nodes.SoCamera.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:

float    aspect = viewer.GetViewportRegion().ViewportAspectRatio;
SoCamera camera = viewer.GetCamera();
SbViewVolume viewVol = camera.GetViewVolume( aspect );
if (aspect < 1)
 viewVol.Scale( 1 / aspect );

See Also