1.6.4. SoHeightFieldRender

SoHeightFieldRender( C++ | Java | .NET ) displays a uniform grid in the XY plane whose vertices are height (Z) values stored in a volume data set with the Z dimension equal to 1. This node is used similar to SoVolumeRender( C++ | Java | .NET ), but instead of an SoVolumeData( C++ | Java | .NET ) node, you use an SoHeightFieldGeometry( C++ | Java | .NET ) for the data set (height values) and one or more SoHeightFieldProperty( C++ | Java | .NET ) nodes for property data sets. Generally it obeys the same rules regarding multiple data sets (see SoMultiDataSeparator( C++ | Java | .NET )).

Any grid vertices whose value is equal to the "undefined" value will be rendered as holes in the grid. The undefined value can be specified during the LDM conversion using the "-u" option to the LDM converter. Or by setting the undefinedValue field in the SoHeightFieldGeometry( C++ | Java | .NET ) node. The default value is NaN (Not a Number).

VolumeViz provides default shaders that conveniently color the surface using a single property, as shown in the images. However it is also possible to combine multiple properties using a custom shader program, in the same way that you would combine multiple volumes.

Use the static method isSupported() to test if height field rendering is supported on the current system. Most graphics board should work, but it does require support for floating point textures and vertex buffer objects (VBO).

In these images we can see that reducing the number of triangles by an order of magnitude only has a small effect on the appearance of the surface. In this example the height field contains some “undefined” values which are not rendered.



Code example:


C++
/ Create nodes
SoHeightFieldGeometry* pHFGeom = new SoHeightFieldGeometry;
pHFGeom->fileName = "$OIVHOME/src/VolumeViz/Data/horizon.ldm";
pHFGeom->dataSetId = 1;

SoHeightFieldProperty* pHFProp = new SoHeightFieldProperty;
pHFProp->fileName = "$OIVHOME/src/VolumeViz/Data/horizon.ldm";
pHFProp->dataSetId = 2;

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

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

SoHeightFieldRender *pHFRend = new SoHeightFieldRender;

// SoComplexity node is used to adjust tessellation level 
// of HeightFieldRender and simplify rendering.
SoComplexity* complexity = new SoComplexity;

// Build scene graph
SoSeparator* pRoot = new SoSeparator;
  SoMultiDataSeparator* pVolSep = new SoMultiDataSeparator;
  pVolSep ->addChild( pHFGeom );
  pVolSep ->addChild( pHFProp );
  pVolSep ->addChild( pMaterial );
  pVolSep ->addChild( pTF );
  pVolSep ->addChild( pHFRend );
pRoot->addChild(complexity);
pRoot->addChild( pVolSep );

.NET
// Create nodes
SoHeightFieldGeometry HFGeom = new SoHeightFieldGeometry ();
HFGeom.fileName.Value = "$OIVHOME/src/VolumeViz/Data/horizon.ldm";
HFGeom.dataSetId.Value = 1;

SoHeightFieldProperty HFProp = new SoHeightFieldProperty ();
HFProp.fileName.Value = "$OIVHOME/src/VolumeViz/Data/horizon.ldm";
HFProp.dataSetId.Value = 2;

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

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

SoHeightFieldRender HFRend = new SoHeightFieldRender();

// SoComplexity node is used to adjust tessellation level 
// of HeightFieldRender and simplify rendering.
SoComplexity complexity = new SoComplexity ();

// Build scene graph
SoSeparator Root = new SoSeparator();
  SoMultiDataSeparator VolSep = new SoMultiDataSeparator();
  VolSep.AddChild( HFGeom );
  VolSep.AddChild( HFProp );
  VolSep.AddChild( Material );
  VolSep.AddChild( TF );
  VolSep.AddChild( HFRend );
Root.AddChild( complexity );
Root.AddChild( VolSep );

Java
// Create nodes
SoHeightFieldGeometry HFGeom = new SoHeightFieldGeometry();
HFGeom.fileName.setValue( "$OIVHOME/src/VolumeViz/Data/horizon.ldm" );
HFGeom.dataSetId.setValue( 1 );

SoHeightFieldProperty HFProp = new SoHeightFieldProperty();
HFProp.fileName.setValue( "$OIVHOME/src/VolumeViz/Data/horizon.ldm" );
HFProp.dataSetId.setValue( 2 );

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

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

SoHeightFieldRender HFRend = new SoHeightFieldRender();

// SoComplexity node is used to adjust tessellation level 
// of HeightFieldRender and simplify rendering.
SoComplexity complexity = new SoComplexity();

// Build scene graph
SoSeparator root = new SoSeparator();
  SoMultiDataSeparator volSep = new SoMultiDataSeparator();
  volSep.addChild( HFGeom );
  volSep.addChild( HFProp );
  volSep.addChild( material );
  volSep.addChild( TF );
  volSep.addChild( HFRend );
root.addChild( complexity ); 
root.addChild( volSep );