1.6.4. SoHeightFieldRender

SoHeightFieldRender SoHeightFieldRender SoHeightFieldRender 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 SoVolumeRender SoVolumeRender , but instead of an SoVolumeData SoVolumeData SoVolumeData node, you use an SoHeightFieldGeometry SoHeightFieldGeometry SoHeightFieldGeometry for the data set (height values) and one or more SoHeightFieldProperty SoHeightFieldProperty SoHeightFieldProperty nodes for property data sets. Generally it obeys the same rules regarding multiple data sets (see SoMultiDataSeparator SoMultiDataSeparator SoMultiDataSeparator ).

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 SoHeightFieldGeometry SoHeightFieldGeometry 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.

Height field 300,000 triangles

Figure 1.74. Height field 300,000 triangles



Height field 30,000 triangles

Figure 1.75. Height field 30,000 triangles



Code example:

/ 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;

// Limit triangles
SoLDMGlobalResourceParameters.setMaxNumTriangles( 30000 );

// 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( pVolSep );
// 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();

// Limit triangles
SoLDMGlobalResourceParameters.SetMaxNumTriangles( 30000 );

// 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( VolSep );
// 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();

// Limit triangles
SoLDMGlobalResourceParameters.setMaxNumTriangles( 30000 );

// 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( volSep );