- Main Page
- Related Pages
- Modules
- Classes
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Friends

# MGeometryData Class Reference

# OpenMayaRender - API module for rendering

This reference page is linked to from the following overview topics: A hardware shading node plug-in example.

Search for all occurrences

## Detailed Description

Geometric data container.

This class allows storage of arbitrary data which is formated to be specifically suitable for usage using a 3D display interface such as OpenGL.

Format options include:

- Currently, each element can be of a 1, 2, 3, 4 tuple.
- Element type can be IEEE single float or double float, signed or unsigned byte (character), 16 or 32 bit signed unsigned integers.

- There are specific "type" identifiers to provide a semantic on for the data. These include:

  - position : vertex position vector
  - normal : vertex normal vector
  - texCoord : vertextexture coordinate vector
  - color : vertex color vector
  - weight : vertex skin weight vector
  - tangent : vertex tangent vector
  - binormal : vertex binormal vector
  - velocity : vertex velocity vector
  - primitiveCenter : center a primitive (e.g. a triangle)
  - colorMask : colour existance mask. 1:1 correspondance with color
  - useData : some user defined data. A semantic that Maya does not understand.

Currently Maya only interprets a fixed format subset for data with recongnized semantics, This does not mean that the user cannot create any arbitrary format for data storage. Support formats with semantics includes:

- 3 float position interpreted as (x,y,z).
- 3 float normal interpreted as (x,y,z).
- 2 float texture coordinate. Coorindate is interpreted as a (U,V) tuple.
- 4 float color. Color is interpreted as (Red, Green, Blue, Alpha) tuple.
- 3 float tangent interpreted as (x,y,z).
- 3 float binormal interpreted as (x,y,z).
- 3 float velocity interpreted as (x,y,z).
- 3 float primitive center position interpreted as (x,y,z).
- 1 float color mask interpreted as 1=mapped, and 0 = unmapped.

Memory allocation of the correct size is left up to the user of this class.

Memory can be marked as "owned" by this class or the user of this class. Ownership by this class is the default behaviour specified in the constructor. If the data is marked as being owned by the class, it is assumed that the data is created using a "new" operation, as the destructor of this class will use a "delete" operation to free memory.

Internal Maya data which is passed to the user via this class is always assumed to be non-modifiable. If modified, stability cannot be ensured.

Examples:

  cgfxShaderNode.cpp, D3DGeometryItem.cpp, GLSLShaderNode.cpp, GLSLShaderNode.h, hlslShader.cpp, hwColorPerVertexShader.cpp, hwPhongShader.cpp, hwPhongShader.h, and OpenGLViewportRenderer.cpp.

`#include <MGeometryData.h>`

List of all members.

## Public Types
enum | ElementSize { kInvalidElementSize = 0, kOne = 1, kTwo, kThree, kFour }
| Specifies the size or dimension of each data element of the storage. More...
enum | ElementType { kInvalidElementType = -1, kFloat = 0, kDouble, kChar, kUnsignedChar, kInt16, kUnsignedInt16, kInt32, kUnsignedInt32 }
| Specifies the data type of each data element of the storage. More...
enum | DataType { kInvalidDataType = 0, kPosition, kNormal, kTexCoord, kColor, kWeight, kAPISupported, kTangent, kBiNormal, kVelocity, kPrimitiveCenter, kColorMask, kUserData, kMaxDataTypeIndex }
| Specifies the data type of the storage array. More...
## Public Member Functions
| MGeometryData (const char *dataName, DataType dataType, ElementType elementType, ElementSize elementSize, unsigned int elementCount, void *dataPtr=NULL, bool ownsData=true)
| Geometry data constructor.
| MGeometryData (const MGeometryData &)
| Copy constructor.
| ~MGeometryData ()
| Class destructor.
const char * | objectName () const
| Return the logical name of the geometry.
int | uniqueID () const
| Return the per session unique identifier.
DataType | dataType () const
| Get the data type for the data.
ElementType | elementType () const
| Returns the data type.
unsigned int | elementTypeSize () const
| Return the element type size.
ElementSize | elementSize () const
| Return element size.
unsigned int | elementCount () const
| Return element count.
void * | data () const
| Retrieve a pointer to the internal data.
void | setCollectionNumber (int cn)
| Set the collection number for the object.
int | collectionNumber () const
| Get the collection number of the data.
void | setObjectOwnsData (bool val)
| Set ownship of the interal data.
bool | objectOwnsData () const
| Return if the MGeometryData object owns the internal data or not.
## Friends
class | MGeometry Search for all occurrences
class | MHardwareRenderer Search for all occurrences
class | MD3D9Renderer Search for all occurrences

## Member Enumeration Documentation

enum ElementSize

Search for all occurrences

Specifies the size or dimension of each data element of the storage.

Enumerator:

  kInvalidElementSize | Invalid element size. Search for all occurrences
  kOne | Single value. Search for all occurrences
  kTwo | 2-tuple Search for all occurrences
  kThree | 3-tuple Search for all occurrences
  kFour | 4-tuple Search for all occurrences

enum ElementType

Search for all occurrences

Specifies the data type of each data element of the storage.

Enumerator:

  kInvalidElementType | Invalid element type (default value) Search for all occurrences
  kFloat | IEEE single precision floating point. Search for all occurrences
  kDouble | IEEE double precision floating point. Search for all occurrences
  kChar | Signed char. Search for all occurrences
  kUnsignedChar | Unsigned char. Search for all occurrences
  kInt16 | Signed 16-bit integer. Search for all occurrences
  kUnsignedInt16 | Unsigned 16-bit integer. Search for all occurrences
  kInt32 | Signed 32-bit integer. Search for all occurrences
  kUnsignedInt32 | Unsigned 32-bit integer. Search for all occurrences

enum DataType

Search for all occurrences

Specifies the data type of the storage array.

Enumerator:

  kInvalidDataType | Invalid data type (default value) Search for all occurrences
  kPosition | Position vector. Search for all occurrences
  kNormal | Normal vector. Search for all occurrences
  kTexCoord | Texture coordinate tuple. Search for all occurrences
  kColor | Color tuple. Search for all occurrences
  kWeight | Vertex weighting data. Search for all occurrences
  kAPISupported | Separator to indicate native draw API supported types. Search for all occurrences
  kTangent | Tangent vector. Search for all occurrences
  kBiNormal | Bi-normal vector. Search for all occurrences
  kVelocity | Velocity vector. Search for all occurrences
  kPrimitiveCenter | Center of primitive. Search for all occurrences
  kColorMask | Mapped, unmapped color mask. Search for all occurrences
  kUserData | Arbitrary "user data". Search for all occurrences
  kMaxDataTypeIndex | Valid entries are < kMaxDataTypeIndex. Search for all occurrences

## Constructor & Destructor Documentation

MGeometryData | ( | const char * | dataName,
|  | MGeometryData::DataType | dataType,
|  | MGeometryData::ElementType | elementType,
|  | MGeometryData::ElementSize | elementSize,
|  | unsigned int | elementCount,
|  | void * | dataPtr = `NULL`,
|  | bool | ownsData = `true`
| ) |  |

Geometry data constructor.

Data is reference counted. On creation the reference count is set to be 1.

Parameters:

  [in] | dataName | name of the data
  [in] | dataType | type of data
  [in] | elementType | element type
  [in] | elementSize | size or dimension of an element. For example, a 3D position vector has three components per position (x, y, z) so it would have an elementSize of kThree.
  [in] | elementCount | element count
  [in] | dataPtr | pointer to contiguous block of data
  [in] | ownsData | flag to tell if the instance owns the data or not.

~MGeometryData | ( |  | ) |

Class destructor.

Automatically releases the associated image array.

## Member Function Documentation

const char * objectName | ( |  | ) | const

Search for all occurrences

Return the logical name of the geometry.

Returns:
  NULL or object name string pointer.

int uniqueID | ( |  | ) | const

Search for all occurrences

Return the per session unique identifier.

Returns:
  Unique data identifier. -1 on error.

MGeometryData::DataType dataType | ( |  | ) | const

Search for all occurrences

Get the data type for the data.

Returns:
  Geometry data type. MGeometryData::kInvalid on error.

MGeometryData::ElementType elementType | ( |  | ) | const

Search for all occurrences

Returns the data type.

Returns:
  Element type. MGeometryData::kInvalidElementType on error.

unsigned int elementTypeSize | ( |  | ) | const

Search for all occurrences

Return the element type size.

Returns:
  Size of element in bytes.

MGeometryData::ElementSize elementSize | ( |  | ) | const

Search for all occurrences

Return element size.

Returns:
  Element size. MGeometryData::kInvalidElementSize is returned on error.

unsigned int elementCount | ( |  | ) | const

Search for all occurrences

Return element count.

Returns:
  Element count. 0 is returned on error.

Examples:
  D3DGeometryItem.cpp, and hlslShader.cpp.

void * data | ( |  | ) | const

Search for all occurrences

Retrieve a pointer to the internal data.

Returns:
  Void pointer to the data. Pointer is NULL on error.

Examples:
  D3DGeometryItem.cpp, hlslShader.cpp, and OpenGLViewportRenderer.cpp.

void setCollectionNumber | ( | int | collectionNumber | ) |

Search for all occurrences

Set the collection number for the object.

Numbers less than 0 are invalid collection numbers.

Parameters:

  [in] | collectionNumber | The number to use

int collectionNumber | ( |  | ) | const

Search for all occurrences

Get the collection number of the data.

Collection numbers are zero-based.

Returns:
  -1 if failed. Else number greather than -1.

void setObjectOwnsData | ( | bool | value | ) |

Search for all occurrences

Set ownship of the interal data.

Parameters:

  [in] | value | ownership flag to set to.

bool objectOwnsData | ( |  | ) | const

Search for all occurrences

Return if the MGeometryData object owns the internal data or not.

Returns:
  True if owned internally, else false.

MGeometryData MGeometryData MGeometryData MGeometryData MGeometryData MGeometryData MGeometryData MGeometryData MGeometryData MGeometryData
MGeometryData MGeometryData MGeometryData MGeometryData MGeometryData MGeometryData MGeometryData MGeometryData MGeometryData MGeometryData