本文整理汇总了C++中MFnDependencyNode类的典型用法代码示例。如果您正苦于以下问题:C++ MFnDependencyNode类的具体用法?C++ MFnDependencyNode怎么用?C++ MFnDependencyNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MFnDependencyNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: setZeroTweaks
//############################################### tima:
bool polyModifierCmd::setZeroTweaks()
{
MFnNumericData numDataFn;
MObject nullVector;
MFnDependencyNode depNodeFn;
numDataFn.create( MFnNumericData::k3Float );
numDataFn.setData( 0, 0, 0 );
nullVector = numDataFn.object();
MObject object = fDagPath.node();
depNodeFn.setObject( object);
MPlug meshTweakPlug = depNodeFn.findPlug( "pnts" );
MPlug tweak;
unsigned numTweaks = fTweakIndexArray.length();
if( !meshTweakPlug.isNull() )
{
for( unsigned i = 0; i < numTweaks; i++ )
{
tweak = meshTweakPlug.elementByLogicalIndex( fTweakIndexArray[i] );
tweak.setValue( nullVector );
}
}
return true;
}
示例3: dData
bool
PxrUsdMayaWriteUtil::ReadMayaAttribute(
const MFnDependencyNode& depNode,
const MString& name,
VtVec3fArray* val)
{
MStatus status;
depNode.attribute(name, &status);
if (status == MS::kSuccess) {
MPlug plug = depNode.findPlug(name);
MObject dataObj;
if ( (plug.getValue(dataObj) == MS::kSuccess) &&
(dataObj.hasFn(MFn::kVectorArrayData)) ) {
MFnVectorArrayData dData(dataObj, &status);
if (status == MS::kSuccess) {
MVectorArray arrayValues = dData.array();
size_t numValues = arrayValues.length();
val->resize(numValues);
for (size_t i = 0; i < numValues; ++i) {
(*val)[i].Set(
arrayValues[i][0],
arrayValues[i][1],
arrayValues[i][2]);
}
return true;
}
}
}
return false;
}
示例4: dagFn
void EntityNode::UnloadArt()
{
MStatus stat;
// remove anything currently imported/referenced
MFnDagNode dagFn( thisMObject() );
while( dagFn.childCount() )
{
stat = MGlobal::deleteNode( dagFn.child( 0 ) );
MContinueErr( stat, ("Unable to delete" + dagFn.fullPathName() ).asChar() );
}
ClearInstances();
MObjectArray forDelete;
GetImportNodes( forDelete );
MFnDependencyNode depFn;
u32 num = forDelete.length();
for( u32 i = 0; i < num; ++i )
{
MObject& node = forDelete[i];
MObjectHandle handle( node );
if( !handle.isValid() )
continue;
depFn.setObject( node );
stat = MGlobal::deleteNode( node );
MContinueErr( stat, ("Unable to delete" + depFn.name() ).asChar() );
}
forDelete.clear();
}
示例5: ExtractAttribute
void ExtractAttribute(MFnDependencyNode& fn, std::string name, SMatAttrib& attrib)
{
MPlug p;
// extract attribute color
std::string r = name + "R";
std::string g = name + "G";
std::string b = name + "B";
p = fn.findPlug(r.c_str()); p.getValue(attrib.color[0]);
p = fn.findPlug(g.c_str()); p.getValue(attrib.color[1]);
p = fn.findPlug(b.c_str()); p.getValue(attrib.color[2]);
// extract attribute texture
MString texname;
p = fn.findPlug(name.c_str());
MPlugArray plugs;
p.connectedTo(plugs,true,true);
for(int i = 0; i != plugs.length(); ++i)
{
if (plugs[i].node().apiType() == MFn::kFileTexture)
{
MFnDependencyNode fnDep(plugs[i].node());
texname = fnDep.name();
break;
}
}
attrib.textureID = GetTextureID( texname );
}
示例6: destFn
//---------------------------------------------------
bool DagHelper::connectToList ( const MPlug& source, const MObject& destination, const MString& destinationAttribute, int* _index )
{
MStatus status;
MFnDependencyNode destFn ( destination );
MPlug dest = destFn.findPlug ( destinationAttribute, &status );
if ( status != MStatus::kSuccess ) return false;
if ( !dest.isArray() ) return false;
int index = ( _index != NULL ) ? *_index : -1;
if ( index < 0 )
{
index = getNextAvailableIndex ( dest, ( int ) dest.evaluateNumElements() );
if ( _index != NULL ) *_index = index;
}
MPlug d = dest.elementByLogicalIndex ( index );
MDGModifier modifier;
modifier.connect ( source, d );
status = modifier.doIt();
return status == MStatus::kSuccess;
}
示例7: parseAttributes
void AttributeParser::parseAttributes(MFnDependencyNode & fnNode, AttributeParser & parser)
{
MStatus status;
unsigned int attrCount = fnNode.attributeCount(&status);
if (!status) return;
std::set<String> parsedAttributes;
for (unsigned int attrIndex = 0; attrIndex < attrCount; ++attrIndex)
{
MObject attrObject = fnNode.attribute(attrIndex, &status);
if (!status) continue;
MFnAttribute fnAttr(attrObject, &status);
if (!status) continue;
MString attrName = fnAttr.name(&status);
if (!status) continue;
// Don't parse the same attribute twice.
// This can happen with compound attributes.
String attrNameStr = attrName.asChar();
if (parsedAttributes.find(attrNameStr) != parsedAttributes.end()) {
continue;
}
parsedAttributes.insert(attrNameStr);
parser.parseAttribute(fnNode, attrObject, parsedAttributes);
}
}
示例8: collectNodeState
// --------------------------------------------------------------------------------------------
void polyModifierCmd::collectNodeState()
// --------------------------------------------------------------------------------------------
{
MStatus status;
// Collect node state information on the given polyMeshShape
//
// - HasHistory (Construction History exists)
// - HasTweaks
// - HasRecordHistory (Construction History is turned on)
//
fDagPath.extendToShape();
MObject meshNodeShape = fDagPath.node();
MFnDependencyNode depNodeFn;
depNodeFn.setObject( meshNodeShape );
MPlug inMeshPlug = depNodeFn.findPlug( "inMesh" );
fHasHistory = inMeshPlug.isConnected();
// Tweaks exist only if the multi "pnts" attribute contains plugs
// which contain non-zero tweak values. Use false, until proven true
// search algorithm.
//
fHasTweaks = false;
MPlug tweakPlug = depNodeFn.findPlug( "pnts" );
if( !tweakPlug.isNull() )
{
// ASSERT: tweakPlug should be an array plug!
//
MAssert( (tweakPlug.isArray()),
"tweakPlug.isArray() -- tweakPlug is not an array plug" );
MPlug tweak;
MFloatVector tweakData;
int i;
int numElements = tweakPlug.numElements();
for( i = 0; i < numElements; i++ )
{
tweak = tweakPlug.elementByPhysicalIndex( i, &status );
if( status == MS::kSuccess && !tweak.isNull() )
{
getFloat3PlugValue( tweak, tweakData );
if( 0 != tweakData.x ||
0 != tweakData.y ||
0 != tweakData.z )
{
fHasTweaks = true;
break;
}
}
}
}
int result;
MGlobal::executeCommand( "constructionHistory -q -tgl", result );
fHasRecordHistory = (0 != result);
}
示例9: addParameter
MStatus PRTAttrs::addParameter(MFnDependencyNode & node, MObject & attr, MFnAttribute& tAttr) {
if(!(node.hasAttribute(tAttr.shortName()))) {
MCHECK(tAttr.setKeyable (true));
MCHECK(tAttr.setHidden(false));
MCHECK(tAttr.setStorable(true));
MCHECK(node.addAttribute(attr));
}
return MS::kSuccess;
}
示例10: node
//---------------------------
String DocumentExporter::dagPathToColladaName ( const MDagPath& dagPath )
{
// Get a COLLADA suitable node name from a DAG path
// For import/export symmetry, this should be exactly the
// Maya node name. If we include any more of the path, we'll
// get viral node names after repeated import/export.
MFnDependencyNode node ( dagPath.node() );
return mayaNameToColladaName ( node.name(), true );
}
示例11: depNode
std::string CMayaNode::GetName()
{
MStatus status;
MFnDependencyNode depNode (m_dagPath.node(), &status);
if (status != MS::kSuccess)
return "";
return depNode.name ().asChar();
}
示例12: fnDep
void Exporter::extractColor(Color& tempcolor, MFnDependencyNode& fn, MString name)
{
MPlug p;
MString r = name;
r += "R";
MString g = name;
g += "G";
MString b = name;
b += "B";
MString a = name;
a += "A";
p = fn.findPlug(r.asChar());
p.getValue(tempcolor.r);
p = fn.findPlug(g.asChar());
p.getValue(tempcolor.g);
p = fn.findPlug(b.asChar());
p.getValue(tempcolor.b);
p = fn.findPlug(a.asChar());
p.getValue(tempcolor.a);
p = fn.findPlug(name.asChar());
MPlugArray connections;
p.connectedTo(connections, true, false);
int debug = connections.length();
for (int i = 0; i != connections.length(); ++i)
{
// if file texture found
if (connections[i].node().apiType() == MFn::kFileTexture)
{
// bind a function set to it ....
MFnDependencyNode fnDep(connections[i].node());
// to get the node name
tempcolor.texfileInternal = fnDep.name().asChar();
MPlug filename = fnDep.findPlug("ftn");
//sparar hela s�kv�gen till texturen
tempcolor.texfileExternal = filename.asString().asChar();
//kopierar texturfiler
std::string base_filename = tempcolor.texfileExternal.substr(tempcolor.texfileExternal.find_last_of("/\\") + 1);
CopyFile(tempcolor.texfileExternal.c_str(), base_filename.c_str(), false);
// stop looping
break;
}
}
}
示例13: depNodeFn
MStatus polyModifierCmd::processModifierNode( MObject modifierNode,
modifyPolyData& data )
{
MStatus status = MS::kSuccess;
MFnDependencyNode depNodeFn ( modifierNode );
data.modifierNodeSrcAttr = depNodeFn.attribute( "outMesh" );
data.modifierNodeDestAttr = depNodeFn.attribute( "inMesh" );
return status;
}
示例14: createExpression
//---------------------------------------------------
MObject DagHelper::createExpression ( const MPlug& plug, const MString& expression )
{
MFnDependencyNode expressionFn;
MObject expressionObj = expressionFn.create ( "expression" );
DagHelper::setPlugValue ( expressionObj, "expression", expression );
MPlug output = expressionFn.findPlug ( "output" );
MPlug firstOutput = output.elementByLogicalIndex ( 0 );
DagHelper::connect ( firstOutput, plug );
return expressionObj;
}
示例15: srcFn
//---------------------------------------------------
bool DagHelper::connectToList ( const MObject& source, const MString& sourceAttribute, const MObject& destination, const MString& destinationAttribute, int* index )
{
MStatus status;
MFnDependencyNode srcFn ( source );
MPlug src = srcFn.findPlug ( sourceAttribute, &status );
if ( status != MStatus::kSuccess ) return false;
return connectToList ( src, destination, destinationAttribute, index );
}