Exemple #1
0
// Function name	: Xrefutil::NodeToXref
// Description	    : This method does a straightforward conversion of a Node to an XRef
// Return type		: void 
// Argument         : INode * pNode
// Argument         : TSTR &filename
// Argument         : bool bProxy
// Argument         : bool bIgnoreAnim
void Xrefutil::NodeToXref(INode * pNode, TSTR &filename, bool bProxy, bool bIgnoreAnim)
{
    IXRefObject * pXRef = (IXRefObject *)m_pInterface->CreateInstance(SYSTEM_CLASS_ID, 
        XREFOBJ_CLASS_ID);
    TSTR obName = TSTR(pNode->GetName());
	AssetUser asset = IAssetManager::GetInstance()->GetAsset(filename, kXRefAsset);
    pXRef->Init(asset, obName, pNode->GetObjectRef(), bProxy);
    pNode->SetObjectRef(pXRef);
    // also, set visual queue that we're ignoring anim if we did
    if (bIgnoreAnim)
        pXRef->SetIgnoreAnim(TRUE,FALSE);
}
Exemple #2
0
bool XRefObjFinder::Proc(INode * pNode)
{
    TSTR workstring;
	
    // NOTE: We dump all info into one big string
    // Not super realistic, and probably won't work with
    // a scene with lots of XRef objects, but in a real exporter
    // situation, you'd be dumping out to a file pointer anyway
	
    if (!pNode || !m_buffer) return false;
    Object *obj = pNode->GetObjectRef();
    if (obj && obj->SuperClassID()==SYSTEM_CLASS_ID && 
		obj->ClassID()==XREFOBJ_CLASS_ID) {
        IXRefObject *ix = (IXRefObject *)obj;
        // if pNode refs an XRef object, let's pull some info out of it
        workstring.printf(_T("Node <%s> XREF <%s> filename:<%s> proxy:<%s> anim-off:<%s> update-mats:<%s> \x0D\x0A"),
            pNode->GetName(), ix->GetCurObjName(), ix->GetCurFile().GetFileName(), 
            (ix->GetUseProxy()) ? _T("T") : _T("F"),
            (ix->GetIgnoreAnim()) ? _T("T") : _T("F"),
            (ix->GetUpdateMats()) ? _T("T") : _T("F"));
        m_buffer->append(workstring);
    }
    return true;
}
Exemple #3
0
inline void xref_low(std::wstring project_path, std::wstring pname) {
	FPInterface* iObjXrefMGR = GetCOREInterface(OBJXREFMGR_INTERFACE_ID);
	FPParams p(1, DUPOBJNAMEACTION_IOBJXREFMGR_TYPEPARAM, OBJXREFMGR_ENUM3::deleteOld);
	iObjXrefMGR->Invoke(DUPOBJNAMEACTION_IOBJXREFMGR_SETTER, &p);

	auto* ip = GetCOREInterface16();
	INodeTab selectedINodes;
	ip->GetSelNodeTab(selectedINodes);

	Tab<const MCHAR*> objNames;
	auto numNodeSelection = selectedINodes.Count();
	objNames.Resize(numNodeSelection);

	FPParams pAddXrefItemFromFile;
	FPValue pFileName;
	std::wstring filename = (project_path + L"\\" + pname + L"_high.max");
	pFileName.type = FILENAME_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM1_TYPE;
	pFileName.s = filename.data();
	pAddXrefItemFromFile.params.append(pFileName);

	FPValue pPromptObjNames;
	pPromptObjNames.type = PROMPTOBJNAMES_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM2_TYPE;
	pPromptObjNames.b = false;
	pAddXrefItemFromFile.params.append(pPromptObjNames);

	FPValue pObjName;
	pObjName.InitTab(OBJNAMES_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM3_TYPE, numNodeSelection);
	auto ptr = pObjName.s_tab;
	for (int i = 0; i < ptr->Count(); ++i) {
		auto selectedNode = selectedINodes[i];
		(*ptr)[i] = selectedNode->GetName();
	}
	pAddXrefItemFromFile.params.append(pObjName);

	FPValue pxrefOptions;
	pxrefOptions.InitTab(XREFOPTIONS_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM4_TYPE, 0);
	pAddXrefItemFromFile.params.append(pxrefOptions);

	FPValue result;
	iObjXrefMGR->Invoke(ADDXREFITEMSFROMFILE_IOBJXREFMGR, result, &pAddXrefItemFromFile);

	FPInterface* IXrefRecord = result.fpi;

	if (IXrefRecord != nullptr)
	{
		FPParams pGetItems;
		FPValue pTypes;

		pGetItems.params.append(&pTypes, 1);
		auto& param1 = pGetItems.params[0];
		param1.InitTab(TYPES_GETITEMS_IIXREFRECORD_PARAM1_TYPE, 1);
		(*param1.i_tab)[0] = (int)ENUM1_IXREFRECORD::XRefObjectType;

		FPValue pXrefItems;
		pGetItems.params.append(&pXrefItems, 1);
		auto& param2 = pGetItems.params[1];
		param2.InitTab(XREFITEMS_GETITEMS_IIXREFRECORD_PARAM2_TYPE, 0);

		IXrefRecord->Invoke(GETITEMS_IIXREFRECORD, result, &pGetItems);
		if (param2.r_tab != nullptr)
		{
			for (int i = 0; i < param2.r_tab->Count(); i++)
			{
				auto item = (*param2.r_tab)[i];

				FPParams pSetProxyItemSrcFile;
				FPValue pitem;
				pSetProxyItemSrcFile.params.append(&pitem, 1);
				auto& p1 = pSetProxyItemSrcFile.params[0];
				p1.type = PROXYITEM_SETPROXYITEMSRCFILE_IOBJXREFMGR_PARAM1_TYPE;
				p1.r = item;

				FPValue pFileName;
				pSetProxyItemSrcFile.params.append(&pFileName, 1);
				auto& p2 = pSetProxyItemSrcFile.params[1];
				p2.type = FILENAME_SETPROXYITEMSRCFILE_IOBJXREFMGR_PARAM2_TYPE;
				std::wstring proxyFile = (project_path + L"\\" + pname + L"_low0.max");
				p2.s = proxyFile.c_str();

				FPValue result;
				iObjXrefMGR->Invoke(SETPROXYITEMSRCFILE_IOBJXREFMGR, result, &pSetProxyItemSrcFile);


				IXRefObject *ix = (IXRefObject8 *)item;

				auto objName = ix->GetCurObjName();

				auto iXrefProxy = IXRefProxy::GetInterface(*item);

				FPParams proxyItemName(1, PROXYITEMNAME_IIXREFPROXY_TYPEPARAM, objName.data());
				iXrefProxy->Invoke(PROXYITEMNAME_IIXREFPROXY_SETTER, &proxyItemName);
			}
		}
		else LOG("r_tab is nullptr\n");
	}
}
Exemple #4
0
inline void xref_low_2(std::wstring project_path, std::wstring pname) {
	FPInterface* iObjXrefMGR = GetCOREInterface(OBJXREFMGR_INTERFACE_ID);
	FPParams p(1, DUPOBJNAMEACTION_IOBJXREFMGR_TYPEPARAM, OBJXREFMGR_ENUM3::deleteOld);
	iObjXrefMGR->Invoke(DUPOBJNAMEACTION_IOBJXREFMGR_SETTER, &p);

	auto* ip = GetCOREInterface16();
	INodeTab selectedINodes;
	ip->GetSelNodeTab(selectedINodes);

	Tab<const MCHAR*> objNames;
	auto numNodeSelection = selectedINodes.Count();
	objNames.Resize(numNodeSelection);
	
	FPParams pAddXrefItemFromFile;
	FPValue pFileName;
	std::wstring filename = (project_path + L"\\" + pname + L"_high.max");
	pFileName.type = FILENAME_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM1_TYPE;
	pFileName.s = filename.data();
	pAddXrefItemFromFile.params.append(pFileName);

	FPValue pPromptObjNames;
	pPromptObjNames.type = PROMPTOBJNAMES_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM2_TYPE;
	pPromptObjNames.b = false;
	pAddXrefItemFromFile.params.append(pPromptObjNames);

	FPValue pObjName;
	pObjName.InitTab(OBJNAMES_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM3_TYPE, numNodeSelection);
	auto ptr = pObjName.s_tab;
	for (int i = 0; i < ptr->Count(); ++i) {
		auto selectedNode = selectedINodes[i];		
		(*ptr)[i] = selectedNode->GetName();
	}
	pAddXrefItemFromFile.params.append(pObjName);

	FPValue pxrefOptions;
	pxrefOptions.InitTab(XREFOPTIONS_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM4_TYPE, 0);
	pAddXrefItemFromFile.params.append(pxrefOptions);
	
	FPValue result;
	iObjXrefMGR->Invoke(ADDXREFITEMSFROMFILE_IOBJXREFMGR, result, &pAddXrefItemFromFile);

	FPInterface* IXrefRecord = result.fpi;
	
	if (IXrefRecord != nullptr)
	{
		FPParams pGetItems;	
		FPValue pTypes;

		//FPInterfaceDesc* interfaceDesc = IXrefRecord->GetDesc();
		//generateInterfaceFuntionsID2(interfaceDesc);
		

// 		pTypes.InitTab(TYPES_GETITEMS_IIXREFRECORD_PARAM1_TYPE, 1);		
// 		(*pTypes.i_tab)[0] = (int)ENUM1_IXREFRECORD::XRefObjectType;
// 		pGetItems.params.append(&pTypes,1);		

		pGetItems.params.append(&pTypes, 1);	
		auto& param1 = pGetItems.params[0];
		param1.InitTab(TYPES_GETITEMS_IIXREFRECORD_PARAM1_TYPE, 1);
		(*param1.i_tab)[0] = (int)ENUM1_IXREFRECORD::XRefObjectType;
	
//  		FPValue pXrefItems;		
//  		pXrefItems.InitTab(XREFITEMS_GETITEMS_IIXREFRECORD_PARAM2_TYPE, 1);
//  		pGetItems.params.append(&pXrefItems,1);
	
 	//	FPValue pXrefItems;
		//Tab<ReferenceTarget*>* tabRefTarg = new Tab<ReferenceTarget*>();
		//tabRefTarg->SetCount(1,true);
		////tabRefTarg->Init();
		////tabRefTarg->ZeroCount();
		////tabRefTarg->Delete(0, 1);
 	//	LOG("Count tabRefTarg element is {}\n", tabRefTarg->Count());
 	//	pXrefItems.type = XREFITEMS_GETITEMS_IIXREFRECORD_PARAM2_TYPE;
 	//	pXrefItems.r_tab = tabRefTarg;
 	//	pGetItems.params.append(&pXrefItems, 1);
		//pGetItems.params[1].r_tab->Delete(0, 1);
		//FPValue result;
		//IXrefRecord->Invoke(GETITEMS_IIXREFRECORD, result, &pGetItems);
		
		FPValue pXrefItems;				
		pGetItems.params.append(&pXrefItems,1);
		auto& param2 = pGetItems.params[1];
		param2.InitTab(XREFITEMS_GETITEMS_IIXREFRECORD_PARAM2_TYPE, 0);

		IXrefRecord->Invoke(GETITEMS_IIXREFRECORD, result, &pGetItems);
		//LOG("first item in original is {}\n", (*pXrefItems.r_tab)[0] != nullptr);
		//LOG("number of item in original is {}\n", pXrefItems.r_tab->Count());
		if (param2.r_tab != nullptr)
		{			
			for (int i = 0; i < param2.r_tab->Count(); i++)
			{
				auto item = (*param2.r_tab)[i];				
		
				FPParams pSetProxyItemSrcFile;
				FPValue pitem;
				pSetProxyItemSrcFile.params.append(&pitem, 1);
				auto& p1 = pSetProxyItemSrcFile.params[0];
				p1.type = PROXYITEM_SETPROXYITEMSRCFILE_IOBJXREFMGR_PARAM1_TYPE;
				p1.r = item;

				FPValue pFileName;
				pSetProxyItemSrcFile.params.append(&pFileName,1);
				auto& p2 = pSetProxyItemSrcFile.params[1];
				p2.type = FILENAME_SETPROXYITEMSRCFILE_IOBJXREFMGR_PARAM2_TYPE;
				std::wstring proxyFile = (project_path + L"\\" + pname + L"_low0.max");
				p2.s = proxyFile.c_str();

				FPValue result;
				iObjXrefMGR->Invoke(SETPROXYITEMSRCFILE_IOBJXREFMGR, result, &pSetProxyItemSrcFile);
				
				
				IXRefObject *ix = (IXRefObject8 *)item;

				auto objName = ix->GetCurObjName();				
				
				auto iXrefProxy = IXRefProxy::GetInterface(*item);

				FPParams proxyItemName(1, PROXYITEMNAME_IIXREFPROXY_TYPEPARAM, objName.data());
				iXrefProxy->Invoke(PROXYITEMNAME_IIXREFPROXY_SETTER,&proxyItemName);
			}
		}
		else LOG("r_tab is nullptr\n"); 		
	}
		

	//const wchar_t* vfilename = s2ws(filename).data();
	//Tab<int> a;
	//LOG(vfilename);
	//FPParams AddXRefItemsFromFile(4, FILENAME_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM1_TYPE, vfilename,
	//	PROMPTOBJNAMES_ADDXREFITEMSTORECORD_IOBJXREFMGR_PARAM2_TYPE, false,
	//	OBJNAMES_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM3_TYPE, objNames_mchartype,
	//	XREFOPTIONS_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM4_TYPE,a
	//);
		
// 	FPValue result;
// 	fpInterface->Invoke(ADDXREFITEMSFROMFILE_IOBJXREFMGR, result, &AddXRefItemsFromFile);
}
Exemple #5
0
// Function name	: Xrefutil::AddNewXrefScene_IXROMGR
// Description	    : The purpose of this method is to provide a show of how to 
//						bring in xref objects by way of the IXRefObjectManager
//						interface.  As pertaining to this sample, the 
//						functionality it provides replaces most of the scene
//						scene enumeration and ::NodeToXref() call.
// Return type		: void 
// Argument         : HWND hWnd
void Xrefutil::AddNewXrefScene_IXROMGR(HWND hWnd)
{
	IXRefObject *pXRef;  // a temporary XRef object to handle the incoming one
	
	//  This is just a copy of the same variables from ::AddNewXrefObject
	INode * pNode = NULL;
    TSTR filename = _T("");
    TSTR pickedname = _T("");
    TSTR * workname = NULL;
	
	
	// getting the interface pointer
	m_pIobjrefmgr = static_cast<IObjXRefManager *>(GetCOREInterface(OBJXREFMANAGER_INTERFACE));
	
	//  if we don't get a good pointer to an IObjXRefManager _IS_REALLY_ bad!
	//  I am opting to just leave the method. 
	if(!m_pIobjrefmgr) {
		return;
	}
	
	// ********************************************************************************
	// ********** BELOW THIS LINE EVERYTHING IS COPIED FROM ::AddNewXrefObject ********
	// ********************************************************************************
	
    INode * pRootNode = m_pInterface->GetRootNode();
    if (!pRootNode) {
        // well, this is actually _really_ bad, but we just exit
        return;
    }
    if (!DoOpenSaveDialog(filename, true)) {
        // either cancel or fail, just return
        return;
    }
	
	// in preparation for merge, flag current scene nodes
    NodeFlagger newFlagger(A_WORK1);
    newFlagger.Enumerate(pRootNode);
	
	// merge in user-picked file into current scene
	// NOTE: We just skip anything in xref'd file that has the same name
	// as an object in the current scene
    if (! m_pInterface->MergeFromFile(filename, TRUE, FALSE, FALSE, MERGE_DUPS_SKIP, NULL)) {
        // error, merge failed
        newFlagger.set_clear(true);
        newFlagger.Enumerate(pRootNode);
        return;
    }
	
    // walk scene and build list of non-flagged nodes
    m_objnamesholder.ZeroCount();
	m_objnamesholder.Shrink();
    UnflaggedNodeNamer newNamer;
    newNamer.m_namelist = &m_objnamesholder;
    newNamer.Enumerate(pRootNode);
    UnflaggedNodeDeleter newDeleter;
	
    // present list of nodes to user, sep. modal dialog
    if (DoPickObjDialog() && m_picknameholder.length() > 0) {
        pNode = m_pInterface->GetINodeByName(m_picknameholder);
        if (pNode) {
            if (m_ignoreanimholder && pNode->IsAnimated()) {
                // if animation is ignored, we basically go through
                // the node and delete all the keys for the node's controllers
                // Note that this won't remove animation for procedural controllers
                DeleteAllAnimation(pNode);
            }
			// Woohoo!  we get to use the IXRefObjectManager interface
			AssetUser asset = IAssetManager::GetInstance()->GetAsset(filename,kXRefAsset);
			pXRef = m_pIobjrefmgr->AddXRefObject(asset, pNode->GetName(), m_proxyholder);
			pNode->SetObjectRef(pXRef);
			
			// also, set visual queue that we're ignoring anim if we did
			if (m_ignoreanimholder)
				pXRef->SetIgnoreAnim(TRUE,FALSE);
			// flag this converted node so we keep it
			pNode->SetAFlag(A_WORK1);
        }
    }
	
    // deleted non-flagged nodes, un-flag original nodes, and return
    newDeleter.Enumerate(pRootNode);
    newFlagger.set_clear(true);
    newFlagger.Enumerate(pRootNode);
    for (int delme = 0; delme < m_objnamesholder.Count(); delme++) { 
        // (clean up TSTRs)
        delete m_objnamesholder[delme];
    }
	
    m_pInterface->RedrawViews(m_pInterface->GetTime());
	
	// ********************************************************************************
	// ********** ABOVE THIS LINE EVERYTHING IS COPIED FROM ::AddNewXrefObject ********
	// ********************************************************************************
}