HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_AttributeInstanceMatrix Class Reference

Compute an instance transform given a set of attributes. More...

#include <GA_AttributeInstanceMatrix.h>

Public Member Functions

 GA_AttributeInstanceMatrix ()
 Default c-tor. More...
 
 GA_AttributeInstanceMatrix (const GA_Attribute *N, const GA_Attribute *v, const GA_Attribute *up, const GA_Attribute *trans, const GA_Attribute *pscale, const GA_Attribute *pscale3, const GA_Attribute *rot, const GA_Attribute *orient, const GA_Attribute *pivot, const GA_Attribute *xform3, const GA_Attribute *xform4)
 
 GA_AttributeInstanceMatrix (const GA_AttributeDict &dict, const UT_StringRef &N_name=GA_Names::N, const UT_StringRef &v_name=GA_Names::v)
 
 GA_AttributeInstanceMatrix (const GA_AttributeDict &dict, const GA_Attribute *N)
 
 ~GA_AttributeInstanceMatrix ()
 
void initialize (const GA_AttributeDict &dict, const UT_StringRef &N_name=GA_Names::N, const UT_StringRef &v_name=GA_Names::v)
 
void initialize (const GA_AttributeDict &dict, const GA_Attribute *N)
 Initialize with a provided, possilby detached N. More...
 
void reset ()
 Clear out any attribute handles. More...
 
void resetScales ()
 Resets only the scale attributes. More...
 
void makeInvalid ()
 Make invalid. More...
 
void getMatrix (UT_Matrix3 &xform, GA_Offset offset) const
 
void getMatrix (UT_DMatrix3 &xform, GA_Offset offset) const
 
void getInverseMatrix (UT_Matrix3 &xform, GA_Offset offset) const
 
void getInverseMatrix (UT_DMatrix3 &xform, GA_Offset offset) const
 
bool hasAnyAttribs () const
 Returns true if there are any attributes bound. More...
 
bool hasNonScales () const
 
bool hasScales () const
 Returns true if myPscale or myPscale3 is bound. More...
 
UT_Vector3D getScales (GA_Offset offset) const
 Returns just the product of myPscale and myPscale3. More...
 
void setN (const GA_Attribute *N)
 Overrides the N attribute with the specified attribute. More...
 
void getDataIds (GA_DataId data_ids[theNumAttribs]) const
 
void getMatrix (UT_Matrix4 &xform, const UT_Vector3 &P, GA_Offset offset, float default_pscale=1) const
 
void getMatrix (UT_Matrix4D &xform, const UT_Vector3D &P, GA_Offset offset, fpreal default_pscale=1) const
 
void getInverseMatrix (UT_Matrix4 &xform, const UT_Vector3 &P, GA_Offset offset, float default_pscale=1) const
 
void getInverseMatrix (UT_Matrix4D &xform, const UT_Vector3D &P, GA_Offset offset, fpreal default_pscale=1) const
 
void getMatrix (UT_Matrix4 &xform, const UT_Vector3 &P, const UT_Quaternion &orient, GA_Offset offset, float default_pscale=1) const
 
void getMatrix (UT_Matrix4D &xform, const UT_Vector3D &P, const UT_QuaternionD &orient, GA_Offset offset, fpreal default_pscale=1) const
 
void getInverseMatrix (UT_Matrix4 &xform, const UT_Vector3 &P, const UT_Quaternion &orient, GA_Offset offset, float default_pscale=1) const
 
void getInverseMatrix (UT_Matrix4D &xform, const UT_Vector3D &P, const UT_QuaternionD &orient, GA_Offset offset, fpreal default_pscale=1) const
 
const GA_ROHandleV3DgetN () const
 
const GA_ROHandleV3DgetUp () const
 
const GA_ROHandleV3DgetTrans () const
 
const GA_ROHandleDgetPscale () const
 
const GA_ROHandleV3DgetPscale3 () const
 
const GA_ROHandleQDgetRot () const
 
const GA_ROHandleQDgetOrient () const
 
const GA_ROHandleV3DgetPivot () const
 
const GA_ROHandleM3DgetXform3 () const
 
const GA_ROHandleM4DgetXform4 () const
 
bool getRemoveScales () const
 

Public Attributes

GA_ROHandleV3D myN
 
GA_ROHandleV3D myUp
 
GA_ROHandleV3D myTrans
 
GA_ROHandleD myPscale
 
GA_ROHandleV3D myPscale3
 
GA_ROHandleQD myRot
 
GA_ROHandleQD myOrient
 
GA_ROHandleV3D myPivot
 
GA_ROHandleM3D myXform3
 
GA_ROHandleM4D myXform4
 
bool myRemoveScales
 

Static Public Attributes

static constexpr int theNumAttribs = 10
 
static constexpr GA_DataId theAttribNotPresentDataId = GA_DataId(-2)
 

Detailed Description

Compute an instance transform given a set of attributes.

Given a normal (or velocity) attribute, along with attributes for the up vector, a translation offset, a uniform scale, a 3-tuple scale, a rotation quaternion and an orientation quaternion, compute a 4x4 transform matrix for a given position.

This transform is the same as the one generated by the copy SOP or by SOHO instancing.

See Also
UT_Matrix4::instance()

Definition at line 40 of file GA_AttributeInstanceMatrix.h.

Constructor & Destructor Documentation

GA_AttributeInstanceMatrix::GA_AttributeInstanceMatrix ( )
inline

Default c-tor.

Definition at line 44 of file GA_AttributeInstanceMatrix.h.

GA_AttributeInstanceMatrix::GA_AttributeInstanceMatrix ( const GA_Attribute N,
const GA_Attribute v,
const GA_Attribute up,
const GA_Attribute trans,
const GA_Attribute pscale,
const GA_Attribute pscale3,
const GA_Attribute rot,
const GA_Attribute orient,
const GA_Attribute pivot,
const GA_Attribute xform3,
const GA_Attribute xform4 
)
inline

Construct given the explicit attributes

All attributes must be bound to the same owner (GA_AttributeOwner). The offset passed into getMatrix() determines which element is used to build the matrix. The owner does not have to be GA_ATTRIB_POINT, though that is the most common case.

Definition at line 54 of file GA_AttributeInstanceMatrix.h.

GA_AttributeInstanceMatrix::GA_AttributeInstanceMatrix ( const GA_AttributeDict dict,
const UT_StringRef N_name = GA_Names::N,
const UT_StringRef v_name = GA_Names::v 
)
inline

Definition at line 82 of file GA_AttributeInstanceMatrix.h.

GA_AttributeInstanceMatrix::GA_AttributeInstanceMatrix ( const GA_AttributeDict dict,
const GA_Attribute N 
)
inline

Definition at line 89 of file GA_AttributeInstanceMatrix.h.

GA_AttributeInstanceMatrix::~GA_AttributeInstanceMatrix ( )
inline

Definition at line 95 of file GA_AttributeInstanceMatrix.h.

Member Function Documentation

void GA_AttributeInstanceMatrix::getDataIds ( GA_DataId  data_ids[theNumAttribs]) const

Get all data IDs of attributes used by this class. This uses a value of theAttribNotPresentDataId for attributes that aren't present.

void GA_AttributeInstanceMatrix::getInverseMatrix ( UT_Matrix4 xform,
const UT_Vector3 P,
GA_Offset  offset,
float  default_pscale = 1 
) const

Create a 4x4 transform matrix given a position (P) and an attribute element for which the GA_ROHandle objects are valid.

If the "pscale" attribute is invalid, the default_pscale will be used.

Note
The position (P) is passed in since the attribute handles may not be bound to point attributes.
void GA_AttributeInstanceMatrix::getInverseMatrix ( UT_Matrix4D xform,
const UT_Vector3D P,
GA_Offset  offset,
fpreal  default_pscale = 1 
) const

Create a 4x4 transform matrix given a position (P) and an attribute element for which the GA_ROHandle objects are valid.

If the "pscale" attribute is invalid, the default_pscale will be used.

Note
The position (P) is passed in since the attribute handles may not be bound to point attributes.
void GA_AttributeInstanceMatrix::getInverseMatrix ( UT_Matrix3 xform,
GA_Offset  offset 
) const
void GA_AttributeInstanceMatrix::getInverseMatrix ( UT_DMatrix3 xform,
GA_Offset  offset 
) const
void GA_AttributeInstanceMatrix::getInverseMatrix ( UT_Matrix4 xform,
const UT_Vector3 P,
const UT_Quaternion orient,
GA_Offset  offset,
float  default_pscale = 1 
) const

Create a 4x4 transform matrix given a position (P), an orientaiton (orient), and an attribute element for which the GA_ROHandle objects are valid.

The provided orientation will be used instead of any rotation attributes on the geometry, but the translation and pivot attributes will still be used.

If the "pscale" attribute is invalid, the default_pscale will be used.

Note
The position (P) is passed in since the attribute handles may not be bound to point attributes.
void GA_AttributeInstanceMatrix::getInverseMatrix ( UT_Matrix4D xform,
const UT_Vector3D P,
const UT_QuaternionD orient,
GA_Offset  offset,
fpreal  default_pscale = 1 
) const

Create a 4x4 transform matrix given a position (P), an orientaiton (orient), and an attribute element for which the GA_ROHandle objects are valid.

The provided orientation will be used instead of any rotation attributes on the geometry, but the translation and pivot attributes will still be used.

If the "pscale" attribute is invalid, the default_pscale will be used.

Note
The position (P) is passed in since the attribute handles may not be bound to point attributes.
void GA_AttributeInstanceMatrix::getMatrix ( UT_Matrix4 xform,
const UT_Vector3 P,
GA_Offset  offset,
float  default_pscale = 1 
) const

Create a 4x4 transform matrix given a position (P) and an attribute element for which the GA_ROHandle objects are valid.

If the "pscale" attribute is invalid, the default_pscale will be used.

Note
The position (P) is passed in since the attribute handles may not be bound to point attributes.
void GA_AttributeInstanceMatrix::getMatrix ( UT_Matrix4D xform,
const UT_Vector3D P,
GA_Offset  offset,
fpreal  default_pscale = 1 
) const

Create a 4x4 transform matrix given a position (P) and an attribute element for which the GA_ROHandle objects are valid.

If the "pscale" attribute is invalid, the default_pscale will be used.

Note
The position (P) is passed in since the attribute handles may not be bound to point attributes.
void GA_AttributeInstanceMatrix::getMatrix ( UT_Matrix3 xform,
GA_Offset  offset 
) const

Create a 3x3 transform matrix ignoring translate components Will include scale if still present!

void GA_AttributeInstanceMatrix::getMatrix ( UT_DMatrix3 xform,
GA_Offset  offset 
) const
void GA_AttributeInstanceMatrix::getMatrix ( UT_Matrix4 xform,
const UT_Vector3 P,
const UT_Quaternion orient,
GA_Offset  offset,
float  default_pscale = 1 
) const

Create a 4x4 transform matrix given a position (P), an orientaiton (orient), and an attribute element for which the GA_ROHandle objects are valid.

The provided orientation will be used instead of any rotation attributes on the geometry, but the translation and pivot attributes will still be used.

If the "pscale" attribute is invalid, the default_pscale will be used.

Note
The position (P) is passed in since the attribute handles may not be bound to point attributes.
void GA_AttributeInstanceMatrix::getMatrix ( UT_Matrix4D xform,
const UT_Vector3D P,
const UT_QuaternionD orient,
GA_Offset  offset,
fpreal  default_pscale = 1 
) const

Create a 4x4 transform matrix given a position (P), an orientaiton (orient), and an attribute element for which the GA_ROHandle objects are valid.

The provided orientation will be used instead of any rotation attributes on the geometry, but the translation and pivot attributes will still be used.

If the "pscale" attribute is invalid, the default_pscale will be used.

Note
The position (P) is passed in since the attribute handles may not be bound to point attributes.
const GA_ROHandleV3D& GA_AttributeInstanceMatrix::getN ( ) const
inline

Accessors

Definition at line 217 of file GA_AttributeInstanceMatrix.h.

const GA_ROHandleQD& GA_AttributeInstanceMatrix::getOrient ( ) const
inline

Accessors

Definition at line 223 of file GA_AttributeInstanceMatrix.h.

const GA_ROHandleV3D& GA_AttributeInstanceMatrix::getPivot ( ) const
inline

Accessors

Definition at line 224 of file GA_AttributeInstanceMatrix.h.

const GA_ROHandleD& GA_AttributeInstanceMatrix::getPscale ( ) const
inline

Accessors

Definition at line 220 of file GA_AttributeInstanceMatrix.h.

const GA_ROHandleV3D& GA_AttributeInstanceMatrix::getPscale3 ( ) const
inline

Accessors

Definition at line 221 of file GA_AttributeInstanceMatrix.h.

bool GA_AttributeInstanceMatrix::getRemoveScales ( ) const
inline

Accessors

Definition at line 227 of file GA_AttributeInstanceMatrix.h.

const GA_ROHandleQD& GA_AttributeInstanceMatrix::getRot ( ) const
inline

Accessors

Definition at line 222 of file GA_AttributeInstanceMatrix.h.

UT_Vector3D GA_AttributeInstanceMatrix::getScales ( GA_Offset  offset) const

Returns just the product of myPscale and myPscale3.

const GA_ROHandleV3D& GA_AttributeInstanceMatrix::getTrans ( ) const
inline

Accessors

Definition at line 219 of file GA_AttributeInstanceMatrix.h.

const GA_ROHandleV3D& GA_AttributeInstanceMatrix::getUp ( ) const
inline

Accessors

Definition at line 218 of file GA_AttributeInstanceMatrix.h.

const GA_ROHandleM3D& GA_AttributeInstanceMatrix::getXform3 ( ) const
inline

Accessors

Definition at line 225 of file GA_AttributeInstanceMatrix.h.

const GA_ROHandleM4D& GA_AttributeInstanceMatrix::getXform4 ( ) const
inline

Accessors

Definition at line 226 of file GA_AttributeInstanceMatrix.h.

bool GA_AttributeInstanceMatrix::hasAnyAttribs ( ) const

Returns true if there are any attributes bound.

bool GA_AttributeInstanceMatrix::hasNonScales ( ) const

Returns true if there are any attributes bound to anything other than myPscale or myPscale3

bool GA_AttributeInstanceMatrix::hasScales ( ) const

Returns true if myPscale or myPscale3 is bound.

void GA_AttributeInstanceMatrix::initialize ( const GA_AttributeDict dict,
const UT_StringRef N_name = GA_Names::N,
const UT_StringRef v_name = GA_Names::v 
)

Initialize attribute lookups based on an attribute dictionary This method scans for:

  • "vector v" or "vector N" (z-axis)
  • "vector up" (up vector for orientation)
  • "vector trans" (translation offset)
  • "vector scale" (per-axis scale)
  • "float pscale" (uniform scale)
  • "vector4 rot" (quaternion)
  • "vector4 orient" (quaternion)
  • "vector pivot" (pivot) N_name defines the name of the attribute to look up to determine orientation. If there is no attribute of the given name, then an attribute named v_name will be searched for.
void GA_AttributeInstanceMatrix::initialize ( const GA_AttributeDict dict,
const GA_Attribute N 
)

Initialize with a provided, possilby detached N.

void GA_AttributeInstanceMatrix::makeInvalid ( )
inline

Make invalid.

Definition at line 126 of file GA_AttributeInstanceMatrix.h.

void GA_AttributeInstanceMatrix::reset ( )

Clear out any attribute handles.

void GA_AttributeInstanceMatrix::resetScales ( )

Resets only the scale attributes.

void GA_AttributeInstanceMatrix::setN ( const GA_Attribute N)
inline

Overrides the N attribute with the specified attribute.

Definition at line 231 of file GA_AttributeInstanceMatrix.h.

Member Data Documentation

GA_ROHandleV3D GA_AttributeInstanceMatrix::myN

Definition at line 253 of file GA_AttributeInstanceMatrix.h.

GA_ROHandleQD GA_AttributeInstanceMatrix::myOrient

Definition at line 259 of file GA_AttributeInstanceMatrix.h.

GA_ROHandleV3D GA_AttributeInstanceMatrix::myPivot

Definition at line 260 of file GA_AttributeInstanceMatrix.h.

GA_ROHandleD GA_AttributeInstanceMatrix::myPscale

Definition at line 256 of file GA_AttributeInstanceMatrix.h.

GA_ROHandleV3D GA_AttributeInstanceMatrix::myPscale3

Definition at line 257 of file GA_AttributeInstanceMatrix.h.

bool GA_AttributeInstanceMatrix::myRemoveScales

Definition at line 263 of file GA_AttributeInstanceMatrix.h.

GA_ROHandleQD GA_AttributeInstanceMatrix::myRot

Definition at line 258 of file GA_AttributeInstanceMatrix.h.

GA_ROHandleV3D GA_AttributeInstanceMatrix::myTrans

Definition at line 255 of file GA_AttributeInstanceMatrix.h.

GA_ROHandleV3D GA_AttributeInstanceMatrix::myUp

Definition at line 254 of file GA_AttributeInstanceMatrix.h.

GA_ROHandleM3D GA_AttributeInstanceMatrix::myXform3

Definition at line 261 of file GA_AttributeInstanceMatrix.h.

GA_ROHandleM4D GA_AttributeInstanceMatrix::myXform4

Definition at line 262 of file GA_AttributeInstanceMatrix.h.

constexpr GA_DataId GA_AttributeInstanceMatrix::theAttribNotPresentDataId = GA_DataId(-2)
static

This uses GA_DataId(-2) to indicate an attribute not being present, to distinguish it from GA_DataId(-1), which is usually considered unequal even to itself.

Definition at line 242 of file GA_AttributeInstanceMatrix.h.

constexpr int GA_AttributeInstanceMatrix::theNumAttribs = 10
static

The number of attributes cached for use with transforms by this class. If an attribute gets added, be sure to update this and the getDataIds function implementation.

Definition at line 237 of file GA_AttributeInstanceMatrix.h.


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