MCPcopy Create free account
hub / github.com/assimp/assimp / LoadAsset

Function LoadAsset

tools/assimp_view/assimp_view.cpp:197–282  ·  view source on GitHub ↗

------------------------------------------------------------------------------- Load the current asset The path to the asset is specified in the global variable g_szFileName -------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

195// The path to the asset is specified in the global variable g_szFileName
196//-------------------------------------------------------------------------------
197int LoadAsset() {
198 // set the world and world rotation matrices to the identity
199 g_mWorldRotate = aiMatrix4x4();
200 g_mWorld = aiMatrix4x4();
201
202 // char szTemp[MAX_PATH+64];
203 // sprintf(szTemp,"Starting to load %s",g_szFileName);
204 CLogWindow::Instance().WriteLine(
205 "----------------------------------------------------------------------------");
206 // CLogWindow::Instance().WriteLine(szTemp);
207 // CLogWindow::Instance().WriteLine(
208 // "----------------------------------------------------------------------------");
209 CLogWindow::Instance().SetAutoUpdate(false);
210
211 // create a helper thread to load the asset
212 DWORD dwID;
213 g_bLoadingCanceled = false;
214 g_pcAsset = new AssetHelper();
215 g_hThreadHandle = CreateThread(nullptr, 0, &LoadThreadProc, nullptr, 0, &dwID);
216
217 if (!g_hThreadHandle) {
218 CLogDisplay::Instance().AddEntry(
219 "[ERROR] Unable to create helper thread for loading",
220 D3DCOLOR_ARGB(0xFF, 0xFF, 0, 0));
221 return 0;
222 }
223
224 // show the progress bar dialog
225 DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_LOADDIALOG),
226 g_hDlg, &ProgressMessageProc);
227
228 // update the log window
229 CLogWindow::Instance().SetAutoUpdate(true);
230 CLogWindow::Instance().Update();
231
232 // now we should have loaded the asset. Check this ...
233 g_bLoadingFinished = false;
234 if (!g_pcAsset || !g_pcAsset->pcScene) {
235 if (g_pcAsset) {
236 delete g_pcAsset;
237 g_pcAsset = nullptr;
238 }
239 return 0;
240 }
241
242 // allocate a new MeshHelper array and build a new instance
243 // for each mesh in the original asset
244 g_pcAsset->apcMeshes = new AssetHelper::MeshHelper *[g_pcAsset->pcScene->mNumMeshes]();
245 for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes; ++i)
246 g_pcAsset->apcMeshes[i] = new AssetHelper::MeshHelper();
247
248 // create animator
249 g_pcAsset->mAnimator = new SceneAnimator(g_pcAsset->pcScene);
250
251 // build a new caption string for the viewer
252 static const size_t Size = MAX_PATH + 10;
253 char szOut[Size];
254 ai_snprintf(szOut, Size, AI_VIEW_CAPTION_BASE " [%s]", g_szFileName);

Callers 3

HandleCommandLineFunction · 0.85
OpenAssetFunction · 0.85
MessageProcFunction · 0.85

Calls 14

aiMatrix4x4Class · 0.85
InstanceClass · 0.85
ai_snprintfFunction · 0.85
ScaleAssetFunction · 0.85
aiVector3DClass · 0.85
CreateAssetDataFunction · 0.85
WriteLineMethod · 0.80
SetAutoUpdateMethod · 0.80
FillDisplayListMethod · 0.80
FillAnimListMethod · 0.80
FillDefaultStatisticsMethod · 0.80
AddEntryMethod · 0.45

Tested by

no test coverage detected