//-------------------------------------------------------------------------------
// Entry point for the loader thread
// The loader thread loads the asset while the progress dialog displays the
// smart progress bar
//-------------------------------------------------------------------------------
DWORD WINAPI LoadThreadProc(LPVOID lpParameter) {
UNREFERENCED_PARAMETER(lpParameter);
// get current time
double fCur = (double)timeGetTime();
aiPropertyStore *props = aiCreatePropertyStore();
aiSetImportPropertyInteger(props, AI_CONFIG_IMPORT_TER_MAKE_UVS, 1);
aiSetImportPropertyFloat(props, AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE, g_smoothAngle);
aiSetImportPropertyInteger(props, AI_CONFIG_PP_SBP_REMOVE, nopointslines ? aiPrimitiveType_LINE | aiPrimitiveType_POINT : 0);
aiSetImportPropertyInteger(props, AI_CONFIG_GLOB_MEASURE_TIME, 1);
//aiSetImportPropertyInteger(props,AI_CONFIG_PP_PTV_KEEP_HIERARCHY,1);
// Call ASSIMPs C-API to load the file
g_pcAsset->pcScene = (aiScene *)aiImportFileExWithProperties(g_szFileName,
ppsteps | /* configurable pp steps */
aiProcess_GenSmoothNormals | // generate smooth normal vectors if not existing
aiProcess_SplitLargeMeshes | // split large, unrenderable meshes into submeshes
aiProcess_Triangulate | // triangulate polygons with more than 3 edges
aiProcess_ConvertToLeftHanded | // convert everything to D3D left handed space
aiProcess_SortByPType | // make 'clean' meshes which consist of a single typ of primitives
0,
nullptr,
props);
aiReleasePropertyStore(props);
// get the end time of zje operation, calculate delta t
double fEnd = (double)timeGetTime();
g_fLoadTime = (float)((fEnd - fCur) / 1000);
g_bLoadingFinished = true;
// check whether the loading process has failed ...
if (nullptr == g_pcAsset->pcScene) {
CLogDisplay::Instance().AddEntry("[ERROR] Unable to load this asset:",
D3DCOLOR_ARGB(0xFF, 0xFF, 0, 0));
// print ASSIMPs error string to the log display
CLogDisplay::Instance().AddEntry(aiGetErrorString(),
D3DCOLOR_ARGB(0xFF, 0xFF, 0, 0));
return 1;
}
return 0;
}
网友评论