本文整理汇总了C++中MFnDependencyNode::name方法的典型用法代码示例。如果您正苦于以下问题:C++ MFnDependencyNode::name方法的具体用法?C++ MFnDependencyNode::name怎么用?C++ MFnDependencyNode::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MFnDependencyNode
的用法示例。
在下文中一共展示了MFnDependencyNode::name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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();
}
示例3: defineColor
MString AppleseedRenderer::defineColor(MFnDependencyNode& shader, MString& attributeName, MString colorSpace = "srgb", float intensity = 1.0f)
{
MColor col(0,0,0);
if(!getColor(attributeName, shader, col))
{
logger.error(MString("Unable to get color values from node: ") + shader.name());
return "";
}
MString colorName = shader.name() + "_" + attributeName;
defineColor(colorName, col, intensity, colorSpace);
return colorName;
}
示例4: preparePrimitivesBase
// --------------------------------------------------------
COLLADASW::PrimitivesBase* GeometryPolygonExporter::preparePrimitivesBase(
const MFnMesh &fnMesh,
const uint numPolygons,
const uint exportType )
{
// Just create a polylist, if there are polygons to export
// If we have holes in the polygon, we have to use <polygons> instead of <polylist>.
// If we want to export as triangles, we have to use <triangles>.
COLLADASW::PrimitivesBase* primitivesBasePoly = createPrimitivesBase ( exportType );
// Begin to write.
primitivesBasePoly->openPrimitiveElement();
// Check if the material should be set
uint realShaderCount = ( uint ) mShaders.length();
if ( mShaderPosition < realShaderCount )
{
// Add shader-specific parameters (TexCoords sets).
// Add symbolic name for the material used on this polygon set.
MFnDependencyNode shaderFn ( mShaders[mShaderPosition] );
String shaderName = shaderFn.name().asChar();
String materialName = DocumentExporter::mayaNameToColladaName ( shaderFn.name() );
primitivesBasePoly->appendMaterial ( materialName );
}
// Set the number of polygons
primitivesBasePoly->appendCount ( numPolygons );
// Get the polygon input list
COLLADASW::InputList& inputList = primitivesBasePoly->getInputList();
getPolygonInputAttributes ( inputList );
primitivesBasePoly->appendInputList();
// Set the vertex count list, if we have a POLYLIST
if ( exportType == PolygonSource::POLYLIST )
{
// Retrieve the vertex count list for the polylist element.
primitivesBasePoly->openVertexCountListElement();
writeVertexCountList ( primitivesBasePoly, fnMesh );
primitivesBasePoly->closeElement();
}
if ( exportType != PolygonSource::POLYGONS )
{
// Prepare the list for add the vertex indexes
primitivesBasePoly->openPolylistElement();
}
return primitivesBasePoly;
}
示例5: 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();
}
示例6: appendForcedNodeToList
// ------------------------------------------------------------
void SceneGraph::appendForcedNodeToList ( const MDagPath& dagPath )
{
// Attach a function set
MFnDependencyNode fn ( dagPath.node() );
String theNodeName = fn.name().asChar();
MDagPath dagPathCopy = dagPath;
while ( dagPathCopy.length() > 0 && !isForcedNode ( dagPathCopy ) )
{
// Attach a function set
MFnDependencyNode fn ( dagPathCopy.node() );
String theNodeName = fn.name().asChar();
mForcedNodes.append ( dagPathCopy );
dagPathCopy.pop();
}
}
示例7: dagPathToColladaName
//---------------------------
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 );
}
示例8: GetName
std::string CMayaNode::GetName()
{
MStatus status;
MFnDependencyNode depNode (m_dagPath.node(), &status);
if (status != MS::kSuccess)
return "";
return depNode.name ().asChar();
}
示例9: 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;
}
示例10: fn
// -------------------------------------------
const String& SceneElement::getNodeName() const
{
if ( mNodeName.empty() )
{
const MObject & _node = getNode();
// Attach a function set
MFnDependencyNode fn ( _node );
mNodeName = DocumentExporter::mayaNameToColladaName ( fn.name() );
}
return mNodeName;
}
示例11: getPlugArrayConnectedTo
//---------------------------------------------------
//
// Find a node connected to a node's array attribute
//
bool DagHelper::getPlugArrayConnectedTo ( const MObject& node, const MString& attribute, MPlug& connectedPlug )
{
MStatus status;
MFnDependencyNode dgFn ( node );
MPlug plug = dgFn.findPlug ( attribute, &status );
if ( status != MS::kSuccess )
{
MGlobal::displayWarning ( MString ( "couldn't find plug on attribute " ) +
attribute + MString ( " on object " ) + dgFn.name() );
return false;
}
if ( plug.numElements() < 1 )
{
MGlobal::displayWarning ( MString ( "plug array doesn't have any connection on attribute " ) +
attribute + MString ( " on object " ) + dgFn.name() );
return false;
}
MPlug firstElementPlug = plug.connectionByPhysicalIndex ( 0 );
// Get the connection - there can be at most one input to a plug
//
MPlugArray connections;
firstElementPlug.connectedTo ( connections, true, true );
if ( connections.length() == 0 )
{
MGlobal::displayWarning ( MString ( "plug connected to an empty array on attribute " ) +
attribute + MString ( " on object " ) + dgFn.name() );
return false;
}
connectedPlug = connections[0];
return true;
}
示例12: createSceneElement
// ------------------------------------------------------------
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: writeAnimLayers
//for each animation layer we have, write out the name of the layer
//we will later write out the layer like a depend node and write out
//each attribute, but we do this seperately so that on import we
//can quickly see what layers are in the ATOM file so that we can
//create them if they are missing
void atomAnimLayers::writeAnimLayers(ofstream &animFile, atomWriter &writer)
{
if(mAnimLayers.length() > 0) // at least one Layer
{
animFile <<kAnimLayers << " { ";
for(unsigned int k = 0; k < mAnimLayers.length(); ++k)
{
if(mAnimLayers[k].hasFn (MFn::kDependencyNode))
{
MFnDependencyNode fnNode (mAnimLayers[k]);
MString layerName = fnNode.name();
animFile <<" " << layerName;
}
}
animFile << " }\n";
}
}
示例14: addAnimLayers
//this function will pass in all anim layer objects found on a particular plug. since we want them to be
//kept in order, but don't want ALL of the anim layers to be specified if they aren't used we
bool atomAnimLayers::addAnimLayers(MObjectArray &layers)
{
if(mOrderedAnimLayerNames.length() > 0)
{
//first time called set up the mAnimLayers object array.
if(mAnimLayers.length() != mOrderedAnimLayerNames.length())
{
mAnimLayers.setLength(mOrderedAnimLayerNames.length());
MObject nullObject;
//initialize with nulls
for(unsigned int k = 0; k < mAnimLayers.length(); ++k)
{
mAnimLayers[k] = nullObject;
}
}
}
//if here we have the ordered name list and the anim layer object list
//now we just need to set the objects passed in correctly
for(unsigned int k = 0; k < layers.length(); ++k)
{
if(layers[k].hasFn (MFn::kDependencyNode))
{
MFnDependencyNode fnNode (layers[k]);
MString layerName = fnNode.name();
for(unsigned int z = 0; z < mOrderedAnimLayerNames.length();++z)
{
if(layerName == mOrderedAnimLayerNames[z])
{
mAnimLayers[z] = layers[k];
break;
}
}
}
}
return true;
}
示例15: exportMaterialsByShaderPlug
//------------------------------------------------------
void MaterialExporter::exportMaterialsByShaderPlug()
{
// Get all shaders, which are in the default shader list.
MObject defaultShaderList = DagHelper::getNode ( ATTR_DEFAULT_SHADER_LIST1 );
MPlug defaultShadersPlug = MFnDependencyNode ( defaultShaderList ).findPlug ( ATTR_SHADERS );
uint shaderCount = defaultShadersPlug.evaluateNumElements();
for ( uint i = 0; i < shaderCount; ++i )
{
MObject shader = DagHelper::getNodeConnectedTo ( defaultShadersPlug.elementByPhysicalIndex ( i ) );
MFnDependencyNode shadingEngineFn ( shader );
// Get the name of the current material (this is the maya material id)
String mayaMaterialId = DocumentExporter::mayaNameToColladaName ( shadingEngineFn.name(), true );
bool doExportMaterial = true;
bool isFromReferencedFile = shadingEngineFn.isFromReferencedFile();
// bool isDefaulNode = shadingEngineFn.isDefaultNode();
// if ( isDefaulNode )
// {
// doExportMaterial = false;
// }
// else if ( isFromReferencedFile )
if ( isFromReferencedFile )
{
if ( ExportOptions::exportXRefs() && ExportOptions::dereferenceXRefs() ) doExportMaterial = true;
else doExportMaterial = false;
}
if ( doExportMaterial )
{
MObject shadingEngine = ShaderHelper::getShadingEngine ( shader );
exportMaterial ( shadingEngine );
}
}
}