---
name: "SoModelMatrixElement"
section: "3"
platform: "linux"
package: "coin"
version: "1:4.0.10-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/SoModelMatrixElement"
---

# SoModelMatrixElement(3)

The SoModelMatrixElement class is used to manage the current transformation.

## NAME

SoModelMatrixElement - The **SoModelMatrixElement** class is used to manage the current transformation.

## SYNOPSIS

\#include \<Inventor/elements/SoModelMatrixElement.h\>

Inherits **SoAccumulatedElement**.

Inherited by **SoBBoxModelMatrixElement**, and **SoGLModelMatrixElement**.

### Public Member Functions

virtual void **init** (**SoState** \*state)\
 virtual void **push** (**SoState** \*state)\
 virtual SbBool **matches** (const **SoElement** \*element) const\
 const **SbMatrix** & **getModelMatrix** (void) const\

Public Member Functions inherited from **SoElement** const **SoType** **getTypeId** (void) const\
 int **getStackIndex** (void) const\
 virtual void **pop** (**SoState** \*state, const **SoElement** \*prevTopElement)\
 void **setDepth** (const int **depth**)\
 int **getDepth** (void) const\
 virtual void **print** (FILE \*file=stdout) const\
 virtual **~SoElement** ()\

### Static Public Member Functions

static **SoType** **getClassTypeId** (void)\
 static int **getClassStackIndex** (void)\
 static void \* **createInstance** (void)\
 static void **initClass** (void)\
 static void **makeIdentity** (**SoState** \*const state, **SoNode** \*const node)\
 static void **set** (**SoState** \*const state, **SoNode** \*const node, const **SbMatrix** &matrix)\
 static void **setCullMatrix** (**SoState** \*state, **SoNode** \*node, const **SbMatrix** &matrix)\
 static void **mult** (**SoState** \*const state, **SoNode** \*const node, const **SbMatrix** &matrix)\
 static void **translateBy** (**SoState** \*const state, **SoNode** \*const node, const **SbVec3f** &translation)\
 static void **rotateBy** (**SoState** \*const state, **SoNode** \*const node, const **SbRotation** &rotation)\
 static void **scaleBy** (**SoState** \*const state, **SoNode** \*const node, const **SbVec3f** &scaleFactor)\
 static **SbMatrix** **pushMatrix** (**SoState** \*const state)\
 static void **popMatrix** (**SoState** \*const state, const **SbMatrix** &matrix)\
 static const **SbMatrix** & **getCombinedCullMatrix** (**SoState** \*const state)\
 static const **SbMatrix** & **get** (**SoState** \*const state)\
 static const **SbMatrix** & **get** (**SoState** \*const state, SbBool &isIdentity)\

Static Public Member Functions inherited from **SoAccumulatedElement** static **SoType** **getClassTypeId** (void)\
 static int **getClassStackIndex** (void)\
 static void **initClass** (void)\

Static Public Member Functions inherited from **SoElement** static void **initClass** (void)\
 static **SoType** **getClassTypeId** (void)\
 static int **getClassStackIndex** (void)\
 static void **initElements** (void)\
 static int **getNumStackIndices** (void)\
 static **SoType** **getIdFromStackIndex** (const int **stackIndex**)\

### Protected Member Functions

virtual **~SoModelMatrixElement** ()\
 virtual void **makeEltIdentity** (void)\
 virtual void **setElt** (const **SbMatrix** &matrix)\
 virtual void **multElt** (const **SbMatrix** &matrix)\
 virtual void **translateEltBy** (const **SbVec3f** &translation)\
 virtual void **rotateEltBy** (const **SbRotation** &rotation)\
 virtual void **scaleEltBy** (const **SbVec3f** &scaleFactor)\
 virtual **SbMatrix** **pushMatrixElt** (void)\
 virtual void **popMatrixElt** (const **SbMatrix** &matrix)\

Protected Member Functions inherited from **SoAccumulatedElement** virtual **~SoAccumulatedElement** ()\
 void **clearNodeIds** (void)\
 void **addNodeId** (const **SoNode** \*const node)\
 void **setNodeId** (const **SoNode** \*const node)\
 void **copyNodeIds** (const **SoAccumulatedElement** \*copyfrom)\
 virtual **SoElement** \* **copyMatchInfo** (void) const\
 virtual void **captureThis** (**SoState** \*state) const\

Protected Member Functions inherited from **SoElement** **SoElement** (void)\
 void **capture** (**SoState** \*const state) const\
 void **setTypeId** (const **SoType** **typeId**)\
 void **setStackIndex** (const int index)\
 **SoElement** \* **getNextInStack** (void) const\
 **SoElement** \* **getNextFree** (void) const\

### Protected Attributes

**SbMatrix** **modelMatrix**\
 **SbMatrix** **cullMatrix**\
 **SbMatrix** **combinedMatrix**\
 uint32\_t **flags**\

Protected Attributes inherited from **SoAccumulatedElement** **SbList**\< SbUniqueId \> **nodeIds**\

Protected Attributes inherited from **SoElement** **SoType** **typeId**\
 int **stackIndex**\
 int **depth**\

### Additional Inherited Members

Static Protected Member Functions inherited from **SoElement** static **SoElement** \* **getElement** (**SoState** \*const state, const int **stackIndex**)\
 static const **SoElement** \* **getConstElement** (**SoState** \*const state, const int **stackIndex**)\
 static int **createStackIndex** (const **SoType** id)\

Static Protected Attributes inherited from **SoElement** static int **classStackIndex**\
 static **SoTypeList** \* **stackToType**\

## Detailed Description

The **SoModelMatrixElement** class is used to manage the current transformation.

**SoModelMatrixElement** contains the object-to-world matrix.

The world-to-camera transformation is stored in the **SoViewingMatrixElement** class.

Note that one thing that can be a little confusing with the API is that **SoModelMatrixElement** does not contain the same matrix as the OpenGL GL\_MODELVIEW matrix.

**See also**

**SoViewingMatrixElement**

## Constructor & Destructor Documentation

### SoModelMatrixElement::~SoModelMatrixElement (void ) \[protected\], \[virtual\]

Destructor.

## Member Function Documentation

### SoType SoModelMatrixElement::getClassTypeId (void ) \[static\]

This static method returns the **SoType** object associated with objects of this class.

### int SoModelMatrixElement::getClassStackIndex (void ) \[static\]

This static method returns the state stack index for the class.

### void \* SoModelMatrixElement::createInstance (void ) \[static\]

*This API member is considered internal to the library, as it is not likely to be of interest to the application programmer.*\

 Creates a new instance of the class type corresponding to the **SoType** object.

### void SoModelMatrixElement::initClass (void ) \[static\]

Initialize relevant common data for all instances, like the type system.

### void SoModelMatrixElement::init (SoState \* state) \[virtual\]

Initializes the element to its default value. The default value for modelMatrix is the identity matrix.

Reimplemented from **SoAccumulatedElement**.

Reimplemented in **SoBBoxModelMatrixElement**, and **SoGLModelMatrixElement**.

### void SoModelMatrixElement::push (SoState \* state) \[virtual\]

This method is called every time a new element is required in one of the stacks. This happens when a writable element is requested, using **SoState::getElement()** or indirectly **SoElement::getElement()**, and the depth of the current element is less than the state depth.

Override this method if your element needs to copy data from the previous top of stack. The **push()** method is called on the new element, and the previous element can be found using **SoElement::getNextInStack()**.

Reimplemented from **SoAccumulatedElement**.

Reimplemented in **SoBBoxModelMatrixElement**, and **SoGLModelMatrixElement**.

### SbBool SoModelMatrixElement::matches (const SoElement \* element) const \[virtual\]

This function returns TRUE is the element matches another element (of the same class), with respect to cache validity.

If the application programmer's extension element has a **matches()** function, it should also have a **copyMatchInfo()** function.

Reimplemented from **SoAccumulatedElement**.

### void SoModelMatrixElement::makeIdentity (SoState \*const state, SoNode \*const node) \[static\]

Sets the current model matrix to the identity matrix.

### void SoModelMatrixElement::set (SoState \*const state, SoNode \*const node, const SbMatrix & matrix) \[static\]

Sets the current model matrix to *matrix*.

### void SoModelMatrixElement::setCullMatrix (SoState \* state, SoNode \* node, const SbMatrix & matrix) \[static\]

Sets the current cull matrix.

### void SoModelMatrixElement::mult (SoState \*const state, SoNode \*const node, const SbMatrix & matrix) \[static\]

Multiplies *matrix* into the model matrix.

### void SoModelMatrixElement::translateBy (SoState \*const state, SoNode \*const node, const SbVec3f & translation) \[static\]

Appends *translation* to the model matrix.

### void SoModelMatrixElement::rotateBy (SoState \*const state, SoNode \*const node, const SbRotation & rotation) \[static\]

Appends *rotation* to the model matrix.

### void SoModelMatrixElement::scaleBy (SoState \*const state, SoNode \*const node, const SbVec3f & scaleFactor) \[static\]

Appends *scaleFactor* to the model matrix.

### SbMatrix SoModelMatrixElement::pushMatrix (SoState \*const state) \[static\]

Used by **SoTransformSeparator** to store and restore model matrix. Don't use it for any other reason.

### void SoModelMatrixElement::popMatrix (SoState \*const state, const SbMatrix & matrix) \[static\]

Used by **SoTransformSeparator** to store and restore model matrix. Don't use it for any other reason.

### const SbMatrix & SoModelMatrixElement::getCombinedCullMatrix (SoState \*const state) \[static\]

Returns the combined cull and model matrix. This matrix is cached.

### const SbMatrix & SoModelMatrixElement::get (SoState \*const state) \[static\]

Returns the current model matrix.

### const SbMatrix & SoModelMatrixElement::get (SoState \*const state, SbBool & isIdentity) \[static\]

Returns the current model matrix. Sets *isIdentity* to TRUE if the model matrix is known to be an identity matrix.

### const SbMatrix & SoModelMatrixElement::getModelMatrix (void ) const

Returns the current model matrix.

### void SoModelMatrixElement::makeEltIdentity (void ) \[protected\], \[virtual\]

virtual method which is called from the static method **makeIdentity()**. Sets element model matrix to identity.

Reimplemented in **SoBBoxModelMatrixElement**, and **SoGLModelMatrixElement**.

### void SoModelMatrixElement::setElt (const SbMatrix & matrix) \[protected\], \[virtual\]

virtual method which is called from the static method **set()**. Sets element model matrix to *matrix*.

Reimplemented in **SoBBoxModelMatrixElement**, and **SoGLModelMatrixElement**.

### void SoModelMatrixElement::multElt (const SbMatrix & matrix) \[protected\], \[virtual\]

virtual method which is called from the static method **mult()**. Multiplies *matrix* into element model matrix.

Reimplemented in **SoBBoxModelMatrixElement**, and **SoGLModelMatrixElement**.

### void SoModelMatrixElement::translateEltBy (const SbVec3f & translation) \[protected\], \[virtual\]

virtual method which is called from the static method **translateBy()**. Appends *translation* to element model matrix.

Reimplemented in **SoBBoxModelMatrixElement**, and **SoGLModelMatrixElement**.

### void SoModelMatrixElement::rotateEltBy (const SbRotation & rotation) \[protected\], \[virtual\]

virtual method which is called from the static method **rotateBy()**. Appends *rotation* to element model matrix.

Reimplemented in **SoBBoxModelMatrixElement**, and **SoGLModelMatrixElement**.

### void SoModelMatrixElement::scaleEltBy (const SbVec3f & scaleFactor) \[protected\], \[virtual\]

virtual method which is called from the static method **scaleBy()**. Appends *scaleFactor* to element model matrix.

Reimplemented in **SoBBoxModelMatrixElement**, and **SoGLModelMatrixElement**.

### SbMatrix SoModelMatrixElement::pushMatrixElt (void ) \[protected\], \[virtual\]

virtual method which is called from the static method **pushMatrix()**. Returns current model matrix.

Reimplemented in **SoBBoxModelMatrixElement**, and **SoGLModelMatrixElement**.

### void SoModelMatrixElement::popMatrixElt (const SbMatrix & matrix) \[protected\], \[virtual\]

virtual method which is called from the static method **popMatrix()**. Restores model matrix to the matrix returned from **pushMatrix()**.

Reimplemented in **SoBBoxModelMatrixElement**, and **SoGLModelMatrixElement**.

## Member Data Documentation

### SbMatrix SoModelMatrixElement::modelMatrix \[protected\]

FIXME: write doc.

### SbMatrix SoModelMatrixElement::cullMatrix \[protected\]

FIXME: write doc.

### SbMatrix SoModelMatrixElement::combinedMatrix \[protected\]

FIXME: write doc.

### uint32\_t SoModelMatrixElement::flags \[protected\]

FIXME: write doc.

## Author

Generated automatically by Doxygen for Coin from the source code.
