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

- Class List
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Static Public Member Functions

# MGeometry Class Reference

# OpenMayaRender - API module for rendering

Search for all occurrences

## Detailed Description

Class for working with geometric structures used to draw objects.

This class provides a means to specify and access geometric data used to draw objects in Viewport 2.0.

Objects of type MGeometry cannot be created or destroyed. They are only accessed through methods on draw override classes such as MPxShaderOverride or MPxGeometryOverride.

Each MGeometry object contains zero or more vertex buffers and zero or more index buffers. In read-only scenarios, these buffers describe geometry that is about to be drawn and can be used to bind custom shaders to the actual geometry streams on the GPU (see MPxShaderOverride for more details). In the non-read only scenario, MGeometry can be used to provide vertex and index data to Maya to use to draw Maya DAG objects with arbitrary shaders (see MPxGeometryOverride). In all cases the MGeometry instance owns the vertex and index buffers and manages their lifetimes.

Examples:

  cgfxShaderNode.cpp, hwColorPerVertexShader.cpp, and hwPhongShader.cpp.

`#include <MHWGeometry.h>`

List of all members.

## Public Types
enum | DataType { kInvalidType, kFloat, kDouble, kChar, kUnsignedChar, kInt16, kUnsignedInt16, kInt32, kUnsignedInt32 }
| Specifies data types to use with buffers. More...
enum | Semantic { kInvalidSemantic, kPosition, kNormal, kTexture, kColor, kTangent, kBitangent, kTangentWithSign }
| Specifies the semantic of a data buffer. More...
enum | Primitive { kInvalidPrimitive, kPoints, kLines, kLineStrip, kTriangles, kTriangleStrip, kAdjacentTriangles, kAdjacentTriangleStrip, kAdjacentLines, kAdjacentLineStrip, kPatch }
| Specifies the data primitive type constructed by the indexing array. More...
enum | DrawMode { kAll, kWireframe, kShaded }
| Specifies draw mode for render items. More...
## Public Member Functions
int | vertexBufferCount () const
| Get the number of vertex buffers contained in this MGeometry object.
const MVertexBuffer * | vertexBuffer (int index) const
| Get the vertex buffer stored at the given index.
MVertexBuffer * | vertexBuffer (int index)
| Get the vertex buffer stored at the given index.
MVertexBuffer * | createVertexBuffer (const MVertexBufferDescriptor &desc)
| Creates a vertex buffer which is owned by this object.
bool | addVertexBuffer (MVertexBuffer *buffer)
| Add a pre-created vertex buffer to this MGeometry object.
bool | deleteVertexBuffer (int index)
| Remove a vertex buffer from this object.
int | indexBufferCount () const
| Get the number of index buffers contained in this MGeometry object.
const MIndexBuffer * | indexBuffer (int index) const
| Get the index buffer stored at the given index.
MIndexBuffer * | indexBuffer (int index)
| Get the index buffer stored at the given index.
MIndexBuffer * | createIndexBuffer (MGeometry::DataType type)
| Creates an index buffer which is owned by this object.
bool | addIndexBuffer (MIndexBuffer *buffer)
| Add a pre-created index buffer to this MGeometry object.
bool | deleteIndexBuffer (int index)
| Remove an index buffer from this object.
## Static Public Member Functions
static const MString & | dataTypeString (MGeometry::DataType d)
| Get a logical string name for the data type.
static const MString & | semanticString (MGeometry::Semantic s)
| Get a logical string name for the semantic.
static const MString & | primitiveString (MGeometry::Primitive p)
| Get a logical string name for the primitive.
static const MString & | drawModeString (MGeometry::DrawMode d)
| Get a logical string name for the semantic.
static const char * | className ()
| Returns the name of this class.

## Member Enumeration Documentation

enum DataType

Search for all occurrences

Specifies data types to use with buffers.

Enumerator:

  kInvalidType | 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 Semantic

Search for all occurrences

Specifies the semantic of a data buffer.

Enumerator:

  kInvalidSemantic | Invalid data type (default value) Search for all occurrences
  kPosition | Position vector. Search for all occurrences
  kNormal | Normal vector. Search for all occurrences
  kTexture | Texture coordinate tuple. Search for all occurrences
  kColor | Color tuple. Search for all occurrences
  kTangent | Tangent vector. Search for all occurrences
  kBitangent | Bi-normal vector. Search for all occurrences
  kTangentWithSign | Tangent vector with winding order sign. Search for all occurrences

enum Primitive

Search for all occurrences

Specifies the data primitive type constructed by the indexing array.

Enumerator:

  kInvalidPrimitive | Default value is not valid. Search for all occurrences
  kPoints | List of points. Search for all occurrences
  kLines | List of lines. Search for all occurrences
  kLineStrip | A line strip. Search for all occurrences
  kTriangles | List of triangles. Search for all occurrences
  kTriangleStrip | A triangle strip. Search for all occurrences
  kAdjacentTriangles | A list of triangle with adjacency. Search for all occurrences
  kAdjacentTriangleStrip | A triangle strip with adjacency. Search for all occurrences
  kAdjacentLines | A list of lines with adjacency. Search for all occurrences
  kAdjacentLineStrip | A line strip with adjacency. Search for all occurrences
  kPatch | A patch. Search for all occurrences

enum DrawMode

Search for all occurrences

Specifies draw mode for render items.

Enumerator:

  kAll | Draw in all modes. Search for all occurrences
  kWireframe | Draw in wireframe mode only. Search for all occurrences
  kShaded | Draw in shaded mode only. Search for all occurrences

## Member Function Documentation

const MString & dataTypeString | ( | MGeometry::DataType | d | ) | `[static]`

Search for all occurrences

Get a logical string name for the data type.

Useful for debug printing.

Parameters:

  [in] | d | The data type

Returns:
  The data type string name

Examples:
  hwPhongShader.cpp.

const MString & semanticString | ( | MGeometry::Semantic | s | ) | `[static]`

Search for all occurrences

Get a logical string name for the semantic.

Useful for debug printing.

Parameters:

  [in] | s | The semantic

Returns:
  The semantic string name

Examples:
  hwPhongShader.cpp.

const MString & primitiveString | ( | MGeometry::Primitive | p | ) | `[static]`

Search for all occurrences

Get a logical string name for the primitive.

Useful for debug printing.

Parameters:

  [in] | p | The primitive

Returns:
  The primitive string name

Examples:
  hwPhongShader.cpp.

const MString & drawModeString | ( | MGeometry::DrawMode | d | ) | `[static]`

Search for all occurrences

Get a logical string name for the semantic.

Useful for debug printing.

Parameters:

  [in] | d | The draw mode

Returns:
  The semantic string name

int vertexBufferCount | ( |  | ) | const

Search for all occurrences

Get the number of vertex buffers contained in this MGeometry object.

Returns:
  The number of vertex buffers in this object

Examples:
  cgfxShaderNode.cpp, hwColorPerVertexShader.cpp, and hwPhongShader.cpp.

const MVertexBuffer * vertexBuffer | ( | int | index | ) | const

Search for all occurrences

Get the vertex buffer stored at the given index.

Note, the vertex buffer is owned by this MGeometry object.

Parameters:

  [in] | index | The index

Returns:
  A const pointer to the vertex buffer at the given index.

Examples:
  cgfxShaderNode.cpp, hwColorPerVertexShader.cpp, and hwPhongShader.cpp.

MVertexBuffer * vertexBuffer | ( | int | index | ) |

Search for all occurrences

Get the vertex buffer stored at the given index.

Note, the vertex buffer is owned by this MGeometry object.

Parameters:

  [in] | index | The index

Returns:
  A pointer to the vertex buffer at the given index.

MVertexBuffer * createVertexBuffer | ( | const MVertexBufferDescriptor & | desc | ) |

Search for all occurrences

Creates a vertex buffer which is owned by this object.

Returns the buffer for modification by the caller. Note that not all vertex buffer descriptors can be used to create vertex buffers as not all combinations of data types, dimensions and semantics are supported. If the descriptor is not supported this method will return NULL.

Parameters:

  [in] | desc | The descriptor for the buffer to create

Returns:
  A pointer to a vertex buffer object

bool addVertexBuffer | ( | MVertexBuffer * | buffer | ) |

Search for all occurrences

Add a pre-created vertex buffer to this MGeometry object.

Ownership of the buffer remains with the caller. Buffers cannot be added to the same object twice. Also, buffers created by MGeometry::createVertexBuffer() cannot be added to any other MGeometry object.

Parameters:

  [in] | buffer | The vertex buffer

Returns:
  True if successful

bool deleteVertexBuffer | ( | int | index | ) |

Search for all occurrences

Remove a vertex buffer from this object.

If this object owns the buffer it will also be destroyed.

Parameters:

  [in] | index | The index of the buffer to remove

Returns:
  True on success

int indexBufferCount | ( |  | ) | const

Search for all occurrences

Get the number of index buffers contained in this MGeometry object.

Returns:
  The number of index buffers in this object

Examples:
  cgfxShaderNode.cpp, hwColorPerVertexShader.cpp, and hwPhongShader.cpp.

const MIndexBuffer * indexBuffer | ( | int | index | ) | const

Search for all occurrences

Get the index buffer stored at the given index.

Note, the index buffer is owned by this MGeometry object.

Parameters:

  [in] | index | The index

Returns:
  A const pointer to the index buffer at the given index.

Examples:
  cgfxShaderNode.cpp, hwColorPerVertexShader.cpp, and hwPhongShader.cpp.

MIndexBuffer * indexBuffer | ( | int | index | ) |

Search for all occurrences

Get the index buffer stored at the given index.

Note, the index buffer is owned by this MGeometry object.

Parameters:

  [in] | index | The index

Returns:
  A pointer to the index buffer at the given index.

MIndexBuffer * createIndexBuffer | ( | MGeometry::DataType | type | ) |

Search for all occurrences

Creates an index buffer which is owned by this object.

Returns the buffer for modification by the caller. Note, not all data types are supported for index buffer creation. If a data type is not supported this method will return NULL.

Parameters:

  [in] | type | The type for the buffer

Returns:
  A pointer to a index buffer object

bool addIndexBuffer | ( | MIndexBuffer * | buffer | ) |

Search for all occurrences

Add a pre-created index buffer to this MGeometry object.

Ownership of the buffer remains with the caller. Buffers cannot be added to the same object twice. Also, buffers created by MGeometry::createIndexBuffer() cannot be added to any other MGeometry object.

Parameters:

  [in] | buffer | The index buffer

Returns:
  True if successful

bool deleteIndexBuffer | ( | int | index | ) |

Search for all occurrences

Remove an index buffer from this object.

If this object owns the buffer it will also be destroyed.

Parameters:

  [in] | index | The index of the buffer to remove

Returns:
  True on success

const char * className | ( |  | ) | `[static]`

Search for all occurrences

Returns the name of this class.

Returns:
  The name of this class.

MGeometry MGeometry MGeometry MGeometry MGeometry MGeometry MGeometry MGeometry MGeometry MGeometry
MGeometry MGeometry MGeometry MGeometry MGeometry MGeometry MGeometry MGeometry MGeometry MGeometry