Accessing Rigid Skinning Information [MEL]

 

 

 

Whenever you create a rigidly skinned mesh within maya, you will end up adding in a number of MFn::kJointCluster nodes into the scene. In essence a joint cluster, simply maintains a list of vertices from a number of shapes that are directly influenced by that joints transformation. ie, rather than parenting an entire geometry object to a specific bone, we are parenting groups of vertices under individual bones.

 

 

 

 

Finding all Joint Clusters in the Scene

When retrieving mesh data, you will need to use an MItDependencyNodes in order to loop through a list of clusters.

 

 

 

 


#include<maya/MFnWeightGeometryFilter.h>
#include<maya/MItDepedencyNodes.h>

// create an iterator to go through all meshes
MItDepedencyNodes it(MFn::kJointCluster);

while(!it.isDone())
{
 

// attach the function set to the object
MFnWeightGeometryFilter
fn(it.item());

// print joint cluster name
cout
<<"Cluster "<< fn.name().asChar() <<endl;

OutputClusterTransform(it.item());

OutputInfluencedGeometry(it.item());

// get next mesh
it.next();

}




 

Finding the influence joint

Finding the influence joint for the joint cluster is simply a case of checking for any connections to the matrix attribute of the joint cluster node.

This function therefore checks for any connections to the attribute and returns the influencing transform.

 

 

 

 


#include<maya/MFnDependencyNode.h>
#include<maya/MPlug.h>
#include<maya/MPlugArray.h>

bool OutputClusterTransform(MObject& jointcluster)
{
 

// attach a function set to the cluster
MFnDependencyNode fnNode(jointCluster);

// get a plug to the matrix attribute

MPlug plug = fnNode.findPlug("matrix");

MPlugArray conns;

// if the attribute is connected to a transform

if (plug.connectedTo(conns,true,false)) {

 

MFnDependencyNode fnTransform(conns[0].node());

cout << "\tbone "
<< fnTransform.
name().asChar()
<<
endl;

return true;

}
return false;

}

 

 

Accessing the influenced Geometry

 

Each joint cluster may influence more than one geometry object. Each object will then have a variable number of it's control points influenced by the actual influencing joint for this cluster.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


#include<maya/MFnWeightGeometryFilter.h>

bool OutputInfluencedGeometry(MFnWeightGeometryFilter& jc)
{

 

// need the set fn to get the cluster members
MFnSet setFn(jc.deformerSet());

MSelectionList Shapes;

// get all the shapes in the cluster
setFn.getMembers(Shapes, true);

for (int i = 0; i < Shapes.length(); ++i)
{

 

MDagPath skinpath;
MObject components;
MFloatArray weights;

// get a path to the i'th shape affected
SetList.getDagPath(i,skinpath,components);

// get the weights and vertex indices for
// the points that are influenced.

// Usually you can ignore the weight values
// since they all tend to be 1
.
fn
.getWeights(skinpath,components,weights);

// attach a function set to the shape so that
// we can access it's name.

MFnDependencyNode
fnShape(skinpath);

cout << "\tShape "
<< fnShape.name().asChar()
<< "\n\tNumPoints "
<< weights.length()
<<"\n";

// output the vertex indices by iterating
// through the geometry components

MItGeometry it(skinpath,components);
for ( ; !it.isDone(); it.next())
{

  cout << "\t\t" << it.index() << "\n";

}

}

}


 

 

 

What Next?

Transform Data

Animation Data

Animation Curves

Smooth Skinning (Skin Clusters)

Blend Shape Deformers

index

Rob Bateman [2004]


[HOME] [MEL] [API]