SoMultipleInstance Class Reference
[Groups]

Group node that renders multiple instances of its children. More...

#include <Inventor/nodes/SoMultipleInstance.h>

Inheritance diagram for SoMultipleInstance:
SoMultipleInstanceBase SoGroup SoNode SoFieldContainer SoBase SoRefCounter SoTypedObject

List of all members.

Public Member Functions

virtual SoType getTypeId () const
 SoMultipleInstance ()

Static Public Member Functions

static SoType getClassTypeId ()

Public Attributes

SoSFUInt32 numInstances
SoSFUInt32 numBatches
SoMFInstanceParameter parameters

Detailed Description

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 the parameters 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 the SoInstanceParameter and SoMFInstanceParameter documentation.

The predefined names for the SoInstanceParameter name field are the following. However we recommend using the SoInstanceParameter static method getPredefinedParameterName() to ensure future compatibility.

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 OivGetShapeInstanceMatrix() 

If no instance parameters were set, the identity matrix is returned

The OivShapeInstanceColor parameter affects the diffuse color of each instance.

Notes:

Limitations:

EXAMPLE

FILE FORMAT/DEFAULT

SEE ALSO

SoInstanceParameter, SoVertexShaderParameter, SoBufferedShape, SoAlgebraicShape, SoShaderProgram, SoMultipleCopy, SoArray, SoSwitch

NOTE: node available since Open Inventor 9.5

See related examples:

MultiInstancingAlgebraicShapes, MultiInstancingBufferedShape


Constructor & Destructor Documentation

SoMultipleInstance::SoMultipleInstance (  ) 

Creates a multiple instance node with default settings.


Member Function Documentation

static SoType SoMultipleInstance::getClassTypeId (  )  [static]

Returns the type identifier for this class.

Reimplemented from SoMultipleInstanceBase.

virtual SoType SoMultipleInstance::getTypeId (  )  const [virtual]

Returns the type identifier for this specific instance.

Reimplemented from SoMultipleInstanceBase.


Member Data Documentation

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. Default is 1.

Number of shape instances to render.

Default is 1.

List of per-instance attributes of type SoVertexShaderParameters.

The predefined names can be queried using SoInstanceParameter::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.

OivShapeInstanceTranslation, OivShapeInstanceScale, OivShapeInstanceRotation are combined together to create an equivalent matrix available in GLSL shaders with the function

If no parameters are present then an identity matrix is returned.

OivShapeInstanceColor affects the diffuse color of each instance.


The documentation for this class was generated from the following file:

Open Inventor Toolkit reference manual, generated on 12 Feb 2024
Copyright © Thermo Fisher Scientific All rights reserved.
http://www.openinventor.com/