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


C++ MFnDependencyNode::userNode方法代码示例

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


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

示例1: exportCustomHwShaderNode

    //---------------------------------------
    void MaterialExporter::exportCustomHwShaderNode( 
        COLLADASW::InstanceEffect &effectInstance, 
        MObject shader )
    {
        MFnDependencyNode fnNode ( shader );
        if ( fnNode.typeId() == cgfxShaderNode::sId ) 
        {
            // Add the technique hint and the effect attributes to the collada document.
            exportCgfxShaderNode ( effectInstance, (cgfxShaderNode*) fnNode.userNode () );
        }

    }
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:13,代码来源:COLLADAMayaMaterialExporter.cpp

示例2: updateStartRules

MStatus PRTAttrs::updateStartRules(MFnDependencyNode & node) {
	PRTNode* prtNode = (PRTNode*)node.userNode();

	const prt::RuleFileInfo::Entry* startRule = 0;

	prt::Status infoStatus = prt::STATUS_UNSPECIFIED_ERROR;
	const prt::RuleFileInfo* info = prt::createRuleFileInfo(prtNode->mResolveMap->getString(prtNode->mRuleFile.c_str()), 0, &infoStatus);
	if (infoStatus == prt::STATUS_OK) {
		for(size_t r = 0; r < info->getNumRules(); r++) {
			if(info->getRule(r)->getNumParameters() > 0) continue;
			for(size_t a = 0; a < info->getRule(r)->getNumAnnotations(); a++) {
				if(!(wcscmp(info->getRule(r)->getAnnotation(a)->getName(), ANNOT_START_RULE))) {
					startRule = info->getRule(r);
					break;
				}
			}
		}
	}
	if(startRule) {
		prtNode->mStartRule = startRule->getName();

		MCHECK(addBoolParameter(node, prtNode->mGenerate,  NAME_GENERATE, true));

		if(prtNode->mGenerateAttrs) {
			prtNode->mGenerateAttrs->destroy();
			prtNode->mGenerateAttrs = 0;
		}

		prt::AttributeMapBuilder* aBuilder = prt::AttributeMapBuilder::create();
		createAttributes(node, prtNode->mRuleFile, prtNode->mStartRule, aBuilder, info);
		prtNode->mGenerateAttrs = aBuilder->createAttributeMap();
		aBuilder->destroy();
	}

  if(info)
		info->destroy();

	return MS::kSuccess;
}
开发者ID:Esri,项目名称:esri-cityengine-sdk,代码行数:39,代码来源:PRTAttrs.cpp

示例3: doIt

//-----------------------------------------------------------------------------
// EntityInstanceNodeCmd::doIt
// execution of the command
//-----------------------------------------------------------------------------
MStatus EntityInstanceNodeCmd::doIt( const MArgList & args )
{
  MStatus stat;

  // parse the command line arguments using the declared syntax
  MArgDatabase argParser( syntax(), args, &stat );

  if( argParser.isFlagSet( ReloadAllArtFlagLong ) )
  {
    EntityNode::UnloadAllArt();
    EntityNode::LoadAllArt();
    return MS::kSuccess;
  }
  else if( argParser.isFlagSet( UnloadAllArtFlagLong ) )
  {
    EntityNode::UnloadAllArt();
    return MS::kSuccess;
  }
  else if( argParser.isFlagSet( UnselectFlag ) )
  {
    MGlobal::executeCommand( "select -all" );

    MSelectionList list;
    MGlobal::getActiveSelectionList( list );
    EntityNode::UnselectAll( list );
    MGlobal::setActiveSelectionList( list );

    return MS::kSuccess;
  }
  else if( argParser.isFlagSet( CreateInstanceFlag ) )
  {
      HELIUM_BREAK();
#pragma TODO( "Reimplement to use the Vault" )
    //File::FileBrowser browserDlg( NULL, -1, "Create Instance" );
    //browserDlg.AddFilter( FinderSpecs::Asset::ENTITY_DECORATION );
    //browserDlg.SetFilterIndex( FinderSpecs::Asset::ENTITY_DECORATION );

    //if ( browserDlg.ShowModal() == wxID_OK )
    //{
    //  tstring fullPath = browserDlg.GetPath();
    //  if ( FileSystem::Exists( fullPath ) )
    //  {
    //    if ( FileSystem::HasExtension( fullPath, FinderSpecs::Asset::ENTITY_DECORATION.GetDecoration() ) )
    //    {
    //      Asset::EntityPtr instance = new Asset::Entity( fullPath );
    //      std::pair< EntityNode*, EntityInstanceNode* >result = EntityNode::CreateInstance( instance );
    //      MFnDependencyNode nodeFn( result.second->thisMObject() );
    //    }
    //  }
    //}

    return MS::kSuccess;
  }
  else if( argParser.isFlagSet( FlattenLong ) )
  {
    EntityNode::FlattenInstances();    
    return MS::kSuccess;
  }

  //
  // the following flags need an EntityNode object to proceed
  //

  MSelectionList selection;
  argParser.getObjects( selection );

  MObject selectedNode;
  selection.getDependNode( 0, selectedNode );

  MFnDependencyNode nodeFn;
  nodeFn.setObject( selectedNode );

  EntityNode* classTransform = NULL;
  if( nodeFn.typeId() == EntityInstanceNode::s_TypeID )
  {
    EntityInstanceNode* node = static_cast< EntityInstanceNode* >( nodeFn.userNode( &stat ) );
    if( !node )
    {
      return MS::kFailure;
    }

    classTransform = &EntityNode::Get( node->GetBackingEntity()->GetEntity()->GetPath() );
    if( *classTransform == EntityNode::Null )
    {
      return MS::kFailure;
    }
  }
  else if ( nodeFn.typeId() == EntityNode::s_TypeID )
  {
    classTransform = static_cast< EntityNode* >( nodeFn.userNode( &stat ) );
    if( !classTransform )
    {
      return MS::kFailure;
    }
  }

//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例4: if


//.........这里部分代码省略.........
		fNodeName = tmpList[0];
		if ( fNodeName.length() ) 
		{
			sWho += " \"";
			sWho += fNodeName;
			sWho += "\"";
		}

		status = selList.getDependNode(0, oNode);
		if (!status)
		{
			return status;
		}

		status = fnNode.setObject( oNode );
		if (!status)
		{
			sFeedback = sWho;
			sFeedback += " is not a cgfxShader node.";
			MGlobal::displayError( sFeedback );

			return status;
		}

		if (fnNode.typeId() != cgfxShaderNode::sId)
		{
			status = MS::kInvalidParameter;
			sFeedback = sWho;
			sFeedback += " is not a cgfxShader node.";
			MGlobal::displayError( sFeedback );
			return status;
		}

		pNode = (cgfxShaderNode*)fnNode.userNode();
		if (!pNode)
		{
			status = MS::kInvalidParameter;
			sFeedback = sWho;
			sFeedback += " is not cgfxShader node.";
			MGlobal::displayError( sFeedback );
			return status;
		}
	}

	if ( fIsQuery ) {
        
        // -fx / -fxFile
        //     Returns the shader file name. 
        if ( fFxFile )
        {
            MString path = pNode->shaderFxFile();
            setResult( path );
            return MS::kSuccess;
        }

        // -fxp / -fxPath 
        //     Returns the path of the fx file.  The path name is in Maya
        //     format ('/' delimited).  Result type is string.
        //     (Query only)
        if ( fFxPath )
        {
            MString path = cgfxFindFile(pNode->shaderFxFile());
            setResult( path );
            return MS::kSuccess;
        }
开发者ID:BigRoy,项目名称:Maya-devkit,代码行数:66,代码来源:cgfxShaderCmd.cpp

示例5: createAttributes

// TODO: make evalAttr finds more robust
MStatus PRTAttrs::createAttributes(MFnDependencyNode & node, const std::wstring & ruleFile, const std::wstring & startRule, prt::AttributeMapBuilder* aBuilder, const prt::RuleFileInfo* info) {
	MStatus           stat;
	MStatus           stat2;
	MFnNumericData    numericData;
	MFnTypedAttribute tAttr;
	MFnStringData     attrDefaultStr;
	PRTNode*          prtNode = (PRTNode*)node.userNode();
	MString           dummy;

	MayaCallbacks* outputHandler = prtNode->createOutputHandler(0, 0);
	const prt::AttributeMap* attrs   = aBuilder->createAttributeMap();

	prt::InitialShapeBuilder* isb = prt::InitialShapeBuilder::create();
	isb->setGeometry(
			UnitQuad::vertices,
			UnitQuad::vertexCount,
			UnitQuad::indices,
			UnitQuad::indexCount,
			UnitQuad::faceCounts,
			UnitQuad::faceCountsCount
	);
	isb->setAttributes(
			ruleFile.c_str(),
			startRule.c_str(),
			UnitQuad::seed,
			L"",
			attrs,
			prtNode->mResolveMap
	);
	const prt::InitialShape* shape = isb->createInitialShapeAndReset();

	prt::generate(&shape, 1, 0, &ENC_ATTR, 1, &prtNode->mAttrEncOpts, outputHandler, PRTNode::theCache, 0);

	const std::map<std::wstring, MayaCallbacks::AttributeHolder>& evalAttrs = outputHandler->getAttrs();

	prtNode->mBriefName2prtAttr[NAME_GENERATE.asWChar()] = NAME_GENERATE.asWChar();

	for(size_t i = 0; i < info->getNumAttributes(); i++) {
		PRTEnum* e = nullptr;

		const MString name = MString(info->getAttribute(i)->getName());
		MObject attr;

		if(info->getAttribute(i)->getNumParameters() != 0) continue;

		prtNode->mBriefName2prtAttr[prtu::toCleanId(name).asWChar()] = name.asWChar();

		switch(info->getAttribute(i)->getReturnType()) {
		case prt::AAT_BOOL: {
				for(size_t a = 0; a < info->getAttribute(i)->getNumAnnotations(); a++) {
					const prt::Annotation* an = info->getAttribute(i)->getAnnotation(a);
					if(!(wcscmp(an->getName(), ANNOT_RANGE)))
						e = new PRTEnum(prtNode, an);
				}
				bool value = evalAttrs.find(name.asWChar())->second.mBool;
				if(e) {
					MCHECK(addEnumParameter(node, attr, name, value, e));
				} else {
					MCHECK(addBoolParameter(node, attr, name, value));
				}
			break;
			}
		case prt::AAT_FLOAT: {
				double min = std::numeric_limits<double>::quiet_NaN();
				double max = std::numeric_limits<double>::quiet_NaN();
				for(size_t a = 0; a < info->getAttribute(i)->getNumAnnotations(); a++) {
					const prt::Annotation* an = info->getAttribute(i)->getAnnotation(a);
					if(!(wcscmp(an->getName(), ANNOT_RANGE))) {
						if(an->getNumArguments() == 2 && an->getArgument(0)->getType() == prt::AAT_FLOAT && an->getArgument(1)->getType() == prt::AAT_FLOAT) {
							min = an->getArgument(0)->getFloat();
							max = an->getArgument(1)->getFloat();
						} else
							e = new PRTEnum(prtNode, an);
					}
				}

				double value = evalAttrs.find(name.asWChar())->second.mFloat;

				if(e) {
					MCHECK(addEnumParameter(node, attr, name, value, e));
				} else {
					MCHECK(addFloatParameter(node, attr, name, value, min, max));
				}
				break;
			}
		case prt::AAT_STR: {
				MString exts;
				bool    asFile  = false;
				bool    asColor = false;
				for(size_t a = 0; a < info->getAttribute(i)->getNumAnnotations(); a++) {
					const prt::Annotation* an = info->getAttribute(i)->getAnnotation(a);
					if(!(wcscmp(an->getName(), ANNOT_RANGE)))
						e = new PRTEnum(prtNode, an);
					else if(!(wcscmp(an->getName(), ANNOT_COLOR)))
						asColor = true;
					else if(!(wcscmp(an->getName(), ANNOT_DIR))) {
						exts = MString(an->getName());
						asFile = true;
					} else if(!(wcscmp(an->getName(), ANNOT_FILE))) {
//.........这里部分代码省略.........
开发者ID:Esri,项目名称:esri-cityengine-sdk,代码行数:101,代码来源:PRTAttrs.cpp

示例6: updateRuleFiles

MStatus PRTAttrs::updateRuleFiles(MFnDependencyNode & node, MString & rulePkg) {
	PRTNode* prtNode = (PRTNode*)node.userNode();
	MStatus  stat;

	std::string utf8Path(rulePkg.asUTF8());
	std::vector<char> percentEncodedPath(2*utf8Path.size()+1);
	size_t len = percentEncodedPath.size();
	prt::StringUtils::percentEncode(utf8Path.c_str(), &percentEncodedPath[0], &len);
	if(len > percentEncodedPath.size()+1){
		percentEncodedPath.resize(len);
		prt::StringUtils::percentEncode(utf8Path.c_str(), &percentEncodedPath[0], &len);
	}

	std::string uri(FILE_PREFIX);
	uri.append(&percentEncodedPath[0]);

	prtNode->mLRulePkg = uri;

	if(prtNode->mCreatedInteractively) {
		int count = (int)node.attributeCount(&stat);
		MCHECK(stat);

		MObjectArray attrs;

		for(int i = 0; i < count; i++) {
			MObject attr = node.attribute(i, &stat);
			if(stat != MS::kSuccess) continue;
			attrs.append(attr);
		}

		for(unsigned int i = 0; i < attrs.length(); i++) {
			MPlug   plug(node.object(), attrs[i]);
			MString name = plug.partialName();

			if(prtNode->mBriefName2prtAttr.count(name.asWChar()))
				node.removeAttribute(attrs[i]);
		}
		prtNode->destroyEnums();
	} else {
		node.removeAttribute(node.attribute(NAME_GENERATE, &stat));
		MCHECK(stat);
	}

	prtNode->mRuleFile.clear();
	prtNode->mStartRule.clear();

	MString      unpackDir       = MGlobal::executeCommandStringResult("workspace -q -fullName");
	unpackDir += "/assets";
	prt::Status resolveMapStatus = prt::STATUS_UNSPECIFIED_ERROR;


	std::wstring utf16URI;
	utf16URI.resize(uri.size()+1);
	len = utf16URI.size();
	if(prt::StringUtils::toUTF16FromUTF8(uri.c_str(), &utf16URI[0], &len)) {
		utf16URI.resize(len);
		prt::StringUtils::toUTF16FromUTF8(uri.c_str(), &utf16URI[0], &len);
	}

	prtNode->mResolveMap = prt::createResolveMap(utf16URI.c_str(), unpackDir.asWChar(), &resolveMapStatus);
	if(resolveMapStatus == prt::STATUS_OK) {
		size_t nKeys;
		const wchar_t * const* keys   = prtNode->mResolveMap->getKeys(&nKeys);
		std::wstring           sCGB(L".cgb");
		for(size_t k = 0; k < nKeys; k++) {
			std::wstring key = std::wstring(keys[k]);
			if(std::equal(sCGB.rbegin(), sCGB.rend(), key.rbegin())) {
				prtNode->mRuleFile = key;
				break;
			}
		}
	} else {
		prtNode->mResolveMap = 0;
	}

	if(prtNode->mRuleFile.length() > 0)
		updateStartRules(node);

	return MS::kSuccess;
}
开发者ID:Esri,项目名称:esri-cityengine-sdk,代码行数:80,代码来源:PRTAttrs.cpp


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