Class SoMultipleInstance
- 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.SoGroup
-
- com.openinventor.inventor.nodes.SoMultipleInstanceBase
-
- com.openinventor.inventor.nodes.SoMultipleInstance
-
- All Implemented Interfaces:
SafeDisposable
public class SoMultipleInstance extends SoMultipleInstanceBase
Group node that renders multiple instances of its children. This group node renders its children multiple times applying different per-instance attributes.This node issues a single multi-instance OpenGL draw call that automatically applies per-instance parameters (
SoInstanceParameter
objects) set in theparameters
field. Some predefined parameter names can be used for common instance parameters like position, rotation, scale factor, or color. Parameter objects with these names are automatically managed and are recognized and used by the default shaders. Applications can define additional parameter objects to be used by custom shaders. Custom shaders can also be used to set per-instance colors and so on.The predefined instance parameters are typically set by the application to position the instances in space. The application does not need to set predefined instance parameter values if the default values are OK. For example, you may not need to set per-instance rotations. In that case you can just set the desired parameters for translating and/or scaling instances. If the application does not set any instance parameters, all the instances will be drawn at the same 3D position without any rotation or scaling factor applied.
Some methods are provided by
SoInstanceParameter
to create these per-instance parameters: see theSoInstanceParameter
andSoMFInstanceParameter
documentation.The predefined names for the
SoInstanceParameter
name field are the following. However we recommend using theSoInstanceParameter
static method getPredefinedParameterName() to ensure future compatibility.- "OivShapeInstanceTranslation":
Data is an array ofSbVec3f
translation values (3 floats) to apply to the instances. - "OivShapeInstanceScale":
Data is an array ofSbVec3f
scale factor values (3 floats) to apply to the instances. - "OivShapeInstanceRotation":
Data is an array ofSbRotation
values (4 floats representing a quaternion) to apply to the instances. - "OivShapeInstanceColor":
Data is an array ofSbColor
values (3 floats) to apply to the instances. - "OivShapeInstanceTransparency":
Data is an array of float values to apply to the instances. - "OivShapeInstanceVisibility":
Data is an array of unsigned int32 values to apply to the instances.
The OivShapeInstanceTranslation, OivShapeInstanceScale and OivShapeInstanceRotation parameters (if present) are combined together to create an equivalent matrix. This matrix is available to application shader programs using the GLSL function
mat4 OivInstanceMatrix() The OivShapeInstanceColor and OivShapeInstanceTransparency parameters affect, respectively, the diffuse color and the transparency of each instance. Note that when one of these parameters is defined, it overrides the diffuse color or the transparency value of a
SoMaterial
node.Notes:
- The number of elements in each
SoVertexShaderParameter
must be greater than or equal to numInstances * SoVertexShaderParameter.instanceDivisor. If not, the attributes will be ignored with warning messages in debug mode. - Traversing the Nth child sets the current switch value to N , for use with inherited switch values (see
SoSwitch
). - Although
SoMultipleInstance
is derived fromSoGroup
, it behaves like anSoSeparator
(traversal state is pushed and popped).
Limitations:
- Multiple instance nodes cannot currently be nested.
SoMultipleInstance
,SoMultipleCopy
andSoArray
nodes may not be children. - This node requires at least version 3.3 of OpenGL.
File format/default:
MultipleInstance {
numInstances 1 numBatches 1 parameters - Since:
- Open Inventor 9.5
- See Also:
SoInstanceParameter
,SoVertexShaderParameter
,SoBufferedShape
,SoAlgebraicShape
,SoShaderProgram
,SoMultipleCopy
,SoArray
,SoSwitch
-
-
Nested Class Summary
-
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 SoSFUInt32
numBatches
When this field is set to 1 (default), all the instances are rendered in one batch.SoSFUInt32
numInstances
Number of shape instances to render.SoMFInstanceParameter
parameters
List of per-instance attributes of type SoVertexShaderParameters.-
Fields inherited from class com.openinventor.inventor.nodes.SoGroup
boundingBoxIgnoring
-
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
-
Constructor Summary
Constructors Constructor Description SoMultipleInstance()
Creates a multiple instance node with default settings.
-
Method Summary
-
Methods inherited from class com.openinventor.inventor.nodes.SoGroup
addChild, findChild, getChild, getNumChildren, insertChild, removeAllChildren, removeChild, removeChild, replaceChild, replaceChild
-
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
-
numInstances
public final SoSFUInt32 numInstances
Number of shape instances to render. Default is 1.
-
numBatches
public final SoSFUInt32 numBatches
When this field is set to 1 (default), all the instances are rendered in one batch. When greater than 1, rendering will be done in numBatches passes, in order to spend less time in the driver code. This is useful when rendering GPU costly shapes (complex shader, big number of vertices...), because the process may spend too much time in the driver leading to a driver timeout on Windows systems.Limitation: When
numBatches
is greater than 1, only instance parameters with a divisor equal to 1 are supported.Default is 1.
-
parameters
public final SoMFInstanceParameter parameters
List of per-instance attributes of type SoVertexShaderParameters. The predefined names can be queried usingSoInstanceParameter.getPredefinedParameterName()
.The number of elements in each
SoVertexShaderParameter
must be greater than or equal to numInstances *SoInstanceParameter.divisor
, if not, the attributes will be ignored with warning messages in debug mode.Some predefined
SoVertexShaderParameter.name
are automaticly managed/interpreted:- OivShapeInstanceTranslation: Handles an array of vec3f translation to apply to vertices of each instance.
- OivShapeInstanceScale: Handles an array of vec3f scale factor applied to vertices of each instance.
- OivShapeInstanceRotation: Handles an array of rotation vec4f to apply to vertices of each instance.
- OivShapeInstanceColor: Handles an array of vec3f color applied to vertices of each instance.
- OivShapeInstanceTransparency: Handles an array of float transparency applied to vertices of each instance.
OivShapeInstanceTranslation, OivShapeInstanceScale, OivShapeInstanceRotation are combined together to create an equivalent matrix available in GLSL shaders with the function
mat4 OivInstanceMatrix() OivShapeInstanceColor affects the diffuse color of each instance.
-
-