本文整理汇总了C++中MFnDependencyNode::setObject方法的典型用法代码示例。如果您正苦于以下问题:C++ MFnDependencyNode::setObject方法的具体用法?C++ MFnDependencyNode::setObject怎么用?C++ MFnDependencyNode::setObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MFnDependencyNode
的用法示例。
在下文中一共展示了MFnDependencyNode::setObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: UnloadArt
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();
}
示例4: 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;
}
示例5: 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);
}
示例6: EntityNodeParent
static MObject EntityNodeParent( MDagPath& path )
{
if( path.hasFn( MFn::kDagNode ) )
{
MDagPath parentPath;
MFnDependencyNode nodeFn;
while( path.pop( 1 ) != MS::kInvalidParameter )
{
nodeFn.setObject( path.node() );
if( nodeFn.typeId() == EntityInstanceNode::s_TypeID )
{
return nodeFn.object();
}
}
}
return MObject::kNullObj;
}
示例7: undoTweakProcessing
// --------------------------------------------------------------------------------------------
MStatus polyModifierCmd::undoTweakProcessing()
// --------------------------------------------------------------------------------------------
{
MStatus status = MS::kSuccess;
if( fHasTweaks )
{
MFnDependencyNode depNodeFn;
MObject meshNodeShape;
MPlug meshTweakPlug;
MPlug tweak;
MObject tweakData;
meshNodeShape = fDagPath.node();
depNodeFn.setObject( meshNodeShape );
meshTweakPlug = depNodeFn.findPlug( "pnts" );
MStatusAssert( (meshTweakPlug.isArray()),
"meshTweakPlug.isArray() -- meshTweakPlug is not an array plug" );
unsigned i;
unsigned numElements = fTweakIndexArray.length();
for( i = 0; i < numElements; i++ )
{
tweak = meshTweakPlug.elementByLogicalIndex( fTweakIndexArray[i] );
getFloat3asMObject( fTweakVectorArray[i], tweakData );
tweak.setValue( tweakData );
}
// In the case of no history, the duplicate node shape will be disconnected on undo
// so, there is no need to undo the tweak processing on it.
//
}
return status;
}
示例8: connectToDependNode
MStatus swissArmyLocatorManip::connectToDependNode(const MObject &node)
{
MStatus stat;
// Get the DAG path
//
MFnDagNode dagNodeFn(node);
dagNodeFn.getPath(fNodePath);
MObject parentNode = dagNodeFn.parent(0);
MFnDagNode parentNodeFn(parentNode);
// Connect the plugs
//
MFnDependencyNode nodeFn;
nodeFn.setObject(node);
// FreePointTriadManip
//
MFnFreePointTriadManip freePointTriadManipFn(fFreePointTriadManip);
MPlug translationPlug = parentNodeFn.findPlug("t", &stat);
if (MStatus::kFailure != stat) {
freePointTriadManipFn.connectToPointPlug(translationPlug);
}
// DirectionManip
//
MFnDirectionManip directionManipFn;
directionManipFn.setObject(fDirectionManip);
MPlug directionPlug = nodeFn.findPlug("arrow2Direction", &stat);
if (MStatus::kFailure != stat) {
directionManipFn.connectToDirectionPlug(directionPlug);
unsigned startPointIndex = directionManipFn.startPointIndex();
addPlugToManipConversionCallback(startPointIndex,
(plugToManipConversionCallback)
&swissArmyLocatorManip::startPointCallback);
}
// DistanceManip
//
MFnDistanceManip distanceManipFn;
distanceManipFn.setObject(fDistanceManip);
MPlug sizePlug = nodeFn.findPlug("size", &stat);
if (MStatus::kFailure != stat) {
distanceManipFn.connectToDistancePlug(sizePlug);
unsigned startPointIndex = distanceManipFn.startPointIndex();
addPlugToManipConversionCallback(startPointIndex,
(plugToManipConversionCallback)
&swissArmyLocatorManip::startPointCallback);
}
// CircleSweepManip
//
MFnCircleSweepManip circleSweepManipFn(fCircleSweepManip);
MPlug arrow1AnglePlug = nodeFn.findPlug("arrow1Angle", &stat);
if (MStatus::kFailure != stat) {
circleSweepManipFn.connectToAnglePlug(arrow1AnglePlug);
unsigned centerIndex = circleSweepManipFn.centerIndex();
addPlugToManipConversionCallback(centerIndex,
(plugToManipConversionCallback)
&swissArmyLocatorManip::startPointCallback);
}
// DiscManip
//
MFnDiscManip discManipFn(fDiscManip);
MPlug arrow3AnglePlug = nodeFn.findPlug("arrow3Angle", &stat);
if (MStatus::kFailure != stat) {
discManipFn.connectToAnglePlug(arrow3AnglePlug);
unsigned centerIndex = discManipFn.centerIndex();
addPlugToManipConversionCallback(centerIndex,
(plugToManipConversionCallback)
&swissArmyLocatorManip::startPointCallback);
}
// StateManip
//
MFnStateManip stateManipFn(fStateManip);
MPlug statePlug = nodeFn.findPlug("state", &stat);
if (MStatus::kFailure != stat) {
stateManipFn.connectToStatePlug(statePlug);
unsigned positionIndex = stateManipFn.positionIndex();
addPlugToManipConversionCallback(positionIndex,
(plugToManipConversionCallback)
&swissArmyLocatorManip::startPointCallback);
}
// ToggleManip
//
MFnToggleManip toggleManipFn(fToggleManip);
MPlug togglePlug = nodeFn.findPlug("toggle", &stat);
if (MStatus::kFailure != stat) {
toggleManipFn.connectToTogglePlug(togglePlug);
unsigned startPointIndex = toggleManipFn.startPointIndex();
addPlugToManipConversionCallback(startPointIndex,
(plugToManipConversionCallback)
&swissArmyLocatorManip::startPointCallback);
}
//.........这里部分代码省略.........
示例9: undoDirectModifier
// --------------------------------------------------------------------------------------------
MStatus polyModifierCmd::undoDirectModifier()
// --------------------------------------------------------------------------------------------
{
MStatus status;
MFnDependencyNode depNodeFn;
MFnDagNode dagNodeFn;
MObject meshNode = fDagPath.node();
depNodeFn.setObject( meshNode );
// For the case with tweaks, we cannot write the mesh directly back onto
// the cachedInMesh, since the shape can have out of date information from the
// cachedInMesh. Thus we temporarily create an duplicate mesh, place our
// old mesh on the outMesh attribute of our duplicate mesh, connect the
// duplicate mesh shape to the mesh shape, and force a DG evaluation.
//
// For the case without tweaks, we can simply write onto the outMesh, since
// the shape relies solely on an outMesh when there is no history nor tweaks.
//
if( fHasTweaks )
{
// Retrieve the inMesh and name of our mesh node (for the DG eval)
//
depNodeFn.setObject( meshNode );
MPlug meshNodeInMeshPlug = depNodeFn.findPlug( "inMesh", &status );
MCheckStatus( status, "Could not retrieve inMesh" );
MString meshNodeName = depNodeFn.name();
// Duplicate our current mesh
//
dagNodeFn.setObject( meshNode );
MObject dupMeshNode = dagNodeFn.duplicate();
// The dagNodeFn::duplicate() returns a transform, but we need a shape
// so retrieve the DAG path and extend it to the shape.
//
MDagPath dupMeshDagPath;
MDagPath::getAPathTo( dupMeshNode, dupMeshDagPath );
dupMeshDagPath.extendToShape();
// Retrieve the outMesh of the duplicate mesh and set our mesh data back
// on it.
//
depNodeFn.setObject( dupMeshDagPath.node() );
MPlug dupMeshNodeOutMeshPlug = depNodeFn.findPlug( "outMesh", &status );
MCheckStatus( status, "Could not retrieve outMesh" );
status = dupMeshNodeOutMeshPlug.setValue( fMeshData );
// Temporarily connect the duplicate mesh node to our mesh node
//
MDGModifier dgModifier;
dgModifier.connect( dupMeshNodeOutMeshPlug, meshNodeInMeshPlug );
status = dgModifier.doIt();
MCheckStatus( status, "Could not connect dupMeshNode -> meshNode" );
// Need to force a DG evaluation now that the input has been changed.
//
MString cmd("dgeval -src ");
cmd += meshNodeName;
cmd += ".inMesh";
status = MGlobal::executeCommand( cmd, false, false );
MCheckStatus( status, "Could not force DG eval" );
// Disconnect and delete the duplicate mesh node now
//
dgModifier.undoIt();
MGlobal::deleteNode( dupMeshNode );
// Restore the tweaks on the mesh
//
status = undoTweakProcessing();
}
else
{
// Restore the original mesh by writing the old mesh data (fMeshData) back
// onto the outMesh of our meshNode
//
depNodeFn.setObject( meshNode );
MPlug meshNodeOutMeshPlug = depNodeFn.findPlug( "outMesh", &status );
MCheckStatus( status, "Could not retrieve outMesh" );
status = meshNodeOutMeshPlug.setValue( fMeshData );
MCheckStatus( status, "Could not set meshData" );
}
return status;
}
示例10: undoCachedMesh
// --------------------------------------------------------------------------------------------
MStatus polyModifierCmd::undoCachedMesh()
// --------------------------------------------------------------------------------------------
{
MStatus status;
// Only need to restore the cached mesh if there was no history. Also
// check to make sure that we are in the record history state.
//
MStatusAssert( (fHasRecordHistory), "fHasRecordHistory == true" );
if( !fHasHistory )
{
MFnDependencyNode depNodeFn;
MString meshNodeName;
MObject meshNodeShape;
MPlug meshNodeDestPlug;
MPlug meshNodeOutMeshPlug;
MObject dupMeshNodeShape;
MPlug dupMeshNodeSrcPlug;
meshNodeShape = fDagPath.node();
dupMeshNodeShape = fDuplicateDagPath.node();
depNodeFn.setObject( meshNodeShape );
meshNodeName = depNodeFn.name();
meshNodeDestPlug = depNodeFn.findPlug( "inMesh", &status );
MCheckStatus( status, "Could not retrieve inMesh" );
meshNodeOutMeshPlug = depNodeFn.findPlug( "outMesh", &status );
MCheckStatus( status, "Could not retrieve outMesh" );
depNodeFn.setObject( dupMeshNodeShape );
dupMeshNodeSrcPlug = depNodeFn.findPlug( "outMesh", &status );
MCheckStatus( status, "Could not retrieve outMesh" );
// For the case with tweaks, we cannot write the mesh directly back onto
// the cachedInMesh, since the shape can have out of date information from the
// cachedInMesh, thus we temporarily connect the duplicate mesh shape to the
// mesh shape and force a DG evaluation.
//
// For the case without tweaks, we can simply write onto the outMesh, since
// the shape relies solely on an outMesh when there is no history nor tweaks.
//
if( fHasTweaks )
{
MDGModifier dgModifier;
dgModifier.connect( dupMeshNodeSrcPlug, meshNodeDestPlug );
status = dgModifier.doIt();
MCheckStatus( status, "Could not connect dupMeshNode -> meshNode" );
// Need to force a DG evaluation now that the input has been changed.
//
MString cmd( "dgeval -src " );
cmd += meshNodeName;
cmd += ".outMesh"; //outMesh statt inMesh, damit undo (ohne history) funzt
status = MGlobal::executeCommand( cmd, false, false );
MCheckStatus( status, "Could not force DG eval" );
// Disconnect the duplicate meshNode now
//
dgModifier.undoIt();
}
else
{
MObject meshData;
status = dupMeshNodeSrcPlug.getValue( meshData );
MCheckStatus( status, "Could not retrieve meshData" );
status = meshNodeOutMeshPlug.setValue( meshData );
MCheckStatus( status, "Could not set outMesh" );
}
}
return status;
}
示例11: GetShapeInstanceShader
// Get shading engine
//
void CScriptedShapeTranslator::GetShapeInstanceShader(MDagPath& dagPath, MFnDependencyNode &shadingEngineNode)
{
// Get instance shadingEngine
shadingEngineNode.setObject(MObject::kNullObj);
// First try the usual way
MPlug shadingGroupPlug = GetNodeShadingGroup(dagPath.node(), (dagPath.isInstanced() ? dagPath.instanceNumber() : 0));
if (!shadingGroupPlug.isNull())
{
shadingEngineNode.setObject(shadingGroupPlug.node());
return;
}
char buffer[64];
// Check connection from any shadingEngine on shape
MStringArray connections;
MGlobal::executeCommand("listConnections -s 1 -d 0 -c 1 -type shadingEngine "+dagPath.fullPathName(), connections);
MSelectionList sl;
if (connections.length() == 0)
{
// Check for direct surface shader connection
MGlobal::executeCommand("listConnections -s 1 -d 0 -c 1 "+dagPath.fullPathName(), connections);
for (unsigned int cidx=0; cidx<connections.length(); cidx+=2)
{
MString srcNode = connections[cidx+1];
// Get node classification, if can find arnold/shader/surface -> got it
MStringArray rv;
MGlobal::executeCommand("getClassification `nodeType "+srcNode+"`", rv);
if (rv.length() > 0 && rv[0].indexW("arnold/shader/surface") != -1)
{
connections.clear();
MGlobal::executeCommand("listConnections -s 0 -d 1 -c 1 -type shadingEngine "+srcNode, connections);
if (connections.length() == 2)
{
sl.add(connections[1]);
}
break;
}
}
}
else if (connections.length() == 2)
{
// Single connection, use same shader for all instances
sl.add(connections[1]);
}
else if (connections.length() > 2)
{
// Many connections, expects the destination plug in shape to be an array
// Use instance number as logical index, if this fails, use first shadingEngine in list
bool found = false;
sprintf(buffer, "[%d]", dagPath.instanceNumber());
MString iidx = buffer;
for (unsigned int cidx = 0; cidx < connections.length(); cidx += 2)
{
MString conn = connections[cidx];
if (conn.length() < iidx.length())
{
continue;
}
if (conn.substring(conn.length() - iidx.length(), conn.length() - 1) != iidx)
{
continue;
}
sl.add(connections[cidx+1]);
found = true;
break;
}
if (!found)
{
MGlobal::displayWarning("[mtoaScriptedTranslators] Instance shader plug not found, use first found shadingEngine \"" + connections[1] + "\"");
sl.add(connections[1]);
}
}
if (sl.length() == 1)
{
MObject shadingEngineObj;
if (sl.getDependNode(0, shadingEngineObj) == MS::kSuccess && shadingEngineObj.apiType() == MFn::kShadingEngine)
{
shadingEngineNode.setObject(shadingEngineObj);
}
//.........这里部分代码省略.........
示例12: cacheMeshTweaks
// --------------------------------------------------------------------------------------------
MStatus polyModifierCmd::cacheMeshTweaks()
// --------------------------------------------------------------------------------------------
{
MStatus status = MS::kSuccess;
// Clear tweak undo information (to be rebuilt)
//
fTweakIndexArray.clear();
fTweakVectorArray.clear();
// Extract the tweaks and store them in our local tweak cache members
//
if( fHasTweaks )
{
// Declare our function sets
//
MFnDependencyNode depNodeFn;
MObject meshNode = fDagPath.node();
MPlug meshTweakPlug;
// Declare our tweak processing variables
//
MPlug tweak;
MPlug tweakChild;
MObject tweakData;
MObjectArray tweakDataArray;
MFloatVector tweakVector;
MPlugArray tempPlugArray;
unsigned i;
depNodeFn.setObject( meshNode );
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
//
getFloat3PlugValue( tweak, tweakVector );
fTweakIndexArray.append( logicalIndex );
fTweakVectorArray.append( tweakVector );
}
}
}
return status;
}
示例13: printShadingData
void exportTerrain::printShadingData(const MFnMesh& theMesh, MString texture)
{
MObjectArray shaders;
MIntArray indices;
MPlug tPlug;
MPlugArray connections,inConnections;
MObject node,shaderObject;
MFnDependencyNode dpNode;
MStatus status;
int i,j;
theMesh.getConnectedShaders(0 , shaders, indices);
fout << "Shading Data:" << endl;
//Will assume that only one shader is used, and therefore only prints
//data for the first index;
//Assuming only one shader
dpNode.setObject( shaders[0] );
dpNode.getConnections(connections);
for(i=0;i < connections.length();++i){
connections[i].connectedTo(inConnections,true,true);
for(j=0;j<inConnections.length();++j){
node = inConnections[j].node();
dpNode.setObject(node);
if(node.hasFn(MFn::kLambert) ){
shaderObject = node;
}
}
}
MFnLambertShader shader(shaderObject, &status);
if(!status){
status.perror("Unable to create MFnLambertShader!");
return;
}
//Collect all the data
fout << "Diffuse_Color: " << (shader.diffuseCoeff(&status)*(MColor(1.0,1.0,1.0) )*shader.color(&status)) *
(MColor(1.0,1.0,1.0) - shader.transparency(&status) )<< endl;
fout << "Ambient: " << shader.ambientColor(&status) << endl;
fout << "Emmision_Color: " << shader.incandescence(&status) << endl;
if(shaderObject.hasFn(MFn::kBlinn) ){
MFnBlinnShader blinn(shaderObject);
fout << "Specular_Color: " << blinn.specularColor() << endl;
fout << "Shininess: " << blinn.eccentricity() << endl;
}
else if(shaderObject.hasFn(MFn::kPhong) ){
MFnPhongShader phong(shaderObject);
fout << "Specular_Color: " << phong.specularColor() << endl;
fout << "Shininess: " << phong.cosPower() << endl;
}
else{
fout << "Specular_Color: " << MColor() << endl;
fout << "Shininess: " << double(0) << endl;
}
fout << "Texture: " << texture << endl;
}
示例14: getSampledType
// returns 0 if static, 1 if sampled, and 2 if a curve
int util::getSampledType(const MPlug& iPlug)
{
MPlugArray conns;
iPlug.connectedTo(conns, true, false);
// it's possible that only some element of an array plug or
// some component of a compound plus is connected
if (conns.length() == 0)
{
if (iPlug.isArray())
{
unsigned int numConnectedElements = iPlug.numConnectedElements();
for (unsigned int e = 0; e < numConnectedElements; e++)
{
int retVal = getSampledType(iPlug.connectionByPhysicalIndex(e));
if (retVal > 0)
return retVal;
}
}
else if (iPlug.isCompound() && iPlug.numConnectedChildren() > 0)
{
unsigned int numChildren = iPlug.numChildren();
for (unsigned int c = 0; c < numChildren; c++)
{
int retVal = getSampledType(iPlug.child(c));
if (retVal > 0)
return retVal;
}
}
return 0;
}
MObject ob;
MFnDependencyNode nodeFn;
for (unsigned i = 0; i < conns.length(); i++)
{
ob = conns[i].node();
MFn::Type type = ob.apiType();
switch (type)
{
case MFn::kAnimCurveTimeToAngular:
case MFn::kAnimCurveTimeToDistance:
case MFn::kAnimCurveTimeToTime:
case MFn::kAnimCurveTimeToUnitless:
{
nodeFn.setObject(ob);
MPlug incoming = nodeFn.findPlug("i", true);
// sampled
if (incoming.isConnected())
return 1;
// curve
else
return 2;
}
break;
case MFn::kMute:
{
nodeFn.setObject(ob);
MPlug mutePlug = nodeFn.findPlug("mute", true);
// static
if (mutePlug.asBool())
return 0;
// curve
else
return 2;
}
break;
default:
break;
}
}
return 1;
}
示例15: 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" );
//.........这里部分代码省略.........