bool cMeshBuilder::Build(const std::vector<const std::string>& i_arguments) { bool wereThereErrors = false; const int vertexCount = 4; const int indexCount = 4; //std::ofstream ofile(m_path_target, std::ios::binary); //ofile.write((char*)&vertexCount, sizeof(int)); //ofile.write((char*)&indexCount, sizeof(int)); _rout = new std::ofstream(m_path_target, std::ios::binary); float vertex1[6] = { -5.0f, 0.0f, 5.0f, 50.0f, 50.0f, 50.0f }; //ofile.write((char*)&vertex1, sizeof(float)*6); //std::cout << "Created meshBuilder \n"; LoadAsset(m_path_source); // Copy the source to the target { const bool dontFailIfTargetAlreadyExists = false; std::string errorMessage; /*if (!eae6320::CopyFile(m_path_source, m_path_target, dontFailIfTargetAlreadyExists)) { wereThereErrors = true; std::stringstream decoratedErrorMessage; decoratedErrorMessage << "Windows failed to copy \"" << m_path_source << "\" to \"" << m_path_target << "\": " << errorMessage; eae6320::OutputErrorMessage(decoratedErrorMessage.str().c_str(), __FILE__); }*/ } return !wereThereErrors; }
int Pipeline::OnInitialize(const AppInitializeInfo& info) { if( PipelineBase::OnInitialize(info) != 0) return -1; if( LoadAsset(info) != 0 ) return -1; return 0; }
void USoundNodeModPlayer::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) { if (PropertyChangedEvent.Property && PropertyChangedEvent.Property->GetFName() == GET_MEMBER_NAME_CHECKED(USoundNodeModPlayer, SoundModAssetPtr)) { LoadAsset(); } }
bool eae6320::cMeshBuilder::Build( const std::vector<std::string>& ) { // Read from Lua Mesh file if (!LoadAsset(m_path_source)) { return false; } // Create and write to a Bin Mesh file if (!CreateBinaryMeshFile()) { return false; } // Deleting the pointers to the vertexData and indexData { delete[] m_vertexData; m_vertexData = NULL; delete[] m_indexData; m_indexData = NULL; } return true; }
MeshLoader::MeshLoader(const char* filename) { currentTime = 0; r_Skeleton = true; std::cout << "MeshLoader:: loading " << filename << std::endl; if (!LoadAsset(filename)) { std::cout << "Error loading file" << std::endl; }; std::cout << "MeshLoader:: finished " << std::endl; }
bool MeshRenderComponent::VInit(TiXmlElement* _pData) { Asset = WE_NEW ModelAsset(); LoadAsset(); Instance = WE_NEW ModelInstance(); Instance->asset = Asset; return true; }
AssetHandle AssetManager::GetAsset(std::string assetId) { int id = GetIdFromName(assetId); if (id == -1) { Asset* a = LoadAsset(assetId); if (!a) throw AssetException(AssetException::ASSETFAILEDTOLOAD); return a; } return GetAsset((unsigned)id); }
bool eae6320::cEffectBuilder::Build( const std::vector<std::string>& ) { // Read from Lua Effect file if (!LoadAsset(m_path_source)) { return false; } // Create and write to a Bin Effect file if (!CreateBinaryEffectFile()) { return false; } return true; }
bool AssetManager::UpdateAssets (const csArray<BaseAsset>& update) { // @@@ Removing assets is not yet supported. At least they will not get unloaded. // The assets table will be updated however. So a Save/Load will remove the asset. csRefArray<iAsset> newassets; // @@@ Remove the collection for removed assets! for (size_t i = 0 ; i < update.GetSize () ; i++) { const BaseAsset& a = update[i]; iAsset* currentAsset = HasAsset (a); if (currentAsset) { newassets.Push (currentAsset); } else { csString normpath = a.GetNormalizedPath (); csString file = a.GetFile (); csString mount = a.GetMountPoint (); csString colName; colName.Format ("__col__%d__", colCounter++); iCollection* collection = engine->CreateCollection (colName); if (!LoadAsset (normpath, file, mount, collection)) return false; RegisterModification (); csRef<IntAsset> asset; asset.AttachNew (new IntAsset (file, a.IsWritable ())); asset->SetMountPoint (mount); asset->SetNormalizedPath (normpath); asset->SetCollection (collection); newassets.Push (asset); } } assets = newassets; return true; }
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // Initialize comctl CoInitializeEx(NULL, COINIT_MULTITHREADED); static const wchar_t *class_name = L"ImGui Example"; // Create application window HINSTANCE instance = GetModuleHandle(NULL); HICON icon = LoadIcon(instance, MAKEINTRESOURCE(IDI_ICON1)); WNDCLASSEX wc = {sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, instance, icon, NULL, NULL, NULL, class_name, NULL}; RegisterClassEx(&wc); HWND hwnd = CreateWindow(class_name, _T("Open Board Viewer"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 1280, 800, NULL, NULL, wc.hInstance, NULL); // Initialize Direct3D LPDIRECT3D9 pD3D; if ((pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == NULL) { UnregisterClass(class_name, wc.hInstance); return 0; } ZeroMemory(&g_d3dpp, sizeof(g_d3dpp)); g_d3dpp.Windowed = TRUE; g_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; g_d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; g_d3dpp.EnableAutoDepthStencil = TRUE; g_d3dpp.AutoDepthStencilFormat = D3DFMT_D16; g_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE; // Create the D3DDevice if (pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &g_d3dpp, &g_pd3dDevice) < 0) { pD3D->Release(); UnregisterClass(class_name, wc.hInstance); return 0; } // Setup ImGui binding ImGui_ImplDX9_Init(hwnd, g_pd3dDevice); // Load Fonts // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt // for more details) ImGuiIO &io = ImGui::GetIO(); int ttf_size; unsigned char *ttf_data = LoadAsset(&ttf_size, ASSET_FIRA_SANS); ImFontConfig font_cfg{}; font_cfg.FontDataOwnedByAtlas = false; io.Fonts->AddFontFromMemoryTTF(ttf_data, ttf_size, 20.0f, &font_cfg); // io.Fonts->AddFontDefault(); // io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f); // io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f); // io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f); // io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f); // io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, // io.Fonts->GetGlyphRangesJapanese()); #if 0 // Get current flag int tmpFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); // Turn on leak-checking bit. tmpFlag |= _CRTDBG_CHECK_ALWAYS_DF; // Set flag to the new value. _CrtSetDbgFlag(tmpFlag); #endif BoardView app{}; bool show_test_window = true; bool show_another_window = false; ImVec4 clear_col = ImColor(20, 20, 30); // Main loop MSG msg; ZeroMemory(&msg, sizeof(msg)); ShowWindow(hwnd, SW_SHOWDEFAULT); UpdateWindow(hwnd); while (msg.message != WM_QUIT) { if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); continue; } ImGui_ImplDX9_NewFrame(); #if 0 // 1. Show a simple window // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window // automatically called "Debug" { static float f = 0.0f; ImGui::Text("Hello, world!"); ImGui::SliderFloat("float", &f, 0.0f, 1.0f); ImGui::ColorEdit3("clear color", (float *)&clear_col); if (ImGui::Button("Test Window")) show_test_window ^= 1; if (ImGui::Button("Another Window")) show_another_window ^= 1; ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); } // 2. Show another simple window, this time using an explicit Begin/End pair if (show_another_window) { ImGui::SetNextWindowSize(ImVec2(200, 100), ImGuiSetCond_FirstUseEver); ImGui::Begin("Another Window", &show_another_window); ImGui::Text("Hello"); ImGui::End(); } #endif #if 0 // 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow() if (show_test_window) { ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver); ImGui::ShowTestWindow(&show_test_window); } #endif app.Update(); if (app.m_wantsQuit) { PostMessage(hwnd, WM_QUIT, 0, 0); } // Rendering g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, false); g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, false); g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, false); D3DCOLOR clear_col_dx = D3DCOLOR_RGBA((int)(clear_col.x * 255.0f), (int)(clear_col.y * 255.0f), (int)(clear_col.z * 255.0f), (int)(clear_col.w * 255.0f)); g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, clear_col_dx, 1.0f, 0); if (g_pd3dDevice->BeginScene() >= 0) { ImGui::Render(); g_pd3dDevice->EndScene(); } g_pd3dDevice->Present(NULL, NULL, NULL, NULL); } ImGui_ImplDX9_Shutdown(); if (g_pd3dDevice) g_pd3dDevice->Release(); if (pD3D) pD3D->Release(); UnregisterClass(class_name, wc.hInstance); return 0; }
void USoundNodeAssetReferencer::PostEditImport() { Super::PostEditImport(); LoadAsset(); }
bool AssetManager::LoadDoc (iDocument* doc) { csRef<iDocumentNode> root = doc->GetRoot (); csRef<iDocumentNode> dynlevelNode = root->GetNode ("dynlevel"); csRef<iDocumentNodeIterator> it = dynlevelNode->GetNodes (); while (it->HasNext ()) { csRef<iDocumentNode> child = it->Next (); if (child->GetType () != CS_NODE_ELEMENT) continue; csString value = child->GetValue (); if (value == "asset") { csString normpath = child->GetAttributeValue ("path"); csString file = child->GetAttributeValue ("file"); csString mount = child->GetAttributeValue ("mount"); bool writable = child->GetAttributeValueAsBool ("writable"); csString colName; colName.Format ("__col__%d__", colCounter++); iCollection* collection = engine->CreateCollection (colName); LoadAsset (normpath, file, mount, collection); csRef<IntAsset> asset; asset.AttachNew (new IntAsset (file, writable)); asset->SetMountPoint (mount); asset->SetNormalizedPath (normpath); asset->SetCollection (collection); assets.Push (asset); } // Ignore the other tags. These are processed below. } csRef<iDocumentNode> metaNode = dynlevelNode->GetNode ("meta"); if (metaNode) { projectData->SetName (metaNode->GetAttributeValue ("name")); projectData->SetShortDescription (metaNode->GetAttributeValue ("short")); projectData->SetDescription (metaNode->GetAttributeValue ("description")); } csRef<iDocumentNode> curveNode = dynlevelNode->GetNode ("curves"); if (curveNode) { csRef<iString> error = curvedMeshCreator->Load (curveNode); if (error) return Error ("Error loading curves '%s'!", error->GetData ()); } for (size_t i = 0 ; i < curvedMeshCreator->GetCurvedFactoryCount () ; i++) { iCurvedFactory* cfact = curvedMeshCreator->GetCurvedFactory (i); iDynamicFactory* fact = dynworld->AddFactory (cfact->GetName (), 1.0, -1); csRef<iGeometryGenerator> ggen = scfQueryInterface<iGeometryGenerator> (cfact); if (ggen) fact->SetGeometryGenerator (ggen); fact->AddRigidMesh (csVector3 (0), 10.0); curvedFactories.Push (fact); } csRef<iDocumentNode> roomNode = dynlevelNode->GetNode ("rooms"); if (roomNode) { csRef<iString> error = roomMeshCreator->Load (roomNode); if (error) return Error ("Error loading rooms '%s'!", error->GetData ()); } for (size_t i = 0 ; i < roomMeshCreator->GetRoomFactoryCount () ; i++) { iRoomFactory* cfact = roomMeshCreator->GetRoomFactory (i); iDynamicFactory* fact = dynworld->AddFactory (cfact->GetName (), 1.0, -1); csRef<iGeometryGenerator> ggen = scfQueryInterface<iGeometryGenerator> (cfact); if (ggen) fact->SetGeometryGenerator (ggen); fact->AddRigidMesh (csVector3 (0), 10.0); roomFactories.Push (fact); } csRef<iDocumentNode> dynworldNode = dynlevelNode->GetNode ("dynworld"); if (dynworldNode) { csRef<iString> error = dynworld->Load (dynworldNode); if (error) return Error ("Error loading dynworld '%s'!", error->GetData ()); } csRef<iDocumentNode> locksNode = dynlevelNode->GetNode ("locks"); if (locksNode) { csRef<iQuestManager> questMgr = csQueryRegistry<iQuestManager> (object_reg); csRef<iCelPlLayer> pl = csQueryRegistry<iCelPlLayer> (object_reg); csRef<iDocumentNodeIterator> it = locksNode->GetNodes (); while (it->HasNext ()) { csRef<iDocumentNode> child = it->Next (); if (child->GetType () != CS_NODE_ELEMENT) continue; csString value = child->GetValue (); iObject* resource = 0; if (value == "template") { iCelEntityTemplate* tpl = pl->FindEntityTemplate (child->GetAttributeValue ("name")); if (tpl) resource = tpl->QueryObject (); } else if (value == "dynfact") { iDynamicFactory* df = dynworld->FindFactory (child->GetAttributeValue ("name")); if (df) resource = df->QueryObject (); } else if (value == "quest") { iQuestFactory* qf = questMgr->GetQuestFactory (child->GetAttributeValue ("name")); if (qf) resource = qf->QueryObject (); } else if (value == "lightfact") { iLightFactory* lf = engine->FindLightFactory (child->GetAttributeValue ("name")); if (lf) resource = lf->QueryObject (); } else return Error ("Unexpected token '%s'!", value.GetData ()); if (resource) { Lock (resource); } else { Warn ("Can't lock resource '%s' with type '%s'!", child->GetAttributeValue ("name"), value.GetData ()); } } } return true; }