Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
Orienting the volume

Once the volume has been loaded it may be necessary to change the orientation of the volume to match the application’s normal camera orientation or to be consistent with other geometry in the scene. For example if we loaded the sample volume “3DHead.ldm” instead of the “3DHead.vol”, the resulting image would look like this:

3DHead.ldm

As usual we have the choice of rotating the geometry in the scene, using a transform node, or rotating the camera to a different orientation. Which choice is better depends on the application, in particular on the orientation of other geometry that may be needed in the scene. In both cases we will apply a rotation of pi radians (180 degrees) around the Z axis. The following (standard Open Inventor) code will rotate the geometry:

C++ :

SoTransform* pTransform = new SoTransform;
pTransform->rotation = SbRotation( SbVec3f( 0, 0, 1 ), ( float )M_PI );
pRoot->addChild( pTransform );

C# :

SoTransform Transform = new SoTransform();
Transform.rotation.Value = new SbRotation( new SbVec3f( 0, 0, 1 ), ( float )Math.PI );
Root.AddChild( Transform );

Java :

SoTransform transform = new SoTransform();
Transform.rotation.setValue( new SbRotation( new SbVec3f( 0, 0, 1 ), ( float )Math.PI ) );
Root.AddChild( Transform );

The following code will rotate the camera:

C++ :

SoCamera* pCamera = pViewer->getCamera();
pCamera->orientation = SbRotation( SbVec3f( 0, 0, 1 ), ( float )M_PI );

C# :

SoCamera Camera = Viewer.GetCamera();
Camera.orientation.Value = new SbRotation( new SbVec3f( 0, 0, 1 ), ( float )Math.PI )

Java :

SoPerspectiveCamera camera = new SoPerspectiveCamera();
camera.orientation.setValue( new SbRotation( new SbVec3f( 0, 0, 1 ), ( float )Math.PI ) );

Resulting image:

“3DHead.ldm” rotated

Although the scaleFactor field of SoTransform can be used to resize the volume in 3D space, it is generally better to specify the 3D extent of the volume using the extent field of SoVolumeData.