本文整理汇总了C++中MFnDependencyNode::attribute方法的典型用法代码示例。如果您正苦于以下问题:C++ MFnDependencyNode::attribute方法的具体用法?C++ MFnDependencyNode::attribute怎么用?C++ MFnDependencyNode::attribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MFnDependencyNode
的用法示例。
在下文中一共展示了MFnDependencyNode::attribute方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processModifierNode
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;
}
示例2: SetNodeID
MStatus Maya::SetNodeID( const MObject& node, const Helium::TUID& id )
{
MStatus status;
MFnDependencyNode nodeFn (node);
// make sure we have the dynamic attribute to store our id created
MObject attr = nodeFn.attribute(MString (s_TUIDAttributeName), &status);
if (status == MS::kFailure)
{
// check to see if we are a locked node
bool nodeWasLocked = nodeFn.isLocked();
if ( nodeWasLocked )
{
// turn off any node locking so an attribute can be added
nodeFn.setLocked( false );
}
// create the attribute
MFnTypedAttribute attrFn;
attr = attrFn.create(MString (s_TUIDAttributeName), MString (s_TUIDAttributeName), MFnData::kString);
status = nodeFn.addAttribute(attr);
// reset to the prior state of wasLocked
if ( nodeWasLocked )
{
nodeFn.setLocked( nodeWasLocked );
}
// error check
if (status == MS::kFailure)
{
MGlobal::displayError(MString ("Unable to create TUID attribute on maya node: ") + nodeFn.name());
return status;
}
}
MPlug plug (node, nodeFn.attribute(MString (s_TUIDAttributeName)));
plug.setLocked(false);
tstring s;
id.ToString(s);
plug.setValue(MString(s.c_str()));
plug.setLocked(true);
return status;
}
示例3: processModifierNode
// --------------------------------------------------------------------------------------------
MStatus polyModifierCmd::processModifierNode( MObject modifierNode,
modifyPolyData& data )
// --------------------------------------------------------------------------------------------
{
MStatus status = MS::kSuccess;
MFnDependencyNode depNodeFn ( modifierNode );
data.modifierNodeSrcAttr = depNodeFn.attribute( "outMesh" , &status);
MCheckStatus( status, "Finden des outMesh Attributes" );
data.modifierNodeDestAttr = depNodeFn.attribute( "inMesh" , &status );
return status;
}
示例4: dumpInfo
void dumpInfo( MObject fileNode,
MFnDependencyNode& nodeFn,
MObjectArray& nodePath )
{
MObject currentNode;
MObject fileAttr = nodeFn.attribute("fileTextureName");
MPlug plugToFile( fileNode, fileAttr );
MFnDependencyNode dgFn;
MStatus stat;
cerr << "Name: " << nodeFn.name() << endl;
MObject fnameValue;
stat = plugToFile.getValue( fnameValue );
if ( !stat ) {
stat.perror("error getting value from plug");
} else {
MFnStringData stringFn( fnameValue );
cerr << "Texture: " << stringFn.string() << endl;
}
cerr << "Path: ";
for ( int i = nodePath.length()-1; i >= 0; i-- ) {
currentNode = nodePath[i];
dgFn.setObject( currentNode );
cerr << dgFn.name() << "(" << dgFn.typeName() << ")";
if ( i > 0)
cerr << " ->\n ";
}
cerr << endl;
}
示例5: 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;
}
示例6: 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);
}
}
示例7:
bool
PxrUsdMayaWriteUtil::ReadMayaAttribute(
const MFnDependencyNode& depNode,
const MString& name,
std::string* 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::kStringData)) ) {
(*val) = std::string(plug.asString().asChar());
return true;
}
}
return false;
}
示例8: parseAttributes
MStatus AttributeParser::parseAttributes(MFnDependencyNode & fnNode, AttributeParser & parser)
{
MStatus status;
unsigned int attrCount = fnNode.attributeCount(&status);
for (unsigned int attrIndex = 0; attrIndex < attrCount; ++attrIndex)
{
MObject attrObject = fnNode.attribute(attrIndex, &status);
MFnAttribute fnAttr(attrObject, &status);
if (!status) continue;
MString attrName = fnAttr.name(&status);
if (!parser.onBeforeAttribute(fnNode, attrObject))
continue;
parser.parseAttribute(fnNode, attrObject);
//if (!parser.onAfterAttribute(fnNode, attrObject))
// continue;
parser.onAfterAttribute(fnNode, attrObject);
}
return MS::kSuccess;
}
示例9: updateRuleFiles
MStatus PRTAttrs::updateRuleFiles(MFnDependencyNode & node, MString & rulePkg) {
PRTNode* prtNode = (PRTNode*)node.userNode();
MStatus stat;
std::string utf8Path(rulePkg.asUTF8());
std::vector<char> percentEncodedPath(2*utf8Path.size()+1);
size_t len = percentEncodedPath.size();
prt::StringUtils::percentEncode(utf8Path.c_str(), &percentEncodedPath[0], &len);
if(len > percentEncodedPath.size()+1){
percentEncodedPath.resize(len);
prt::StringUtils::percentEncode(utf8Path.c_str(), &percentEncodedPath[0], &len);
}
std::string uri(FILE_PREFIX);
uri.append(&percentEncodedPath[0]);
prtNode->mLRulePkg = uri;
if(prtNode->mCreatedInteractively) {
int count = (int)node.attributeCount(&stat);
MCHECK(stat);
MObjectArray attrs;
for(int i = 0; i < count; i++) {
MObject attr = node.attribute(i, &stat);
if(stat != MS::kSuccess) continue;
attrs.append(attr);
}
for(unsigned int i = 0; i < attrs.length(); i++) {
MPlug plug(node.object(), attrs[i]);
MString name = plug.partialName();
if(prtNode->mBriefName2prtAttr.count(name.asWChar()))
node.removeAttribute(attrs[i]);
}
prtNode->destroyEnums();
} else {
node.removeAttribute(node.attribute(NAME_GENERATE, &stat));
MCHECK(stat);
}
prtNode->mRuleFile.clear();
prtNode->mStartRule.clear();
MString unpackDir = MGlobal::executeCommandStringResult("workspace -q -fullName");
unpackDir += "/assets";
prt::Status resolveMapStatus = prt::STATUS_UNSPECIFIED_ERROR;
std::wstring utf16URI;
utf16URI.resize(uri.size()+1);
len = utf16URI.size();
if(prt::StringUtils::toUTF16FromUTF8(uri.c_str(), &utf16URI[0], &len)) {
utf16URI.resize(len);
prt::StringUtils::toUTF16FromUTF8(uri.c_str(), &utf16URI[0], &len);
}
prtNode->mResolveMap = prt::createResolveMap(utf16URI.c_str(), unpackDir.asWChar(), &resolveMapStatus);
if(resolveMapStatus == prt::STATUS_OK) {
size_t nKeys;
const wchar_t * const* keys = prtNode->mResolveMap->getKeys(&nKeys);
std::wstring sCGB(L".cgb");
for(size_t k = 0; k < nKeys; k++) {
std::wstring key = std::wstring(keys[k]);
if(std::equal(sCGB.rbegin(), sCGB.rend(), key.rbegin())) {
prtNode->mRuleFile = key;
break;
}
}
} else {
prtNode->mResolveMap = 0;
}
if(prtNode->mRuleFile.length() > 0)
updateStartRules(node);
return MS::kSuccess;
}
示例10: processTweaks
// --------------------------------------------------------------------------------------------
MStatus polyModifierCmd::processTweaks( modifyPolyData& data )
// --------------------------------------------------------------------------------------------
{
MStatus status = MS::kSuccess;
// Clear tweak undo information (to be rebuilt)
//
fTweakIndexArray.clear();
fTweakVectorArray.clear();
// Extract the tweaks and place them into a polyTweak node. This polyTweak node
// will be placed ahead of the modifier node to maintain the order of operations.
// Special care must be taken into recreating the tweaks:
//
// 1) Copy tweak info (including connections!)
// 2) Remove tweak info from both meshNode and a duplicate meshNode (if applicable)
// 3) Cache tweak info for undo operations
//
//if( fHasTweaks && fHasHistory && !speedupTweakProcessing())
if( fHasTweaks && fHasHistory )
{
// Declare our function sets
//
MFnDependencyNode depNodeFn;
// Declare our attributes and plugs
//
MPlug meshTweakPlug;
MPlug upstreamTweakPlug;
MObject tweakNodeTweakAttr;
// Declare our tweak processing variables
//
MPlug tweak;
MPlug tweakChild;
MObject tweakData;
MObjectArray tweakDataArray;
MFloatVector tweakVector;
MIntArray tweakSrcConnectionCountArray;
MPlugArray tweakSrcConnectionPlugArray;
MIntArray tweakDstConnectionCountArray;
MPlugArray tweakDstConnectionPlugArray;
MPlugArray tempPlugArray;
unsigned i;
unsigned j;
unsigned k;
// Create the tweak node and get its attributes
//
data.tweakNode = fDGModifier.MDGModifier::createNode( "polyTweak" );
depNodeFn.setObject( data.tweakNode );
data.tweakNodeSrcAttr = depNodeFn.attribute( "output" );
data.tweakNodeDestAttr = depNodeFn.attribute( "inputPolymesh" );
tweakNodeTweakAttr = depNodeFn.attribute( "tweak" );
depNodeFn.setObject( data.meshNodeShape );
meshTweakPlug = depNodeFn.findPlug( "pnts" );
// ASSERT: meshTweakPlug should be an array plug!
//
MStatusAssert( (meshTweakPlug.isArray()),
"meshTweakPlug.isArray() -- meshTweakPlug is not an array plug" );
unsigned numElements = meshTweakPlug.numElements();
// Gather meshTweakPlug data
//
for( i = 0; i < numElements; i++ )
{
// MPlug::numElements() only returns the number of physical elements
// in the array plug. Thus we must use elementByPhysical index when using
// the index i.
//
tweak = meshTweakPlug.elementByPhysicalIndex(i);
// If the method fails, the element is NULL. Only append the index
// if it is a valid plug.
//
if( !tweak.isNull() )
{
// Cache the logical index of this element plug
//
unsigned logicalIndex = tweak.logicalIndex();
// Collect tweak data and cache the indices and float vectors
//
tweak.getValue( tweakData );
tweakDataArray.append( tweakData );
getFloat3PlugValue( tweak, tweakVector );
fTweakIndexArray.append( logicalIndex );
fTweakVectorArray.append( tweakVector );
// Collect tweak connection data
//
// Parse down to the deepest level of the plug tree and check
// for connections - look at the child nodes of the element plugs.
// If any connections are found, record the connection and disconnect
//.........这里部分代码省略.........
示例11: GetNodeID
Helium::TUID Maya::GetNodeID( const MObject& node, bool create )
{
if (node == MObject::kNullObj)
{
return Helium::TUID::Null;
}
MObject attr = MObject::kNullObj;
MStatus status = MS::kFailure;
MFnDependencyNode nodeFn (node);
if ( create )
{
//
// GUID->TUID legacy handling
//
// look for the old GUID attribute
attr = nodeFn.attribute(MString (s_GUIDAttributeName), &status);
// if we found it
if ( status == MS::kSuccess && !attr.isNull() )
{
// get the GUID value
MString str;
MPlug plug (node, attr);
status = plug.getValue(str);
HELIUM_ASSERT( status != MS::kFailure );
// parse it
Helium::GUID id;
bool parsed = id.FromString(str.asTChar());
HELIUM_ASSERT( parsed );
// convert it to a TUID and set the new attribute
Helium::TUID tuid;
tuid.FromGUID( id );
status = SetNodeID( node, tuid );
HELIUM_ASSERT( status != MS::kFailure );
// check to see if we are a locked node
bool nodeWasLocked = nodeFn.isLocked();
if ( nodeWasLocked )
{
// turn off any node locking so an attribute can be added
nodeFn.setLocked( false );
}
// unlock the attribute
status = plug.setLocked( false );
HELIUM_ASSERT( status != MS::kFailure );
// remove the attribute
status = nodeFn.removeAttribute( attr );
HELIUM_ASSERT( status != MS::kFailure );
// reset to the prior state of wasLocked
if ( nodeWasLocked )
{
nodeFn.setLocked( nodeWasLocked );
}
}
}
// look for the TUID attribute
attr = nodeFn.attribute(MString (s_TUIDAttributeName));
// retrieve the attribute value (may be empty if we are not creating a new id)
MString str;
MPlug plug (node, attr);
plug.getValue(str);
// if we don't have an existing id and we should create one
if ( str.length() == 0 && create )
{
// generate a new ID
Helium::TUID id( Helium::TUID::Generate() );
// set the new ID value on the node
if( SetNodeID( node, id ) )
{
return id;
}
else
{
return Helium::TUID::Null;
}
}
// parse the value (this may be null if we did not create the attribute)
Helium::TUID id;
id.FromString(str.asTChar());
return id;
}
示例12: 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);
//.........这里部分代码省略.........