本文整理汇总了C++中MFnDagNode::attribute方法的典型用法代码示例。如果您正苦于以下问题:C++ MFnDagNode::attribute方法的具体用法?C++ MFnDagNode::attribute怎么用?C++ MFnDagNode::attribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MFnDagNode
的用法示例。
在下文中一共展示了MFnDagNode::attribute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processUpstreamNode
MStatus polyModifierCmd::processUpstreamNode( modifyPolyData& data )
{
MStatus status = MS::kSuccess;
// Declare our function sets - Although dagNodeFn derives from depNodeFn, we need
// both since dagNodeFn can only refer to DAG objects.
// We will use depNodeFn for all times other when dealing
// with the DAG.
//
MFnDependencyNode depNodeFn;
MFnDagNode dagNodeFn;
// Use the selected node's plug connections to find the upstream plug.
// Since we are looking at the selected node's inMesh attribute, it will
// always have only one connection coming in if it has history, and none
// otherwise.
//
// If there is no history, copy the selected node and place it ahead of the
// modifierNode as the new upstream node so that the modifierNode has an
// input mesh to operate on.
//
MPlugArray tempPlugArray;
if( fHasHistory )
{
// Since we have history, look for what connections exist on the
// meshNode "inMesh" plug. "inMesh" plugs should only ever have one
// connection.
//
data.meshNodeDestPlug.connectedTo( tempPlugArray, true, false);
// ASSERT: Only one connection should exist on meshNodeShape.inMesh!
//
MStatusAssert( (tempPlugArray.length() == 1),
"tempPlugArray.length() == 1 -- 0 or >1 connections on meshNodeShape.inMesh" );
data.upstreamNodeSrcPlug = tempPlugArray[0];
// Construction history only deals with shapes, so we can grab the
// upstreamNodeShape off of the source plug.
//
data.upstreamNodeShape = data.upstreamNodeSrcPlug.node();
depNodeFn.setObject( data.upstreamNodeShape );
data.upstreamNodeSrcAttr = data.upstreamNodeSrcPlug.attribute();
// Disconnect the upstream node and the selected node, so we can
// replace them with our own connections below.
//
fDGModifier.disconnect( data.upstreamNodeShape,
data.upstreamNodeSrcAttr,
data.meshNodeShape,
data.meshNodeDestAttr );
}
else // No History (!fHasHistory)
{
// Use the DAG node function set to duplicate the shape of the meshNode.
// The duplicate method will return an MObject handle to the transform
// of the duplicated shape, so traverse the dag to locate the shape. Store
// this duplicate shape as our "upstream" node to drive the input for the
// modifierNode.
//
dagNodeFn.setObject( data.meshNodeShape );
data.upstreamNodeTransform = dagNodeFn.duplicate( false, false );
dagNodeFn.setObject( data.upstreamNodeTransform );
// Ensure that our upstreamNode is pointing to a shape.
//
MStatusAssert( (0 < dagNodeFn.childCount()),
"0 < dagNodeFn.childCount() -- Duplicate meshNode transform has no shape." );
data.upstreamNodeShape = dagNodeFn.child(0);
// Re-parent the upstreamNodeShape under our original transform
//
status = fDagModifier.reparentNode( data.upstreamNodeShape, data.meshNodeTransform );
MCheckStatus( status, "reparentNode" );
// Perform the DAG re-parenting
//
// Note: This reparent must be performed before the deleteNode() is called.
// See polyModifierCmd.h (see definition of fDagModifier) for more details.
//
status = fDagModifier.doIt();
MCheckStatus( status, "fDagModifier.doIt()" );
// Mark the upstreamNodeShape (the original shape) as an intermediate object
// (making it invisible to the user)
//
dagNodeFn.setObject( data.upstreamNodeShape );
dagNodeFn.setIntermediateObject( true );
// Get the upstream node source attribute
//
data.upstreamNodeSrcAttr = dagNodeFn.attribute( "outMesh" );
// Remove the duplicated transform node (clean up)
//
status = fDagModifier.deleteNode( data.upstreamNodeTransform );
MCheckStatus( status, "deleteNode" );
//.........这里部分代码省略.........
示例2: processUpstreamNode
// --------------------------------------------------------------------------------------------
MStatus polyModifierCmd::processUpstreamNode( modifyPolyData& data )
// --------------------------------------------------------------------------------------------
{
MStatus status = MS::kSuccess;
// Declare our function sets - Although dagNodeFn derives from depNodeFn, we need
// both since dagNodeFn can only refer to DAG objects.
// We will use depNodeFn for all times other when dealing
// with the DAG.
//
MFnDependencyNode depNodeFn;
MFnDagNode dagNodeFn;
// Use the selected node's plug connections to find the upstream plug.
// Since we are looking at the selected node's inMesh attribute, it will
// always have only one connection coming in if it has history, and none
// otherwise.
//
// If there is no history, copy the selected node and place it ahead of the
// modifierNode as the new upstream node so that the modifierNode has an
// input mesh to operate on.
//
//save the meshDagPath for later use
MDagPath::getAPathTo(data.meshNodeShape,myMeshPath);
MPlugArray tempPlugArray;
if( fHasHistory )
{
// Since we have history, look for what connections exist on the
// meshNode "inMesh" plug. "inMesh" plugs should only ever have one
// connection.
//
data.meshNodeDestPlug.connectedTo( tempPlugArray, true, false);
// ASSERT: Only one connection should exist on meshNodeShape.inMesh!
//
MStatusAssert( (tempPlugArray.length() == 1),
"tempPlugArray.length() == 1 -- 0 or >1 connections on meshNodeShape.inMesh" );
data.upstreamNodeSrcPlug = tempPlugArray[0];
// Construction history only deals with shapes, so we can grab the
// upstreamNodeShape off of the source plug.
//
// Dieser Bereich muss bleiben, weil diese Attribute noch bentigt werden
data.upstreamNodeShape = data.upstreamNodeSrcPlug.node();
depNodeFn.setObject( data.upstreamNodeShape );
data.upstreamNodeSrcAttr = data.upstreamNodeSrcPlug.attribute();
// Disconnect the upstream node and the selected node, so we can
// replace them with our own connections below.
//
MPlug nodePlug(data.meshNodeShape,data.meshNodeDestAttr ) ;
INVIS(cout<<data.upstreamNodeSrcPlug.name().asChar()<<" --|-- "<<nodePlug.name().asChar()<<endl);
status = fDGModifier.disconnect( data.upstreamNodeSrcPlug,
nodePlug );
MCheckStatus( status, "Disconnect Upstream mit meshNode" );
}
else // No History (!fHasHistory)
{
// Use the DAG node function set to duplicate the shape of the meshNode.
// The duplicate method will return an MObject handle to the transform
// of the duplicated shape, so traverse the dag to locate the shape. Store
// this duplicate shape as our "upstream" node to drive the input for the
// modifierNode.
//
depNodeFn.setObject( data.meshNodeShape );
data.upstreamNodeTransform = createDuplicate.createNode("mesh");
createDuplicate.doIt();
dagNodeFn.setObject( data.upstreamNodeTransform );
// Ensure that our upstreamNode is pointing to a shape.
//
MStatusAssert( (0 < dagNodeFn.childCount()),
"0 < dagNodeFn.childCount() -- Duplicate meshNode transform has no shape." );
data.upstreamNodeShape = dagNodeFn.child(0);
MPlug outMeshPlug = depNodeFn.findPlug("outMesh");
depNodeFn.setObject(data.upstreamNodeShape);
//jetzt inMesh upstreamNodeShape mit outMesh meshShape füllen
MDGModifier tempMod;
tempMod.connect(outMeshPlug,depNodeFn.findPlug("inMesh"));
tempMod.doIt();
//force DGEVAL
MString cmd = "dgeval -src ";
cmd += depNodeFn.name();
cmd += ".outMesh";
//.........这里部分代码省略.........
示例3: extractFaces_Func
bool tm_polyExtract::extractFaces_Func( MSelectionList &selectionList, MStringArray &node_names)
{
MStatus status;
MObject meshObj;
status = selectionList.getDependNode( 0, meshObj);
if(!status){MGlobal::displayError("tm_polyExtract::extractFaces_Func: Can't find object !");return false;}
MFnMesh meshFn( meshObj, &status);
if(!status){MGlobal::displayError("tm_polyExtract::extractFaces_Func: Non mesh object founded !");return false;}
MDagPath meshDagPath_first, meshDagPath;
selectionList.getDagPath( 0, meshDagPath_first);
MObject multiFaceComponent;
MIntArray inputFacesArray;
inputFacesArray.clear();
inputFacesArray.setSizeIncrement( 4096);
MFnComponentListData compListFn;
compListFn.create();
for (MItSelectionList faceComponentIter(selectionList, MFn::kMeshPolygonComponent); !faceComponentIter.isDone(); faceComponentIter.next())
{
faceComponentIter.getDagPath(meshDagPath, multiFaceComponent);
if(!(meshDagPath_first == meshDagPath))
{
MGlobal::displayError("tm_polyExtract::extractFaces_Func: Different meshes faces founded !");
return false;
}
if (!multiFaceComponent.isNull())
{
for (MItMeshPolygon faceIter(meshDagPath, multiFaceComponent); !faceIter.isDone(); faceIter.next())
{
int faceIndex = faceIter.index();
#ifdef _DEBUG
infoMStr += faceIndex;
infoMStr += " ";
#endif
inputFacesArray.append( faceIndex);
compListFn.add( multiFaceComponent );
}
}
}
if( inputFacesArray.length() == 0)
{
MGlobal::displayError("tm_polyExtract::extractFaces_Func: No faces founded !");
return false;
}
#ifdef _DEBUG
MGlobal::displayInfo( infoMStr);
#endif
meshFn.setObject( meshDagPath_first);
meshObj = meshFn.object();
// MDagModifier dagModifier;
MFnDagNode meshDagNodeFn;
MFnDependencyNode depNodeFn;
meshDagNodeFn.setObject( meshDagPath_first);
MString meshName = meshDagNodeFn.name();
MObject outMesh_attrObject = meshDagNodeFn.attribute( "outMesh");
// ----------------------------------- duplicate shape
MObject duplicated_meshObjectA;
MObject duplicated_meshObjectB;
MObject inMesh_attrObjectA;
MObject inMesh_attrObjectB;
/*
MStringArray commandResult;
MSelectionList selList;
MGlobal::executeCommand( "duplicate " + meshDagNodeFn.name(), commandResult, 1, 1);
selList.add( commandResult[0]);
selList.getDependNode( 0, duplicated_meshObjectA);
meshDagNodeFn.setObject( duplicated_meshObjectA);
meshDagNodeFn.setName( meshName + "_tA");
duplicated_meshObjectA = meshDagNodeFn.child(0);
meshDagNodeFn.setObject( duplicated_meshObjectA);
meshDagNodeFn.setName( meshName + "_sA");
inMesh_attrObjectA = meshDagNodeFn.attribute( "inMesh");
meshDagNodeFn.setObject( meshDagPath_first);
selList.clear();
MGlobal::executeCommand( "duplicate " + meshDagNodeFn.name(), commandResult, 1, 1);
selList.add( commandResult[0]);
selList.getDependNode( 0, duplicated_meshObjectB);
meshDagNodeFn.setObject( duplicated_meshObjectB);
meshDagNodeFn.setName( meshName + "_tB");
duplicated_meshObjectB = meshDagNodeFn.child(0);
meshDagNodeFn.setObject( duplicated_meshObjectB);
meshDagNodeFn.setName( meshName + "_sB");
inMesh_attrObjectB = meshDagNodeFn.attribute( "inMesh");
*/
duplicated_meshObjectA = meshDagNodeFn.duplicate();
meshDagNodeFn.setObject( duplicated_meshObjectA);
meshDagNodeFn.setName( meshName + "_tA");
duplicated_meshObjectA = meshDagNodeFn.child(0);
meshDagNodeFn.setObject( duplicated_meshObjectA);
meshDagNodeFn.setName( meshName + "_sA");
inMesh_attrObjectA = meshDagNodeFn.attribute( "inMesh");
meshDagNodeFn.setObject( meshDagPath_first);
//.........这里部分代码省略.........