本文整理汇总了C++中MDagPath::partialPathName方法的典型用法代码示例。如果您正苦于以下问题:C++ MDagPath::partialPathName方法的具体用法?C++ MDagPath::partialPathName怎么用?C++ MDagPath::partialPathName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDagPath
的用法示例。
在下文中一共展示了MDagPath::partialPathName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetSpecifiedSkinnerNode
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
MDagPath CVsSkinnerCmd::GetSpecifiedSkinnerNode()
{
MSelectionList skinnerNodes;
MSelectionList optSelectionList;
m_undo.ArgDatabase().getObjects( optSelectionList );
GetSpecifiedSkinnerNodes( optSelectionList, skinnerNodes );
MDagPath mDagPath;
if ( skinnerNodes.length() == 0U )
return mDagPath;
if ( skinnerNodes.length() > 1U )
{
skinnerNodes.getDagPath( 0U, mDagPath );
mwarn << "Using vsSkinnerNode " << mDagPath.partialPathName() << ", ignoring extra vsSkinnerNode";
if ( skinnerNodes.length() > 2U )
mwarn << "s";
mwarn << ":";
for ( uint i( 1U ); i != skinnerNodes.length(); ++i )
{
skinnerNodes.getDagPath( i, mDagPath );
mwarn << " " << mDagPath.partialPathName();
}
mwarn << std::endl;
}
skinnerNodes.getDagPath( 0U, mDagPath );
return mDagPath;
}
示例2: writeParent
//
// Write out a 'parent' command to parent one DAG node under another.
//
void maTranslator::writeParent(
fstream& f, const MDagPath& parent, const MDagPath& child, bool addIt
)
{
f << "parent -s -nc -r ";
//
// If this is not the first parent then we have to include the "-a/add"
// flag.
//
if (addIt) f << "-a ";
//
// If the parent is the world, then we must include the "-w/world" flag.
//
if (parent.length() == 0) f << "-w ";
f << "\"" << child.partialPathName().asChar() << "\"";
//
// If the parent is NOT the world, then give the parent's name.
//
if (parent.length() != 0)
f << " \"" << parent.partialPathName().asChar() << "\"";
f << ";" << endl;
}
示例3: writeCreateNode
//
// Write out a 'createNode' command for a DAG node.
//
void maTranslator::writeCreateNode(
fstream& f, const MDagPath& nodePath, const MDagPath& parentPath
)
{
MObject node(nodePath.node());
MFnDagNode nodeFn(node);
//
// Write out the 'createNode' command for this node.
//
f << "createNode " << nodeFn.typeName().asChar();
//
// If the node is shared, then add a "-s/shared" flag to the command.
//
if (nodeFn.isShared()) f << " -s";
f << " -n \"" << nodeFn.name().asChar() << "\"";
//
// If this is not a top-level node, then include its first parent in the
// command.
//
if (parentPath.length() > 0)
f << " -p \"" << parentPath.partialPathName().asChar() << "\"";
f << ";" << endl;
}
示例4: DoLs
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
MStatus CVsSkinnerCmd::DoLs()
{
MSelectionList tmpList;
if ( m_undo.ArgDatabase().isFlagSet( kOptSelected ) )
{
MSelectionList skinnerNodes;
m_undo.ArgDatabase().getObjects( skinnerNodes );
GetSpecifiedSkinnerNodes( skinnerNodes, tmpList );
}
else
{
MDagPath eDagPath;
FindSkinnerNodesInHierarchy( eDagPath, tmpList );
}
const bool longPath( m_undo.ArgDatabase().isFlagSet( kOptLong ) );
MStringArray result;
MDagPath mDagPath;
for ( MItSelectionList sIt( tmpList ); !sIt.isDone(); sIt.next() )
{
if ( sIt.getDagPath( mDagPath ) )
{
result.append( longPath ? mDagPath.fullPathName() : mDagPath.partialPathName() );
}
}
setResult( result );
return MS::kSuccess;
}
示例5: DoCreate
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
MStatus CVsSkinnerCmd::DoCreate()
{
// Get name command line arg
MString optName;
if ( m_undo.ArgDatabase().isFlagSet( kOptName ) )
{
m_undo.ArgDatabase().getFlagArgument( kOptName, 0, optName );
}
// Create vsSkinner node
MObject stObj; // Skinner transform object
MObject vsSkinnerObj; // Skinner shape object
MDagModifier &mDagModifier( m_undo.DagModifier() );
if ( vm::CreateDagNode(
"vsSkinner",
optName.length() ? optName.asChar() : GetName().asChar(),
MObject ::kNullObj,
&stObj,
&vsSkinnerObj,
&mDagModifier ) != MS::kSuccess )
{
displayError( MString( "Couldn't create " ) + GetName() + " transform node" );
m_undo.Undo();
return MS::kFailure;
}
MDagPath stPath;
MDagPath::getAPathTo( stObj, stPath );
setResult( stPath.partialPathName() );
MDagPath skinnerPath;
MDagPath::getAPathTo( vsSkinnerObj, skinnerPath );
MSelectionList optSelectionList;
m_undo.ArgDatabase().getObjects( optSelectionList );
MSelectionList volumeList( DoNewVolumes( skinnerPath, optSelectionList ) );
if ( volumeList.length() )
{
MGlobal::setActiveSelectionList( volumeList, MGlobal::kReplaceList );
}
else
{
MGlobal::select( stPath, MObject::kNullObj, MGlobal::kReplaceList );
}
return MS::kSuccess;
}
示例6: findAvailableSystems
MStatus unShowAvailableSystems::findAvailableSystems(std::string& str,MDagPath& dagPath)
{
MStatus stat = MS::kSuccess;
if(dagPath.hasFn(MFn::kJoint))
{
MFnIkJoint jointFn(dagPath);
std::string name = dagPath.partialPathName().asChar();
MPlug plug = jointFn.findPlug("unRibbonEnabled");
if(!plug.isNull())
{
bool enabled;
plug.getValue(enabled);
char s[256];
sprintf(s,"%s RibbonSystem %s\n",name.c_str(),enabled ? "True" : "False");
str += s;
}
plug = jointFn.findPlug("unParticleEnabled");
if(!plug.isNull())
{
bool enabled;
plug.getValue(enabled);
char s[256];
sprintf(s,"%s ParticleSystem %s\n",name.c_str(),enabled ? "True" : "False");
str += s;
}
}
for (unsigned int i = 0; i < dagPath.childCount(); i++)
{
MObject child = dagPath.child(i);
MDagPath childPath;
stat = MDagPath::getAPathTo(child,childPath);
if (MS::kSuccess != stat)
{
return MS::kFailure;
}
stat = findAvailableSystems(str,childPath);
if (MS::kSuccess != stat)
return MS::kFailure;
}
return MS::kSuccess;
}
示例7: BindViewerToPanel
MStatus CMayaManager::BindViewerToPanel (const char* strView)
{
//HRESULT hr= S_OK;
HWND renderwnd= NULL;
MDagPath MayaCamera;
if(strView == NULL)
strView= "";
StringCchCopyA(m_ViewerBinding, MAX_PATH, strView);
if(strView && (strView[0] != '\0'))
{
if(0 == lstrcmpiA(strView, "floating"))
{
g_Viewer.BindToWindow(NULL, true);
}
else
{
M3dView ourView;
M3dView::get3dView(0,ourView);
for(UINT iView= 0; iView < M3dView::numberOf3dViews(); iView++)
{
M3dView::get3dView(iView, ourView);
ourView.getCamera(MayaCamera);
MayaCamera.pop();
if(MayaCamera.partialPathName() == MString(strView))
{
renderwnd= (HWND)ourView.window();
g_Viewer.BindToWindow(ourView.window(), true);
break;
}
}
}
}
//e_Exit:
return MS::kSuccess;
}
示例8: OutputSkinCluster
void Exporter::OutputSkinCluster(MObject& obj)
{
// attach a skin cluster function set to
// access the data
skinData SD;
MFnSkinCluster fn(obj);
MDagPathArray infs;
//Get influences
SD.influences = fn.influenceObjects(infs);
// loop through the geometries affected by this cluster
int nGeoms = fn.numOutputConnections();
for (int i = 0; i < nGeoms; ++i) {
unsigned int index;
index = fn.indexForOutputConnection(i);
// get the dag path of the i'th geometry
MDagPath skinPath;
fn.getPathAtIndex(index, skinPath);
// iterate through the components of this geometry
MItGeometry gIter(skinPath);
// print out the name of the skin cluster,
// the vertexCount and the influenceCount
cout << "Skin: " << skinPath.partialPathName().asChar() << endl;
cout << "pointcount: " << gIter.count() << endl;
cout << "numInfluences: " << SD.influences << endl;
//Get points affected
SD.points = gIter.count();
for (; !gIter.isDone(); gIter.next()) {
MObject comp = gIter.component();
// Get the weights for this vertex (one per influence object)
//
MFloatArray wts;
unsigned int infCount;
fn.getWeights(skinPath, comp, wts, infCount);
if (0 != infCount && !gIter.isDone())
{
int numWeights = 0;
float outWts[40] = { 1.0f, 0 };
int outInfs[40] = { 0 };
// Output the weight data for this vertex
//
for (int j = 0; j != infCount; ++j)
{
// ignore weights of little effect
if (wts[j] > 0.001f)
{
if (numWeights != 0)
{
outWts[0] -= wts[j];
outWts[numWeights] = wts[j];
}
outInfs[numWeights] = j;
++numWeights;
}
}
float norm = outWts[0] + outWts[1] + outWts[2] + outWts[3];
MDagPath dag_path;
MItDag dag_iter(MItDag::kBreadthFirst, MFn::kMesh);
int currentmesh = 0, y = 0;
while (!dag_iter.isDone())
{
if (dag_iter.getPath(dag_path))
{
MFnDagNode dag_node = dag_path.node();
if (!dag_node.isIntermediateObject())
{
MFnMesh mesh(dag_path);
if (!strcmp(skinPath.partialPathName().asChar(), mesh.partialPathName().asChar()))
currentmesh = y;
y++;
}
}
dag_iter.next();
}
for (int x = 0; x < 4; x++)
{
scene_.meshes[currentmesh].points[gIter.index()].boneIndices[x] = outInfs[x];
scene_.meshes[currentmesh].points[gIter.index()].boneWeigths[x] = outWts[x] / norm;
}
scene_.meshes[currentmesh].hasSkeleton = true;
}
}
}
}
示例9: doIt
MStatus exportJointClusterData::doIt( const MArgList& args )
//
// Process the command
// 1. parse the args
// 2. find the jointClusters in the scene
// 3. iterate over their members, writing their weight data out to file
//
{
// parse args to get the file name from the command-line
//
MStatus stat = parseArgs(args);
if (stat != MS::kSuccess) {
return stat;
}
// count the processed jointClusters
//
unsigned int jcCount = 0;
// Iterate through graph and search for jointCluster nodes
//
MItDependencyNodes iter( MFn::kJointCluster);
for ( ; !iter.isDone(); iter.next() ) {
MObject object = iter.item();
MFnWeightGeometryFilter jointCluster(object);
// get the joint driving this cluster
//
MObject joint = jointForCluster(object);
if (joint.isNull()) {
displayError("Joint is not attached to cluster.");
continue;
}
MObject deformSet = jointCluster.deformerSet(&stat);
CheckError(stat,"Error getting deformer set.");
MFnSet setFn(deformSet, &stat); //need the fn to get the members
CheckError(stat,"Error getting deformer set fn.");
MSelectionList clusterSetList;
//get all the members
//
stat = setFn.getMembers(clusterSetList, true);
CheckError(stat,"Could not make member list with getMembers.");
// print out the name of joint and the number of associated skins
//
MFnDependencyNode fnJoint(joint);
fprintf(file,"%s %u\n",fnJoint.name().asChar(),
clusterSetList.length());
for (unsigned int kk = 0; kk < clusterSetList.length(); ++kk) {
MDagPath skinpath;
MObject components;
MFloatArray weights;
clusterSetList.getDagPath(kk,skinpath,components);
jointCluster.getWeights(skinpath,components,weights);
// print out the path name of the skin & the weight count
//
fprintf(file,
"%s %u\n",skinpath.partialPathName().asChar(),
weights.length());
// loop through the components and print their index and weight
//
unsigned counter =0;
MItGeometry gIter(skinpath,components);
for (/* nothing */ ; !gIter.isDone() &&
counter < weights.length(); gIter.next()) {
fprintf(file,"%d %f\n",gIter.index(),weights[counter]);
counter++;
}
}
jcCount++;
}
fclose(file);
if (0 == jcCount) {
displayError("No jointClusters found in this scene.");
return MS::kFailure;
}
return MS::kSuccess;
}
示例10: PerspectiveCamera_Synchronize
HRESULT CMayaManager::PerspectiveCamera_Synchronize()
{
MDagPath MayaCamera;
M3dView panel;
for(UINT iView= 0; iView < M3dView::numberOf3dViews(); iView++)
{
D3DXMATRIX mCamera;
M3dView::get3dView(iView, panel);
panel.getCamera(MayaCamera);
MayaCamera.pop();
MString perspNameStr( "persp" );
MString cameraNameStr = MayaCamera.partialPathName();
cameraNameStr = cameraNameStr.substring(0, perspNameStr.length()-1 );
const char* cameraName= cameraNameStr.asChar();
if(cameraNameStr == perspNameStr )
{
MayaCamera.extendToShape();
MFloatMatrix fView(MayaCamera.inclusiveMatrix().matrix );
ConvertWorldMatrix(mCamera, fView);
panel.getCamera(MayaCamera);
MFnCamera fnMayaCamera(MayaCamera.node());
MVector mUp= fnMayaCamera.upDirection();
MVector mAt= fnMayaCamera.viewDirection();
MPoint mEye= fnMayaCamera.eyePoint(MSpace::kWorld);
D3DXVECTOR3 dxEye( (float)mEye.x, (float)mEye.y, (float)-mEye.z );
D3DXVECTOR3 dxAt( (float)mAt.x, (float)mAt.y, (float)-mAt.z );
D3DXVECTOR3 dxUp( (float)mUp.x, (float)mUp.y, (float)-mUp.z );
D3DXVECTOR4 fEye;
D3DXVECTOR4 fAt;
D3DXVECTOR3 fUp;
D3DXVec3Transform(&fEye, &dxEye,(D3DXMATRIX*)&mCamera);
D3DXVec3Transform(&fAt, &dxAt,(D3DXMATRIX*)&mCamera);
D3DXVec3TransformNormal(&fUp, &dxUp,(D3DXMATRIX*)&mCamera);
D3DXMatrixLookAtLH(&PerspectiveCamera_View,
(D3DXVECTOR3*)&fEye,
(D3DXVECTOR3*)&fAt,
&fUp);
// Projection matrix
float zNear = (float)fnMayaCamera.nearClippingPlane();
float zFar = (float)fnMayaCamera.farClippingPlane();
float hFOV = (float)fnMayaCamera.horizontalFieldOfView();
float f = (float) (1.0f / (float) tan( hFOV / 2.0f ));
ZeroMemory( &PerspectiveCamera_Projection, sizeof(PerspectiveCamera_Projection) );
PerspectiveCamera_Projection._11 = f;
PerspectiveCamera_Projection._22 = f;
PerspectiveCamera_Projection._33 = (zFar+zNear) / (zFar-zNear);
PerspectiveCamera_Projection._34 = 1.0f;
PerspectiveCamera_Projection._43 = -2 * (zFar*zNear)/(zFar-zNear);
break;
}
}
return S_OK;
}
示例11: doIt
MStatus mshUtil::doIt( const MArgList& args )
{
MString objname, mcfname;
MArgDatabase argData(syntax(), args);
MSelectionList selList;
MGlobal::getActiveSelectionList ( selList );
if ( selList.length() < 2 ) {
MGlobal:: displayError ( "Not sufficient selection!" );
return MS::kSuccess;
}
MItSelectionList iter( selList );
iter.reset();
MDagPath meshPath;
iter.getDagPath( meshPath );
meshPath.extendToShape();
MObject meshObj = meshPath.node();
MString surface = meshPath.partialPathName();
MStatus status;
MFnMesh meshFn(meshPath, &status );
if(!status) {
MGlobal:: displayError ( "Not sufficient selection!" );
return MS::kSuccess;
}
MPointArray vxa;
meshFn.getPoints (vxa, MSpace::kWorld);
MPoint cenfrom(0.f, 0.f, 0.f);
for(unsigned i=0; i<vxa.length(); i++) cenfrom += vxa[i];
cenfrom = cenfrom/(float)vxa.length();
iter.next();
iter.getDagPath( meshPath );
meshPath.extendToShape();
MFnMesh mesh1Fn(meshPath, &status );
if(!status) {
MGlobal:: displayError ( "Not sufficient selection!" );
return MS::kSuccess;
}
vxa.clear();
mesh1Fn.getPoints (vxa, MSpace::kWorld);
MPoint cento(0.f, 0.f, 0.f);
for(unsigned i=0; i<vxa.length(); i++) cento += vxa[i];
cento = cento/(float)vxa.length();
MVector diff = cento - cenfrom;
MDoubleArray res;
res.append(diff.x);
res.append(diff.y);
res.append(diff.z);
setResult ( res );
/*
if ( !argData.isFlagSet("-i") || !argData.isFlagSet("-o") ) {
//MGlobal::displayError( "No .obj or .mcf file specified to translate! Example: mshUtil -i filename.obj -o filename.mcf" );
return MS::kSuccess;
}
else {
argData.getFlagArgument("-i", 0, objname);
argData.getFlagArgument("-o", 0, mcfname);
return MS::kSuccess;
}
*/
return MS::kSuccess;
}
示例12: getIsExportNode
// --------------------------------------------------------------------
bool SceneGraph::getIsExportNode (
const MDagPath& dagPath,
bool& isForced,
bool& isVisible )
{
// Does this dagPath already exist? If so, only recurse if FollowInstancedChildren() is set.
MFnDagNode dagFn ( dagPath );
String dagNodeName = dagFn.name().asChar();
bool isSceneRoot = dagPath.length() == 0;
// Ignore default and intermediate nodes (history items)
bool isIntermediateObject = dagFn.isIntermediateObject();
if ( ( dagFn.isDefaultNode() && !isSceneRoot ) || isIntermediateObject )
{
return false;
}
MString nodeName = dagPath.partialPathName();
if ( nodeName == MString ( NIMA_INTERNAL_PHYSIKS ) )
{
// Skip this node, which is only used
// by Nima as a work-around for a Maya bug.
return false;
}
// If we are not already forcing this node, its children
// check whether we should be forcing it (skinning of hidden joints).
isForced = isForcedNode ( dagPath );
DagHelper::getPlugValue ( dagPath.node(), ATTR_VISIBILITY, isVisible );
bool isInstanced = dagPath.isInstanced();
uint instanceNumber = dagPath.instanceNumber();
if ( !isForced )
{
// Check for visibility
if ( !ExportOptions::exportInvisibleNodes() && !isVisible )
{
// Check if the visibility of the element is animated.
AnimationSampleCache* animationCache = mDocumentExporter->getAnimationCache();
if ( !AnimationHelper::isAnimated ( animationCache, dagPath.node(), ATTR_VISIBILITY ) )
{
return false;
}
}
else if ( !isVisible && !ExportOptions::exportDefaultCameras() )
{
// Check for the default camera transform names.
if ( nodeName == CAMERA_PERSP || nodeName == CAMERA_TOP || nodeName == CAMERA_SIDE || nodeName == CAMERA_FRONT ||
nodeName == CAMERA_PERSP_SHAPE || nodeName == CAMERA_TOP_SHAPE || nodeName == CAMERA_SIDE_SHAPE || nodeName == CAMERA_FRONT_SHAPE )
return false;
}
}
isForced &= !isVisible;
if ( !isForced )
{
// We don't want to process manipulators
if ( dagPath.hasFn ( MFn::kManipulator ) || dagPath.hasFn ( MFn::kViewManip ) ) return false;
// Check for constraints which are not exported
//if ( !ExportOptions::exportConstraints() && dagPath.hasFn ( MFn::kConstraint ) ) return false;
if ( dagPath.hasFn ( MFn::kConstraint ) ) return false;
// Check set membership exclusion/inclusion
if ( SetHelper::isExcluded ( dagPath ) ) return false;
}
return true;
}
示例13: load
//.........这里部分代码省略.........
{
if(vertexWeights[j] >= 0.00001f || vertexWeights[j] <= -0.00001f )
{
// 记录该节点j
Ids[i].append(j);
weights[i].append(vertexWeights[j]);
}
}
//weights[i]= vertexWeights;
if (MS::kSuccess != stat)
{
std::cout << "Error retrieving vertex weights\n";
}
// get ids for the joints
if (m_pSkeleton)
{
jointIds[i].clear();
if(weights[i].length() > 0 )
{
MDagPathArray influenceObjs;
m_pSkinCluster->influenceObjects(influenceObjs,&stat);
if (MS::kSuccess != stat)
{
std::cout << "Error retrieving influence objects for given skin cluster\n";
}
jointIds[i].setLength(weights[i].length());
for (int j=0; j<jointIds[i].length(); j++)
{
bool foundJoint = false;
for (int k=0; k<m_pSkeleton->getJoints().size() && !foundJoint; k++)
{
if (influenceObjs[Ids[i][j]].partialPathName() == m_pSkeleton->getJoints()[k].name)
{
foundJoint=true;
jointIds[i][j] = m_pSkeleton->getJoints()[k].id;
}
}
}
}
}
}
}
// create an iterator to go through mesh polygons
if (mesh.numPolygons() > 0)
{
const char *name = mesh.name().asChar();
MItMeshPolygon faceIter(mesh.object(),&stat);
if (MS::kSuccess != stat)
{
std::cout << "Error accessing mesh polygons\n";
return MS::kFailure;
}
// iterate over mesh polygons
for (; !faceIter.isDone(); faceIter.next())
{
int numTris=0;
faceIter.numTriangles(numTris);
// for every triangle composing current polygon extract triangle info
for (int iTris=0; iTris<numTris; iTris++)
{
MPointArray triPoints;
MIntArray tempTriVertexIdx,triVertexIdx;
示例14: if
//.........这里部分代码省略.........
// Returns the names of blacklisted UV sets. These UV sets
// are disabled from being passed to the shader because there
// is at least one mesh where the UV set name is defined but
// has no faces mapped. Due to a bug in Maya (in 5.0 and
// possibly some other releases), Maya crashes if an empty
// UV set is accessed by a hardware shader. Blacklisting is
// intended to protect the user against accidentally hitting
// the bug and crashing Maya. After the Maya fix has been
// verified, this option can continue to be accepted for awhile
// for compatibility, returning an empty result array.
// Result type is string[]. (Query only; set internally)
if ( fEmptyUV )
{
setResult( pNode->getEmptyUVSets() );
return MS::kSuccess;
}
// -eus / -emptyUVShapes
// Returns the names of shape nodes that have empty UV sets
// which are causing the UV set names to be blacklisted.
// After the Maya bug fix has been verified, this option
// can remain for awhile for compatibility, returning an
// empty result array.
// Result type is string[]. (Query only; set internally)
if ( fEmptyUVShapes )
{
const MObjectArray& oaShapes = pNode->getEmptyUVSetShapes();
MFnDagNode fnDagNode;
MDagPath dpShape;
for ( unsigned iShape = 0; iShape < oaShapes.length(); ++iShape )
{
fnDagNode.setObject( oaShapes[ iShape ] );
fnDagNode.getPath( dpShape );
saResult.append( dpShape.partialPathName() );
}
setResult( saResult );
return MS::kSuccess;
}
// -tcs / -texCoordSource
// Returns the value of the texCoordSource attribute, because
// the MEL "getAttr" command doesn't work with string arrays.
// Result type is string[]. (Query only; set via "setAttr")
if ( fTexCoordSource )
{
setResult( pNode->getTexCoordSource() );
return MS::kSuccess;
}
#if MAYA_API_VERSION >= 700
// -cs / -colorSource
// Returns the value of the colorSource attribute, because
// the MEL "getAttr" command doesn't work with string arrays.
// Result type is string[]. (Query only; set via "setAttr")
if ( fColorSource )
{
setResult( pNode->getColorSource() );
return MS::kSuccess;
}
#endif
// Error if -q with no other query flags.
return MS::kInvalidParameter;
}
示例15: fillBones
void DMPDSExporter::fillBones( DMPSkeletonData::SubSkeletonStruct* subSkel, string parent, DMPParameters* param, MDagPath& jointDag )
{
MStatus status;
if (jointDag.apiType() != MFn::kJoint)
{
return; // early out.
}
DMPSkeletonData::BoneStruct newBone;
newBone.boneHandle = (unsigned int)subSkel->bones.size();
newBone.name = jointDag.partialPathName().asUTF8();
newBone.parentName = parent;
MFnIkJoint fnJoint(jointDag, &status);
// matrix = [S] * [RO] * [R] * [JO] * [IS] * [T]
/*
These matrices are defined as follows:
•[S] : scale
•[RO] : rotateOrient (attribute name is rotateAxis)
•[R] : rotate
•[JO] : jointOrient
•[IS] : parentScaleInverse
•[T] : translate
The methods to get the value of these matrices are:
•[S] : getScale
•[RO] : getScaleOrientation
•[R] : getRotation
•[JO] : getOrientation
•[IS] : (the inverse of the getScale on the parent transformation matrix)
•[T] : translation
*/
MVector trans = fnJoint.getTranslation(MSpace::kTransform);
double scale[3];
fnJoint.getScale(scale);
MQuaternion R, RO, JO;
fnJoint.getScaleOrientation(RO);
fnJoint.getRotation(R);
fnJoint.getOrientation(JO);
MQuaternion rot = RO * R * JO;
newBone.translate[0] = trans.x * param->lum;
newBone.translate[1] = trans.y * param->lum;
newBone.translate[2] = trans.z * param->lum;
newBone.orientation[0] = rot.w;
newBone.orientation[1] = rot.x;
newBone.orientation[2] = rot.y;
newBone.orientation[3] = rot.z;
newBone.scale[0] = scale[0];
newBone.scale[1] = scale[1];
newBone.scale[2] = scale[2];
subSkel->bones.push_back(newBone);
// Load child joints
for (unsigned int i=0; i<jointDag.childCount();i++)
{
MObject child;
child = jointDag.child(i);
MDagPath childDag = jointDag;
childDag.push(child);
fillBones(subSkel, newBone.name, param, childDag);
}
// now go for animations
if (param->bExportSkelAnimation)
{
for (unsigned int i = 0; i < subSkel->animations.size(); ++i)
{
DMPSkeletonData::TransformAnimation& anim = subSkel->animations[i];
DMPSkeletonData::TransformTrack subTrack;
subTrack.targetBone = newBone.name;
MPlug plugT; // translate
MPlug plugR; // R
MPlug plugRO; // RO
MPlug plugJO; // JO
MPlug plugS; // scale
double dataT[3];
double dataR[3];
double dataRO[3];
double dataJO[3];
double dataS[3];
MFnDependencyNode fnDependNode( jointDag.node(), &status );
plugT = fnDependNode.findPlug("translate", false, &status);
plugR = fnDependNode.findPlug("rotate", false, &status);
plugRO = fnDependNode.findPlug("rotateAxis", false, &status);
plugJO = fnDependNode.findPlug("jointOrient", false, &status);
plugS = fnDependNode.findPlug("scale", false, &status);
float timeStep = param->samplerRate;
if (param->animSampleType == DMPParameters::AST_Frame)
{
timeStep /= param->fps;
}
for (float curTime = anim.startTime; curTime <= anim.endTime; curTime += timeStep)
{
MTime mayaTime;
DMPSkeletonData::TransformKeyFrame keyframe;
//.........这里部分代码省略.........