Class SoHeightFieldRender
- java.lang.Object
 - 
- com.openinventor.inventor.Inventor
 - 
- com.openinventor.inventor.misc.SoBase
 - 
- com.openinventor.inventor.fields.SoFieldContainer
 - 
- com.openinventor.inventor.nodes.SoNode
 - 
- com.openinventor.inventor.nodes.SoShape
 - 
- com.openinventor.ldm.nodes.SoLdmShape
 - 
- com.openinventor.volumeviz.nodes.SoVolumeShape
 - 
- com.openinventor.volumeviz.nodes.SoSlice
 - 
- com.openinventor.volumeviz.nodes.SoHeightFieldRender
 
 
 
 
 
 
 
 
 
 
- 
- All Implemented Interfaces:
 SafeDisposable
public class SoHeightFieldRender extends SoSlice
Heightfield rendering node.SoHeightFieldRenderdisplays a uniform grid in the XY plane whose vertices are height (Z) values stored in 2D LDM format (any LDM data set with the Z dimension equal to 1). Adding the combination of LDM data management with advanced GPU features provides a way to handle extremely large surfaces. Just as with volume data, LDM uses tiles of data and multiple levels of resolution to enable interactive frame rates even for data sets that cannot fit in system memory.This node is used similarly to other VolumeViz shapes, but instead of an
SoVolumeDatanode, you use anSoHeightFieldGeometryfor the data set (height values) and optionally one or moreSoHeightFieldPropertynodes for property data sets. When one or moreSoHeightFieldPropertynodes are used, because there are multiple data nodes, they must be children of anSoMultiDataSeparatornode and the rules for multiple data sets apply (seeSoVolumeDatathe parent class ofSoHeightFieldGeometry). Otherwise, if noSoHeightFieldPropertynodes are used and only anSoHeightFieldGeometrynode is present, the following rules apply:- If an 
SoTransferFunctionnode is on the state, then theSoHeightFieldGeometrynode is also used as a property node and the height field is colored according to the height values and the transfer function, just as if anSoHeightFieldPropertynode was defined with the same data. - If no 
SoTransferFunctionnode is on the state, then the height field is colored using the current material on state. 
Note that
SoHeightFieldRenderis derived fromSoSliceand those inherited fields affect the rendering. In particular note that the alphaUse field applies to height field rendering and the default value (since Open Inventor 10.0) is ALPHA_OPAQUE. It means, for example, that the transparency in the color map will not affect rendering of the height map unless alphaUse is set to ALPHA_AS_IS.Data set values are converted to height values in 3D space in two ways depending on the data type:
- Integer values are normalized between [0,1] ([-1,1] for signed types) based on the range of values for the specific data type. For example, for UNSIGNED BYTE values the range 0..255 is mapped to 0..1.
 - Floating point values are not normalized (are used "as is").
 
Any height value in the
SoHeightFieldGeometrydata set that is equal to the "undefined" value will be rendered as a hole in the mesh. The undefined value can be specified during the LDM conversion using the "-u" option to the LDM converter:
Or by setting the undefinedValue field of theconvert -u 127 -b 1 inputFile.lst SoHeightFieldGeometrynode. The default value is NaN (Not a Number).An
SoHeightFieldPropertyMasknode can also be used to specify undefined cells in the mesh. An undefined cell effectively removes the four corresponding height values from the mesh. (SoVolumeMaskdoes not apply to height field rendering.)
A lighted heightfield 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.
The field
cellOutlineenables drawing the edges of the mesh cells. BoundaryCells are cells close to an undefined value. If theboundaryCellsfield is set to ALWAYS, these cells must always be considered at all resolution levels to avoid artifacts. In SMART mode, the default, we don't take this into account for distant views.Normally this node uses the OpenGL tessellation shader extension to speed up rendering and automatically adjust the number of generated triangles depending on the camera position and orientation. In this mode, to change the number of generated triangles, use an
SoComplexitynode. A value of 1 means a full tessellation with a maximum of 4 triangles per pixel and a value of 0.5 means a maximum of 1 triangle per pixel.If tessellation shaders are not available, a value of 1 means full resolution data is used to generate triangles (a grid of 10x10 will then generate 10x10 x2 triangles). A value of 0 means the lower resolution will be used.
To check if tessellation shaders are supported, use the method isAvailable( "GL_ARB_tessellation_shader" ) of
SoGLExtensionclassWhen no
SoHeightFieldPropertynodes are used and only anSoHeightFieldGeometrynode is defined, the standard VolumeViz rules apply to the creation of a scene graph usingSoHeightFieldRender. A minimal scene graph displaying a height field in this case is:EXAMPLE // Create nodes SoHeightFieldGeometry HFGeom = new SoHeightFieldGeometry(); HFGeom.fileName.setValue( "$OIVHOME/examples/data/VolumeViz/horizon.ldm" ); 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 (optional) SoComplexity complexity = new SoComplexity(); complexity.value.setValue( 0.25 ); // Build scene graph SoSeparator volSep = new SoSeparator(); volSep.addChild( HFGeom ); volSep.addChild( material ); volSep.addChild( complexity ); volSep.addChild( TF ); volSep.addChild( HFRend ); root.addChild( volSep ); When one or more
SoHeightFieldPropertynodes are used, multidata rules apply to the creation of a scene graph usingSoHeightFieldRenderand anSoMultiDataSeparatornode must be used instead ofSoSeparator. A minimal scene graph displaying a heightfield in this case is:EXAMPLE // Create nodes SoHeightFieldGeometry HFGeom = new SoHeightFieldGeometry(); HFGeom.fileName.setValue( "$OIVHOME/examples/data/VolumeViz/horizon.ldm" ); HFGeom.dataSetId.setValue( 1 ); SoHeightFieldProperty HFProp = new SoHeightFieldProperty(); HFProp.fileName.setValue( "$OIVHOME/examples/data/VolumeViz/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 (optional) SoComplexity complexity = new SoComplexity(); complexity.value.setValue( 0.25 ); // Build scene graph SoMultiDataSeparator volSep = new SoMultiDataSeparator(); volSep.addChild( HFGeom ); volSep.addChild( HFProp ); volSep.addChild( material ); volSep.addChild( complexity ); volSep.addChild( TF ); volSep.addChild( HFRend ); root.addChild( volSep ); Shaders
When used with an
SoVolumeShader, a new shader function is available to compute lighting:- vec4 VVizComputeFrontColor(vec3 normal, vec4 color)): Add lighting to the color col.
 
The following shader code will light a heightfield:
Multiple Data://!oiv_include <VolumeViz/vvizCoordinates_frag.h> //!oiv_include <VolumeViz/vvizfnc_frag.h> //!oiv_include <VolumeViz/vvizCombine_frag.h> //!oiv_include <VolumeViz/vvizComputeFragmentColor_frag.h> //!oiv_include <VolumeViz/vvizOutputColor_frag.h> vec4 VVizComputeFrontColor(vec3 n, vec4 col); void main() { vec3 tCoord0 = VVizComputeCoordinates(OivFragmentTexCoord(0).xyz); vec3 normal = normalize(VVizComputeNormal(texCoord)); float sf = VVizCombineData(tCoord0); vec4 col = VVizComputeFragmentColor(vox, texCoord); col = VVizComputeFrontColor(normal, col); VVizOutputColor(col); } Using an
SoMultiDataSeparator, it is possible to combine datasets that have different dimensions or tile sizes. For instance, anSoHeightFieldGeometrydataset can be used with anSoHeightFieldPropertyeven if they don't have the same dimensions or tile sizes.Composition with VolumeData:
It is possible to color a height field according to the values of a volume data. To do such rendering, the HeightField datasets and the
SoVolumeDatanodes must be in the sameSoMultiDataSeparator. A custom shader must also be defined to fetch values from the right datasets using their dataSetId. This is demonstrated in the HorizonInVolume example.In addition, texture coordinates conversion functions are provided in the VolumeViz/vvizStructure.h shader include in order to help fetch the correct VolumeData values in custom shaders.
For instance,
can be used to convert texture coordinates related to one dataset to texture coordinates related to another dataset.vec3 VVizTextureToTextureVec(in VVizDataSetId datasetSrc, in VVizDataSetId datasetDst, in vec3 texCoord); 
The conversion is based solely on the transformations applied to each dataset, which are defined by their model matrix and their extent.
Please note that the model matrix of a dataset is defined by theSoTransformationnodes that are placed before theSoDataSetnode in the order of the traversal.Picking:
Similar to other geometry,
SoPickedPointcan return anSoDetailobject specific to theSoHeightFieldRendernode. The specific class isSoHeightFieldDetail.Only GPU picking is supported. This means that the
SoRayPickActionused for picking must have its scene manager initialized using the methodSoAction.setSceneManager().SoHandleEventActiondoes this automatically, so it is not necessary for the application to take any action when using (for example) anSoEventCallbacknode and calling the getPickedPoint() method. However if the application creates its ownSoRayPickActionthen it must set the scene manager. If no scene manager is specified, a warning message is issued.Limitations:
- At least one 
SoHeightFieldPropertywhich defines a property data set associated with the grid must be in the state. - If an 
SoROIis in the state,SoHeightFieldRenderrenders only one box of the ROI (ie: correct rendering only ifSoROI's flag field is set to SUB_VOLUME) - Only 
SoHeightFieldGeometrydata sets with a depth of 1 (Z dimension = 1) can be rendered. - The 
SoHeightFieldPropertyandSoHeightFieldPropertyMaskdata sets must have exactly the same dimensions as theSoHeightFieldGeometry. - Triangle orientation after GPU tessellation cannot be controlled. Undefined value rendering is indeterministic.
 
 - For low resolution, undefined values can be taken into account in the property but not in the geometry. In such cases, coloring artifacts can appear.
 
 - Lighting is limited to directional lights and base color. Other kinds of lights can be implemented manually using a custom shader.
 
 - By default, two-sided lighting is not enabled ("back" side of surface will not be lighted). Use an 
SoShapeHintsnode to enable two-sided lighting. - The 
enableBumpMappingfield is not supported on this node SoHeightFieldPropertyMaskandcellOutlinecan be used only if tesselation shaders are supported. Use theSoGLExtensionmethod isAvailable( "GL_ARB_tessellation_shader" ) to check this support.
File format/default:
HeightFieldRender {
} 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSoHeightFieldRender.BoundaryCellsTypeBoundary cells mode.- 
Nested classes/interfaces inherited from class com.openinventor.volumeviz.nodes.SoSlice
SoSlice.AlphaUses 
- 
Nested classes/interfaces inherited from class com.openinventor.volumeviz.nodes.SoVolumeShape
SoVolumeShape.Compositions, SoVolumeShape.Interpolations 
- 
Nested classes/interfaces inherited from class com.openinventor.inventor.nodes.SoShape
SoShape.ShapeTypes 
- 
Nested classes/interfaces inherited from class com.openinventor.inventor.nodes.SoNode
SoNode.RenderModes 
- 
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand 
 - 
 
- 
Field Summary
Fields Modifier and Type Field Description SoSFEnum<SoHeightFieldRender.BoundaryCellsType>boundaryCellsBoundary cells mode.SoSFBoolcellOutlineIf true, draw outline of each heightField cell (default is false).SoSFColorcellOutlineColorWhencellOutlineis true, this value specifies the cell outline color.SoSFFloatcellOutlineWidthWhencellOutlineis true, this value specifies the cell outline width in pixels.- 
Fields inherited from class com.openinventor.volumeviz.nodes.SoSlice
alphaUse, alternateRep, bumpScale, enableBumpMapping, largeSliceSupport, useRGBA 
- 
Fields inherited from class com.openinventor.volumeviz.nodes.SoVolumeShape
composition, interpolation 
- 
Fields inherited from class com.openinventor.inventor.nodes.SoShape
boundingBoxIgnoring 
- 
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle 
 - 
 
- 
Constructor Summary
Constructors Constructor Description SoHeightFieldRender()Constructor. 
- 
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisSupported()Calls isSupported((com.openinventor.inventor.misc.SoState)null).static booleanisSupported(SoState state)Returns true if graphic card can render anSoHeightFieldRender.- 
Methods inherited from class com.openinventor.inventor.nodes.SoShape
getShapeType, isPrimitiveRestartAvailable, isPrimitiveRestartAvailable 
- 
Methods inherited from class com.openinventor.inventor.nodes.SoNode
affectsState, callback, copy, copy, distribute, doAction, getAlternateRep, getBoundingBox, getByName, getMatrix, getPrimitiveCount, getRenderEngineMode, getRenderUnitID, GLRender, GLRenderBelowPath, GLRenderInPath, GLRenderOffPath, grabEventsCleanup, grabEventsSetup, handleEvent, isBoundingBoxIgnoring, isOverride, pick, rayPick, search, setOverride, touch, write 
- 
Methods inherited from class com.openinventor.inventor.fields.SoFieldContainer
copyFieldValues, copyFieldValues, enableNotify, fieldsAreEqual, get, getAllFields, getEventIn, getEventOut, getField, getFieldName, hasDefaultValues, isNotifyEnabled, set, setToDefaults 
- 
Methods inherited from class com.openinventor.inventor.misc.SoBase
dispose, getName, isDisposable, isSynchronizable, setName, setSynchronizable 
- 
Methods inherited from class com.openinventor.inventor.Inventor
getNativeResourceHandle 
 - 
 
 - 
 
- 
- 
Field Detail
- 
cellOutline
public final SoSFBool cellOutline
If true, draw outline of each heightField cell (default is false). 
- 
cellOutlineWidth
public final SoSFFloat cellOutlineWidth
WhencellOutlineis true, this value specifies the cell outline width in pixels. Default is 2 pixels.- Since:
 - Open Inventor 9.7
 
 
- 
cellOutlineColor
public final SoSFColor cellOutlineColor
WhencellOutlineis true, this value specifies the cell outline color. Default is black : (0, 0, 0).- Since:
 - Open Inventor 9.7
 
 
- 
boundaryCells
public final SoSFEnum<SoHeightFieldRender.BoundaryCellsType> boundaryCells
Boundary cells mode. Setting this field to SMART will not compute boundary cells for distant views. . Default is SMART. 
 - 
 
- 
Method Detail
- 
isSupported
public static boolean isSupported()
Calls isSupported((com.openinventor.inventor.misc.SoState)null). 
- 
isSupported
public static boolean isSupported(SoState state)
Returns true if graphic card can render anSoHeightFieldRender. GPU must support geometry shaders, floating point textures and vertex buffer objects (VBO) and tessellation shaders 
 - 
 
 -