Reference geometry


HOOPS Visualize supports the reuse of segments with the include segment paradigm. Organizing your scene tree using include segments lets you make better use of memory. However, sometimes you might want to only refer to a specific piece of geometry in a given segment and set attributes that are relevant to that part of the scene graph. Visualize provides the functionality to do this using reference geometry. Referencing geometry provides more flexibility than including an entire segment because you can instance only the geometry that you need. Once it is referenced, you can set any number of attributes on the referenced geometry.

For instance, if you were to build a scene depicting the assembly line for a mountain bike, you could create a single segment in your library that contains the geometry for all the different screws for the bike. To add one of the screws to your scene, you could instance it via the HPS::SegmentKey::ReferenceGeometry method and apply any necessary attributes like a rotation matrix. If the scene has six screws in it, you would only need to create the screw once in your library and reference it six times in your scene graph. We recommend the geometry library be defined in an isolated root segment, so it can be referenced and rendered only as required.

Using reference geometry in this way saves memory, and when combined with segment-level display lists, offers good performance as well. The following sample code demonstrates how to reference a piece of geometry:

// setting up the geometry that will be duplicated
HPS::ShellKey shellKey = isolatedSegment.InsertShell(shellKit);
// ...
// importing a copy of the geometry into 'mySegmentKey'
HPS::ReferenceKey refKey = mySegmentKey.ReferenceGeometry(shellKey);
refKey.SetModellingMatrix(matrixKit);
// remove the reference
refKey.Delete();
// setting up the geometry that will be duplicated
HPS.ShellKey shellKey = isolatedSegment.InsertShell(shellKit);
// ...
// importing a copy of the geometry into 'mySegmentKey'
HPS.ReferenceKey refKey = mySegmentKey.ReferenceGeometry(shellKey);
refKey.SetModellingMatrix(matrixKit);
// remove the reference
refKey.Delete();



Except for modeling matrices and priority, you cannot set geometry-level attributes on referenced geometry. If you need to set attributes, do so at the segment level.

For a complete example of reference geometry, see our reference geometry sample.