本文整理汇总了C++中MFnDependencyNode::findPlug方法的典型用法代码示例。如果您正苦于以下问题:C++ MFnDependencyNode::findPlug方法的具体用法?C++ MFnDependencyNode::findPlug怎么用?C++ MFnDependencyNode::findPlug使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MFnDependencyNode
的用法示例。
在下文中一共展示了MFnDependencyNode::findPlug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
示例2: 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);
}
示例3: extractColor
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;
}
}
}
示例4: exportImage
//---------------------------------------------------------------
String EffectTextureExporter::exportImage ( const MObject &texture )
{
// Retrieve the texture filename
MFnDependencyNode textureNode ( texture );
MString mayaName = textureNode.name();
MPlug filenamePlug = textureNode.findPlug ( ATTR_FILE_TEXTURE_NAME );
// Get the maya image id.
String mayaImageId = DocumentExporter::mayaNameToColladaName ( textureNode.name() );
// Generate a COLLADA id for the new light object
String colladaImageId;
// Check if there is an extra attribute "colladaId" and use this as export id.
MString attributeValue;
DagHelper::getPlugValue ( texture, COLLADA_ID_ATTRIBUTE_NAME, attributeValue );
if ( attributeValue != EMPTY_CSTRING )
{
// Generate a valid collada name, if necessary.
colladaImageId = mDocumentExporter->mayaNameToColladaName ( attributeValue, false );
}
else
{
// Generate a COLLADA id for the new light object
colladaImageId = DocumentExporter::mayaNameToColladaName ( textureNode.name() );
}
// Make the id unique and store it in a map for refernences.
colladaImageId = mImageIdList.addId ( colladaImageId );
mMayaIdColladaImageId [mayaImageId] = colladaImageId;
// Get the maya filename with the path to the file.
MString mayaFileName;
filenamePlug.getValue ( mayaFileName );
if ( mayaFileName.length () == 0 ) return NULL;
String sourceFile = mayaFileName.asChar ();
COLLADASW::URI sourceFileUri ( COLLADASW::URI::nativePathToUri ( sourceFile ) );
if ( sourceFileUri.getScheme ().empty () )
sourceFileUri.setScheme ( COLLADASW::URI::SCHEME_FILE );
COLLADASW::Image* colladaImage = exportImage ( mayaImageId, colladaImageId, sourceFileUri );
if ( colladaImage == NULL ) return NULL;
// Export the node type, because PSD textures don't behave the same as File textures.
String nodeType = texture.hasFn ( MFn::kPsdFileTexture ) ? MAYA_TEXTURE_PSDTEXTURE : MAYA_TEXTURE_FILETEXTURE;
colladaImage->addExtraTechniqueParameter ( PROFILE_MAYA, MAYA_TEXTURE_NODETYPE, nodeType );
// Export whether this image is in fact an image sequence
MPlug imgSeqPlug = textureNode.findPlug ( ATTR_IMAGE_SEQUENCE );
bool isImgSeq = false;
imgSeqPlug.getValue ( isImgSeq );
colladaImage->addExtraTechniqueParameter ( PROFILE_MAYA, MAYA_TEXTURE_IMAGE_SEQUENCE, isImgSeq );
return colladaImage->getImageId();
}
示例5: setBindPoseInverse
//---------------------------------------------------
// set the bind pose for a transform
//
MStatus DagHelper::setBindPoseInverse ( const MObject& node, const MMatrix& bindPoseInverse )
{
MStatus status;
MFnDependencyNode dgFn ( node );
MPlug bindPosePlug = dgFn.findPlug ( "bindPose", &status );
if ( status != MS::kSuccess )
{
MGlobal::displayWarning ( MString ( "No bindPose found on node " ) + dgFn.name() );
return status;
}
MFnMatrixData matrixFn;
MObject val = matrixFn.create ( bindPoseInverse.inverse(), &status );
MObject invval = matrixFn.create ( bindPoseInverse, &status );
if ( status != MS::kSuccess )
{
MGlobal::displayWarning ( MString ( "Error setting bindPose on node " ) + dgFn.name() );
return status;
}
// set the bind pose on the joint itself
bindPosePlug.setValue ( val );
// Now, perhaps more significantly, see if there's a
// skinCluster using this bone and update its bind
// pose (as the joint bind pose is not connected to
// the skin - it's set at bind time from the joint's
// current position, and our importer may not want to
// disturb the current scene state just to put bones
// in a bind position before creating skin clusters)
MObject _node ( node );
MItDependencyGraph it ( _node, MFn::kSkinClusterFilter );
while ( !it.isDone() )
{
MPlug plug = it.thisPlug();
unsigned int idx = plug.logicalIndex();
MFnDependencyNode skinFn ( plug.node() );
MPlug skinBindPosePlug = skinFn.findPlug ( "bindPreMatrix", &status );
if ( status == MS::kSuccess )
{
// The skinCluster stores inverse inclusive matrix
// so notice we use invval (the MObject created off
// the inverse matrix here)
skinBindPosePlug = skinBindPosePlug.elementByLogicalIndex ( idx );
skinBindPosePlug.setValue ( invval );
}
it.next();
}
return status;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: ExtractNormalMap
void ExtractNormalMap(MFnDependencyNode& fn, unsigned int* tex = NULL)
{
MString texname;
MPlug p = fn.findPlug( "normalCamera" );
MPlugArray plugs;
p.connectedTo(plugs,true,true);
for(int i = 0; i != plugs.length(); ++i)
{
if (plugs[i].node().apiType() == MFn::kBump)
{
MFnDependencyNode fnDepBump( plugs[i].node() );
MPlug pp = fnDepBump.findPlug( "bumpValue" );
MPlugArray pplugs;
pp.connectedTo(pplugs, true, true);
for(int j = 0; j != pplugs.length(); ++j)
{
if (pplugs[j].node().apiType() == MFn::kFileTexture)
{
MFnDependencyNode fnDep(pplugs[j].node());
texname = fnDep.name();
break;
}
}
}
}
*tex = GetTextureID( texname );
}
示例10: getConnectedFileTexturePath
MString getConnectedFileTexturePath(const MString& plugName, MFnDependencyNode& depFn)
{
MStatus stat;
MString path = "";
MPlug plug = depFn.findPlug(plugName, &stat);
if (!stat)
return path;
if (plug.isConnected())
{
MPlugArray parray;
plug.connectedTo(parray, true, false, &stat);
if (!stat)
return path;
if (parray.length() == 0)
return path;
MPlug destPlug = parray[0];
MObject fileNode = destPlug.node();
if (!fileNode.hasFn(MFn::kFileTexture))
{
return path;
}
MFnDependencyNode fileDepFn(fileNode);
MPlug ftn = fileDepFn.findPlug("fileTextureName", &stat);
if (!stat)
{
return path;
}
path = ftn.asString();
}
return path;
}
示例11: getConnectedChildPlugs
void getConnectedChildPlugs(const char *attrName, MFnDependencyNode& depFn, bool dest, MPlugArray& thisNodePlugs, MPlugArray& otherSidePlugs)
{
MPlug p = depFn.findPlug(attrName);
if (p.isCompound() && !p.isArray())
{
getConnectedChildPlugs(p, dest, thisNodePlugs, otherSidePlugs);
return;
}
if (p.isArray())
{
for (uint i = 0; i < p.numElements(); i++)
{
if (p[i].numConnectedChildren() == 0)
continue;
if (!p[i].isCompound())
getConnectedChildPlugs(p[i], dest, thisNodePlugs, otherSidePlugs);
else
{
if (getAttributeNameFromPlug(p) == MString("colorEntryList"))
{
getConnectedChildPlugs(p[i].child(1), dest, thisNodePlugs, otherSidePlugs);
}
}
}
}
}
示例12: TfToken
static bool
_GetMetadataUnchecked(
const MFnDependencyNode& node,
const TfToken& key,
VtValue* value)
{
VtValue fallback = SdfSchema::GetInstance().GetFallback(key);
if (fallback.IsEmpty()) {
return false;
}
std::string mayaAttrName = _GetMayaAttrNameForMetadataKey(key);
MPlug plug = node.findPlug(mayaAttrName.c_str());
if (plug.isNull()) {
return false;
}
TfType ty = fallback.GetType();
VtValue result = UsdMayaWriteUtil::GetVtValue(plug, ty, TfToken());
if (result.IsEmpty()) {
TF_RUNTIME_ERROR(
"Cannot convert plug '%s' into metadata '%s' (%s)",
plug.name().asChar(),
key.GetText(),
ty.GetTypeName().c_str());
return false;
}
*value = result;
return true;
}
示例13: getConnectedFileTextureObject
MObject getConnectedFileTextureObject(MString& plugName, MFnDependencyNode& depFn)
{
MStatus stat;
MString path = "";
MPlug plug = depFn.findPlug(plugName, &stat);
if( !stat )
return MObject::kNullObj;
if( plug.isConnected())
{
MPlugArray parray;
plug.connectedTo(parray, true, false, &stat);
if( !stat )
return MObject::kNullObj;
if( parray.length() == 0 )
return MObject::kNullObj;
MPlug destPlug = parray[0];
MObject fileNode = destPlug.node();
if( !fileNode.hasFn(MFn::kFileTexture) )
{
return MObject::kNullObj;
}else{
return fileNode;
}
}
return MObject::kNullObj;
}
示例14: addAngleParameter
// ------------------------------------------------------------
void EffectTextureExporter::addAngleParameter (
COLLADASW::Texture* colladaTexture,
const char* plugName,
MFnDependencyNode &placement2d )
{
MStatus status;
MPlug plug = placement2d.findPlug ( plugName, &status );
if ( status == MStatus::kSuccess )
{
float angleRad;
plug.getValue ( angleRad );
float angleDeg = COLLADABU::Math::Utils::radToDegF ( angleRad );
// The target id for the animation
String targetSid = mAnimationTargetPath + plugName;
// Create the animation
AnimationExporter* animationExporter = mDocumentExporter->getAnimationExporter();
bool animated = animationExporter->addPlugAnimation ( plug, targetSid, kBoolean );
// Add the parameter
String paramSid = EMPTY_STRING;
if ( animated ) paramSid = plugName;
colladaTexture->addExtraTechniqueParameter ( PROFILE_MAYA, plugName, angleDeg, paramSid );
}
}
示例15: parseMatrixAttribute
void AttributeParser::parseMatrixAttribute(MFnDependencyNode & node, MObject & attribute)
{
MStatus status;
MFnMatrixAttribute fnMatrixAttribute(attribute, &status);
if (!status) return;
MPlug plug = node.findPlug(attribute, &status);
if (!status) return;
MPlugArray plugArray;
bool hasConnection = plug.connectedTo(plugArray, true, false, &status);
if (!status) return;
if (hasConnection)
{
MPlug externalPlug = plugArray[0];
bool externalPlugNull = externalPlug.isNull(&status);
if (!status) return;
if (!externalPlugNull)
{
MFnAttribute fnAttribute(attribute, &status);
if (!status) return;
MString name = fnAttribute.name(&status);
if (!status) return;
//MObject pluggedObject = externalPlug.node(&status);
//if (!status) return;
// TODO pass matrix to callback? onMatrix(...) instead of onConnection(...)?
onConnection(plug, name, externalPlug);
}
}
}