本文整理汇总了C++中MFnDagNode类的典型用法代码示例。如果您正苦于以下问题:C++ MFnDagNode类的具体用法?C++ MFnDagNode怎么用?C++ MFnDagNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MFnDagNode类的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:
std::pair< EntityNode*, EntityInstanceNode*> EntityNode::CreateInstance( const Asset::EntityInstancePtr& entity )
{
EntityNode* artClass = &Get( entity->GetEntity()->GetPath() );
M_EntityNode::iterator instItor = artClass->m_Instances.find( entity->m_ID );
EntityInstanceNode* entityNode = NULL;
if( instItor == artClass->m_Instances.end() )
{
MFnDagNode nodeFn;
MObject instanceObject = nodeFn.create( EntityInstanceNode::s_TypeID, entity->GetName().c_str() );
nodeFn.setDoNotWrite( true );
entityNode = static_cast< EntityInstanceNode* >( nodeFn.userNode() );
artClass->m_Instances[ entity->m_ID ] = entityNode;
entityNode->SetBackingEntity( entity );
entityNode->Show( *artClass );
}
else
{
entityNode = instItor->second;
entityNode->SetBackingEntity( entity );
}
return std::pair< EntityNode*, EntityInstanceNode* >( artClass, entityNode );
}
示例3: processMeshNode
// --------------------------------------------------------------------------------------------
MStatus polyModifierCmd::processMeshNode( modifyPolyData& data )
// --------------------------------------------------------------------------------------------
{
MStatus status = MS::kSuccess;
// Declare our function sets. Use MFnDagNode here so
// we can retrieve the parent transform.
//
MFnDagNode dagNodeFn;
// Use the DAG path to retrieve our mesh shape node.
//
data.meshNodeShape = fDagPath.node();
dagNodeFn.setObject( data.meshNodeShape );
// ASSERT: meshNodeShape node should have a parent transform!
//
MStatusAssert( (0 < dagNodeFn.parentCount()),
"0 < dagNodeFn.parentCount() -- meshNodeshape has no parent transform" );
data.meshNodeTransform = dagNodeFn.parent(0);
data.meshNodeDestPlug = dagNodeFn.findPlug( "inMesh" );
data.meshNodeDestAttr = data.meshNodeDestPlug.attribute();
return status;
}
示例4: printf
void RadiosityRenderer::printTransformData(const MDagPath& dagPath)
{
printf("got");
//This method simply determines the transformation information on the DAG node and prints it out.
MStatus status;
MObject transformNode = dagPath.transform(&status);
// This node has no transform - i.e., it’s the world node
if (!status && status.statusCode () == MStatus::kInvalidParameter)
return;
MFnDagNode transform (transformNode, &status);
if (!status) {
status.perror("MFnDagNode constructor");
return;
}
MTransformationMatrix matrix (transform.transformationMatrix());
//cout << " translation: " << matrix.translation(MSpace::kWorld)
//<< endl;
double threeDoubles[3];
MTransformationMatrix::RotationOrder rOrder;
matrix.getRotation (threeDoubles, rOrder, MSpace::kWorld);
cout << " rotation: ["
<< threeDoubles[0] << ", "
<< threeDoubles[1] << ", "
<< threeDoubles[2] << "]\n";
matrix.getScale (threeDoubles, MSpace::kWorld);
cout << " scale: ["
<< threeDoubles[0] << ", "
<< threeDoubles[1] << ", "
<< threeDoubles[2] << "]\n";
}
示例5: dagNode
// ------------------------------------------------------
// Unlike Maya's default behavior, we want to consider set membership to be inheritable
bool SetHelper::isMemberOfSet ( const MDagPath& dagPath, MFnSet& Set )
{
if ( Set.isMember ( dagPath ) )
{
return true;
}
else
{
MFnDagNode dagNode ( dagPath );
MSelectionList setMembers;
Set.getMembers ( setMembers, true );
for ( unsigned int i = 0; i < setMembers.length(); ++i )
{
MObject memberObject;
if ( setMembers.getDependNode ( i, memberObject ) )
{
if ( dagNode.isChildOf ( memberObject ) )
{
return true;
}
}
}
}
return false;
}
示例6: while
// ------------------------------------------------------------
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 );
}
}
}
}
}
示例7: M3dView
void SGToolContext::toolOnSetup(MEvent& evt)
{
MStatus status;
SGPermit permit;
SGKey::initializeKeys();
SGMouse::initializeButtons();
SGMesh::getSelection(SGToolCondition::option.symInfo);
SGSelection::sels.initialize(SGMesh::pMesh);
M3dView activeView = M3dView().active3dView();
manip = (SGManip*)SGManip::newManipulator(Names::manipName, m_oManip);
if (!manip) sgPrintf("manip is null");
this->addManipulator(m_oManip);
toolWidget = new SGWidget(MQtUtil::mainWindow());
toolWidget->startEvent();
this->setCursor( MCursor::editCursor );
if ( SGMesh::pMesh->dagPath.node().isNull() ) {
//MGlobal::displayWarning("Select mesh first");
}
else {
MFnMesh fnMesh = SGMesh::pMesh->dagPath;
MFnDagNode dagNode = fnMesh.parent(0);
char buffer[128];
sprintf(buffer, "maintainActiveChangeSelectMode %s", dagNode.partialPathName().asChar() );
MGlobal::executeCommand(buffer);
}
SGMarkingMenu::menu.setDefaultMenu();
SGToolCondition::toolIsOn = true;
}
示例8: dagNode
CBaseNode *CMayaNode::GetChild(int childId)
{
MStatus status;
MFnDagNode dagNode (m_dagPath, &status);
if (status != MS::kSuccess)
return 0;
MObject objChild = dagNode.child (childId, &status);
if (status != MS::kSuccess)
return 0;
MFnDagNode childDagNode (objChild, &status);
if (status != MS::kSuccess)
return 0;
MDagPath childPath;
if (childDagNode.getPath (childPath) != MS::kSuccess)
return 0;
CMayaNode *pNode = new CMayaNode;
if (!pNode->Create (childPath))
{
delete pNode;
return 0;
}
return pNode;
}
示例9: CM_TRACE_FUNC
void tLocatorMgr::scanScene(const float lframe__, const int sample__,
boost::shared_ptr< liqRibHT > &htable__,
int &count__,
MStatus &returnStatus__)
{
CM_TRACE_FUNC("tLocatorMgr::scanScene("<<lframe__<<","<<sample__<<",htable__,count__,returnStatus__)");
//[refactor 10] beg from scanScene()
MItDag dagCoordSysIterator( MItDag::kDepthFirst, MFn::kLocator, &returnStatus__);
for (; !dagCoordSysIterator.isDone(); dagCoordSysIterator.next())
{
#if (Refactoring == 0)
LIQ_CHECK_CANCEL_REQUEST;
#endif
MDagPath path;
MObject currentNode;
currentNode = dagCoordSysIterator.item();
MFnDagNode dagNode;
dagCoordSysIterator.getPath( path );
if(MS::kSuccess != returnStatus__)
continue;
if(!currentNode.hasFn(MFn::kDagNode))
continue;
returnStatus__ = dagNode.setObject( currentNode );
if(MS::kSuccess != returnStatus__)
continue;
// scanScene: if it's a coordinate system then insert it into the hash table
if( dagNode.typeName() == "liquidCoordSys" )
{
int coordType = 0;
MPlug typePlug = dagNode.findPlug( "type", &returnStatus__ );
if( MS::kSuccess == returnStatus__ )
typePlug.getValue( coordType );
bool useSamples( ( sample__ > 0 ) && isObjectMotionBlur( path ) );
ObjectType mrttype = getMRTType(currentNode, coordType);
ObjectType mrttype_shouldbe = ( coordType == 5 )? MRT_ClipPlane : MRT_Coord;
if( mrttype != mrttype_shouldbe ){
liquidMessage2(messageError, "mrttype[%d] should be %d", mrttype_shouldbe);
}
htable__->insert( path,
lframe__,
( useSamples )? sample__ : 0,
mrttype, //( coordType == 5 )? MRT_ClipPlane : MRT_Coord,
count__++ );
continue;
}
}
//[refactor 10] end from scanScene()
}
示例10: IsPathTemplated
bool IsPathTemplated(MDagPath& path)
{
MStatus stat = MStatus::kSuccess;
while (stat == MStatus::kSuccess)
{
MFnDagNode node;
node.setObject(path.node());
if (IsTemplated(node))
return true;
stat = path.pop();
}
return false;
}
示例11: transformFn
void EntityInstanceNode::Hide()
{
MFnTransform transformFn( thisMObject() );
u32 len = transformFn.childCount();
MFnDagNode nodeFn;
for( u32 i = 0; i < len; ++i )
{
nodeFn.setObject( transformFn.child( 0 ) );
MDagPath path;
nodeFn.getPath( path );
MGlobal::deleteNode( path.node() );
}
}
示例12: SceneElement
// ------------------------------------------------------------
SceneElement* SceneGraph::createSceneElement (
const MDagPath &dagPath,
SceneElement* parentSceneElement )
{
// Create a new scene element
SceneElement* sceneElement = new SceneElement ( dagPath );
// Attach a function set
MFnDependencyNode fn ( dagPath.node() );
// Check for multiple instances.
bool isInstanced = dagPath.isInstanced ();
if ( parentSceneElement == 0 )
{
// dagPath.getAllPathsTo ( ) ()
}
// Get the node name
String nodeName = DocumentExporter::mayaNameToColladaName ( fn.name() );
sceneElement->setNodeName ( nodeName );
// Check if it's a node to export and
// tell the scene node to be transformed or not.
bool isForced = false;
bool isVisible = false;
bool isExportNode = getIsExportNode ( dagPath, isForced, isVisible );
sceneElement->setIsForced ( isForced );
sceneElement->setIsVisible ( isVisible );
// Check for a file reference
MFnDagNode dagFn ( dagPath );
bool isLocal = !dagFn.isFromReferencedFile();
if ( ExportOptions::exportXRefs() && ExportOptions::dereferenceXRefs()) isLocal = true;
if ( !isLocal && !ExportOptions::exportXRefs() ) isExportNode = false;
sceneElement->setIsExportNode ( isExportNode );
sceneElement->setIsLocal ( isLocal );
if ( parentSceneElement != NULL )
{
if ( !sceneElement->containsParentElement ( parentSceneElement ) )
sceneElement->addParentElement ( parentSceneElement );
if ( !parentSceneElement->containsChildElement ( sceneElement ) )
parentSceneElement->addChildElement ( sceneElement );
}
return sceneElement;
}
示例13: MTime
MStatus sgBDataCmd_key::importData()
{
MStatus status;
MTime::Unit currentUnit = MTime().unit();
MPlugArray connections;
sgObject_keyData& objectKeyData = m_objectKeyDataImport;
MObject& oTarget = objectKeyData.oTargetNode;
MDoubleArray& dArrTime = objectKeyData.dArrTime;
MTime::Unit unit = (MTime::Unit)objectKeyData.unit;
MFnDagNode fnNode = oTarget;
MPlugArray targetPlugs;
unsigned int numAttr = objectKeyData.namesAttribute.length();
unsigned int lengthTime = dArrTime.length();
for( unsigned int j=0; j<numAttr; j++ )
{
if( numAttr <= j ) break;
MPlug targetPlug = fnNode.findPlug( objectKeyData.namesAttribute[j] );
targetPlug.connectedTo( connections, true, false );
if( connections.length() ){
m_dgMod_connection.disconnect( connections[0], targetPlug );
m_dgMod_delete.deleteNode( connections[0].node() );
}
m_dgMod_connection.doIt();
m_dgMod_delete.doIt();
MObject oAnimCurve = MFnAnimCurve().create( targetPlug );
m_oArrKeyAfter.append( oAnimCurve );
MFnAnimCurve fnAnimCurve( oAnimCurve );
for( unsigned int k=0; k<lengthTime; k++ )
{
double& dTime = dArrTime[k];
double& dValue = objectKeyData.dArrValuesArray[ k*numAttr+j ];
MTime mTime( dTime, unit );
mTime.setUnit( currentUnit );
fnAnimCurve.addKeyframe( mTime, dValue );
}
}
return MS::kSuccess;
};
示例14: doIt
MStatus testSelectAddAttribute::doIt( const MArgList& args )
{
MDagPath node;
MObject component;
MSelectionList list;
MFnDagNode nodeFn;
MGlobal::getActiveSelectionList( list );
for ( unsigned int index = 0; index < list.length(); index++ )
{
list.getDagPath( index, node, component );
nodeFn.setObject( node );
cout<<nodeFn.name().asChar( ) << "is selected" << endl;
}
return MS::kSuccess;
}
示例15: if
EntityNode& EntityNode::Get( const Helium::Path& path, bool createIfNotExisting )
{
MFnDagNode dagFn;
try
{
M_IdClassTransform::iterator findItor = s_ClassTransformsMap.find( path.Hash() );
if( findItor != s_ClassTransformsMap.end() )
{
return *findItor->second;
}
else if ( createIfNotExisting )
{
// we couldn't find it, so create it and return the loaded art class
Asset::AssetClassPtr assetClass = Asset::AssetClass::LoadAssetClass( path );
if ( assetClass.ReferencesObject() )
{
tstring artFilePath = assetClass->GetPath().Get();
MObject classTransform = dagFn.create( EntityNode::s_TypeID, assetClass->GetShortName().c_str() );
dagFn.setDoNotWrite( true );
EntityNode* artClass = static_cast<EntityNode*>( dagFn.userNode() );
artClass->m_AssetPath = path;
artClass->SetArtFilePath( artFilePath.c_str() );
s_ClassTransformsMap[ path.Hash() ] = artClass;
artClass->LoadArt();
return *artClass;
}
}
}
catch (Helium::Exception& )
{
if ( createIfNotExisting )
{
MGlobal::displayError( MString("Unable to create EntityNode!") );
}
}
return EntityNode::Null;
}