当前位置: 首页>>代码示例>>C++>>正文


C++ MItDag::item方法代码示例

本文整理汇总了C++中MItDag::item方法的典型用法代码示例。如果您正苦于以下问题:C++ MItDag::item方法的具体用法?C++ MItDag::item怎么用?C++ MItDag::item使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MItDag的用法示例。


在下文中一共展示了MItDag::item方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:27,代码来源:VstAttachmentCmd.cpp

示例2: 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;
    }
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:93,代码来源:COLLADAMayaSceneGraph.cpp

示例3: 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);
		}
	}
}
开发者ID:DimondTheCat,项目名称:xray,代码行数:64,代码来源:maTranslator.cpp

示例4: redoIt


//.........这里部分代码省略.........
			{
				MPlug mP( toAimFn.findPlug( "rotateAxis" ) );
				if ( !mP.isNull() )
				{
					MAngle rx, ry, rz;
					mP.child( 0 ).getValue( rx );
					mP.child( 1 ).getValue( ry );
					mP.child( 2 ).getValue( rz );
					if ( abs( rx.value() ) > FLT_EPSILON || abs( ry.value() ) > FLT_EPSILON || abs( rz.value() ) > FLT_EPSILON )
					{
						mwarn << "Rotate Axis on node being constrained is non-zero ( " << rx.asDegrees() << " " << ry.asDegrees() << " " << rz.asDegrees() << " ), setting to 0" << std::endl;
						mP.child( 0 ).setValue( MAngle( 0.0 ) );
						mP.child( 1 ).setValue( MAngle( 0.0 ) );
						mP.child( 2 ).setValue( MAngle( 0.0 ) );
					}
				}
			}

			MDagPath aimAt;
			optSelectionList.getDagPath( 0, aimAt );
			const MFnDagNode aimAtFn( aimAt );

			// toAim.rotateOrder -> vstAim.rotateOrder
			sP = toAimFn.findPlug( "rotateOrder" );
			dP = vstAimFn.findPlug( "rotateOrder" );
			m_mDagModifier->connect( sP, dP );

			// toAim.translate -> vstAim.translate
			sP = toAimFn.findPlug( "translate" );
			dP = vstAimFn.findPlug( "translate" );
			m_mDagModifier->connect( sP, dP );

			// toAim.parentMatrix[ instance ] -> vstAim.parentSpace
			sP = toAimFn.findPlug( "parentMatrix" );
			sP = sP.elementByLogicalIndex( toAim.instanceNumber() );
			dP = vstAimFn.findPlug( "parentSpace" );
			m_mDagModifier->connect( sP, dP );

			// aimAt.worldMatrix[ instance ] -> vstAim.aimSpace
			sP = aimAtFn.findPlug( "worldMatrix" );
			sP = sP.elementByLogicalIndex( aimAt.instanceNumber() );
			dP = vstAimFn.findPlug( "aimSpace" );
			m_mDagModifier->connect( sP, dP );

			// vstAim.rotation -> toAim.rotation
			// These have to be connected individually because Maya plays stupid tricks
			// with rotateOrder if they aren't
			sP = vstAimFn.findPlug( "rotateX" );
			dP = toAimFn.findPlug( "rotateX" );
			m_mDagModifier->connect( sP, dP );

			sP = vstAimFn.findPlug( "rotateY" );
			dP = toAimFn.findPlug( "rotateY" );
			m_mDagModifier->connect( sP, dP );

			sP = vstAimFn.findPlug( "rotateZ" );
			dP = toAimFn.findPlug( "rotateZ" );
			m_mDagModifier->connect( sP, dP );

			if ( m_mDagModifier->doIt() != MS::kSuccess )
			{
				displayWarning( MString( GetName() ) + ": Couldn't connect everything when creating" );
			}

			// Save the current selection just in case we want to undo stuff
			MGlobal::getActiveSelectionList( m_mSelectionList );

			MGlobal::select( vstAimObj, MGlobal::kReplaceList );
			setResult( vstAimFn.name() );
		}
		else if ( m_mArgDatabase->isFlagSet( "select" ) )
		{
			MSelectionList mSelectionList;
			MDagPath mDagPath;

			for ( MItDag dagIt; !dagIt.isDone(); dagIt.next() )
			{
				if ( MFnDependencyNode( dagIt.item() ).typeName() == GetName() )
				{
					dagIt.getPath( mDagPath );
					mSelectionList.add( mDagPath, MObject::kNullObj, true );
				}
			}

			if ( mSelectionList.length() )
			{
				m_undoable = true;
				// Save the current selection just in case we want to undo stuff
				MGlobal::getActiveSelectionList( m_mSelectionList );
				MGlobal::setActiveSelectionList( mSelectionList, MGlobal::kReplaceList );
			}
		}
		else
		{
			displayError( GetName() + ": No valid operation specified via command line arguments\n" );
		}
	}

	return MS::kSuccess;
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:101,代码来源:VstAimCmd.cpp

示例5: 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);
		}
	}
}
开发者ID:DimondTheCat,项目名称:xray,代码行数:80,代码来源:maTranslator.cpp


注:本文中的MItDag::item方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。