Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SoMultipleInstance Class Reference

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

#include <Inventor/nodes/SoMultipleInstance.h>

+ Inheritance diagram for SoMultipleInstance:

Public Member Functions

virtual SoType getTypeId () const
 Returns the type identifier for this specific instance.
 
 SoMultipleInstance ()
 Creates a multiple instance node with default settings.
 
- Public Member Functions inherited from SoGroup
 SoGroup ()
 Creates an empty group node.
 
 SoGroup (int nChildren)
 Constructor that takes approximate number of children.
 
virtual void addChild (SoNode *child)
 Adds a child as last one in group.
 
virtual void insertChild (SoNode *child, int newChildIndex)
 Adds a child so that it becomes the one with the given index.
 
virtual SoNodegetChild (int index) const
 Returns pointer the child node with the given index.
 
virtual int findChild (const SoNode *child) const
 Finds index of given child within group.
 
virtual int getNumChildren () const
 Returns number of children.
 
virtual void removeChild (int index)
 Removes child with given index from group.
 
virtual void removeChild (SoNode *child)
 Removes first instance of given child from group.
 
virtual void removeAllChildren ()
 Removes all children from group.
 
virtual void replaceChild (int index, SoNode *newChild)
 Replaces child with given index with new child.
 
virtual void replaceChild (SoNode *oldChild, SoNode *newChild)
 Replaces first instance of given child with new child.
 
- Public Member Functions inherited from SoNode
virtual void setOverride (const SbBool state)
 Turns the override flag on or off.
 
virtual SbBool isOverride () const
 Returns the state of the override flag.
 
virtual SoNodecopy (SbBool copyConnections=FALSE) const
 Creates and returns an exact copy of the node.
 
virtual void touch ()
 Marks an instance as modified, simulating a change to it.
 
- Public Member Functions inherited from SoFieldContainer
void setToDefaults ()
 Sets all fields in this object to their default values.
 
SbBool hasDefaultValues () const
 Returns TRUE if all of the object's fields have their default values.
 
SbBool fieldsAreEqual (const SoFieldContainer *fc) const
 Returns TRUE if this object's fields are exactly equal to fc's fields.
 
void copyFieldValues (const SoFieldContainer *fc, SbBool copyConnections=FALSE)
 Copies the contents of fc's fields into this object's fields.
 
SoNONUNICODE SbBool set (const char *fieldDataString)
 Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format.
 
SbBool set (const SbString &fieldDataString)
 Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format.
 
void get (SbString &fieldDataString)
 Returns the values of the fields of this object in the Open Inventor ASCII file format in the given string.
 
virtual int getFields (SoFieldList &list) const
 Appends references to all of this object's fields to resultList, and returns the number of fields appended.
 
virtual int getAllFields (SoFieldList &list) const
 Returns a list of fields, including the eventIn's and eventOut's.
 
virtual SoFieldgetField (const SbName &fieldName) const
 Returns a the field of this object whose name is fieldName.
 
virtual SoFieldgetEventIn (const SbName &fieldName) const
 Returns a the eventIn with the given name.
 
virtual SoFieldgetEventOut (const SbName &fieldName) const
 Returns the eventOut with the given name.
 
SbBool getFieldName (const SoField *field, SbName &fieldName) const
 Returns the name of the given field in the fieldName argument.
 
SbBool enableNotify (SbBool flag)
 Notification at this Field Container is enabled (if flag == TRUE) or disabled (if flag == FALSE).
 
SbBool isNotifyEnabled () const
 Notification is the process of telling interested objects that this object has changed.
 
virtual void setUserData (void *data)
 Sets application data.
 
void * getUserData (void) const
 Gets user application data.
 
- Public Member Functions inherited from SoBase
virtual SbName getName () const
 Returns the name of an instance.
 
virtual void setName (const SbName &name)
 Sets the name of an instance.
 
void setSynchronizable (const bool b)
 Sets this to be a ScaleViz synchronizable object.
 
bool isSynchronizable () const
 Gets the ScaleViz synchronizable state of this object.
 
- Public Member Functions inherited from SoRefCounter
void ref () const
 Adds a reference to an instance.
 
void unref () const
 Removes a reference from an instance.
 
void unrefNoDelete () const
 unrefNoDelete() should be called when it is desired to decrement the reference count, but not delete the instance if this brings the reference count to zero.
 
int getRefCount () const
 Returns current reference count.
 
void lock () const
 lock this instance.
 
void unlock () const
 unlock this instance.
 
- Public Member Functions inherited from SoTypedObject
SbBool isOfType (const SoType &type) const
 Returns TRUE if this object is of the type specified in type or is derived from that type.
 
template<typename TypedObjectClass >
SbBool isOfType () const
 Returns TRUE if this object is of the type of class TypedObjectClass or is derived from that class.
 

Static Public Member Functions

static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
- Static Public Member Functions inherited from SoMultipleInstanceBase
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
- Static Public Member Functions inherited from SoGroup
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
- Static Public Member Functions inherited from SoNode
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
static SoNodegetByName (const SbName &name)
 A node's name can be set using SoBase::setName().
 
static int getByName (const SbName &name, SoNodeList &list)
 A node's name can be set using SoBase::setName().
 
- Static Public Member Functions inherited from SoFieldContainer
static SoType getClassTypeId ()
 Returns the type of this class.
 
- Static Public Member Functions inherited from SoBase
static SoType getClassTypeId ()
 Returns type identifier for this class.
 
- Static Public Member Functions inherited from SoTypedObject
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 

Public Attributes

SoSFUInt32 numInstances
 Number of shape instances to render.
 
SoSFUInt32 numBatches
 When this field is set to 1 (default), all the instances are rendered in one batch.
 
SoMFInstanceParameter parameters
 List of per-instance attributes of type SoVertexShaderParameters.
 
- Public Attributes inherited from SoGroup
SoSFBool boundingBoxIgnoring
 Whether to ignore this node during bounding box traversal.
 

Friends

class SoInstanceMatrixAccessorAttributes
 

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.

  • "OivShapeInstanceTranslation":
    Data is an array of SbVec3f translation values (3 floats) to apply to the instances.
  • "OivShapeInstanceScale":
    Data is an array of SbVec3f scale factor values (3 floats) to apply to the instances.
  • "OivShapeInstanceRotation":
    Data is an array of SbRotation values (4 floats representing a quaternion) to apply to the instances.
  • "OivShapeInstanceColor":
    Data is an array of SbColor 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()
Get the transformation matrix to apply to the current geometry instance, i.e., the combination of ins...

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

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 from SoGroup, it behaves like an SoSeparator (traversal state is pushed and popped).

Limitations:

EXAMPLE

FILE FORMAT/DEFAULT

    MultipleInstance {
    numInstances 1
    numBatches 1
    parameters
    }

SEE ALSO

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

NOTE: node available since Open Inventor 9.5

Definition at line 161 of file SoMultipleInstance.h.

Constructor & Destructor Documentation

◆ SoMultipleInstance()

SoMultipleInstance::SoMultipleInstance ( )

Creates a multiple instance node with default settings.

Member Function Documentation

◆ getClassTypeId()

static SoType SoMultipleInstance::getClassTypeId ( )
static

Returns the type identifier for this class.


◆ getTypeId()

virtual SoType SoMultipleInstance::getTypeId ( ) const
virtual

Returns the type identifier for this specific instance.

Reimplemented from SoMultipleInstanceBase.

Friends And Related Symbol Documentation

◆ SoInstanceMatrixAccessorAttributes

friend class SoInstanceMatrixAccessorAttributes
friend

Definition at line 248 of file SoMultipleInstance.h.

Member Data Documentation

◆ numBatches

SoSFUInt32 SoMultipleInstance::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.

Definition at line 185 of file SoMultipleInstance.h.

◆ numInstances

SoSFUInt32 SoMultipleInstance::numInstances

Number of shape instances to render.

Default is 1.

Definition at line 170 of file SoMultipleInstance.h.

◆ parameters

SoMFInstanceParameter SoMultipleInstance::parameters

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.
  • 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

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

OivShapeInstanceColor affects the diffuse color of each instance.

Definition at line 219 of file SoMultipleInstance.h.


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