MFnSubd Class Reference
[OpenMaya - API module for common classesFunctionSet classes]

#include <MFnSubd.h>

Inheritance diagram for MFnSubd:

Inheritance graph
[legend]
Collaboration diagram for MFnSubd:

Collaboration graph
[legend]

List of all members.


Detailed Description

Subdivision surface function set.

This function set provides access to subdivision surfaces. Objects of type MFn::kSubdiv, MFn::kSubdivData, and MFn::kSubdivGeom are supported. MFn::kSubdiv objects are shapes in the DAG, MFn::kSubdivGeom objects are the raw geometry that the shapes use, and MFn::kSubdivData objects are the data that is passed through dependency graph connections.

Maya implements fully hierarchical Catmull-Clark quad based subdivision surfaces. You can use them without any hierarchical edits, but their full power is only realized when you do use the hierarchy. Using the hierarchy lets you access additional vertices on the existing faces. For example, a single 4 vertex plane can give you access, through hierarchy, to over 16,000,000 points at the finest level of the hierarchy (please don't try it). Additionally, the points at the finer levels are created only as you need them and only in the areas where you need them, giving you an implied level of detail workflow.

The "base" mesh is sometimes used to describe the coarsest level of the hierarchy. Once we go one level finer (to level "1") all faces are four sided (though not all vertices are of valence 4). At that point, each face can be considered to have 4 "children" faces. Starting with a 4 vertex single face plane, there will be 4 faces (and 9 vertices) at level 1, 16 faces (and 25 vertices) at level 2, etc. You can go as deep as level 12.

Please consult Maya documentation on subdivision surfaces for more details.

Subdivision Surface Construction Subdivision surfaces are created by specifying a base polygonal mesh, hierarchical edits (optional) and creases (optional).

The base mesh contains a vertex list, a list of vertex counts per-polygon, and a list of vertices that make up the polygons. If you are familiar with the creation of polygonal meshes, this is exactly equivalent to that setup. With a small set of limitations, any polygonal object can be converted into a subdivision surface. The current limitations are:

The easiest way to create a subdivision surface is probably to use polyToSubdiv MEL command to create it from a polygon. Alternativelly, the same functionality is available through the API using createFromPolygon method.

Alternatively, you can create a subdivision surface either by converting an existing NURBS surface with createFromNurbsSurface or directly, by specifying vertex lists, vertex connections lists, etc. The last method will look familiar to those that have used MFnMesh::create method to create a polygon.

The following lists are used by the create method to construct a subdivision surface:

Texture Coordinates (UV's) You can optionally specify texture (uv) coordinates. UV coordinates are 2-d coordinates used for mapping textures to the polygons of a surface. Each polygon contains as many UV's as it has vertices. The UV values are not shared and you can think of them as "owned" by a polygon, rather than each vertex in that polygon.

Subdivision Surface Component API Names

In order to successfully use the subdivision surface API, you need to familiarize yourself with the naming convention used for its components within the API.

In the polygon case, we simply number the vertices 0, 1, ... N-1. The faces and the edges and the faces are numbered similarly.

For the subdivision surfaces, this is not the case, mostly because of the hierarchical approach we took. Since it would be prohibitive to instantiate all the faces all the time (think of those 16M that can from just one original face) the names have to be order of creation independent.

The simplest way to think about each API name is "start with a face and follow a path into the finer levels of the hierarchy recording each turn along the way".

Here's some details. You should also consult MFnSubdNames class which contains a number of helpful methods for interpreting, creating and modifying the component API names. While this will take some getting used to, the good news is that instantiating more vertices does not change the names of the existing ones (unless you're adding more level 0 vertices) so any vertex animation, etc. will not be affected by a need to model more detail into another part of the surface.

For the subdivision surfaces, the most important names are those of the faces. Given a face name, each vertex on that face is named based on that face. That does mean that each vertex will typically have more than one name. Maya will always give you a unique name by choosing the one that is numerically the smallest (in the 64 bit sense).
Examples:

pointOnSubdNode.cpp.


Public Member Functions

virtual MFn::Type type () const
 Function set type.
virtual ~MFnSubd ()
 Destructor.
 MFnSubd ()
 Default constructor.
 MFnSubd (MObject &object, MStatus *ReturnStatus=NULL)
 Constructor.
 MFnSubd (const MDagPath &object, MStatus *ret=NULL)
 Constructor.
MObject createBaseMesh (bool reverseNormal, int numVertices, int numPolygons, const MPointArray &vertexArray, const MIntArray &polygonCounts, const MIntArray &polygonConnects, MObject parentOrOwner=MObject::kNullObj, MStatus *ReturnStatus=NULL)
MObject copy (const MObject &source, MObject parentOrOwner=MObject::kNullObj, MStatus *ReturnStatus=NULL)
MObject collapse (const int level, bool makeNewNodeInvisible, MStatus *ReturnStatus=NULL)
int vertexBaseMeshAdd (double x, double y, double z, MStatus *ReturnStatus=NULL)
MUint64 polygonBaseMeshAdd (int vertexCount, const int vertexIds[], MStatus *ReturnStatus=NULL)
MUint64 polygonBaseMeshAddWithUVs (int vertexCount, const int vertexIds[], const double uValues[], const double vValues[], MStatus *ReturnStatus=NULL)
int editsPending (MStatus *ReturnStatus=NULL) const
void editsUpdateAll (MStatus *ReturnStatus=NULL)
unsigned int levelMaxCurrent (MStatus *ReturnStatus=NULL) const
unsigned int levelMaxAllowed (MStatus *ReturnStatus=NULL) const
void levelFullySubdivideTo (int level, MStatus *ReturnStatus=NULL)
unsigned int vertexCount (int level=0, MStatus *ReturnStatus=NULL) const
MUint64 vertexIdFromBaseVertexIndex (int baseVertexIndex, MStatus *ReturnStatus=NULL) const
int vertexBaseIndexFromVertexId (MUint64 vertexId, MStatus *ReturnStatus=NULL) const
MStatus vertexEditsGetAllNonBase (MUint64Array &vertexIds, MVectorArray &edits, MSpace::Space space=MSpace::kObject) const
MStatus vertexEditsSetAllNonBase (const MUint64Array &vertexIds, const MVectorArray &edits, MSpace::Space space=MSpace::kObject)
MStatus vertexEditsClearAllNonBase ()
MStatus vertexPositionGet (MUint64 vertId, MPoint &position, MSpace::Space space=MSpace::kObject) const
MStatus vertexEditGet (MUint64 vertId, MVector &edit, MSpace::Space space=MSpace::kObject) const
MStatus vertexPositionGetNoEdit (MUint64 vertId, MPoint &position, MSpace::Space space=MSpace::kObject) const
MStatus vertexPositionSet (MUint64 vertId, const MPoint &position, bool updateEdits, MSpace::Space space=MSpace::kObject)
MStatus vertexEditSet (MUint64 vertId, const MVector &edit, bool updateEdits, MSpace::Space space=MSpace::kObject)
MStatus vertexBaseMeshGet (MPointArray &positions, MSpace::Space space=MSpace::kObject) const
MStatus vertexBaseMeshSet (const MPointArray &positions, MSpace::Space space=MSpace::kObject)
MStatus vertexBaseMeshGetWithId (MPointArray &positions, MUint64Array &vertexIds, MSpace::Space space=MSpace::kObject) const
MStatus vertexBaseMeshSetWithId (const MPointArray &positions, const MUint64Array &vertexIds, MSpace::Space space=MSpace::kObject)
int vertexValence (MUint64 vertId, MStatus *ReturnStatus=NULL) const
MStatus vertexNormal (MUint64 vertId, MVector &normal) const
MStatus vertexAdjacentVertices (MUint64 vertId, MUint64Array &vertList) const
MStatus vertexIncidentEdges (MUint64 vertId, MUint64Array &edgeList) const
MStatus vertexIncidentPolygons (MUint64 vertId, MUint64Array &polyList) const
bool vertexIsBoundary (MUint64 vertId, MStatus *ReturnStatus=NULL) const
bool vertexIsValid (MUint64 vertId, MStatus *ReturnStatus=NULL) const
bool vertexIsCreased (MUint64 vertId, MStatus *ReturnStatus=NULL) const
bool vertexCreaseRelevant (MUint64 vertId, MStatus *ReturnStatus=NULL) const
MStatus vertexSetCrease (MUint64 vertId, bool creased) const
MStatus vertexChildren (MUint64 vertId, MUint64Array &children) const
MStatus creasesGetAll (MUint64Array &vertexIds, MUint64Array &edgeIds) const
MStatus creasesSetAll (const MUint64Array &vertexIds, const MUint64Array &edgeIds)
MStatus creasesClearAll () const
MStatus updateAllEditsAndCreases ()
unsigned int edgeCount (int level=0, MStatus *ReturnStatus=NULL) const
MUint64 edgeBetween (MUint64 vertex1, MUint64 vertex2, MStatus *ReturnStatus=NULL) const
MStatus edgeVertices (MUint64 edge, MUint64 &v1, MUint64 &v2) const
MStatus edgeAdjacentPolygon (MUint64 edge, MUint64Array &polys) const
bool edgeIsBoundary (MUint64 edge, MStatus *ReturnStatus=NULL) const
bool edgeIsValid (MUint64 edgeId, MStatus *ReturnStatus=NULL) const
bool edgeIsCreased (MUint64 edgeId, MStatus *ReturnStatus=NULL) const
bool edgeCreaseRelevant (MUint64 edgeId, MStatus *ReturnStatus=NULL) const
MStatus edgeSetCrease (MUint64 edgeId, bool creased) const
MStatus edgeChildren (MUint64 edgeId, MUint64Array &children) const
unsigned int polygonCount (int level=0, MStatus *ReturnStatus=NULL) const
int polygonCountMaxWithGivenBaseMesh (int level=1, MStatus *ReturnStatus=NULL) const
unsigned int polygonVertexCount (MUint64 polyId, MStatus *ReturnStatus=NULL) const
MStatus polygonVertices (MUint64 polyId, MUint64Array &vertIds) const
unsigned int polygonEdgeCount (MUint64 polyId, MStatus *ReturnStatus=NULL) const
MStatus polygonEdges (MUint64 polyId, MUint64Array &edgeIds) const
bool polygonIsValid (MUint64 polyId, MStatus *ReturnStatus=NULL) const
bool polygonHasChildren (MUint64 polyId, MStatus *ReturnStatus=NULL) const
MStatus polygonChildren (MUint64 polyId, MUint64Array &children) const
MStatus polygonSubdivide (MUint64 polyId)
MStatus polygonSetUseUVs (MUint64 polyId, bool useThem)
bool polygonHasVertexUVs (MUint64 polyId, MStatus *ReturnStatus=NULL)
MStatus polygonGetVertexUVs (MUint64 polyId, MDoubleArray &uValues, MDoubleArray &vValues) const
MStatus polygonSetVertexUVs (MUint64 polyId, const MDoubleArray &uValues, const MDoubleArray &vValues)
MStatus polygonGetCenterUV (MUint64 polyId, double &u, double &v) const
MStatus evaluatePosition (MUint64 polyId, double u, double v, bool uvNormalized, MPoint &) const
MStatus evaluateNormal (MUint64 polyId, double u, double v, bool uvNormalized, MVector &nrml) const
MStatus evaluatePositionAndNormal (MUint64 polyId, double u, double v, bool uvNormalized, MPoint &pos, MVector &nrml) const
bool getCubicSpline (MUint64 polyId, MPointArray vertices, MStatus *ReturnStatus=NULL)
MStatus getConnectedSetsAndMembers (unsigned int instanceNumber, MObjectArray &sets, MObjectArray &comps, bool renderableSetsOnly) const
MStatus getConnectedShaders (unsigned int instanceNumber, MObjectArray &shaders, MUint64Array &faces, MIntArray &indices) const
MObject tesselate (bool uniform, int depth, int sample, MObject parentOrOwner=MObject::kNullObj, MStatus *ReturnStatus=NULL)
MObject tessellateViaNurbs (MObject parentOrOwner=MObject::kNullObj, MStatus *ReturnStatus=NULL)
MStatus convertToNurbs (MObjectArray &newNurbsSurfaces)
MStatus updateSubdSurface ()
MStatus vertexBaseMeshAddWithIndex (double x, double y, double z, int index)
 MFnSubd (const MObject &object, MStatus *ret=NULL)
 Constructor.
bool getCubicSpline (MUint64 polyId, MPoint vertices[16], MStatus *ReturnStatus=NULL)
 NO SCRIPT SUPPORT.

Protected Member Functions

virtual const char * className () const
 Class name.

Constructor & Destructor Documentation

MFnSubd::~MFnSubd (  )  [virtual]

Destructor.

Class destructor.

MFnSubd::MFnSubd ( MObject object,
MStatus ReturnStatus = NULL 
)

Constructor.

Class constructor that initializes the function set to the given MObject.

Parameters:
[in] object The MObject to attach the function set to
[out] ReturnStatus the return status
Status Codes:

MFnSubd::MFnSubd ( const MDagPath object,
MStatus ReturnStatus = NULL 
)

Constructor.

Class constructor that initializes the function set to the given constant MDagPath object.

Parameters:
[in] object The const MDagPath to attach the function set to
[out] ReturnStatus The return status
Status Codes:

MFnSubd::MFnSubd ( const MObject object,
MStatus ReturnStatus = NULL 
)

Constructor.

Class constructor that initializes the function set to the given MObject.

Parameters:
[in] object The MObject to attach the function set to
[out] ReturnStatus the return status
Status Codes:


Member Function Documentation

MFn::Type MFnSubd::type (  )  const [virtual]

Function set type.

Return the class type : MFn::kSubdiv

Reimplemented from MFnDagNode.

const char * MFnSubd::className (  )  const [protected, virtual]

Class name.

Return the class name : "MFnSubd"

Reimplemented from MFnDagNode.

MObject MFnSubd::createBaseMesh ( bool  reverseNormal,
int  numVertices,
int  numPolygons,
const MPointArray vertexArray,
const MIntArray polygonCounts,
const MIntArray polygonConnects,
MObject  parentOrOwner = MObject::kNullObj,
MStatus ReturnStatus = NULL 
)

Creates a new subdivision surface given an array of vertices and connection information and sets this function set to operate on the new surface.

This method is meant to be as efficient as possible and thus assumes that all the given data is topologically correct.

The parentOrOwner argument is used to specify the owner of the new surface.

If the parentOrOwner is kSubdivData then the created surface will be of type kSubdivGeom and will be returned. The parentOrOwner will become the owner of the new subdivision surface.

If parentOrOwner is NULL then a new transform will be created and returned which will be the parent for the subdivision surface. The new transform will be added to the DAG.

If parentOrOwner is a DAG node then the new subdivision surface will be returned and the parentOrOwner will become its parent.

Parameters:
[in] numVertices number of vertices
[in] numPolygons number of polygons
[in] vertexArray point (vertex) array
[in] polygonCounts array of vertex counts for each polygon
[in] polygonConnects array of vertex connections for each polygon
[in] parentOrOwner parent of the polygon that will be created
[out] ReturnStatus Status code
Returns:
  • If parentOrOwner is NULL then the transform for this surface is returned
  • If parentOrOwner is a DAG object then the new surface shape is returned
  • The surface geometry is returned if parentOrOwner is of type kSubdivData
Status Codes:
  • Array length does not match given item count
  • ParentOrOwner was not valid
  • There was no model present to add the object to

MObject MFnSubd::copy ( const MObject source,
MObject  parentOrOwner = MObject::kNullObj,
MStatus ReturnStatus = NULL 
)

This method creates a copy of a given source subdivision surface. After the copy this function set will operate on the new subdivision surface.

The parentOrOwner argument is used to specify the owner of the new surface.

If the parentOrOwner is kSubdivData then the created surface will be of type kSubdivGeom and will be returned. The parentOrOwner will become the owner of the new subdivision surface.

If parentOrOwner is NULL then a new transform will be created and returned which will be the parent for the subdivision surface. The new transform will be added to the DAG.

If parentOrOwner is a DAG node then the new subdivision surface will be returned and the parentOrOwner will become its parent.

Parameters:
[in] source the subdivision surface to be copied
[in] parentOrOwner the DAG parent or kSubdivData the new subdivision surface will belong to
[out] ReturnStatus Status code
Returns:
  • If parentOrOwner is NULL then the transform for this surface is returned
  • If parentOrOwner is a DAG object then the new surface shape is returned
  • The surface geometry is returned if parentOrOwner is of type kSubdivData
Status Codes:
  • parentOrOwner was not valid
  • if the source object is not one of kSubdivGeom, kSubdivData, kSubdiv
  • dataSubdiv or underlying geometry was null
  • Source object was null
  • There was no model present to add the object to

MObject MFnSubd::collapse ( const int  level,
bool  makeNewNodeInvisible,
MStatus ReturnStatus = NULL 
)

This method creates a copy of a given source subdivision surface collapsed by the given number of levels. After the collapse this function set will operate on the new subdivision surface.

As an example, a collapse of one level means the level one vertices of the current subdivision surface become the level zero vertices of the new subdivision surface.

Be careful passing in a large value for the level, as each level of collapse increases the number of faces on the new subdivision surface significantly.

Collapsing a surface by one level means that the resulting surface is all quads. This can be useful in certain situations.

NOTE: the collapse() method will fail if the function set has not been initialized with a dag path.

Parameters:
[in] level the number of levels of the hierarchy to collapse
[in] makeNewNodeInvisible sets the invisible attribute of the new node
[out] ReturnStatus Status code
Returns:
The new collapsed subdivision object
Status Codes:

int MFnSubd::vertexBaseMeshAdd ( double  x,
double  y,
double  z,
MStatus ReturnStatus = NULL 
)

Add a vertex to the base mesh and return its "index" name. Note that it will not have a valid 64-bit name until you actually create a polygon that holds it.

Parameters:
[in] x X location of the vertex
[in] y Y location of the vertex
[in] z Z location of the vertex
[out] ReturnStatus Status code
Returns:
The index of the newly created vertex. It will be -1 if the creation failed.
Status Codes:

MUint64 MFnSubd::polygonBaseMeshAdd ( int  vertexCount,
const int  vertexIndex[],
MStatus ReturnStatus = NULL 
)

Add a polygon at the base mesh level. You will need to use the index names of the vertices (remember, they get their 64-bit names only after they have been added to a polygon).

Parameters:
[in] vertexCount Number of vertices in the polygon
[in] vertexIndex The vertex indices (0, 1, 2, ...)
[out] ReturnStatus Status code
Returns:
The name of the newly created polygon
Status Codes:

MUint64 MFnSubd::polygonBaseMeshAddWithUVs ( int  vertexCount,
const int  vertexIds[],
const double  uValues[],
const double  vValues[],
MStatus ReturnStatus = NULL 
)

Add a polygon at the base mesh level. You will need to use the index names of the vertices (remember, they get their 64-bit names only after they have been added to a polygon). Specify the UV values as well.

Parameters:
[in] vertexCount Number of vertices in the polygon
[in] vertexIds The vertex indices (0, 1, 2, ...)
[out] ReturnStatus Status code
Returns:
The name of the newly created polygon
Status Codes:

int MFnSubd::editsPending ( MStatus ReturnStatus = NULL  )  const

As the new hierarchical vertex offsets are being introduced, you can choose to not apply them to the surface immediatelly. If you do that, the number of edits pending will increase. Any edits are not actually made until you call "updateEdits". This functions lets you know if you need to call it or not.

Parameters:
[out] ReturnStatus Status code
Returns:
Edits pending (1) or not (0).
Status Codes:

void MFnSubd::editsUpdateAll ( MStatus ReturnStatus = NULL  ) 

If there are pending edits, this function will update the surface so that there are no pending edits.

Parameters:
[out] ReturnStatus Status code
Status Codes:

unsigned int MFnSubd::levelMaxCurrent ( MStatus ReturnStatus = NULL  )  const

Returns the finest level that currently exist. As int as a single face exists at a level, that level is counted. Note that this not mean that all of the faces exist on all levels.

Parameters:
[out] ReturnStatus Status code
Returns:
The finest level in the hierarchy
Status Codes:

unsigned int MFnSubd::levelMaxAllowed ( MStatus ReturnStatus = NULL  )  const

Returns the maximum level that can be created. You should probably avoid fully subdividing the surface to that level as you will most likelly just run out of memory.

Parameters:
[out] ReturnStatus Status code
Returns:
The maximum possibly value for the finest level in the hierarchy
Status Codes:

void MFnSubd::levelFullySubdivideTo ( int  level,
MStatus ReturnStatus = NULL 
)

Fully subdivide the whole surface to the specified level. This could be very expensive, so be careful, or you will run out of memory. As a rule, each level has 4 times more faces than the previous one.

Parameters:
[in] level The level to which to fully subdivide
[out] ReturnStatus Status code
Status Codes:

unsigned int MFnSubd::vertexCount ( int  level = 0,
MStatus ReturnStatus = NULL 
) const

Returns the finest vertex count at a particular level. These are the vertices that are currently instantiated.

Parameters:
[in] level The level we are interested in
[out] ReturnStatus Status code
Returns:
The number of vertices at the given level
Status Codes:

MUint64 MFnSubd::vertexIdFromBaseVertexIndex ( int  baseVertexIndex,
MStatus ReturnStatus = NULL 
) const

Vertices are named using 64-bit integers. The base mesh vertices will also have a simple 0, 1, 2, N-1 indices. Use this function to compute the proper 64-bit name using the 0, 1, 2, ... indices.

Parameters:
[in] baseVertexIndex The index in the base mesh vertex array of this vertex
[out] ReturnStatus Status code
Returns:
The 64-bit name of the vertex
Status Codes:

int MFnSubd::vertexBaseIndexFromVertexId ( MUint64  vertexId,
MStatus ReturnStatus = NULL 
) const

Given a 64-bit id of the vertex, return its index (0, 1, ...) if it happens to be a base mesh vertex. It is an error to call this function with a non base mesh vertex.

Parameters:
[in] vertexId The 64-bit name of the vertex
[out] ReturnStatus Status code
Returns:
The index in the base mesh vertex array of this vertex
Status Codes:

MStatus MFnSubd::vertexEditsGetAllNonBase ( MUint64Array vertexIds,
MVectorArray edits,
MSpace::Space  space = MSpace::kObject 
) const

Returns all the vertices below the base mesh that have been modified from their original position (the original position is specified by the position of the base mesh vertices). The two arrays will be of the same length upon return. Length 0 would suggest that there have been no edits from the original positions.

Parameters:
[in] vertexIds The names of the vertices
[in] edits The offsets from the original position
[in] space Specifies the coordinate system for this operation
Returns:
Status code
Status Codes:

MStatus MFnSubd::vertexEditsSetAllNonBase ( const MUint64Array vertexIds,
const MVectorArray edits,
MSpace::Space  space = MSpace::kObject 
)

Given an array of vertex names and the offsets from their original positions, set the new vertex positions.

Parameters:
[in] vertexIds The names of the vertices
[in] edits The offsets from the original positions
[in] space Specifies the coordinate system for this operation
Returns:
Status code
Status Codes:

MStatus MFnSubd::vertexEditsClearAllNonBase (  ) 

Find all vertices with edits and remove those edits, setting them back to their original position.

Returns:
Status code
Status Codes:

MStatus MFnSubd::vertexPositionGet ( MUint64  vertexId,
MPoint position,
MSpace::Space  space = MSpace::kObject 
) const

Get the position of the vertex with a given name.

Parameters:
[in] vertexId The name of the vertex
[out] position The vertex position in the appropriate space
[in] space Specifies the coordinate system for this operation
Returns:
Status code
Status Codes:

MStatus MFnSubd::vertexEditGet ( MUint64  vertexId,
MVector edit,
MSpace::Space  space = MSpace::kObject 
) const

Get the offset of the specified vertex from its original position. This vector really is vertexPositionGet() - vertexPositionGetNoEdit().

Parameters:
[in] vertexId The name of the vertex
[out] edit The offset in object space
[in] space Specifies the coordinate system for this operation
Returns:
Status code
Status Codes:

MStatus MFnSubd::vertexPositionGetNoEdit ( MUint64  vertexId,
MPoint position,
MSpace::Space  space = MSpace::kObject 
) const

What would the position of this vertex be if there were no edits; i.e., what was its original position.

Parameters:
[in] vertexId The name of the vertex
[out] position The original position
[in] space Specifies the coordinate system for this operation
Returns:
Status code
Status Codes:

MStatus MFnSubd::vertexPositionSet ( MUint64  vertexId,
const MPoint position,
bool  updateEdits,
MSpace::Space  space = MSpace::kObject 
)

Set the position of the vertex with a given name.

Parameters:
[in] vertexId The vertex name
[out] position The new vertex position
[in] updateEdits If false, you will need to call updateSubdSurface() before any change would be applied. Further, you must set this to true before you start calling the same function on the vertices of the finer levels.
[in] space Specifies the coordinate system for this operation
Returns:
Status code
Status Codes:

MStatus MFnSubd::vertexEditSet ( MUint64  vertexId,
const MVector edit,
bool  updateEdits,
MSpace::Space  space = MSpace::kObject 
)

Set the original position offset for the given vertex.

Parameters:
[in] vertexId The name of the vertex
[out] edit The offset from the original position
[in] updateEdits If false, you will need to call updateSubdSurface() before any change would be applied. Further, you must set this to true before you start calling the same function on the vertices of the finer levels.
Returns:
Status code
Status Codes:

MStatus MFnSubd::vertexBaseMeshGet ( MPointArray positions,
MSpace::Space  space = MSpace::kObject 
) const

Return all base mesh vertices in the array using their indices (not the 64-bit names).

Parameters:
[out] positions The array of point positions
[in] space Specifies the coordinate system for this operation
Returns:
Status code
Status Codes:

MStatus MFnSubd::vertexBaseMeshSet ( const MPointArray positions,
MSpace::Space  space = MSpace::kObject 
)

Set the positions for the base mesh vertices using the 0, 1,... indexing instead of the 64-bit vertex names.

Parameters:
[out] positions The positions for the vertices
[in] space Specifies the coordinate system for this operation
Returns:
Status code
Status Codes:

MStatus MFnSubd::vertexBaseMeshGetWithId ( MPointArray positions,
MUint64Array vertexIds,
MSpace::Space  space = MSpace::kObject 
) const

Return all base mesh vertices in the array using their indices but also provide the 64-bit names.

Parameters:
[out] positions The array of point positions
[out] vertexIds The vertex 64-bit ids
[in] space The space we are working in
Returns:
Status code
Status Codes:

MStatus MFnSubd::vertexBaseMeshSetWithId ( const MPointArray positions,
const MUint64Array vertexIds,
MSpace::Space  space = MSpace::kObject 
)

Set the positions for the base mesh vertices using the 64-bit names. The ordering of the elements in the array is irrelevant. The edits will be automatically updated (i.e., editsPending() will return 0 after the call to this function).

Parameters:
[out] positions The positions for the vertices
[out] vertexIds The vertex 64-bit ids
[in] space The space we are working in
Returns:
Status code
Status Codes:

int MFnSubd::vertexValence ( MUint64  vertexId,
MStatus ReturnStatus = NULL 
) const

Returns the valence (number of incident edges) of the given vertex.

Parameters:
[in] vertexId The vertex 64-bit id
[out] ReturnStatus Status code
Returns:
The finest level in the hierarchy
Status Codes:

MStatus MFnSubd::vertexNormal ( MUint64  vertexId,
MVector normal 
) const

Returns the normal at the vertex

Parameters:
[in] vertexId The vertex 64-bit ID.
[out] normal The value of the normal
Returns:
Status code
Status Codes:

MStatus MFnSubd::vertexAdjacentVertices ( MUint64  vertexId,
MUint64Array vertList 
) const

Return the list of adjacent vertices as their 64-bit ids.

Parameters:
[in] vertexId The vertex 64-bit name
[out] vertList The resulting list of adjacent vertices
Returns:
Status code
Status Codes:

MStatus MFnSubd::vertexIncidentEdges ( MUint64  vertexId,
MUint64Array edgeList 
) const

Return the list of incident edges as their 64-bit ids.

Parameters:
[in] vertexId The vertex 64-bit name
[out] edgeList The resulting list of incident edges
Returns:
Status code
Status Codes:

MStatus MFnSubd::vertexIncidentPolygons ( MUint64  vertexId,
MUint64Array polyList 
) const

Return the list of incident polygons as their 64-bit ids.

Parameters:
[in] vertexId The vertex 64-bit name
[out] polyList The resulting list of incident polygons
Returns:
Status code
Status Codes:

bool MFnSubd::vertexIsBoundary ( MUint64  vertexId,
MStatus ReturnStatus = NULL 
) const

Return true if the vertex is a boundary vertex.

Parameters:
[in] vertexId The vertex 64-bit name
[out] ReturnStatus Status code
Returns:
Whether the vertex is boundary or not
Status Codes:

bool MFnSubd::vertexIsValid ( MUint64  vertexId,
MStatus ReturnStatus = NULL 
) const

Return true if the vertex is a valid vertex.

Parameters:
[in] vertexId The vertex 64-bit name
[out] ReturnStatus Status code
Returns:
Whether the vertex is valid or not. Valid means that the vertex has been instantiated on the surface. Not all vertices at all levels exist by default. A vertex only exists if it was created at the time the subdiv was first created or if the subdiv was refined.
Status Codes:

bool MFnSubd::vertexIsCreased ( MUint64  vertexId,
MStatus ReturnStatus = NULL 
) const

Return true if the vertex is creased.

Parameters:
[in] vertexId The vertex 64-bit name
[out] ReturnStatus Status code
Returns:
Whether the vertex is creased or not
Status Codes:

bool MFnSubd::vertexCreaseRelevant ( MUint64  vertexId,
MStatus ReturnStatus = NULL 
) const

Return true if the crease of the vertex is a relevant piece of information. The vertex inherits the crease state from its parent. So, its crease state is relevant only if different from its parent (or if there is no direct parent vertex).

Parameters:
[in] vertexId The vertex 64-bit name
[out] ReturnStatus Status code
Returns:
Whether the vertex has relevant crease information
Status Codes:

MStatus MFnSubd::vertexSetCrease ( MUint64  vertexId,
bool  creased 
) const

Set the particular vertex' crease state.

Parameters:
[in] vertexId The 64-bit name of the vertex
[in] creased Crease (true) or smooth (false)
Returns:
Status code
Status Codes:

MStatus MFnSubd::vertexChildren ( MUint64  vertexId,
MUint64Array children 
) const

Returns the "children" of the particular vertex if they exist. The children are defined as the finer-level version of the current vertex plus the neighbors of that vertex. For a valence n vertex this means 2n+1 vertices are returned if a finer level exists.

Parameters:
[in] vertexId 64-bit name of the vertex
[out] children 64-bit names of the children of this vertex
Returns:
Status code
Status Codes:

MStatus MFnSubd::creasesGetAll ( MUint64Array vertexIds,
MUint64Array edgeIds 
) const

Returns all creases on the subdivision surface in two arrays of 64-bit ids; one for the vertices, one for edges.

Note that this information alone is not suitable for "copying" the surface; there may be some relevant crease information in the non-creased vertices or edges which will not be part of the arrays returned here. Consider a vertex at level N that is creased while the corresponding vertex at level N+1 is not creased. Calling creasesGetAll will return the level N vertex. Applying the creasing to this vertex in the copy will also set the vertex at level N+1 to be creased as well, since vertices inherit creasing from their parent unless they have a different creasing set explicitly. So to get correct behavior when copying surfaces it is necessary to set the creasing attribute explicitly to the appropriate value on all the vertices, not just the creased vertices. The same applies to edges.

Parameters:
[out] vertexIds The ids of the vertices that are creased
[out] edgeIds The ids of the edges that are creased
Returns:
Status code
Status Codes:

MStatus MFnSubd::creasesSetAll ( const MUint64Array vertexIds,
const MUint64Array edgeIds 
)

Set the creases on all vertices and edges with a given 64-bit name. Note that the combination of creasesGetAll() and creasesSetAll() will not exactly duplicate the crease information between two surfaces.

Parameters:
[in] vertexIds The ids of the vertices that are creased
[in] edgeIds The ids of the edges that are creased
Returns:
Status code
Status Codes:

MStatus MFnSubd::creasesClearAll (  )  const

Clear all crease information from this surface. No vertices or edges will be creased after this function completes.

Returns:
Status code
Status Codes:

MStatus MFnSubd::updateAllEditsAndCreases (  ) 

If you have been editing offsets without updating the surface, this function will save you. This will dirty up the complete surface and recompute the positions of all the cvs, updating the crease info along the way. Not cheap to call.

Returns:
Status code
Status Codes:

unsigned int MFnSubd::edgeCount ( int  level = 0,
MStatus ReturnStatus = NULL 
) const

Returns the number of edges at a level.

Parameters:
[in] level The level where we're counting the edges
[out] ReturnStatus Status code
Returns:
Number of edges at the given level
Status Codes:

MUint64 MFnSubd::edgeBetween ( MUint64  vertex1,
MUint64  vertex2,
MStatus ReturnStatus = NULL 
) const

Return the name of the edge that connects the two vertices. If the edge doesn't exist, it will be created.

Parameters:
[in] vertex1 The name of the first vertex
[in] vertex2 The name of the second vertex
[out] ReturnStatus Status code
Returns:
The name of the edge between the two
Status Codes:

MStatus MFnSubd::edgeVertices ( MUint64  edgeId,
MUint64 &  v1,
MUint64 &  v2 
) const

Given an edge, return the two vertices at its ends.

Parameters:
[in] edgeId The 64-bit edge name
[out] v1 First vertex on the edge
[out] v2 Second vertex on the edge
Returns:
Status code
Status Codes:

MStatus MFnSubd::edgeAdjacentPolygon ( MUint64  edgeId,
MUint64Array polys 
) const

Return the polygons adjacent to this edge. There can be at most two, as non-manifold topology is not allowed.

Parameters:
[in] edgeId The 64-bit edge name
[out] polys The 64-bit names of the polygons (1 or 2)
Returns:
Status code
Status Codes:

bool MFnSubd::edgeIsBoundary ( MUint64  edgeId,
MStatus ReturnStatus = NULL 
) const

Test if the edge specified is a boundary edge or not.

Parameters:
[in] edgeId The 64-bit edge name
[out] ReturnStatus Status code
Returns:
True if the edge is a boundary edge, false otherwise.
Status Codes:

bool MFnSubd::edgeIsValid ( MUint64  edgeId,
MStatus ReturnStatus = NULL 
) const

Returns true if the specified edge name is valid.

Parameters:
[in] edgeId The 64-bit edge name
[out] ReturnStatus Status code
Returns:
True if the edge name is valid, false otherwise.
Status Codes:

bool MFnSubd::edgeIsCreased ( MUint64  edgeId,
MStatus ReturnStatus = NULL 
) const

Return true if the edge is creased.

Parameters:
[in] edgeId The 64-bit name of the edge
[out] ReturnStatus Status code
Returns:
True if the edge is creased, false otherwise
Status Codes:

bool MFnSubd::edgeCreaseRelevant ( MUint64  edgeId,
MStatus ReturnStatus = NULL 
) const

Return true if the crease of the edge is a relevant piece of information. The edge inherits the crease state from its parent. So, its crease state is relevant only if different from its parent (or if there is no direct parent edge).

Parameters:
[in] edgeId The edge 64-bit name
[out] ReturnStatus Status code
Returns:
Whether the edge has relevant crease information
Status Codes:

MStatus MFnSubd::edgeSetCrease ( MUint64  edgeId,
bool  creased 
) const

Set the particular edge's crease state.

Parameters:
[in] edgeId The 64-bit name of the edge
[in] creased Crease (true) or smooth (false)
Returns:
Status code
Status Codes:

MStatus MFnSubd::edgeChildren ( MUint64  edgeId,
MUint64Array children 
) const

Returns the "children" of the particular edge. If the edge has children, there will always be two child edges.

Parameters:
[in] edgeId 64-bit name of the edge
[out] children 64-bit names of the children of this edge
Returns:
Status code
Status Codes:

unsigned int MFnSubd::polygonCount ( int  level = 0,
MStatus ReturnStatus = NULL 
) const

Returns the number of polygons currently existing at the specified level of the hierarchy.

Parameters:
[in] level Level at which we're counting
[out] ReturnStatus Status code
Returns:
The number of polygons at the specified level
Status Codes:

int MFnSubd::polygonCountMaxWithGivenBaseMesh ( int  level = 1,
MStatus ReturnStatus = NULL 
) const

If you were to fully subdivide at a given level, how many polygons would you have at that level? This function will tell you and possibly save you from running out of memory if you go too deep. Note that this is exactly the same as "polygonCount" for levels 0 and 1.

Parameters:
[in] level The level where you would be counting
[out] ReturnStatus Status code
Returns:
The number of polygons at the given level if you were to fully subdivide at that level.
Status Codes:

unsigned int MFnSubd::polygonVertexCount ( MUint64  polyId,
MStatus ReturnStatus = NULL 
) const

How many vertices on a given polygon? The vertices are at the same level as the polygon.

Parameters:
[in] polyId The 64-bit name of the polygon
[out] ReturnStatus Status code
Returns:
The number of vertices on this polygon
Status Codes:

MStatus MFnSubd::polygonVertices ( MUint64  polyId,
MUint64Array vertexIds 
) const

Given the polygon, return its vertices. The vertices are at the same level as the polygon.

Parameters:
[in] polyId The 64-bit name of the polygon
[out] vertexIds The 64-bit names of the vertices
Returns:
Status code
Status Codes:

unsigned int MFnSubd::polygonEdgeCount ( MUint64  polyId,
MStatus ReturnStatus = NULL 
) const

The number of edges on the given polygon.

Parameters:
[in] polyId The 64-bit name of the polygon
[out] ReturnStatus Status code
Returns:
The number of edges on this polygon
Status Codes:

MStatus MFnSubd::polygonEdges ( MUint64  polyId,
MUint64Array edgeIds 
) const

Given the polygon, return its edges. The edges are at the same level as the polygon.

Parameters:
[in] polyId The 64-bit name of the polygon
[out] edgeIds The 64-bit names of the edges
Returns:
Status code
Status Codes:

bool MFnSubd::polygonIsValid ( MUint64  polygonId,
MStatus ReturnStatus = NULL 
) const

Return true if the polygon is a valid polygon.

Parameters:
[in] polygonId The polygon 64-bit name
[out] ReturnStatus Status code
Returns:
Whether the polygon is valid or not. Valid means that the polygon has been instantiated on the surface. Not all polygons at all levels exist by default. A polygon only exists if it was created at the time the subdiv was first created or if the subdiv was refined.
Status Codes:

bool MFnSubd::polygonHasChildren ( MUint64  polyId,
MStatus ReturnStatus = NULL 
) const

Returns whether or not the given polygon has children.

Parameters:
[in] polyId The polygon 64-bit name
[out] ReturnStatus Status code
Returns:
Whether the polygon has children.
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred. This can happen if the polyId passed in refers to a face that is not currently instantiated on the surface.

MStatus MFnSubd::polygonChildren ( MUint64  polyId,
MUint64Array children 
) const

Returns the list of children polygons on the given polygon. If the children array is not empty, we will just append to it.

Parameters:
[in] polyId The 64-bit name of the original polygon
[out] children The 64-bit name of the child polygons
Returns:
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred. This can happen if the polyId passed in refers to a face that is not currently instantiated on the surface.

MStatus MFnSubd::polygonSubdivide ( MUint64  polyId  ) 

Subdivide the given polygon into 4 children (if this happens to be the level 0 polygon you will get as many children as that polygon has edges).

Parameters:
[in] polyId The 64-bit name of the polygon
Returns:
Status code
Status Codes:

MStatus MFnSubd::polygonSetUseUVs ( MUint64  polyId,
bool  useThem 
)

If this is set, the polygon will use the user specified UVs.

Parameters:
[in] polyId The 64-bit polygon name
[in] useThem Use the user set UVs
Returns:
Status code
Status Codes:

bool MFnSubd::polygonHasVertexUVs ( MUint64  polyId,
MStatus ReturnStatus = NULL 
)

Returns true if there are user specified UVs on this polygon.

Parameters:
[in] polyId The 64-bit polygon name
[out] ReturnStatus Status code
Returns:
True if there were explicitly specified UVs on this polygon.
Status Codes:

MStatus MFnSubd::polygonGetVertexUVs ( MUint64  polyId,
MDoubleArray uValues,
MDoubleArray vValues 
) const

Get the vertex UVs from the polygon. The values come back in exactly the same order as the polygon vertices do.

Parameters:
[in] polyId The 64-bit polygon name
[out] uValues Array of U values
[out] vValues Array of V values
Returns:
Status code
Status Codes:

MStatus MFnSubd::polygonSetVertexUVs ( MUint64  polyId,
const MDoubleArray uValues,
const MDoubleArray vValues 
)

Set the UV values on the polygon.

Parameters:
[in] polyId The 64-bit polygon name
[in] uValues Array of U values
[in] vValues Array of V values
Returns:
Status code
Status Codes:

MStatus MFnSubd::polygonGetCenterUV ( MUint64  polyId,
double &  u,
double &  v 
) const

Return the UV values in the "center" of this polygon.

Parameters:
[in] polyId The 64-bit polygon name
[out] u The resulting U value
[out] v The resulting V value
Returns:
Status code
Status Codes:

MStatus MFnSubd::evaluatePosition ( MUint64  polyId,
double  u,
double  v,
bool  uvNormalized,
MPoint pos 
) const

Evaluate the surface position at the given parameter point on the polygon. The limitation is that this cannot be a base mesh polygon; i.e., it has to be at least level 1.

Parameters:
[in] polyId The 64-bit polygon name
[in] u U value on the face
[in] v V value on the face
[in] uvNormalized If true, its as if U, V are in [0,1]
[out] pos The resulting 3d position
Returns:
Status code
Status Codes:

MStatus MFnSubd::evaluateNormal ( MUint64  polyId,
double  u,
double  v,
bool  uvNormalized,
MVector nrml 
) const

Evaluate the surface normal at the given parameter point on the polygon. The limitation is that this cannot be a base mesh polygon; i.e., it has to be at least level 1.

Parameters:
[in] polyId The 64-bit polygon name
[in] u U value on the face
[in] v V value on the face
[in] uvNormalized If true, its as if U, V are in [0,1]
[out] nrml The resulting surface normal
Returns:
Status code
Status Codes:

MStatus MFnSubd::evaluatePositionAndNormal ( MUint64  polyId,
double  u,
double  v,
bool  uvNormalized,
MPoint pos,
MVector nrml 
) const

Evaluate the surface position and normal at the given parameter point on the polygon. The limitation is that this cannot be a base mesh polygon; i.e., it has to be at least level 1.

Parameters:
[in] polyId The 64-bit polygon name
[in] u U value on the face
[in] v V value on the face
[in] uvNormalized If true, its as if U, V are in [0,1]
[out] pos The resulting 3d position
[out] nrml The resulting surface normal
Returns:
Status code
Status Codes:

bool MFnSubd::getCubicSpline ( MUint64  polyId,
MPointArray  vertices,
MStatus ReturnStatus = NULL 
)

Some of the faces (usually at level 2 or below) happen to be exactly the same as uniform bi-cubic B-splines. This routine will return the 16 points that define such spline.

Parameters:
[in] polyId The 64-bit polygon name
[out] vertices point array
[out] ReturnStatus Status code
Returns:
True if we can make the conversion, false otherwise
Status Codes:

MStatus MFnSubd::getConnectedSetsAndMembers ( unsigned int  instanceNumber,
MObjectArray sets,
MObjectArray comps,
bool  renderableSetsOnly 
) const

Returns all the sets connected to the specified instance of this mesh. For each set in the "sets" array there is a corresponding entry in the "comps" array which are all the components in that set. If the entire object is in a set, then the corresponding entry in the comps array will have no elements in it.

Parameters:
[in] instanceNumber The instance number of the mesh to query
[out] sets Storage for the sets
[out] comps Storage for the components that are in the corresponding set
[in] renderableSetsOnly If true then this method will only return renderable sets
Returns:
Status code
Status Codes:

MStatus MFnSubd::getConnectedShaders ( unsigned int  instanceNumber,
MObjectArray shaders,
MUint64Array faces,
MIntArray indices 
) const

Returns all the shaders (sets) connected to the specified instance of this subdivision surface and two arrays indicating face/shader assignments. For each face in the face array, there is a corresponding entry in the indices array to indicate the assigned shader in the shader array.

For instance, faces[0] is the 64-bit index of the face on the subdivision surface. Then indices[0] is an index into the shaders array, eg. "3". Then shaders[3] is the shader assigned to the subdivision surface face.

If a face does not have a shader assigned to it, the value of the index will be -1. The shader objects can be derived from the sets returned.

See also getConnectedSetsAndMembers.

Parameters:
[in] instanceNumber The instance number of the subdivision surface to query
[out] shaders Storage for set objects (shader objects)
[out] faces Storage for indices matching faces to indices
[out] indices Storage for indices matching indices to shaders
Returns:
Status code
Status Codes:

MObject MFnSubd::tesselate ( bool  uniform,
int  depth,
int  sample,
MObject  parentOrOwner = MObject::kNullObj,
MStatus ReturnStatus = NULL 
)

Performs tesselation on this surface and create a new mesh in the DAG. The parentOrOwner argument is used to specify the owner of the new surface.

If the parentOrOwner is kMeshData then the created surface will be of type kMeshGeom and will be returned. The parentOrOwner will become the owner of the new mesh.

If parentOrOwner is NULL then a new transform will be created and returned which will be the parent for the mesh. The new transform will be added to the DAG.

If parentOrOwner is a DAG node then the new mesh will be returned and the parentOrOwner will become its parent.

Note: Each level 1 face will tesselate into approximatelly: 2 * 4^(depth-1) * sample^2 triangles in the uniform case, so be careful as to how you choose these parameters.

Parameters:
[in] uniform Use uniform tesselation if this is set.
[in] depth Used in the uniform tesselation: how deep do we go
[in] sample In both tesselation cases, once we decide which level to tesselate at, how many times do we sample.
[in] parentOrOwner the DAG parent or kMeshData the new Mesh will belong to
[out] ReturnStatus Status Code
Returns:
  • If parentOrOwner is NULL then the transform for this surface is returned
  • If parentOrOwner is a DAG object then the new surface shape is returned
  • The surface geometry is returned if parentOrOwner is of type kMeshData
Status Codes:

MObject MFnSubd::tessellateViaNurbs ( MObject  parentOrOwner = MObject::kNullObj,
MStatus ReturnStatus = NULL 
)

Performs tesselation on this surface and create a new mesh in the DAG. The parentOrOwner argument is used to specify the owner of the new surface.

If the parentOrOwner is kMeshData then the created surface will be of type kMeshGeom and will be returned. The parentOrOwner will become the owner of the new mesh.

If parentOrOwner is NULL then a new transform will be created and returned which will be the parent for the mesh. The new transform will be added to the DAG.

If parentOrOwner is a DAG node then the new mesh will be returned and the parentOrOwner will become its parent.

Note: Each level 1 face will tesselate into approximatelly: 2 * 4^(depth-1) * sample^2 triangles in the uniform case, so be careful as to how you choose these parameters.

Parameters:
[in] parentOrOwner the DAG parent or kMeshData the new Mesh will belong to
[out] ReturnStatus Status Code
Returns:
  • If parentOrOwner is NULL then the transform for this surface is returned
  • If parentOrOwner is a DAG object then the new surface shape is returned
  • The surface geometry is returned if parentOrOwner is of type kMeshData
Status Codes:

MStatus MFnSubd::convertToNurbs ( MObjectArray newNurbsSurfaces  ) 

Converts this surface to a set of nurbs surfaces.

Parameters:
[out] newNurbsSurfaces Storage for the arary of NURBS
Returns:
Status code.
Status Codes:

MStatus MFnSubd::updateSubdSurface (  ) 

Signal that this subdivision surface has changed and needs to redraw itself.

Returns:
Status code
Status Codes:

MStatus MFnSubd::vertexBaseMeshAddWithIndex ( double  x,
double  y,
double  z,
int  index 
)

Very similar to vertexBaseMeshAdd, this gives you an advanced option of specifying the index for the new vertex to be created. You have to be extremelly careful to end up with the indices 0, 1, ... N-1 for N total vertices.

Parameters:
[in] x X location of the vertex
[in] y Y location of the vertex
[in] z Z location of the vertex
[in] index The index the vertex is to take
Returns:
Status code
Status Codes:

bool MFnSubd::getCubicSpline ( MUint64  polyId,
MPoint  vertices[16],
MStatus ReturnStatus = NULL 
)

NO SCRIPT SUPPORT.

Some of the faces (usually at level 2 or below) happen to be exactly the same as uniform bi-cubic B-splines. This routine will return the 16 points that define such spline.

Parameters:
[in] polyId The 64-bit polygon name
[out] vertices 16 vertices that define the cubic spline
[out] ReturnStatus Status code
Returns:
True if we can make the conversion, false otherwise
Status Codes:


Autodesk® Maya® 2009 © 1997-2008 Autodesk, Inc. All rights reserved. Generated with doxygen 1.5.6