MGeometry Class Reference


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
}
 

Specifies the semantic of a data buffer.

More...
enum   Primitive {
  kInvalidPrimitive, kPoints, kLines, kLineStrip,
  kTriangles, kTriangleStrip
}
 

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  deleteVertexBuffer (int index)
  Remove and destroy 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  deleteIndexBuffer (int index)
  Remove and destroy 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

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.

Specifies the data primitive type constructed by the indexing array.

Enumerator:
kInvalidPrimitive 

Default value is not valid.

kPoints 

Corresponds to GL_POINTS in OpenGL.

kLines 

Corresponds to GL_LINES in OpenGL.

kLineStrip 

Corresponds to GL_LINE_STRIP in OpenGL.

kTriangles 

Corresponds to GL_TRIANGLES In OpenGL.

kTriangleStrip 

Corresponds to GL_TRIANGLE_STRIP in OpenGL.

enum DrawMode

Specifies draw mode for render items.

Enumerator:
kAll 

Draw in all modes.

kWireframe 

Draw in wireframe mode only.

kShaded 

Draw in shaded mode only.


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] d The 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] s The 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] p The 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] d The 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] 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 )

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 )

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 deleteVertexBuffer ( int  index )

Remove and destroy a vertex buffer from this object.

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

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 )

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 deleteIndexBuffer ( int  index )

Remove and destroy an index buffer from this object.

Parameters:
[in] index The 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