本文整理汇总了C++中MItDag::next方法的典型用法代码示例。如果您正苦于以下问题:C++ MItDag::next方法的具体用法?C++ MItDag::next怎么用?C++ MItDag::next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MItDag
的用法示例。
在下文中一共展示了MItDag::next方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
}
}
}
}
示例2: FindSkinnerNodesInHierarchy
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
MStatus CVsSkinnerCmd::FindSkinnerNodesInHierarchy(
const MDagPath &iDagPath,
MSelectionList &oList )
{
MStatus retVal( MS::kFailure );
MDagPath rDagPath( iDagPath ); // Root dag path
while ( rDagPath.length() > 1U )
{
rDagPath.pop();
}
MDagPath mDagPath;
MDagPath sDagPath;
uint nShapes;
MItDag dIt;
if ( rDagPath.length() )
{
dIt.reset( rDagPath );
}
for ( ; !dIt.isDone(); dIt.next() )
{
if ( !dIt.getPath( mDagPath ) )
continue;
mDagPath.numberOfShapesDirectlyBelow( nShapes );
for ( uint i( 0U ); i != nShapes; ++i )
{
sDagPath = mDagPath;
sDagPath.extendToShapeDirectlyBelow( i );
if ( !IsSkinnerNode( sDagPath ) )
continue;
oList.add( sDagPath, MObject::kNullObj, true );
retVal = MS::kSuccess;
}
if ( !ConnectedToSkinnerNode( mDagPath, sDagPath ) )
continue;
oList.add( sDagPath, MObject::kNullObj, true );
retVal = MS::kSuccess;
}
return retVal;
}
示例3: GetCurves
bool HesperisIO::GetCurves(const MDagPath &root, MDagPathArray & dst)
{
MStatus stat;
MItDag iter;
iter.reset(root, MItDag::kDepthFirst, MFn::kNurbsCurve);
for(; !iter.isDone(); iter.next()) {
MDagPath apath;
iter.getPath( apath );
if(IsCurveValid(apath)) {
MFnDagNode fdag(apath);
if(!fdag.isIntermediateObject())
dst.append(apath);
}
}
return dst.length() > 0;
}
示例4: DoSelect
//-----------------------------------------------------------------------------
// Selects all vstAttachment nodes in the scene
//-----------------------------------------------------------------------------
MStatus CVstAttachmentCmd::DoSelect()
{
MSelectionList mSelectionList;
MDagPath mDagPath;
for ( MItDag dagIt; !dagIt.isDone(); dagIt.next() )
{
if ( MFnDependencyNode( dagIt.item() ).typeName() == "vstAttachment" )
{
dagIt.getPath( mDagPath );
mSelectionList.add( mDagPath, MObject::kNullObj, true );
}
}
if ( mSelectionList.length() )
{
// Save the current selection just in case we want to undo stuff
MGlobal::getActiveSelectionList( m_mSelectionList );
MGlobal::setActiveSelectionList( mSelectionList, MGlobal::kReplaceList );
m_undoable = true;
}
return MS::kSuccess;
}
示例5: retrieveExportNodes
// ------------------------------------------------------------
bool SceneGraph::retrieveExportNodes()
{
// Create a selection list containing only the root nodes (implies export all!)
MSelectionList allTargets;
for ( MItDag it ( MItDag::kBreadthFirst );
it.depth()<=1 && it.item()!=MObject::kNullObj;
it.next() )
{
MDagPath path;
MStatus status = it.getPath ( path );
String pathName = path.fullPathName().asChar();
// Attach a function set
MFnDependencyNode fn ( path.node() );
String theNodeName = fn.name().asChar();
// Check if it's the world node
if ( it.depth() == 0 ) continue;
if ( status == MStatus::kSuccess )
{
if ( mExportSelectedOnly )
allTargets.add ( path );
else
mTargets.add ( path );
}
}
// now fill in the targets, either the same as allTargets, or it is export selection only
if ( mExportSelectedOnly )
{
// Export the selection:
// Grab the selected DAG components
if ( MStatus::kFailure == MGlobal::getActiveSelectionList ( mTargets ) )
{
std::cerr << "MGlobal::getActiveSelectionList" << std::endl;
return false;
}
// For all the non-transforms selected, make sure to extend to the transforms underneath.
MDagPathArray additions;
MIntArray removals;
for ( uint32 i = 0; i < mTargets.length(); ++i )
{
MDagPath itemPath;
mTargets.getDagPath ( i, itemPath );
if ( !itemPath.node().hasFn ( MFn::kTransform ) )
{
MDagPath transformPath = itemPath;
while ( transformPath.length() > 0 )
{
transformPath.pop();
if ( !mTargets.hasItem ( transformPath ) )
{
additions.append ( transformPath );
break;
}
}
removals.append ( i );
}
}
for ( uint32 i = 0; i < removals.length(); ++i ) mTargets.remove ( removals[i] - i );
for ( uint32 i = 0; i < additions.length(); ++i ) mTargets.add ( additions[i] );
// Add all the forced nodes to the list.
uint32 forceNodeCount = mForcedNodes.length();
for ( uint32 i = 0; i < forceNodeCount; ++i )
{
MDagPath p = mForcedNodes[i];
if ( mTargets.hasItem ( p ) ) continue;
mTargets.add ( p );
}
// Add additional selection paths for any objects in our
// selection which have been instanced (either directly, or
// via instancing of an ancestor) - as otherwise, the selection
// will only include ONE of the DAG paths
//
addInstancedDagPaths ( mTargets );
// remove any selected nodes CONTAINED within other selected
// hierarchies (to ensure we don't export subtrees multiple times)
//
removeMultiplyIncludedDagPaths ( mTargets );
}
return true;
}
示例6: getBoundingBox
MBoundingBox AbcWriteJob::getBoundingBox(double iFrame, const MMatrix & eMInvMat)
{
MStatus status;
MBoundingBox curBBox;
if (iFrame == mFirstFrame)
{
// Set up bbox shape map in the first frame.
// If we have a lot of transforms and shapes, we don't need to
// iterate them for each frame.
MItDag dagIter;
for (dagIter.reset(mCurDag); !dagIter.isDone(); dagIter.next())
{
MObject object = dagIter.currentItem();
MDagPath path;
dagIter.getPath(path);
// short-circuit if the selection flag is on but this node is not in the
// active selection
// MGlobal::isSelected(ob) doesn't work, because DG node and DAG node is
// not the same even if they refer to the same MObject
if (mArgs.useSelectionList && !mSList.hasItem(path))
{
dagIter.prune();
continue;
}
MFnDagNode dagNode(path, &status);
if (status == MS::kSuccess)
{
// check for riCurves flag for flattening all curve object to
// one curve group
MPlug riCurvesPlug = dagNode.findPlug("riCurves", &status);
if ( status == MS::kSuccess && riCurvesPlug.asBool() == true)
{
MBoundingBox box = dagNode.boundingBox();
box.transformUsing(path.exclusiveMatrix()*eMInvMat);
curBBox.expand(box);
// Prune this curve group
dagIter.prune();
// Save children paths
std::map< MDagPath, util::ShapeSet, util::cmpDag >::iterator iter =
mBBoxShapeMap.insert(std::make_pair(mCurDag, util::ShapeSet())).first;
if (iter != mBBoxShapeMap.end())
(*iter).second.insert(path);
}
else if (object.hasFn(MFn::kParticle)
|| object.hasFn(MFn::kMesh)
|| object.hasFn(MFn::kNurbsCurve)
|| object.hasFn(MFn::kNurbsSurface) )
{
if (util::isIntermediate(object))
continue;
MBoundingBox box = dagNode.boundingBox();
box.transformUsing(path.exclusiveMatrix()*eMInvMat);
curBBox.expand(box);
// Save children paths
std::map< MDagPath, util::ShapeSet, util::cmpDag >::iterator iter =
mBBoxShapeMap.insert(std::make_pair(mCurDag, util::ShapeSet())).first;
if (iter != mBBoxShapeMap.end())
(*iter).second.insert(path);
}
}
}
}
else
{
// We have already find out all the shapes for the dag path.
std::map< MDagPath, util::ShapeSet, util::cmpDag >::iterator iter =
mBBoxShapeMap.find(mCurDag);
if (iter != mBBoxShapeMap.end())
{
// Iterate through the saved paths to calculate the box.
util::ShapeSet& paths = (*iter).second;
for (util::ShapeSet::iterator pathIter = paths.begin();
pathIter != paths.end(); pathIter++)
{
MFnDagNode dagNode(*pathIter, &status);
if (status == MS::kSuccess)
{
MBoundingBox box = dagNode.boundingBox();
box.transformUsing((*pathIter).exclusiveMatrix()*eMInvMat);
curBBox.expand(box);
}
}
}
}
return curBBox;
}
示例7: ExportMayaNodes
void MayaMeshExporter::ExportMayaNodes(MItDag& dag_iterator)
{
int start_frame = static_cast<int>(MAnimControl::minTime().as(MTime::kNTSCField));
int end_frame = static_cast<int>(MAnimControl::maxTime().as(MTime::kNTSCField));
int num_frames = end_frame - start_frame + 1;
meshml_obj_.NumFrames(num_frames);
MAnimControl::setCurrentTime(MTime(start_frame, MTime::kNTSCField));
for (MItDependencyNodes dn(MFn::kSkinClusterFilter); !dn.isDone(); dn.next())
{
MStatus status = MS::kSuccess;
MObject object = dn.item();
shared_ptr<MFnSkinCluster> skin_cluster = MakeSharedPtr<MFnSkinCluster>(object, &status);
std::vector<MObject> objs;
unsigned int num_geometries = skin_cluster->numOutputConnections();
for (unsigned int i = 0; i < num_geometries; ++ i)
{
unsigned int index = skin_cluster->indexForOutputConnection(i);
objs.push_back(skin_cluster->outputShapeAtIndex(index));
}
if (num_geometries > 0)
{
skin_clusters_.push_back(std::make_pair(skin_cluster, objs));
}
MDagPathArray influence_paths;
int num_influence_objs = skin_cluster->influenceObjects(influence_paths, &status);
MDagPath joint_path, root_path;
for (int i = 0; i < num_influence_objs; ++ i)
{
joint_path = influence_paths[i];
if (joint_path.hasFn(MFn::kJoint))
{
// Try to retrieve the root path
root_path = joint_path;
while (joint_path.length() > 0)
{
joint_path.pop();
if (joint_path.hasFn(MFn::kJoint) && (joint_path.length() > 0))
{
root_path = joint_path;
}
}
if (root_path.hasFn(MFn::kJoint))
{
MFnIkJoint fn_joint(root_path);
// Don't work on existing joints
KLAYGE_AUTO(iter, joint_to_id_.find(fn_joint.fullPathName().asChar()));
if (iter == joint_to_id_.end())
{
this->ExportJoint(NULL, fn_joint, root_path);
}
}
}
}
}
MDagPath dag_path;
for (; !dag_iterator.isDone(); dag_iterator.next())
{
MStatus status = dag_iterator.getPath(dag_path);
if (!status)
{
std::cout << "Fail to get DAG path." << std::endl;
continue;
}
MString obj_name = dag_iterator.partialPathName();
switch (dag_path.apiType())
{
case MFn::kTransform:
{
/*MFnTransform fnTransform(dagPath, &status);
if (status == MS::kSuccess)
{
MFloatMatrix matrix = fnTransform.transformation().asMatrix();
// TODO: how to handle transformations?
}
else
std::cout << "Fail to initialize transform node." << std::endl;*/
}
break;
case MFn::kMesh:
{
MFnMesh fn_mesh(dag_path, &status);
if (MS::kSuccess == status)
{
if (!fn_mesh.isIntermediateObject())
{
this->ExportMesh(obj_name, fn_mesh, dag_path);
}
else
{
//.........这里部分代码省略.........
示例8: doPress
MStatus HairToolContext::doPress( MEvent& event )
{
// if we have a left mouse click
if(event.mouseButton() == MEvent::kLeftMouse)
{
//Our Viewer
m_View = M3dView::active3dView();
//Get Screen click position
event.getPosition( m_storage[0], m_storage[1] );
screenPoints = vector<vec2>();
screenPoints.push_back(vec2(m_storage[0], m_storage[1]));
//char buffer[200];
//sprintf(buffer, "print \"%i, %i\\n\"", m_storage[0], m_storage[1]);
//MGlobal::executeCommand(buffer);
//Camera stuff
MPoint origin = MPoint();
MVector direction = MVector();
m_View.viewToWorld(m_storage[0], m_storage[1], origin, direction);
//Iterate through meshes in scene
bool intersection = false;
MPointArray points = MPointArray();
MIntArray polygonIds = MIntArray();
MItDag dagIter = MItDag(MItDag::kBreadthFirst, MFn::kInvalid);
for( ; !dagIter.isDone(); dagIter.next() ){
MDagPath dagPath;
dagIter.getPath(dagPath);
MFnDagNode dagNode( dagPath);
//Object cannot be intermediate, it must be a mesh
if( dagNode.isIntermediateObject() ) continue;
if( !dagPath.hasFn(MFn::kMesh) ) continue;
if( dagPath.hasFn(MFn::kTransform) ) continue;
MGlobal::executeCommand(MString("print \"node is a mesh \\n\""));
//MFnMesh mesh = MFnMesh(dagPath);
MFnMesh mesh(dagPath);
points = MPointArray();
polygonIds = MIntArray();
intersection = mesh.intersect(origin, direction, points, 1e-010, MSpace::kWorld, &polygonIds);
if(intersection){
break;
}
}
if(intersection){
intersectionFound = true;
MDagPath dagPath;
dagIter.getPath(dagPath);
// MFnMesh mesh = MFnMesh(dagPath);
MFnMesh mesh(dagPath);
//Polygon Normal
MVector polygonNormal;
mesh.getPolygonNormal(polygonIds[0], polygonNormal, MSpace::kWorld);
if(polygonNormal.normal().angle(direction.normal()) < 20.0f){
//polygonNormal = mesh.get
}
//Camera Right
m_View.getCamera(dagPath);
MFnCamera camera(dagPath);
MVector cameraRight = camera.rightDirection(MSpace::kWorld);
//Resulting Plane
//Point
point = points[0];
//Normal
normal = cameraRight^polygonNormal;
//pushback point
splinePoints = vector<MPoint>();
splinePoints.push_back(MPoint(points[0].x, points[0].y, points[0].z, points[0].w));
/*//Calculate Tvalue
tValue = (points[0].x - origin.x)/direction.x;*/
}
else{
intersectionFound = false;
MGlobal::executeCommand("print \" No Intersection \\n\"");
}
// yay!
return MS::kSuccess;
}
// just let the base class handle the event*/
return MPxContext::doPress(event);
}
示例9: DoNewVolumes
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
MSelectionList CVsSkinnerCmd::DoNewVolumes(
const MDagPath &skinnerPath,
const MSelectionList &skeletonList )
{
MSelectionList retList;
const bool optSelected( m_undo.ArgDatabase().isFlagSet( kOptSelected ) );
MSelectionList optSelection;
m_undo.ArgDatabase().getObjects( optSelection );
// TODO: Maybe some fancier logic to only create volumes on joints that make sense?
// Perhaps the ol' has children but no shapes gag? Watch out for vstHelperBones!
MDagPath mDagPath;
for ( MItSelectionList sIt( optSelection ); !sIt.isDone(); sIt.next() )
{
if ( sIt.itemType() == MItSelectionList::kDagSelectionItem && sIt.getDagPath( mDagPath ) && mDagPath.hasFn( MFn::kTransform ) )
{
if ( optSelected )
{
MObject cObj( DoNewVolume( skinnerPath, mDagPath ) );
if ( cObj.isNull() )
{
mwarn << "Couldn't create new volume on " << skinnerPath.partialPathName()
<< " using " << mDagPath.partialPathName() << " as a parent" << std::endl;
}
else
{
retList.add( skinnerPath, cObj, true );
}
}
else
{
MItDag dIt;
for ( dIt.reset( mDagPath ); !dIt.isDone(); dIt.next() )
{
dIt.getPath( mDagPath );
if ( mDagPath.childCount() )
{
uint nShapes( 0 );
mDagPath.numberOfShapesDirectlyBelow( nShapes );
if ( nShapes == 0U || mDagPath.hasFn( MFn::kJoint ) )
{
MObject cObj( DoNewVolume( skinnerPath, mDagPath ) );
if ( cObj.isNull() )
{
mwarn << "Couldn't create new volume on " << skinnerPath.partialPathName()
<< " using " << mDagPath.partialPathName() << " as a parent" << std::endl;
}
else
{
retList.add( skinnerPath, cObj, true );
}
}
}
}
}
}
}
return retList;
}
示例10: redoIt
MStatus CVstAimCmd::redoIt()
{
MStatus mStatus;
if ( !mStatus )
{
setResult( MString( "Cannot parse command line" ) + mStatus.errorString() );
return MS::kFailure;
}
if ( m_mArgDatabase->isFlagSet( kHelp ) )
{
PrintHelp();
}
else
{
// See if there are two object specified
MDagPath mDagPath;
MSelectionList optSelectionList;
// Validate specified items to whole dag nodes
{
MSelectionList tmpSelectionList;
m_mArgDatabase->getObjects( tmpSelectionList );
for ( MItSelectionList sIt( tmpSelectionList, MFn::kDagNode ); !sIt.isDone(); sIt.next() )
{
if ( sIt.getDagPath( mDagPath ) )
{
optSelectionList.add( mDagPath, MObject::kNullObj, true );
}
}
}
if ( m_mArgDatabase->isFlagSet( "create" ) || optSelectionList.length() >= 2 && m_mArgDatabase->numberOfFlagsUsed() == 0 )
{
// Error if there aren't at least two
if ( optSelectionList.length() < 2 )
{
displayError( GetName() + " needs at least two objects specified or selected when -create is used" );
return MS::kFailure;
}
// Get name command line arg
MString optName;
if ( m_mArgDatabase->isFlagSet( "name" ) )
{
m_mArgDatabase->getFlagArgument( "name", 0, optName );
}
m_undoable = true;
m_mDagModifier = new MDagModifier;
MObject vstAimObj( m_mDagModifier->MDGModifier::createNode( GetName() ) );
if ( m_mDagModifier->doIt() != MS::kSuccess )
{
displayError( MString( "Couldn't create " ) + GetName() + " node" );
m_mDagModifier->undoIt();
delete m_mDagModifier;
m_mDagModifier = NULL;
m_undoable = false;
return MS::kFailure;
}
m_mDagModifier->renameNode( vstAimObj, optName.length() ? optName : GetName() );
if ( m_mDagModifier->doIt() != MS::kSuccess )
{
if ( optName.length() )
{
displayWarning( MString( "Couldn't rename newly created vstNode \"" ) + optName + "\"" );
}
}
// Set options on the newly create vstAim node
MFnDependencyNode vstAimFn( vstAimObj );
MPlug sP;
MPlug dP;
if ( m_mArgDatabase->isFlagSet( kAim ) )
{
MVector aim;
m_mArgDatabase->getFlagArgument( kAim, 0, aim.x );
m_mArgDatabase->getFlagArgument( kAim, 1, aim.y );
m_mArgDatabase->getFlagArgument( kAim, 2, aim.z );
sP = vstAimFn.findPlug( "aimX" );
sP.setValue( aim.x );
sP = vstAimFn.findPlug( "aimY" );
sP.setValue( aim.y );
sP = vstAimFn.findPlug( "aimZ" );
sP.setValue( aim.z );
}
if ( m_mArgDatabase->isFlagSet( kUp ) )
{
//.........这里部分代码省略.........
示例11: writeReferenceNodes
void maTranslator::writeReferenceNodes(fstream& f)
{
//
// We don't write out createNode commands for reference nodes, but
// we do write out parenting between them and non-reference nodes,
// as well as attributes added and attribute values changed after the
// referenced file was loaded
//
writeRefNodeParenting(f);
//
// Output the commands for DAG nodes first.
//
MItDag dagIter;
for (dagIter.next(); !dagIter.isDone(); dagIter.next())
{
MObject node = dagIter.item();
MFnDependencyNode nodeFn(node);
if (nodeFn.isFromReferencedFile()
&& !nodeFn.isFlagSet(fAttrFlag))
{
writeNodeAttrs(f, node, false);
//
// Make note of any connections to this node which have been
// broken by the main scene.
//
MFileIO::getReferenceConnectionsBroken(
node, fBrokenConnSrcs, fBrokenConnDests, true, true
);
nodeFn.setFlag(fAttrFlag, true);
}
}
//
// Now do the remaining, non-DAG nodes.
//
MItDependencyNodes nodeIter;
for (; !nodeIter.isDone(); nodeIter.next())
{
MObject node = nodeIter.item();
MFnDependencyNode nodeFn(node);
if (nodeFn.isFromReferencedFile()
&& !nodeFn.isFlagSet(fAttrFlag))
{
writeNodeAttrs(f, node, false);
//
// Make note of any connections to this node which have been
// broken by the main scene.
//
MFileIO::getReferenceConnectionsBroken(
node, fBrokenConnSrcs, fBrokenConnDests, true, true
);
nodeFn.setFlag(fAttrFlag, true);
}
}
}
示例12: writeDagNodes
void maTranslator::writeDagNodes(fstream& f)
{
fParentingRequired.clear();
MItDag dagIter;
dagIter.traverseUnderWorld(true);
MDagPath worldPath;
dagIter.getPath(worldPath);
//
// We step over the world node before starting the loop, because it
// doesn't get written out.
//
for (dagIter.next(); !dagIter.isDone(); dagIter.next())
{
MDagPath path;
dagIter.getPath(path);
//
// If the node has already been written, then all of its descendants
// must have been written, or at least checked, as well, so prune
// this branch of the tree from the iteration.
//
MFnDagNode dagNodeFn(path);
if (dagNodeFn.isFlagSet(fCreateFlag))
{
dagIter.prune();
continue;
}
//
// If this is a default node, it will be written out later, so skip
// it.
//
if (dagNodeFn.isDefaultNode()) continue;
//
// If this node is not writable, and is not a shared node, then mark
// it as having been written, and skip it.
//
if (!dagNodeFn.canBeWritten() && !dagNodeFn.isShared())
{
dagNodeFn.setFlag(fCreateFlag, true);
continue;
}
unsigned int numParents = dagNodeFn.parentCount();
if (dagNodeFn.isFromReferencedFile())
{
//
// We don't issue 'creatNode' commands for nodes from referenced
// files, but if the node has any parents which are not from
// referenced files, other than the world, then make a note that
// we'll need to issue extra 'parent' commands for it later on.
//
unsigned int i;
for (i = 0; i < numParents; i++)
{
MObject altParent = dagNodeFn.parent(i);
MFnDagNode altParentFn(altParent);
if (!altParentFn.isFromReferencedFile()
&& (altParentFn.object() != worldPath.node()))
{
fParentingRequired.append(path);
break;
}
}
}
else
{
//
// Find the node's parent.
//
MDagPath parentPath = worldPath;
if (path.length() > 1)
{
//
// Get the parent's path.
//
parentPath = path;
parentPath.pop();
//
// If the parent is in the underworld, then find the closest
// ancestor which is not.
//
if (parentPath.pathCount() > 1)
{
//
// The first segment of the path contains whatever
// portion of the path exists in the world. So the closest
// worldly ancestor is simply the one at the end of that
//.........这里部分代码省略.........
示例13: writeConnections
//
// Write out all of the connections in the scene.
//
void maTranslator::writeConnections(fstream& f)
{
//
// If the scene has broken any connections which were made in referenced
// files, handle those first so that the attributes are free for any new
// connections which may come along.
//
writeBrokenRefConnections(f);
//
// We're about to write out the scene's connections in three parts: DAG
// nodes, non-DAG non-default nodes, then default nodes.
//
// It's really not necessary that we group them like this and would in
// fact be more efficient to do them all in one MItDependencyNodes
// traversal. However, this is the order in which the normal MayaAscii
// translator does them, so this makes it easier to compare the output
// of this translator to Maya's output.
//
//
// Write out connections for the DAG nodes first.
//
MItDag dagIter;
dagIter.traverseUnderWorld(true);
for (dagIter.next(); !dagIter.isDone(); dagIter.next())
{
MObject node = dagIter.item();
MFnDagNode dagNodeFn(node);
if (!dagNodeFn.isFlagSet(fConnectionFlag)
&& dagNodeFn.canBeWritten()
&& !dagNodeFn.isDefaultNode())
{
writeNodeConnections(f, dagIter.item());
dagNodeFn.setFlag(fConnectionFlag, true);
}
}
//
// Now do the non-DAG, non-default nodes.
//
MItDependencyNodes nodeIter;
for (; !nodeIter.isDone(); nodeIter.next())
{
MFnDependencyNode nodeFn(nodeIter.item());
if (!nodeFn.isFlagSet(fConnectionFlag)
&& nodeFn.canBeWritten()
&& !nodeFn.isDefaultNode())
{
writeNodeConnections(f, nodeIter.item());
nodeFn.setFlag(fConnectionFlag, true);
}
}
//
// And finish up with the default nodes.
//
unsigned int numNodes = fDefaultNodes.length();
unsigned int i;
for (i = 0; i < numNodes; i++)
{
MFnDependencyNode nodeFn(fDefaultNodes[i]);
if (!nodeFn.isFlagSet(fConnectionFlag)
&& nodeFn.canBeWritten()
&& nodeFn.isDefaultNode())
{
writeNodeConnections(f, fDefaultNodes[i]);
nodeFn.setFlag(fConnectionFlag, true);
}
}
}