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


C++ MDagPathArray::append方法代码示例

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


在下文中一共展示了MDagPathArray::append方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 );
                    }
                }
            }
        }
    }
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:61,代码来源:COLLADAMayaSceneGraph.cpp

示例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 );
	}
}
开发者ID:cnpinto,项目名称:cortex,代码行数:26,代码来源:LiveScene.cpp

示例3: writeSelectedCurve

MStatus HesperisCmd::writeSelectedCurve(const MSelectionList & selList)
{
	MItSelectionList iter( selList );
	
	MDagPathArray curves;
	MDagPathArray tms;
	
	for(; !iter.isDone(); iter.next()) {								
		MDagPath apath;		
		iter.getDagPath( apath );
		tms.append(apath);
		ASearchHelper::LsAllTypedPaths(curves, apath, MFn::kNurbsCurve);
	}
	
	if(curves.length() < 1) {
		MGlobal::displayInfo(" zero curve selction!");
		return MS::kSuccess;
	}
	
	HesperisFile hesf;
	bool fstat = hesf.create(m_fileName.asChar());
	if(!fstat) {
		MGlobal::displayWarning(MString(" cannot create file ")+ m_fileName);
		return MS::kSuccess;
	}
	
	HesperisIO::WriteTransforms(tms, &hesf);
	HesperisCurveIO::WriteCurves(curves, &hesf);
	
	writeMesh(&hesf);
	
	MGlobal::displayInfo(" done.");
	
	return MS::kSuccess;
}
开发者ID:spinos,项目名称:aphid,代码行数:35,代码来源:HesperisCmd.cpp

示例4: getRootObjects

    // --------------------------------------
    void ReferenceManager::getRootObjects(
        const MObject& referenceNode, 
        MDagPathArray& rootPaths, 
        MObjectArray& subReferences)
    {
        rootPaths.clear();
        subReferences.clear();

        MFnDependencyNode referenceNodeFn(referenceNode);

        // Get the paths of all the dag nodes included in this reference
        MStringArray nodeNames;
        MString command = MString("reference -rfn \"") + referenceNodeFn.name() + "\" -q -node -dp;";
        MGlobal::executeCommand(command, nodeNames);

        uint nodeNameCount = nodeNames.length();
        MDagPathArray nodePaths;
        for (uint j = 0; j < nodeNameCount; ++j)
        {
            MObject o = DagHelper::getNode(nodeNames[j]);
            MDagPath p = DagHelper::getShortestDagPath(o);
            if (p.length() > 0)
            {
                nodePaths.append(p);
            }
            else
            {
                if (o != MObject::kNullObj && o.apiType() == MFn::kReference
                    && strstr(nodeNames[j].asChar(), "_UNKNOWN_REF_NODE") == NULL)
                {
                    subReferences.append(o);
                }
            }
        }

        // Keep only the root transform for the reference in our path arrays
        uint nodePathCount = nodePaths.length();
        for (uint j = 0; j < nodePathCount; ++j)
        {
            const MDagPath& p = nodePaths[j];
            if ( !isRootTransform ( nodePaths, p ) ) continue;
            rootPaths.append(p);
        }
    }
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:45,代码来源:COLLADAMayaReferenceManager.cpp

示例5: tAttr

MStatus Molecule3Cmd::doIt( const MArgList &args )
{
	MStatus stat;
	
	// Initialize options to default values
	MFnTypedAttribute tAttr( 
	/*
	radius.setValue( 0.1 );
	segs = 6;
	ballRodRatio = 2.0;
	*/
	
	selMeshes.clear();
	
	// Get the options from the command line
	MArgDatabase argData( syntax(), args, &stat );
	if( !stat )
		return stat;

	if( argData.isFlagSet( radiusFlag ) )
		argData.getFlagArgument( radiusFlag, 0, radius );
	
	if( argData.isFlagSet( segsFlag ) )
		argData.getFlagArgument( segsFlag, 0, segs );

	if( argData.isFlagSet( ballRatioFlag ) )
		argData.getFlagArgument( ballRatioFlag, 0, ballRodRatio );
	
	// Get a list of currently selected objects
	MSelectionList selection;
	MGlobal::getActiveSelectionList( selection );

	// Iterate over the meshes
	MDagPath dagPath;
	MItSelectionList iter( selection, MFn::kMesh );
	for ( ; !iter.isDone(); iter.next() )
	{								
		iter.getDagPath( dagPath );
		selMeshes.append( dagPath );	
	}
	
	if( selMeshes.length() == 0 )
	{
		MGlobal::displayWarning( "Select one or more meshes" );
		return MS::kFailure;
	}	
		
	return redoIt();
}
开发者ID:animformed,项目名称:complete-maya-programming-book-files,代码行数:49,代码来源:Molecule3Cmd.cpp

示例6: 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;
}
开发者ID:ahmidou,项目名称:aphid,代码行数:16,代码来源:HesperisIO.cpp

示例7: exportSelected

MS DCTranslator::exportSelected()
{
	MS status;
	MSelectionList selection;
	MGlobal::getActiveSelectionList(selection);
	MItSelectionList selIt(selection);
	if (selIt.isDone()) {
		status.perror("MayaToolKit: Nothing Selected!");
		MGlobal::displayWarning("kaleido maya toolkit: Nothing selected!");
		return MS::kFailure;
	}

	MDagPathArray pathArray;
	for (; !selIt.isDone(); selIt.next()) {
		MItDag dagIt(MItDag::kDepthFirst, MFn::kInvalid, &status);
		MDagPath objPath;
		status = selIt.getDagPath(objPath);
		status = dagIt.reset(objPath.node(), MItDag::kDepthFirst, MFn::kInvalid);
		do {
			MDagPath dagPath;
			MObject component = MObject::kNullObj;
			status = dagIt.getPath(dagPath);
			MFnDagNode dagNode(dagPath, &status);
			if (dagNode.isIntermediateObject())
			{

			}
			else if (dagPath.hasFn(MFn::kMesh))
			{
				if (!dagPath.hasFn(MFn::kTransform))
				{
					SpMesh curMesh{ new Mesh };
					status = GetMeshFromNode(dagPath, status, *curMesh);
					//WriteTheMesh Here
					if (status == MS::kSuccess) {
						(*m_MeshArch) << curMesh;
						MGlobal::displayInfo("Write Mesh finished.");
						m_Meshes.push_back(curMesh);
					}
					else {
						MGlobal::displayError("Error GetMesh From Node.");
					}
				}
			}
			else if (dagPath.hasFn(MFn::kCamera))
			{
				if (!dagPath.hasFn(MFn::kTransform))
				{
					pathArray.append(dagPath);
				}
			}
			else if (dagPath.hasFn(MFn::kSpotLight))
			{
				if (!dagPath.hasFn(MFn::kTransform))
				{
					pathArray.append(dagPath);
				}
			}
			dagIt.next();
		} while (!dagIt.isDone());
	}

	return status;
}
开发者ID:gitter-badger,项目名称:kaleido3d,代码行数:64,代码来源:DCTranslator.cpp

示例8: doConversion

bool ToMayaSkinClusterConverter::doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const
{
    MStatus s;

    IECore::ConstSmoothSkinningDataPtr skinningData = IECore::runTimeCast<const IECore::SmoothSkinningData>( from );
    assert( skinningData );

    const std::vector<std::string> &influenceNames = skinningData->influenceNames()->readable();
    const std::vector<Imath::M44f> &influencePoseData  = skinningData->influencePose()->readable();
    const std::vector<int> &pointIndexOffsets  = skinningData->pointIndexOffsets()->readable();
    const std::vector<int> &pointInfluenceCounts = skinningData->pointInfluenceCounts()->readable();
    const std::vector<int> &pointInfluenceIndices = skinningData->pointInfluenceIndices()->readable();
    const std::vector<float> &pointInfluenceWeights = skinningData->pointInfluenceWeights()->readable();

    MFnDependencyNode fnSkinClusterNode( to, &s );
    MFnSkinCluster fnSkinCluster( to, &s );
    if ( s != MS::kSuccess )
    {
        /// \todo: optional parameter to allow custom node types and checks for the necessary attributes
        /// \todo: create a new skinCluster if we want a kSkinClusterFilter and this isn't one
        throw IECore::Exception( ( boost::format( "ToMayaSkinClusterConverter: \"%s\" is not a valid skinCluster" ) % fnSkinClusterNode.name() ).str() );
    }

    const unsigned origNumInfluences = influenceNames.size();
    unsigned numInfluences = origNumInfluences;
    std::vector<bool> ignoreInfluence( origNumInfluences, false );
    std::vector<int> indexMap( origNumInfluences, -1 );
    const bool ignoreMissingInfluences = m_ignoreMissingInfluencesParameter->getTypedValue();
    const bool ignoreBindPose = m_ignoreBindPoseParameter->getTypedValue();

    // gather the influence objects
    MObject mObj;
    MDagPath path;
    MSelectionList influenceList;
    MDagPathArray influencePaths;
    for ( unsigned i=0, index=0; i < origNumInfluences; i++ )
    {
        MString influenceName( influenceNames[i].c_str() );
        s = influenceList.add( influenceName );
        if ( !s )
        {
            if ( ignoreMissingInfluences )
            {
                ignoreInfluence[i] = true;
                MGlobal::displayWarning( MString( "ToMayaSkinClusterConverter: \"" + influenceName + "\" is not a valid influence" ) );
                continue;
            }

            throw IECore::Exception( ( boost::format( "ToMayaSkinClusterConverter: \"%s\" is not a valid influence" ) % influenceName ).str() );
        }

        influenceList.getDependNode( index, mObj );
        MFnIkJoint fnInfluence( mObj, &s );
        if ( !s )
        {
            if ( ignoreMissingInfluences )
            {
                ignoreInfluence[i] = true;
                influenceList.remove( index );
                MGlobal::displayWarning( MString( "ToMayaSkinClusterConverter: \"" + influenceName + "\" is not a valid influence" ) );
                continue;
            }

            throw IECore::Exception( ( boost::format( "ToMayaSkinClusterConverter: \"%s\" is not a valid influence" ) % influenceName ).str() );
        }

        fnInfluence.getPath( path );
        influencePaths.append( path );
        indexMap[i] = index;
        index++;
    }

    MPlugArray connectedPlugs;

    bool existingBindPose = true;
    MPlug bindPlug = fnSkinClusterNode.findPlug( "bindPose", true, &s );
    if ( !bindPlug.connectedTo( connectedPlugs, true, false ) )
    {
        existingBindPose = false;
        if ( !ignoreBindPose )
        {
            throw IECore::Exception( ( boost::format( "ToMayaSkinClusterConverter: \"%s\" does not have a valid bindPose" ) % fnSkinClusterNode.name() ).str() );
        }
    }

    MPlug bindPoseMatrixArrayPlug;
    MPlug bindPoseMemberArrayPlug;
    if ( existingBindPose )
    {
        MFnDependencyNode fnBindPose( connectedPlugs[0].node() );
        if ( fnBindPose.typeName() != "dagPose" )
        {
            throw IECore::Exception( ( boost::format( "ToMayaSkinClusterConverter: \"%s\" is not a valid bindPose" ) % fnBindPose.name() ).str() );
        }

        bindPoseMatrixArrayPlug = fnBindPose.findPlug( "worldMatrix", true, &s );
        bindPoseMemberArrayPlug = fnBindPose.findPlug( "members", true, &s );
    }

    /// \todo: optional parameter to reset the skinCluster's geomMatrix plug
//.........这里部分代码省略.........
开发者ID:mor-vfx,项目名称:cortex,代码行数:101,代码来源:ToMayaSkinClusterConverter.cpp

示例9: 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

示例10: 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
//.........这里部分代码省略.........
开发者ID:DimondTheCat,项目名称:xray,代码行数:101,代码来源:maTranslator.cpp

示例11: parseArgs

// Custom parsing to support array argument. Not using MSyntax.
MStatus skinClusterWeights::parseArgs( const MArgList& args )
{
    MStatus	    status = MS::kSuccess;
    MObject         node;
    MDagPath        dagPath;
    MSelectionList  selList;
    
    editUsed  = true;
    queryUsed = false;
    unsigned int i, nth = 0;
    unsigned int numArgs = args.length();	
    while(status == MS::kSuccess && nth < numArgs-1) {
	MString inputString = args.asString(nth, &status);

	if (status != MS::kSuccess) {
	    MGlobal::displayError("skinClusterWeights syntax error");
	    return status;
	}
      
	if (inputString == kEditFlag || inputString == kEditFlagLong) {
	    editUsed  = true;
	    queryUsed = false;
	    nth++;
	    continue;
	}
      
	if (inputString == kQueryFlag || inputString == kQueryFlagLong) {
	    queryUsed = true;
	    editUsed  = false;
	    nth++;
	    continue;
	}
      
	if (inputString == kInfluenceFlag || inputString == kInfluenceFlagLong) {	    
	    nth++;
	    MStringArray stringArray = args.asStringArray(nth, &status);
	    selList.clear();
	    for (i = 0; i < stringArray.length(); i++) {
	      selList.add(stringArray[i]);
	    }
	    for (i = 0; i < selList.length(); i++) {
	      status = selList.getDagPath(i, dagPath);
	      if (status == MS::kSuccess && dagPath.hasFn(MFn::kTransform)) {
		influenceArray.append(dagPath);
	      } else {
		MGlobal::displayError(inputString + " is not a valid influence object.\n");
		return status;
	      }
	    }
	    nth++;
	    continue;
	}

	if (inputString == kSkinClusterFlag || inputString == kSkinClusterFlagLong) {
	    nth++;
	    MStringArray stringArray = args.asStringArray(nth, &status);
	    selList.clear();
	    for (i = 0; i < stringArray.length(); i++) {
	      selList.add(stringArray[i]);
	    }
	    for (i = 0; i < selList.length(); i++) {
	      status = selList.getDependNode(i, node);
	      if (status == MS::kSuccess && node.hasFn(MFn::kSkinClusterFilter)) {
		skinClusterArray.append(node);
	      } else {
		MGlobal::displayError(inputString + " is not a valid skinCluster.\n");
		return status;
	      }
	    }
	    nth++;
	    continue;
	}

	if (inputString == kWeightFlag || inputString == kWeightFlagLong) {
	    nth++;
	    weightArray = args.asDoubleArray(nth, &status);
	    if (status != MS::kSuccess) {
		MGlobal::displayError("error while parsing weight array");
	    }
	    nth++;
	    continue;
	}

	if (inputString == kAssignAllToSingleFlag || inputString == kAssignAllToSingleFlagLong) {
	    assignAllToSingle = true;
	    nth++;
	    continue;
	}

	MGlobal::displayError("invalid command syntax at " + inputString);
	return MS::kFailure;
    }

    // parse command objects
    // nth should equals to numArgs-1 at this point
    geometryArray = args.asStringArray(nth, &status);
    if (status != MS::kSuccess) {
	MGlobal::displayError("Command object invalid");
	return status;
//.........这里部分代码省略.........
开发者ID:BigRoy,项目名称:Maya-devkit,代码行数:101,代码来源:skinClusterWeights.cpp

示例12: status

liqRibCurvesData::liqRibCurvesData( MObject curveGroup )
: nverts(),
  CVs(),
  NuCurveWidth()
{
	CM_TRACE_FUNC("liqRibCurvesData::liqRibCurvesData("<<curveGroup.apiTypeStr()<<")");

	LIQDEBUGPRINTF( "-> creating nurbs curve group\n" );

	MStatus status( MS::kSuccess );
	MFnDagNode fnDag( curveGroup, &status );
	MFnDagNode fnTrans( fnDag.parent( 0 ) );

	MSelectionList groupList; 
	groupList.add( fnTrans.partialPathName() );
	MDagPath groupPath;
	groupList.getDagPath( 0, groupPath );
	MMatrix m( groupPath.inclusiveMatrix() );

	MStringArray curveList;
	MObjectArray curveObj;
	MDagPathArray curveDag;

	// using the transforms not the nurbsCurves so instances are supported
	MGlobal::executeCommand( MString( "ls -dag -type transform " ) + fnTrans.partialPathName(), curveList );
	for( unsigned i( 0 ); i < curveList.length(); i++ )
	{
		MSelectionList list; 
		list.add( curveList[i] );
		MObject curveNode;
		MDagPath path;
		list.getDependNode( 0, curveNode );
		list.getDagPath( 0, path );
		MFnDagNode fnCurve( curveNode );
		MObject shape( fnCurve.child( 0 ) );
		if( shape.hasFn( MFn::kNurbsCurve ) )
		{
			curveObj.append( curveNode );
			curveDag.append( path );
		}
	}

	if( liqglo.liqglo_renderAllCurves )
	  ncurves = curveObj.length();
	else
		ncurves = 0;  
	  
	if( !ncurves )
		return;

	nverts = shared_array< RtInt >( new RtInt[ ncurves ] );

	unsigned cvcount( 0 );

	unsigned long curvePts(0);
	for( unsigned i( 0 ); i < ncurves; i++ )
	{
		MFnDagNode fnDag( curveObj[i] );
		MFnNurbsCurve fnCurve( fnDag.child( 0 ) );
		nverts[i] = fnCurve.numCVs() + 4;
		cvcount += nverts[i];
	}

	CVs = shared_array< RtFloat >( new RtFloat[ cvcount * 3 ] );

	unsigned k( 0 );
	for( unsigned i( 0 ); i < ncurves; i++ )
	{
		MFnDagNode fnCurve( curveObj[i] );
		MMatrix mCurve( curveDag[i].inclusiveMatrix() );
		mCurve -= m;
		mCurve += MMatrix::identity;

		MObject oCurveChild( fnCurve.child( 0 ) );
		MItCurveCV curveIt( oCurveChild );
		MPoint pt = curveIt.position();
		pt *= mCurve;
		CVs[k++] = (float)pt.x;
		CVs[k++] = (float)pt.y;
		CVs[k++] = (float)pt.z;
		CVs[k++] = (float)pt.x;
		CVs[k++] = (float)pt.y;
		CVs[k++] = (float)pt.z;
		for( curveIt.reset(); !curveIt.isDone(); curveIt.next() )
		{
			pt = curveIt.position();
			pt *= mCurve;
			CVs[k++] = (float)pt.x;
			CVs[k++] = (float)pt.y;
			CVs[k++] = (float)pt.z;
		}
		CVs[k++] = (float)pt.x;
		CVs[k++] = (float)pt.y;
		CVs[k++] = (float)pt.z;
		CVs[k++] = (float)pt.x;
		CVs[k++] = (float)pt.y;
		CVs[k++] = (float)pt.z;
	}

	liqTokenPointer pointsPointerPair;
//.........这里部分代码省略.........
开发者ID:matrixworld,项目名称:maya2renderer,代码行数:101,代码来源:liqRibCurvesData.cpp


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