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; }
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"); } }
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); }