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


C++ MDagPath::node方法代码示例

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


在下文中一共展示了MDagPath::node方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: onOtherNode

void liqIPRNodeMessage::onOtherNode(const MString &node, std::vector<MString> &updateObjectName)
{
	MStringArray descendents;
	MString cmd("listRelatives -allDescendents "+node);
	MGlobal::executeCommand(cmd, descendents);

	for(int i=0; i<descendents.length(); ++i)
	{
		addUpdateObject(updateObjectName, descendents[i]);//record descendents[i]
		
		MDagPath dagPath;
		getDagPathByName(dagPath, descendents[i].asChar());

		if( dagPath.node().hasFn(MFn::kTransform) )
		{
			onOtherNode(descendents[i], updateObjectName);//visit descendents[i]
		}
		else if( dagPath.node().hasFn(MFn::kMesh) )
		{
			std::vector<std::string> shaderPlugs;
			liquid::RendererMgr::getInstancePtr()->
				getRenderer()->getValidShaderPlugsInShadingGroup(shaderPlugs);


			IfMErrorWarn(dagPath.extendToShape());//extend to shape

			std::vector<std::string> shadingGroups;
			getShadingGroups(dagPath.fullPathName(), shadingGroups);
			for(std::size_t j=0; j<shadingGroups.size(); ++j)//for each shading group
			{
				MString shadingGroup(shadingGroups[j].c_str());

				for(std::size_t k=0; k<shaderPlugs.size(); ++k)//for each shader plug
				{
					MString shaderPlug(shaderPlugs[k].c_str());

					int isShaderPlugExist;
					cmd = "attributeQuery -node \""+shadingGroup+"\" -ex \""+shaderPlug+"\"";
					IfMErrorMsgWarn(MGlobal::executeCommand( cmd, isShaderPlugExist), cmd);
					if( isShaderPlugExist )
					{
						//get the source shade node of $shadingGroup.$shaderPlug
						MStringArray shaders;
						cmd = "listConnections -s true -d false -plugs false (\""+shadingGroup+"\" + \"."+shaderPlug+"\")";
						IfMErrorMsgWarn(MGlobal::executeCommand( cmd, shaders), cmd);
						
						if( shaders.length() > 0 )//has source shader node
						{
							onShaderNode(shaders[0], updateObjectName);
						}//if( shaders.length() > 0 )//has source shader node

					}//if( isShaderPlugExist )
				}//for each shader plug


			}//for each shading group
		}//kMesh
	}//for(int i=0; i<descendents.length(); ++i)

}
开发者ID:maya2renderer,项目名称:maya2renderer,代码行数:60,代码来源:liqIPRNodeMessageCmd.cpp

示例3: getObjectShadingGroups

bool getObjectShadingGroups(const MDagPath& shapeObjectDP, MObject& shadingGroup)
{
    // if obj is a light, simply return the mobject
    if (shapeObjectDP.hasFn(MFn::kLight))
        shadingGroup = shapeObjectDP.node();

    if (shapeObjectDP.hasFn(MFn::kMesh))
    {
        // Find the Shading Engines Connected to the SourceNode
        MFnMesh fnMesh(shapeObjectDP.node());

        // A ShadingGroup will have a MFnSet
        MObjectArray sets, comps;
        fnMesh.getConnectedSetsAndMembers(shapeObjectDP.instanceNumber(), sets, comps, true);

        // Each set is a Shading Group. Loop through them
        for (unsigned int i = 0; i < sets.length(); ++i)
        {
            shadingGroup = sets[i];
            return true;
        }
    }

    if (shapeObjectDP.hasFn(MFn::kNurbsSurface)||shapeObjectDP.hasFn(MFn::kParticle)||shapeObjectDP.hasFn(MFn::kNParticle))
    {

        MObject instObjGroupsAttr;
        if (shapeObjectDP.hasFn(MFn::kNurbsSurface))
        {
            MFnNurbsSurface fnNurbs(shapeObjectDP.node());
            instObjGroupsAttr = fnNurbs.attribute("instObjGroups");
        }
        if (shapeObjectDP.hasFn(MFn::kParticle)||shapeObjectDP.hasFn(MFn::kNParticle))
        {
            MFnParticleSystem fnPart(shapeObjectDP.node());
            instObjGroupsAttr = fnPart.attribute("instObjGroups");
        }
        MPlug instPlug(shapeObjectDP.node(), instObjGroupsAttr);

        // Get the instance that our node is referring to;
        // In other words get the Plug for instObjGroups[intanceNumber];
        MPlug instPlugElem = instPlug.elementByLogicalIndex(shapeObjectDP.instanceNumber());

        // Find the ShadingGroup plugs that we are connected to as Source
        MPlugArray SGPlugArray;
        instPlugElem.connectedTo(SGPlugArray, false, true);

        // Loop through each ShadingGroup Plug
        for (unsigned int i=0; i < SGPlugArray.length(); ++i)
        {
            shadingGroup = SGPlugArray[i].node();
            return true;
        }
    }
    return false;
}
开发者ID:dictoon,项目名称:appleseed-maya,代码行数:56,代码来源:shadingutils.cpp

示例4: joint

    // In order to correctly extract skinweights we first
    // need to go into bindpose. (and we need to remember the current
    // pose, to be able to undo it).
    //
    // I know: nearly no error-checking.
    void
    BindPoseTool::GoIntoBindPose()
    {
		MStatus status;
        std::cout << " Going into bindpose ";
        // == turn IK off
        // save current state
        undoInfo.ikSnap = MIkSystem::isGlobalSnap(&status);
        undoInfo.ikSolve = MIkSystem::isGlobalSolve();
        // turn it off
        MIkSystem::setGlobalSnap(false);
        MIkSystem::setGlobalSolve(false);

        // == put joints into bindPose
        for (MItDag dagIt(MItDag::kDepthFirst, MFn::kJoint);
             !dagIt.isDone();
             dagIt.next())
        {
            std::cout << ".";
            MDagPath jointPath;
            dagIt.getPath(jointPath);
            if (jointPath.isInstanced())
            { // we only work on the first instance of an instanced joint.
                if (jointPath.instanceNumber() != 0)
                    continue;
            }

            BindPoseUndoInformation::JointMatrixVector::value_type joint2transform;

            MFnIkJoint joint(jointPath.node());

            MTransformationMatrix currentTransform = joint.transformation(&status);

            joint2transform.first = jointPath.node();
            joint2transform.second = currentTransform;
            undoInfo.savedTransforms.push_back(joint2transform);

            MMatrix bindPoseMatrix = getBindPoseMatrix(joint);
            joint.set(bindPoseMatrix);
        }
        std::cout << std::endl;

        //cout << "bindPose end" << endl;
        // don't know, if this is really necessary, but MS xporttranslator
        // does it...
        syncMeshes();

	// remember the change
	inBindPose = true;
    }
开发者ID:cpzhang,项目名称:zen,代码行数:55,代码来源:bindPoseTool.cpp

示例5: DoConnectGeometry

//-----------------------------------------------------------------------------
// This is here for reference. It isn't currently used
//-----------------------------------------------------------------------------
void CVsSkinnerCmd::DoConnectGeometry(
	const MDagPath &skinnerPath,
	const MDagPath &gDagPath )
{
	MObject skinnerObj( skinnerPath.node() );
	const MFnDependencyNode vsSkinnerFn( skinnerObj );
	const MFnMesh meshFn( gDagPath );

	// Connect things up

	MPlug sP;
	MPlug dP;

	MDagModifier &mDagModifier( m_undo.DagModifier() );

	// Connect mesh.worldMatrix[#] vsSkinner.geometryWorldMatrix
	sP = meshFn.findPlug( "worldMatrix" );
	sP = sP.elementByLogicalIndex( gDagPath.instanceNumber() );
	dP = vsSkinnerFn.findPlug( "geometryWorldMatrix" );
	mDagModifier.connect( sP, dP );

	sP = meshFn.findPlug( "outMesh" );
	dP = vsSkinnerFn.findPlug( "inputGeometry" );
	mDagModifier.connect( sP, dP );

	mDagModifier.doIt();

	// Add the default volume
	MSelectionList emptyList;
	MGlobal::setActiveSelectionList( DoNewVolumes( skinnerPath, emptyList ), MGlobal::kReplaceList );
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:34,代码来源:vsSkinnerCmd.cpp

示例6: IsLayerVisible

bool IsLayerVisible(MDagPath& dp)
{
   MStatus stat = MStatus::kSuccess;
   MDagPath dagPath = dp;
   while (stat == MStatus::kSuccess)
   {
      MFnDependencyNode node(dagPath.node());
	  MPlug doPlug = node.findPlug("drawOverride", &stat);
	  if( stat )
	  {
		  MObject layer = getOtherSideNode(doPlug);
		  MFnDependencyNode layerNode(layer, &stat);
		  if( stat )
		  {
			  MGlobal::displayInfo(MString("check layer ") + layerNode.name() + " for node " + dagPath.fullPathName());
			  bool visibility = true;
			  if(getBool("visibility", layerNode, visibility))
				  if(!visibility)
					  return false;
		  }
	  }
      stat = dagPath.pop();
   }
   return true;
}
开发者ID:MassW,项目名称:OpenMaya,代码行数:25,代码来源:tools.cpp

示例7:

/// Returns STATIC or ANIMATED if an extra translate is needed to compensate for
/// Maya's instancer translation behavior on the given prototype DAG node.
/// (This function may return false positives, which are OK but will simply
/// contribute extra data. It should never return false negatives, which
/// would cause correctness problems.)
bool
PxrUsdTranslators_InstancerWriter::_NeedsExtraInstancerTranslate(
        const MDagPath& prototypeDagPath,
        bool* instancerTranslateAnimated) const
{
    // XXX: Maybe we could be smarter here and figure out if the animation
    // affects instancerTranslate?
    bool animated = !_GetExportArgs().timeSamples.empty() &&
            MAnimUtil::isAnimated(prototypeDagPath.node(), false);
    if (animated) {
        *instancerTranslateAnimated = true;
        return true;
    }

    GfVec3d origin;
    bool translated =
            _GetTransformedOriginInLocalSpace(prototypeDagPath, &origin) &&
            !GfIsClose(origin, GfVec3d(0.0), _EPSILON);
    if (translated) {
        *instancerTranslateAnimated = false;
        return true;
    }

    return false;
}
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:30,代码来源:instancerWriter.cpp

示例8: IsVisible

bool IsVisible(MDagPath& node)
{
    MFnDagNode dagNode(node.node());
    if (!IsVisible(dagNode) || IsTemplated(dagNode) || IsPathTemplated(node)  || !IsInRenderLayer(node) || !IsPathVisible(node) || !IsLayerVisible(node))
        return false;
    return true;
}
开发者ID:dictoon,项目名称:appleseed-maya,代码行数:7,代码来源:tools.cpp

示例9: checkCurveGrp

bool AbcWriteJob::checkCurveGrp()
{
    MItDag itDag(MItDag::kBreadthFirst, MFn::kNurbsCurve);
    itDag.reset(mCurDag, MItDag::kBreadthFirst, MFn::kNurbsCurve);

    bool init = false;
    int degree = 0;
    MFnNurbsCurve::Form form = MFnNurbsCurve::kInvalid;
    for (; !itDag.isDone(); itDag.next())
    {
        MDagPath curvePath;
        if (itDag.getPath(curvePath) == MS::kSuccess)
        {
            MObject curve = curvePath.node();
            if (!util::isIntermediate(curve) && curve.hasFn(MFn::kNurbsCurve))
            {
                MFnNurbsCurve fn(curvePath);
                if (!init)
                {
                    degree = fn.degree();
                    form = fn.form();
                    init = true;
                }
                else
                {
                    if (degree != fn.degree() || form != fn.form())
                        return false;
                }
            }
        }
    }
    return true;
}
开发者ID:boberfly,项目名称:gafferDependencies,代码行数:33,代码来源:AbcWriteJob.cpp

示例10: doIt

MStatus DDConvexHullCmd::doIt(const MArgList& args)
{
    if (args.length() != 1)
    {
        MGlobal::displayError("Needs at least 2 args");
        return MS::kFailure;
    }
    MString input = args.asString(0);
    MString output = args.asString(1);
    
    // Get the mObject for the input
    MSelectionList selList;
    selList.add(input);
    MDagPath inputMesh;
    selList.getDagPath(0, inputMesh);
    
    // Ensure we're looking at the shape
    inputMesh.extendToShape();

    // Create output object
    MDagModifier dm;
    MObject outMeshNode = dm.createNode(MFn::kMesh);
    MFnDependencyNode outMeshDag(outMeshNode);
    outMeshDag.setName("poopShape#");
    DDConvexHullUtils::hullOpts hullOptions;
    return DDConvexHullUtils::generateMayaHull(outMeshNode,
                                               inputMesh.node(), hullOptions);

}
开发者ID:digitaldestructo,项目名称:DDConvexHull,代码行数:29,代码来源:DDConvexHullCmd.cpp

示例11: updateViewFrustum

void ProxyViz::updateViewFrustum(const MDagPath & cameraPath)
{
	MMatrix cameraMat = cameraPath.inclusiveMatrix();
	AHelper::ConvertToMatrix44F(*cameraSpaceR(), cameraMat);
	MMatrix cameraInvMat = cameraPath.inclusiveMatrixInverse();
	AHelper::ConvertToMatrix44F(*cameraInvSpaceR(), cameraInvMat);
	float peye[3];
	peye[0] = cameraMat.matrix[3][0];
	peye[1] = cameraMat.matrix[3][1];
	peye[2] = cameraMat.matrix[3][2];
	setEyePosition(peye);
	
    float farClip = -20.f;
    if(numPlants() > 0) getFarClipDepth(farClip, gridBoundingBox() );
    
	MFnCamera fcam(cameraPath.node() );
	if(fcam.isOrtho() ) {
		float orthoW = fcam.orthoWidth();
		float orthoH = orthoW * fcam.aspectRatio();
		setOrthoFrustum(orthoW, orthoH, -10.f, farClip );
		
	} else {
		float hfa = fcam.horizontalFilmAperture();
		float vfa = fcam.verticalFilmAperture();
		float fl = fcam.focalLength();
	
		setFrustum(hfa, vfa, fl, -10.f, farClip );
	}
	setOverscan(fcam.overscan() );
}
开发者ID:spinos,项目名称:aphid,代码行数:30,代码来源:ProxyVizNode.cpp

示例12: dag

AlembicObject::AlembicObject(SceneNodePtr eNode, AlembicWriteJob* in_Job,
                             Abc::OObject oParent)
    : mExoSceneNode(eNode),
      mJob(in_Job),
      mMyParent(oParent),
      mNumSamples(0),
      nodeName(eNode->dccIdentifier.c_str()),
      mHasParent(false)
{
  MSelectionList sl;
  sl.add(nodeName);
  MDagPath dagPath;
  sl.getDagPath(0, dagPath);

  MObject in_Ref = dagPath.node();
  AddRef(in_Ref);

  MFnDagNode dag(in_Ref);
  for (unsigned int i = 0; i < dag.parentCount(); ++i) {
    MObject parentRef = dag.parent(i);
    if (!parentRef.isNull()) {
      mHasParent = in_Job->ObjectExists(parentRef);
      if (mHasParent) {
        break;
      }
    }
  }
}
开发者ID:BlackGinger,项目名称:ExocortexCrate,代码行数:28,代码来源:AlembicObject.cpp

示例13: cacheMeshData

MStatus polyModifierCmd::cacheMeshData()
{
	MStatus status = MS::kSuccess;

	MFnDependencyNode depNodeFn;
	MFnDagNode dagNodeFn;

	MObject meshNode = fDagPath.node();
	MObject dupMeshNode;
	MPlug dupMeshNodeOutMeshPlug;

	// Duplicate the mesh
	//
	dagNodeFn.setObject( meshNode );
	dupMeshNode = dagNodeFn.duplicate();

	MDagPath dupMeshDagPath;
	MDagPath::getAPathTo( dupMeshNode, dupMeshDagPath );
	dupMeshDagPath.extendToShape();

	depNodeFn.setObject( dupMeshDagPath.node() );
	dupMeshNodeOutMeshPlug = depNodeFn.findPlug( "outMesh", &status );
	MCheckStatus( status, "Could not retrieve outMesh" );

	// Retrieve the meshData
	//
	status = dupMeshNodeOutMeshPlug.getValue( fMeshData );
	MCheckStatus( status, "Could not retrieve meshData" );

	// Delete the duplicated node
	//
	MGlobal::deleteNode( dupMeshNode );

	return status;
}
开发者ID:AlbertR,项目名称:cgru170,代码行数:35,代码来源:polyModifierCmd.cpp

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

示例15: IsLayerVisible

bool IsLayerVisible(MDagPath& dp)
{
    MStatus stat = MStatus::kSuccess;
    MDagPath dagPath = dp;
    while (stat == MStatus::kSuccess)
    {
        MFnDependencyNode node(dagPath.node());
        MPlug doPlug = node.findPlug("drawOverride", &stat);
        if (stat)
        {
            MObject layer = getOtherSideNode(doPlug);
            MFnDependencyNode layerNode(layer, &stat);
            if (stat)
            {
                bool visibility = true;
                if (getBool("visibility", layerNode, visibility))
                    if (!visibility)
                        return false;
                if (getEnumInt("displayType", layerNode) == 1) // template
                    return false;
            }
        }
        stat = dagPath.pop();
    }
    return true;
}
开发者ID:dictoon,项目名称:appleseed-maya,代码行数:26,代码来源:tools.cpp


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