1.5.2. SoVolumeRender

There is currently only one volume rendering primitive, the SoVolumeRender( C++ | Java | .NET ) node. A simple example using this node is shown below. The structure of the program is the same as the slice primitive example and is similar for all VolumeViz primitives. Note the example also uses the property node SoVolumeRenderingQuality( C++ | Java | .NET ) to set some commonly used values that are specific to volume rendering. This node will be discussed in the next sub-section.


C++
// Create nodes SoVolumeData* pVolData = new SoVolumeData;
pVolData->fileName = "$OIVHOME/src/VolumeViz/Data/3DHead.vol";

SoMaterial* pMaterial = new SoMaterial;
pMaterial->diffuseColor.setValue( 1, 1, 1 );

SoTransferFunction* pTF = new SoTransferFunction;
pTF->predefColorMap = SoTransferFunction::INTENSITY;

SoDataRange* pRange = new SoDataRange;

SoVolumeRenderingQuality* pVolQual = new SoVolumeRenderingQuality;
pVolQual->preIntegrated = TRUE;
pVolQual->lighting = TRUE;
pVolQual->lightingModel = SoVolumeRenderingQuality::OPENGL;
pVolQual->surfaceScalarExponent = 8;

SoVolumeRender *pVolRend = new SoVolumeRender;

// Build scene graph
SoSeparator* pRoot = new SoSeparator;
  SoSeparator* pVolSep = new SoSeparator;
  pVolSep ->addChild( pVolData );
  pVolSep ->addChild( pMaterial );
  pVolSep ->addChild( pTF );
  pVolSep ->addChild( pRange );
  pVolSep ->addChild( pVolQual );
  pVolSep ->addChild( pVolRend );
 pRoot->addChild( pVolSep );

.NET
// Create nodes
SoVolumeData VolData = new SoVolumeData();
VolData.fileName.Value = "$OIVHOME/src/VolumeViz/Data/3DHead.vol";

SoMaterial Material = new SoMaterial ();
Material.diffuseColor.SetValue( 1, 1, 1 );

SoTransferFunction TF = new SoTransferFunction();
TF.predefColorMap.Value = SoTransferFunction.PredefColorMaps.INTENSITY;

SoDataRange Range = new SoDataRange();

SoVolumeRenderingQuality VolQual = new SoVolumeRenderingQuality();
VolQual.preIntegrated.Value = true;
VolQual.lighting.Value = true;
VolQual.lightingModel.Value = SoVolumeRenderingQuality.LightingModels.OPENGL;
VolQual.surfaceScalarExponent.Value = 8;

SoVolumeRender VolRend = new SoVolumeRender();

// Build scene graph SoSeparator Root = new SoSeparator();
SoSeparator VolSep = new SoSeparator();
  VolSep.AddChild( VolData );
  VolSep.AddChild( Material );
  VolSep.AddChild( TF );
  VolSep.AddChild( Range );
  VolSep.AddChild( VolQual );
  VolSep.AddChild( VolRend );
 Root.AddChild( VolRend );

Java
// Create nodes
SoVolumeData volData = new SoVolumeData();
volData.fileName.setValue( "$OIVHOME/src/VolumeViz/Data/3DHead.vol" );

SoMaterial material = new SoMaterial ();
material.diffuseColor.setValue( 1, 1, 1 );

SoTransferFunction TF = new SoTransferFunction();
TF.predefColorMap.setValue( SoTransferFunction.PredefColorMaps.INTENSITY );

SoDataRange range = new SoDataRange();

SoVolumeRenderingQuality volQual = new SoVolumeRenderingQuality();
volQual.preIntegrated.setValue( true );
volQual.lighting.setValue( true );
volQual.lightingModel.setValue(SoVolumeRenderingQuality.LightingModels.OPENGL);
volQual.surfaceScalarExponent.setValue(8);

SoVolumeRender volRend = new SoVolumeRender();

// Build scene graph
SoSeparator root = new SoSeparator();
  SoSeparator volSep = new SoSeparator();
  volSep.addChild( volData );
  volSep.addChild( material );
  volSep.addChild( TF );
  volSep.addChild( range );
  volSep.addChild( volQual );
  volSep.addChild( volRend );
 root.addChild( volRend );