本文整理汇总了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 );
}
}
}
}
}
示例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)
}
示例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;
}
示例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;
}
示例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 );
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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() );
}
示例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;
}
}
}
}
示例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;
}
示例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;
}
示例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;
}