本文整理汇总了C++中MDagPath::push方法的典型用法代码示例。如果您正苦于以下问题:C++ MDagPath::push方法的具体用法?C++ MDagPath::push怎么用?C++ MDagPath::push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDagPath
的用法示例。
在下文中一共展示了MDagPath::push方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getDagPathByChildName
bool getDagPathByChildName(MDagPath & ioDagPath, const std::string & iChildName)
{
unsigned int numChildren = ioDagPath.childCount();
std::string strippedName = stripPathAndNamespace(iChildName);
MObject closeMatch;
for (unsigned int i = 0; i < numChildren; ++i)
{
MObject child = ioDagPath.child(i);
MFnDagNode dagChild(child);
std::string name = dagChild.partialPathName().asChar();
if (name == iChildName)
{
ioDagPath.push(child);
return true;
}
if (closeMatch.isNull())
{
if (strippedName == stripPathAndNamespace(name))
{
closeMatch = child;
}
}
}
if (!closeMatch.isNull())
{
ioDagPath.push(closeMatch);
return true;
}
return false;
}
示例2: getChildDags
void LiveScene::getChildDags( const MDagPath& dagPath, MDagPathArray& paths ) const
{
for( unsigned i=0; i < dagPath.childCount(); ++i )
{
MDagPath childPath = dagPath;
childPath.push( dagPath.child( i ) );
if( dagPath.length() == 0 )
{
// bizarrely, this iterates through things like the translate manipulator and
// the view cube too, so lets skip them so they don't show up:
if( childPath.node().hasFn( MFn::kManipulator3D ) )
{
continue;
}
// looks like it also gives us the ground plane, so again, lets skip that:
if( childPath.fullPathName() == "|groundPlane_transform" )
{
continue;
}
}
paths.append( childPath );
}
}
示例3: GetShapeNode
MStatus GetShapeNode(MDagPath& path, bool intermediate) {
MStatus status;
if (IsShapeNode(path)) {
// Start at the transform so we can honor the intermediate flag.
path.pop();
}
if (path.hasFn(MFn::kTransform)) {
unsigned int shapeCount = path.childCount();
for (unsigned int i = 0; i < shapeCount; ++i) {
status = path.push(path.child(i));
CHECK_MSTATUS_AND_RETURN_IT(status);
if (!IsShapeNode(path)) {
path.pop();
continue;
}
MFnDagNode fnNode(path, &status);
CHECK_MSTATUS_AND_RETURN_IT(status);
if ((!fnNode.isIntermediateObject() && !intermediate) ||
(fnNode.isIntermediateObject() && intermediate)) {
return MS::kSuccess;
}
// Go to the next shape
path.pop();
}
}
// No valid shape node found.
return MS::kFailure;
}
示例4: findForcedNodes
// ------------------------------------------------------------
void SceneGraph::findForcedNodes()
{
MStatus status;
if ( mExportSelectedOnly )
{
MSelectionList selectedItems;
MGlobal::getActiveSelectionList ( selectedItems );
uint selectedCount = selectedItems.length();
MDagPathArray queue;
for ( uint i = 0; i < selectedCount; ++i )
{
MDagPath selectedPath;
status = selectedItems.getDagPath ( i, selectedPath );
if ( status == MStatus::kSuccess ) queue.append ( selectedPath );
}
while ( queue.length() > 0 )
{
MDagPath selectedPath = queue[queue.length() - 1];
queue.remove ( queue.length() - 1 );
// Queue up the children.
uint childCount = selectedPath.childCount();
for ( uint i = 0; i < childCount; ++i )
{
MObject node = selectedPath.child ( i );
MDagPath childPath = selectedPath;
childPath.push ( node );
queue.append ( childPath );
}
// Look for a mesh
if ( selectedPath.node().hasFn ( MFn::kMesh ) )
{
// export forced nodes in path
addForcedNodes ( selectedPath );
}
}
}
else
{
for ( MItDag dagIt ( MItDag::kBreadthFirst ); !dagIt.isDone(); dagIt.next() )
{
MDagPath currentPath;
status = dagIt.getPath ( currentPath );
if ( status == MStatus::kSuccess )
{
MFnDagNode node ( currentPath );
String nodeName = node.name().asChar();
if ( currentPath.node().hasFn ( MFn::kMesh ) )
{
// export forced nodes in path
addForcedNodes ( currentPath );
}
}
}
}
}
示例5: isLightTransform
// todo: extend with own light extensions.
bool isLightTransform(MDagPath& dagPath)
{
uint numChilds = dagPath.childCount();
for (uint chId = 0; chId < numChilds; chId++)
{
MDagPath childPath = dagPath;
MStatus stat = childPath.push(dagPath.child(chId));
if (!stat)
{
continue;
}
if (childPath.node().hasFn(MFn::kLight))
return true;
}
return false;
}
示例6: findCamera
bool findCamera(MDagPath& dagPath)
{
if (dagPath.node().hasFn(MFn::kCamera))
return true;
uint numChilds = dagPath.childCount();
for (uint chId = 0; chId < numChilds; chId++)
{
MDagPath childPath = dagPath;
MStatus stat = childPath.push(dagPath.child(chId));
if (!stat)
{
continue;
}
MString childName = childPath.fullPathName();
return findCamera(childPath);
}
return false;
}
示例7: createChildSceneElements
// ------------------------------------------------------------
bool SceneGraph::createChildSceneElements ( SceneElement* sceneElement )
{
// Get the current path
MDagPath dagPath = sceneElement->getPath();
// Now, whip through this node's DAG children
MFnDagNode dagFn ( dagPath );
uint childCount = dagFn.childCount();
for ( uint i = 0; i < childCount; ++i )
{
MObject child = dagFn.child ( i );
MDagPath childDagPath = dagPath;
childDagPath.push ( child );
SceneElement* childSceneElement = createSceneElement ( childDagPath, sceneElement );
// Recursive call to take the children
createChildSceneElements ( childSceneElement );
}
return true;
}
示例8: traverseSubSkeleton
void DMPDSExporter::traverseSubSkeleton( DMPParameters* param, const MDagPath& dagPath )
{
MStatus stat;
fillSubSkeleton(param, dagPath);
// look for meshes and cameras within the node's children
for (unsigned int i=0; i<dagPath.childCount(); i++)
{
MObject child = dagPath.child(i);
MDagPath childPath = dagPath;
stat = childPath.push(child);
if (MStatus::kSuccess != stat)
{
std::cout << "Error retrieving path to child " << i << " of: " << dagPath.fullPathName().asChar();
std::cout.flush();
return;
}
fillSubSkeleton(param, childPath);
if (MStatus::kSuccess != stat)
{
return;
}
}
}
示例9: processReference
// --------------------------------------
void ReferenceManager::processReference ( const MObject& referenceNode )
{
MStatus status;
MFnDependencyNode referenceNodeFn ( referenceNode, &status );
if (status != MStatus::kSuccess) return;
#if MAYA_API_VERSION >= 600
MString referenceNodeName = MFnDependencyNode( referenceNode ).name();
Reference* reference = new Reference();
reference->referenceNode = referenceNode;
mReferences.push_back ( reference );
// Get the paths of the root transforms included in this reference
MObjectArray subReferences;
getRootObjects ( referenceNode, reference->paths, subReferences );
uint pathCount = reference->paths.length();
// Process the sub-references first
uint subReferenceCount = subReferences.length();
for (uint i = 0; i < subReferenceCount; ++i)
{
MObject& subReference = subReferences[i];
if ( subReference != MObject::kNullObj ) processReference ( subReference );
}
// Retrieve the reference node's filename
MString command = MString("reference -rfn \"") + referenceNodeFn.name() + MString("\" -q -filename;");
MString filename;
status = MGlobal::executeCommand ( command, filename );
if (status != MStatus::kSuccess || filename.length() == 0) return;
// Strip the filename of the multiple file token
int stripIndex = filename.index('{');
if (stripIndex != -1) filename = filename.substring(0, stripIndex - 1);
// Avoid transform look-ups on COLLADA references.
int extLocation = filename.rindex('.');
if (extLocation > 0)
{
MString ext = filename.substring(extLocation + 1, filename.length() - 1).toLowerCase();
if (ext == "dae" || ext == "xml") return;
}
// Check for already existing file information
// Otherwise create a new file information sheet with current node names
for ( ReferenceFileList::iterator it = mFiles.begin(); it != mFiles.end(); ++it )
{
if ((*it)->filename == filename)
{
reference->file = (*it);
break;
}
}
if ( reference->file == NULL ) reference->file = processReferenceFile(filename);
// Get the list of the root transform's first child's unreferenced parents.
// This is a list of the imported nodes!
for (uint j = 0; j < pathCount; ++j)
{
MDagPath path = reference->paths[j];
if (path.childCount() > 0)
{
path.push ( path.child(0) );
MFnDagNode childNode ( path );
if (!childNode.object().hasFn(MFn::kTransform)) continue;
uint parentCount = childNode.parentCount();
for (uint k = 0; k < parentCount; ++k)
{
MFnDagNode parentNode(childNode.parent(k));
if (parentNode.object() == MObject::kNullObj || parentNode.isFromReferencedFile()) continue;
MDagPath parentPath = MDagPath::getAPathTo(parentNode.object());
if (parentPath.length() > 0)
{
ReferenceRootList::iterator it =
reference->reroots.insert( reference->reroots.end(), ReferenceRoot() );
(*it).index = j;
(*it).reroot = parentPath;
}
}
}
}
#endif
}
示例10: 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;
//.........这里部分代码省略.........
示例11: loadJoint
//.........这里部分代码省略.........
plug.getValue(tail);
plug = jointFn.findPlug("unParticleUnShaded");
bool unshaded;
plug.getValue(unshaded);
plug = jointFn.findPlug("unParticleUnFogged");
bool unfogged;
plug.getValue(unfogged);
plug = jointFn.findPlug("unParticleBlockByY0");
bool blockByY0 = false;
if(!plug.isNull())
plug.getValue(blockByY0);
newJoint.particle.visible = visible;
newJoint.particle.speed = speed;
newJoint.particle.variation = variation / 100.0f;
newJoint.particle.coneAngle = coneAngle;
newJoint.particle.gravity = gravity;
newJoint.particle.explosiveForce = explosiveForce;
newJoint.particle.life = life;
newJoint.particle.lifeVar = lifeVar;
newJoint.particle.emissionRate = emissionRate;
newJoint.particle.initialNum = initialNum;
newJoint.particle.limitNum = limitNum;
newJoint.particle.attachToEmitter = attachToEmitter;
newJoint.particle.moveWithEmitter = moveWithEmitter;
newJoint.particle.forTheSword = forTheSword;
newJoint.particle.forTheSwordInitialAngle = forTheSwordInitialAngle;
newJoint.particle.wander = wander;
newJoint.particle.wanderRadius = wanderRadius;
newJoint.particle.wanderSpeed = wanderSpeed;
newJoint.particle.aspectRatio = aspectRatio;
newJoint.particle.initialAngleBegin = angleBegin;
newJoint.particle.initialAngleEnd = angleEnd;
newJoint.particle.rotationSpeed = rotationSpeed;
newJoint.particle.rotationSpeedVar = rotationSpeedVar;
newJoint.particle.width = width;
newJoint.particle.length = length;
newJoint.particle.height = height;
newJoint.particle.blendMode = blendMode;
newJoint.particle.textureFilename = textureName.asChar();
newJoint.particle.textureRows = rows;
newJoint.particle.textureCols = cols;
newJoint.particle.changeStyle = changeStyle;
newJoint.particle.changeInterval = changeInterval;
newJoint.particle.tailLength = tailLength;
newJoint.particle.timeMiddle = timeMiddle;
newJoint.particle.colorStart[0] = colorStart[0];
newJoint.particle.colorStart[1] = colorStart[1];
newJoint.particle.colorStart[2] = colorStart[2];
newJoint.particle.colorMiddle[0] = colorMiddle[0];
newJoint.particle.colorMiddle[1] = colorMiddle[1];
newJoint.particle.colorMiddle[2] = colorMiddle[2];
newJoint.particle.colorEnd[0] = colorEnd[0];
newJoint.particle.colorEnd[1] = colorEnd[1];
newJoint.particle.colorEnd[2] = colorEnd[2];
newJoint.particle.alpha[0] = alpha[0];
newJoint.particle.alpha[1] = alpha[1];
newJoint.particle.alpha[2] = alpha[2];
newJoint.particle.scale[0] = scale[0];
newJoint.particle.scale[1] = scale[1];
newJoint.particle.scale[2] = scale[2];
newJoint.particle.scaleVar[0] = scaleVar[0];
newJoint.particle.scaleVar[1] = scaleVar[1];
newJoint.particle.scaleVar[2] = scaleVar[2];
newJoint.particle.fixedSize = fixedSize;
newJoint.particle.headLifeSpan[0] = headLifeSpan[0];
newJoint.particle.headLifeSpan[1] = headLifeSpan[1];
newJoint.particle.headLifeSpan[2] = headLifeSpan[2];
newJoint.particle.headDecay[0] = headDecay[0];
newJoint.particle.headDecay[1] = headDecay[1];
newJoint.particle.headDecay[2] = headDecay[2];
newJoint.particle.tailLifeSpan[0] = tailLifeSpan[0];
newJoint.particle.tailLifeSpan[1] = tailLifeSpan[1];
newJoint.particle.tailLifeSpan[2] = tailLifeSpan[2];
newJoint.particle.tailDecay[0] = tailDecay[0];
newJoint.particle.tailDecay[1] = tailDecay[1];
newJoint.particle.tailDecay[2] = tailDecay[2];
newJoint.particle.head = head;
newJoint.particle.tail = tail;
newJoint.particle.unshaded = unshaded;
newJoint.particle.unfogged = unfogged;
newJoint.particle.blockByY0 = blockByY0;
}
}
m_joints.push_back(newJoint);
// Get pointer to newly created joint
parentJoint = &newJoint;
}
// Load children joints
for (i=0; i<jointDag.childCount();i++)
{
MObject child;
child = jointDag.child(i);
MDagPath childDag = jointDag;
childDag.push(child);
loadJoint(childDag,parentJoint);
}
}
示例12: translateNode
//.........这里部分代码省略.........
std::cout.flush();
}
else
{
std::cout << "Error, Aborting operation\n";
std::cout.flush();
return MS::kFailure;
}
}
}
}
if (dagPath.hasFn(MFn::kMesh)&&(m_params.exportMesh||m_params.exportMaterial||m_params.exportSkeleton)
&& (dagPath.childCount() == 0))
{ // we have found a mesh shape node, it can't have any children, and it contains
// all the mesh geometry data
MDagPath meshDag = dagPath;
MFnMesh meshFn(meshDag);
if (!meshFn.isIntermediateObject())
{
std::cout << "Found mesh node: " << meshDag.fullPathName().asChar() << "\n";
std::cout << "Loading mesh node " << meshDag.fullPathName().asChar() << "...\n";
std::cout.flush();
stat = m_pMesh->load(meshDag,m_params);
if (MS::kSuccess == stat)
{
std::cout << "OK\n";
std::cout.flush();
}
else
{
std::cout << "Error, mesh skipped\n";
std::cout.flush();
}
}
}
else if (dagPath.hasFn(MFn::kCamera)&&(m_params.exportCameras) && (!dagPath.hasFn(MFn::kShape)))
{ // we have found a camera shape node, it can't have any children, and it contains
// all information about the camera
MFnCamera cameraFn(dagPath);
if (!cameraFn.isIntermediateObject())
{
std::cout << "Found camera node: "<< dagPath.fullPathName().asChar() << "\n";
std::cout << "Translating camera node: "<< dagPath.fullPathName().asChar() << "...\n";
std::cout.flush();
stat = writeCamera(cameraFn);
if (MS::kSuccess == stat)
{
std::cout << "OK\n";
std::cout.flush();
}
else
{
std::cout << "Error, Aborting operation\n";
std::cout.flush();
return MS::kFailure;
}
}
}
else if ( ( dagPath.apiType() == MFn::kParticle ) && m_params.exportParticles )
{ // we have found a set of particles
MFnDagNode fnNode(dagPath);
if (!fnNode.isIntermediateObject())
{
std::cout << "Found particles node: "<< dagPath.fullPathName().asChar() << "\n";
std::cout << "Translating particles node: "<< dagPath.fullPathName().asChar() << "...\n";
std::cout.flush();
Particles particles;
particles.load(dagPath,m_params);
stat = particles.writeToXML(m_params);
if (MS::kSuccess == stat)
{
std::cout << "OK\n";
std::cout.flush();
}
else
{
std::cout << "Error, Aborting operation\n";
std::cout.flush();
return MS::kFailure;
}
}
}
// look for meshes and cameras within the node's children
for (uint i=0; i<dagPath.childCount(); i++)
{
MObject child = dagPath.child(i);
MDagPath childPath = dagPath;
stat = childPath.push(child);
if (MS::kSuccess != stat)
{
std::cout << "Error retrieving path to child " << i << " of: " << dagPath.fullPathName().asChar();
std::cout.flush();
return MS::kFailure;
}
stat = translateNode(childPath);
if (MS::kSuccess != stat)
return MS::kFailure;
}
return MS::kSuccess;
}