This reference page is linked to from the following overview topics: 2.2 Geometric Data (MGeometry).



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 { kWireframe = (0x1 << 1), kShaded = (0x1 << 2), kTextured = (0x1 << 3), kAll = (kWireframe | kShaded | kTextured) }
 

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 MVertexBuffervertexBuffer (int index) const
 Get the vertex buffer stored at the given index.
MVertexBuffervertexBuffer (int index)
 Get the vertex buffer stored at the given index.
MVertexBuffercreateVertexBuffer (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 MIndexBufferindexBuffer (int index) const
 Get the index buffer stored at the given index.
MIndexBufferindexBuffer (int index)
 Get the index buffer stored at the given index.
MIndexBuffercreateIndexBuffer (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 MStringdataTypeString (MGeometry::DataType d)
 Get a logical string name for the data type.
static const MStringsemanticString (MGeometry::Semantic s)
 Get a logical string name for the semantic.
static const MStringprimitiveString (MGeometry::Primitive p)
 Get a logical string name for the primitive.
static const MStringdrawModeString (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

Specifies data types to use with buffers.

Enumerator:
kInvalidType 

Invalid element type (default value)

kFloat 

IEEE single precision floating point.

kDouble 

IEEE double precision floating point.

kChar 

Signed char.

kUnsignedChar 

Unsigned char.

kInt16 

Signed 16-bit integer.

kUnsignedInt16 

Unsigned 16-bit integer.

kInt32 

Signed 32-bit integer.

kUnsignedInt32 

Unsigned 32-bit integer.

enum Semantic

Specifies the semantic of a data buffer.

Enumerator:
kInvalidSemantic 

Invalid data type (default value)

kPosition 

Position vector.

kNormal 

Normal vector.

kTexture 

Texture coordinate tuple.

kColor 

Color tuple.

kTangent 

Tangent vector.

kBitangent 

Bi-normal vector.

kTangentWithSign 

Tangent vector with winding order sign.

enum Primitive

Specifies the data primitive type constructed by the indexing array.

Enumerator:
kInvalidPrimitive 

Default value is not valid.

kPoints 

List of points.

kLines 

List of lines.

kLineStrip 

A line strip.

kTriangles 

List of triangles.

kTriangleStrip 

A triangle strip.

kAdjacentTriangles 

A list of triangle with adjacency.

kAdjacentTriangleStrip 

A triangle strip with adjacency.

kAdjacentLines 

A list of lines with adjacency.

kAdjacentLineStrip 

A line strip with adjacency.

kPatch 

A patch.

enum DrawMode

Specifies draw mode for render items.

Enumerator:
kWireframe 

Draw in wireframe mode only.

kShaded 

Draw in shaded mode only.

kTextured 

Draw in textured mode only.

kAll 

Draw in all modes.


Member Function Documentation

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

Get a logical string name for the data type.

Useful for debug printing.

Parameters:
[in]dThe data type
Returns:
The data type string name
Examples:
hwPhongShader.cpp.
const MString & semanticString ( MGeometry::Semantic  s) [static]

Get a logical string name for the semantic.

Useful for debug printing.

Parameters:
[in]sThe semantic
Returns:
The semantic string name
Examples:
hwPhongShader.cpp.
const MString & primitiveString ( MGeometry::Primitive  p) [static]

Get a logical string name for the primitive.

Useful for debug printing.

Parameters:
[in]pThe primitive
Returns:
The primitive string name
Examples:
hwPhongShader.cpp.
const MString & drawModeString ( MGeometry::DrawMode  d) [static]

Get a logical string name for the semantic.

Useful for debug printing.

Parameters:
[in]dThe draw mode
Returns:
The semantic string name
int vertexBufferCount ( ) const

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

Get the vertex buffer stored at the given index.

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

Parameters:
[in]indexThe 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)

Get the vertex buffer stored at the given index.

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

Parameters:
[in]indexThe index
Returns:
A pointer to the vertex buffer at the given index.
MVertexBuffer * createVertexBuffer ( const MVertexBufferDescriptor desc)

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]descThe descriptor for the buffer to create
Returns:
A pointer to a vertex buffer object
bool addVertexBuffer ( MVertexBuffer buffer)

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]bufferThe vertex buffer
Returns:
True if successful
bool deleteVertexBuffer ( int  index)

Remove a vertex buffer from this object.

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

Parameters:
[in]indexThe index of the buffer to remove
Returns:
True on success
int indexBufferCount ( ) const

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

Get the index buffer stored at the given index.

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

Parameters:
[in]indexThe 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)

Get the index buffer stored at the given index.

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

Parameters:
[in]indexThe index
Returns:
A pointer to the index buffer at the given index.
MIndexBuffer * createIndexBuffer ( MGeometry::DataType  type)

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]typeThe type for the buffer
Returns:
A pointer to a index buffer object
bool addIndexBuffer ( MIndexBuffer buffer)

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]bufferThe index buffer
Returns:
True if successful
bool deleteIndexBuffer ( int  index)

Remove an index buffer from this object.

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

Parameters:
[in]indexThe index of the buffer to remove
Returns:
True on success
const char * className ( ) [static]

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