Programming Guide   >   Viewing   >   Model Attributes

Instance Modifiers

InstanceModifiers allow you to activate certain special behaviors generally related to drawing the scene. They are all activated with a single function for convenience. InstanceModifiers can serve very different purposes.

Setting and Unsetting

An InstanceModifier can be set with the setInstanceModifier() function by specifying the InstanceModifier type, the NodeIds it should apply to and passing "true" as the third parameter.

hwv.model.setInstanceModifier(Communicator.InstanceModifier.AlwaysDraw, [nodeid], true)

Similar to the setNodesVisibility() behavior (information about node visibility here) this function will "push" the InstanceModifier activation all the way to the leaf nodes of the model tree (e.g. if you are applying an InstanceModifier to the root node of the model tree it will be active for all nodes in the model).

To deactivate an InstanceModifier simply call the same function but with "false" as the final parameter:

hwv.model.setInstanceModifier(Communicator.InstanceModifier.AlwaysDraw, [nodeid], false)

There is currently no way to query if an InstanceModifier is active on a node. You will need to keep track of that yourself.

AlwaysDraw

If set, the instance will be drawn before other instances and will not be culled to reach the target frame rate. This can be useful if you want to ensure that a piece of geometry stays visible (e.g. during an editing operation) especially if the bounding box for that geometry is small relative to other objects and so the object would ordinarily be culled during interaction if the scene is complex.

DoNot Modifiers

DoNotCut

Geometry with the DoNotCut InstanceModifier set will not be affected when cutting planes are active. In general, you might want to activate those settings on geometry that is not part of the main model like widgets or 3D annotations.

DoNotExplode

Geometry with the DoNotExplode InstanceModifier set will not be affected when the model is exploded or cutting planes are active. In general, you might want to activate those settings on geometry that is not part of the main model like widgets or 3D annotations.

DoNotLight

If set, the instance will not be lit. We are using this setting internally when rendering PMI text that should not be shaded.

PMI drawn with the DoNotLight InstanceModifier set. No shading is applied to the text.

DoNotOutlineHighlight

If set, the instance will not be outlined when highlighted. We are using this setting internally to avoid outlining PMI text while highlighting.

DoNotSelect

If set, the instance will not be selectable. Excluding geometry from selection or making it only selectable in certain circumstances can be useful for geometry that is not part of the main model like handles or other types of widgets.

DoNotUseVertexColors

If set, the instance will not use the mesh's per-vertex colors. This can be useful if you want to temporarily force a mesh to be drawn in a certain color.

DoNotXRay

If set, the instance will not be affected by DrawMode.XRay. This InstanceModifier would generally be applied to geometry that is not part of the main model.

ExcludeBounding

If set, the instance will not be included in bounding calculations. This InstanceModifier would generally be applied to geometry that is not part of the main model and therefore should be ignored for bounding calculations.

OverrideSceneVisibility

If set, then scene visibility (global visibility for faces/edges/points) will not be applied to the specified nodes.

A model in Wireframe rendering mode with the OverrideSceneVisiblity Instance Modifier set for one of its parts

ScreenOriented

If set, the instance will be oriented such that the cardinal axes of object space are aligned with the cardinal axes of screen space. In practice, that means that the insertion point of the geometry will still move and rotate with the camera the geometry itself will not rotate. Use this InstanceModifier for geometry you want to display billboarded (always facing the camera).

ScreenSpace

If set, the instance will be oriented such that the cardinal axes of object space are aligned with the cardinal axes of screen space.

ScreenSpaceStretched

If set, the instance will be drawn in a space that extends from X=-1 at the left side of the screen to X=1 at the right side of the screen and from Y=-1 at the bottom of the screen to Y=1 at the top of the screen.

With one of those InstanceModifiers set you can essentially render your geometry in a fixed screen space location meaning that the geometry will not move with the main camera.

SuppressCameraScale

If set, the instance will be drawn at the same size regardless of camera settings. We are using this InstanceModifier internally to draw the geometry handles that rotate and move with the camera like any other geometry but always retain the same size relative to the main window.

Geometry handles drawn with the SuppressCameraScale InstanceModifier to ensure that they stay the same size no matter how far the main camera is zoomed in or out