#include
<MGeometryManager.h>
This class provides methods for managing MGeometry resources.
It provides an interface for loading and using hardware textures.
Public Types |
|
enum | GeometricShape { kDefaultSphere = 0, kDefaultPlane, kDefaultCube } |
Default geometry shapes. More... |
|
Static Public Member Functions |
|
static MGeometry | getGeometry (const MDagPath &shape, const MGeometryRequirements &requirements, MObject *components=NULL) |
static MGeometryList * | referenceDefaultGeometry (const MGeometryManager::GeometricShape geomShape, const MGeometryRequirements &requirements) |
static MStatus | dereferenceDefaultGeometry (MGeometryList *data) |
MGeometry MGeometryManager::getGeometry | ( | const MDagPath & | shape, | |
const MGeometryRequirements & | requirements, | |||
MObject * | components = NULL |
|||
) | [static] |
Access the Geometry cache for a shape.
[in] | shape | the surface |
[in] | requirements | the surface data you want in the cache. Attempting to access cache data not included in the requirements will fail. |
[in] | components | an optional component group, for accessing a sub-selection of faces (e.g. the faces assigned to a material) |
MGeometryList * MGeometryManager::referenceDefaultGeometry | ( | const MGeometryManager::GeometricShape | geomShape, | |
const MGeometryRequirements & | requirements | |||
) | [static] |
Obtain a reference to geometry for some "default" shapes maintained by the manager such that the geometry returned will match a set of geometric requirements (MGeometryRequirements). The actual form is a geometric iterator (MGeometryList), which can be used to iterate over the internal data kept (MGeometry).
Note that all data is assumed to be "read-only", as the data is not owned by the caller. To maintain proper reference counting of internal data, the user must "deference" the data when no longer using it via the MGeometryManager::dereferenceGeometry() calls. It is recommended to immediately dereference the data after each use. There is negligable overhead to reference and dereference data in this manner.
Available default shapes include:
{ // Set up a NULL path MDagPath path; // Get the requirements from the hardware shader MGeometryRequirements requirements; populateRequirements(path, requirements); // Ask for a default sphere MGeometryManager::GeometricShape shape = MGeometryManager::kDefaultSphere; MGeometryList* geomIter = MGeometryManager::referenceDefaultGeometry(shape, requirements); if(geomIter == NULL) { return MStatus::kFailure; } // Set up where to draw to .... // Now draw using the geometry iterator returned. // for( ; !geomIter->isDone(); geomIter->next()) { // Get the current geometry MGeometry& geometry = geomIter->geometry(MGeometryList::kNone); // Get the current object to world matrix const MMatrix& mtm = geomIter->objectToWorldMatrix(); glMatrixMode(GL_MODELVIEW); glLoadMatrixd(mtm[0]); // Get some data tro draw MGeometryPrimitive primitives = geometry.primitiveArray(0); const MGeometryData pos = geometry.position(); const MGeometryData normal = geometry.normal(); if (pos.data() != NULL && primitives.data() != NULL) { // Set up position and normals for drawing // glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, (float*) pos.data()); if (normal.data()) { glEnableClientState(GL_NORMAL_ARRAY); glNormalPointer(GL_FLOAT, 0, normal.data()); } // Draw with the current indexing structure MGeometryPrimitive primitives = geometry.primitiveArray(0); glDrawElements(GL_TRIANGLES, primitives.elementCount(), GL_UNSIGNED_INT, primitives.data()); glDisableClientState(GL_VERTEX_ARRAY); if (normal.data()) glDisableClientState(GL_NORMAL_ARRAY); } } // Now dereference the geometry iterator used. MGeometryManager::dereferenceDefaultGeometry(geomIter); }
[in] | geomShape | Desired geometry shape. |
[in] | requirements | Geometry requirements (MGeometryRequirements). |
MStatus MGeometryManager::dereferenceDefaultGeometry | ( | MGeometryList * | geomIterator | ) | [static] |
This is the companion method to referenceDefaultGeometry() and must always be called immediately after usage of data supplied by the reference call.
This call simply maintains proper internal state for any data used.
[in] | geomIterator | The geometry iterator returned from referenceDefaultGeometry(). |
Autodesk® Maya® 2011 © 1997-2010 Autodesk, Inc. All rights reserved. | Generated with 1.5.6 |