当前位置: 首页>>代码示例>>C++>>正文


C++ MFnDagNode::typeId方法代码示例

本文整理汇总了C++中MFnDagNode::typeId方法的典型用法代码示例。如果您正苦于以下问题:C++ MFnDagNode::typeId方法的具体用法?C++ MFnDagNode::typeId怎么用?C++ MFnDagNode::typeId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MFnDagNode的用法示例。


在下文中一共展示了MFnDagNode::typeId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LoadArt

void EntityNode::LoadArt()
{
    MStatus stat;
    bool callbackRemoved = false;
    if( s_EditNodeAddedCBId != -1 )
    {
        MDGMessage::removeCallback( s_EditNodeAddedCBId );
        s_EditNodeAddedCBId = -1;
        callbackRemoved = true;
    }

    UnloadArt();

    MString artFilePath;
    GetArtFilePath( artFilePath );
    std::cout << "Importing from: " << artFilePath.asTChar() << "..." << std::endl;

    // add the callback to catch all the imported objects
    MObjectArray objectArrays[NodeArrays::Count];
    s_ImportNodeAddedCBId = MDGMessage::addNodeAddedCallback( ImportNodeAddedCallback, kDefaultNodeType, &objectArrays );

    // import stuff
    MFileIO::import( artFilePath, NULL, false );

    // remove the callback
    MDGMessage::removeCallback( s_ImportNodeAddedCBId );

    // add all imported stuff under this guy's transform
    MFnDagNode nodeFn( thisMObject() );
    for( u32 i=0; i<objectArrays[NodeArrays::KeepNodes].length(); ++i )
    {
        if( objectArrays[NodeArrays::KeepNodes][i].isNull() )
        {
            continue;
        }

        MObjectHandle handle( objectArrays[NodeArrays::KeepNodes][i] );
        if ( !handle.isValid() )
        {
            continue;
        }

        // We should be getting only MFnDagNode in here, but just in case
        MFnDagNode dagFn( objectArrays[NodeArrays::KeepNodes][i], &stat );
        if ( stat == MStatus::kSuccess )
        {
            stat = dagFn.setDoNotWrite( true );
        }
        else
        {
            MFnDependencyNode depNodeFn( objectArrays[NodeArrays::KeepNodes][i], &stat );
            stat = depNodeFn.setDoNotWrite( true );
        }

#ifdef _DEBUG
        MString name = dagFn.name();
        MString type = dagFn.typeName();
        std::string nodeTypeStr( objectArrays[NodeArrays::KeepNodes][i].apiTypeStr() );

        if ( name.length() )
        {
            std::cout << " - Importing Child: " << name.asTChar() << " " << type.asTChar() << "(" << nodeTypeStr << ")" << std::endl;
        }
#endif

        AddImportNode( objectArrays[NodeArrays::KeepNodes][i] );   
        nodeFn.addChild( objectArrays[NodeArrays::KeepNodes][i] );
    }

    for( u32 i=0; i<objectArrays[NodeArrays::DeleteNodes].length(); ++i )
    {
        MGlobal::deleteNode( objectArrays[NodeArrays::DeleteNodes][i] );
    }

    MFnDagNode otherFn;
    for( u32 i=0 ; i<nodeFn.childCount(); ++i )
    {
        MObject child = nodeFn.child( i );
        if( !child.hasFn( MFn::kDagNode ) ) 
        {
            continue;
        }

        otherFn.setObject( child );
        if( otherFn.typeId() == EntityNode::s_TypeID )
        {
            MDagModifier mod;
            u32 numChild = otherFn.childCount();
            for( u32 j = 0; j < numChild; ++j )
            {
                stat = mod.reparentNode( otherFn.child( j ), thisMObject() );
            }
            mod.doIt();

            MGlobal::deleteNode( child );
            break;
        }
    }

    std::cout << "Done" << std::endl;
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的MFnDagNode::typeId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。