void Water::ReInit() { float c[3], d; if (count!=waves.Count()) { waves.SetCount(count); waves.Resize(count); } // Reseed random number generator srand(randSeed); // Compute wave centers on sphere with radius size for (int i = 0; i < count; i++) { WaveDesc &wv = waves[i]; c[0] = frand(); c[1] = (type == 0) ? frand() : 0.0f; c[2] = frand(); d = size/(float)sqrt(c[0]*c[0]+c[1]*c[1]+c[2]*c[2]); wv.cent[0] = c[0]*d; wv.cent[1] = c[1]*d; wv.cent[2] = c[2]*d; wv.period = (((float)(rand()&0x7FFF))/32768.0f)* (maxperiod-minperiod)+minperiod; wv.rate = (float)sqrt(maxperiod/wv.period); } }
void Water::SetNum(int i, TimeValue t, BOOL init) { count = i; waves.SetCount(count); waves.Resize(count); // pblock->SetValue(PB_NUM, t, i); pblock->SetValue(water_num, t, i); if (init) ReInit(); }
void Composite::Init() { macroRecorder->Disable(); ivalid.SetEmpty(); offset = 0; subTex.Resize(0); // mapOn.Resize(0); SetNumMaps(2); macroRecorder->Enable(); }
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); }
void xref_low_error(std::wstring project_path, std::wstring pname) { //Tab<const MCHAR*> sourceFile_Files; Tab<const MCHAR*>* pointer_sourceFile_Files = new Tab<const MCHAR*>(); std::wstring filename = (project_path + L"\\" + pname + L"_low0.max"); const wchar_t* file = filename.c_str(); sourceFile_Files.Append(1, &file); sourceFile_Files.Shrink(); pointer_sourceFile_Files->Init(); pointer_sourceFile_Files->Append(1, &file); Tab<MSTR*> tstr_tab; MSTR str(filename.c_str()); MSTR* a = &str; tstr_tab.Append(1, &a); tstr_tab.Shrink(); Tab<MSTR*> tstr_tab_dynamic_allocate_items; MSTR* str_dynamic_allocate_items = new MSTR(filename.c_str()); tstr_tab_dynamic_allocate_items.Append(1, &str_dynamic_allocate_items); tstr_tab_dynamic_allocate_items.Shrink(); //FPValue param1; //int i = 10; ////param1.LoadPtr(FILENAME_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM1_TYPE, filename.data()); //param1.type = FILENAME_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM1_TYPE; //param1.s = filename.data(); //param1.LoadPtr(ParamType2::TYPE_INT_BP, &i); //LOG("param1.s here= "); LOG(param1.s); LOG("\n"); // FPValue param1_FPValue; // TCHAR* param1_TCHAR = _T("Test Track View"); // param1_FPValue.type = TYPE_STRING, // param1_FPValue.s = param1_TCHAR; // param1.type = (ParamType2)TYPE_FPVALUE; // param1.fpv = ¶m1_FPValue; try { { //std::lock_guard<std::mutex> lock(mymutex); //FPValue param3; param3.type = ParamType2::TYPE_STRING_TAB; //param3.s_tab = pointer_sourceFile_Files; param3.s_tab = &sourceFile_Files; //OBJNAMES_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM3_TYPE; //param3.InitTab(ParamType2::TYPE_STRING_TAB, sourceFile_Files.Count()); //param3.LoadPtr(ParamType2::TYPE_STRING_TAB_BV, &sourceFile_Files); //param3.Load(ParamType2::TYPE_STRING_TAB_BV,&sourceFile_Files); //param3.LoadPtr(ParamType2::TYPE_STRING_TAB, &sourceFile_Files); //param3.LoadPtr(ParamType2::TYPE_STRING_TAB_BV, tstr_tab); //param3.LoadPtr(ParamType2::TYPE_STRING_TAB_BV, &tstr_tab_dynamic_allocate_items); //SYSTEM_CALL(param3.LoadPtr(ParamType2::TYPE_STRING_TAB_BV, &sourceFile_Files);) //param3.Load(ParamType2::TYPE_STRING_TAB, &sourceFile_Files); mprintf((*param3.s_tab)[0]); //LOG(); } } catch (const std::exception&) { //LOG("Why this is error, tell me pls"); }; // FPValue param4; // param4.type = ParamType2::TYPE_FPVALUE_TAB_BV; // Tab<FPValue*> param4_fpvalues; // FPValue param4_fpvalue; // FPValue* pointer_param4_fpvalue; // param4_fpvalue.type = (ParamType2)1; // param4_fpvalue.i = 10; // param4_fpvalues.Append(1, &pointer_param4_fpvalue); // param4.fpv_tab = ¶m4_fpvalues; FPValue param4; //param4.type = ParamType2::TYPE_INT_TAB; //param4.type = ParamType2::TYPE_INT_TAB_BV; //param4.type = ParamType2::TYPE_INT_TAB_BR; Tab<int> xrefoptions; xrefoptions.Resize(1); int h = 1; xrefoptions.Append(1, &h); //param4.i_tab = &xrefoptions; //LOG("type is {0}", param4.type); //FPParams fnParams; //FPValue result, param1; //FPValue param1_FPValue; //TCHAR* param1_TCHAR = _T("Test Track View"); //param1_FPValue.type = TYPE_STRING, // param1_FPValue.s = param1_TCHAR; //param1.type = (ParamType2)TYPE_FPVALUE, // param1.fpv = ¶m1_FPValue; //fnParams.params.append(¶m1,1); //LOG("type is {0}", param1.type); // auto s_tab = param3.s_tab; // auto count = s_tab->Count(); // LOG("count here is {}\n", count); // for (int i = 0; i < count; i++) // { // auto sp = (*s_tab)[i]; // LOG("Name {} from param3.s_tab ", i); LOG(sp); LOG("\n"); // } // if (s_tab == nullptr) // LOG("this not good\n"); // else // LOG("uha\n"); }
void Unreal3DExport::GetTris() { // Export triangle data FJSMeshTri nulltri = FJSMeshTri(); for( int n=0; n<Nodes.Count(); ++n ) { CheckCancel(); IGameNode* node = Nodes[n]; IGameMesh* mesh = static_cast<IGameMesh*>(node->GetIGameObject()); if( mesh->InitializeData() ) { int vertcount = mesh->GetNumberOfVerts(); int tricount = mesh->GetNumberOfFaces(); if( vertcount > 0 && tricount > 0 ) { // Progress ProgressMsg.printf(GetString(IDS_INFO_MESH),n+1,Nodes.Count(),TSTR(node->GetName())); pInt->ProgressUpdate(Progress+(static_cast<float>(n)/Nodes.Count()*U3D_PROGRESS_MESH), FALSE, ProgressMsg.data()); // Alloc triangles space Tris.Resize(Tris.Count()+tricount); // Append triangles for( int i=0; i!=tricount; ++i ) { FaceEx* f = mesh->GetFace(i); if( f ) { FJSMeshTri tri(nulltri); // TODO: add material id listing RegisterMaterial( node, mesh, f, &tri ); tri.iVertex[0] = VertsPerFrame + f->vert[0]; tri.iVertex[1] = VertsPerFrame + f->vert[1]; tri.iVertex[2] = VertsPerFrame + f->vert[2]; Point2 p; if( mesh->GetTexVertex(f->texCoord[0],p) ){ tri.Tex[0] = FMeshUV(p); } if( mesh->GetTexVertex(f->texCoord[1],p) ){ tri.Tex[1] = FMeshUV(p); } if( mesh->GetTexVertex(f->texCoord[2],p) ){ tri.Tex[2] = FMeshUV(p); } Tris.Append(1,&tri); } } VertsPerFrame += vertcount; } else { // remove invalid node Nodes.Delete(n--,1); } } node->ReleaseIGameObject(); } Progress += U3D_PROGRESS_MESH; }