From f5ef0788345d55e2b9c1e4ea7d09ac1f901e3026 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 4 Feb 2019 22:15:15 +0100 Subject: [PATCH] fix openfiledialog in modelviewer. --- tools/assimp_view/Display.cpp | 7 ++--- tools/assimp_view/Input.cpp | 2 +- tools/assimp_view/MessageProc.cpp | 50 +++++++++++++++++++++++++++---- tools/assimp_view/assimp_view.cpp | 25 +++++++--------- 4 files changed, 58 insertions(+), 26 deletions(-) diff --git a/tools/assimp_view/Display.cpp b/tools/assimp_view/Display.cpp index 196e8a2ac..ab29c1d3e 100644 --- a/tools/assimp_view/Display.cpp +++ b/tools/assimp_view/Display.cpp @@ -102,17 +102,16 @@ void GetNodeCount(aiNode* pcNode, unsigned int* piCnt) } //------------------------------------------------------------------------------- -int CDisplay::EnableAnimTools(BOOL hm) -{ +int CDisplay::EnableAnimTools(BOOL hm) { EnableWindow(GetDlgItem(g_hDlg,IDC_PLAY),hm); EnableWindow(GetDlgItem(g_hDlg,IDC_SLIDERANIM),hm); + return 1; } //------------------------------------------------------------------------------- // Fill animation combo box -int CDisplay::FillAnimList(void) -{ +int CDisplay::FillAnimList(void) { if (0 != g_pcAsset->pcScene->mNumAnimations) { // now fill in all animation names diff --git a/tools/assimp_view/Input.cpp b/tools/assimp_view/Input.cpp index 56007bdf1..88e04b437 100644 --- a/tools/assimp_view/Input.cpp +++ b/tools/assimp_view/Input.cpp @@ -194,7 +194,7 @@ void HandleMouseInputSkyBox( void ) //------------------------------------------------------------------------------- //------------------------------------------------------------------------------- -void HandleMouseInputLightIntensityAndColor( void ) +void HandleMouseInputLightIntensityAndColor() { POINT mousePos; GetCursorPos( &mousePos ); diff --git a/tools/assimp_view/MessageProc.cpp b/tools/assimp_view/MessageProc.cpp index 823edc643..8afecd602 100644 --- a/tools/assimp_view/MessageProc.cpp +++ b/tools/assimp_view/MessageProc.cpp @@ -333,8 +333,7 @@ void ToggleWireFrame() { //------------------------------------------------------------------------------- // Toggle the "MultiSample" state //------------------------------------------------------------------------------- -void ToggleMS() -{ +void ToggleMS() { g_sOptions.bMultiSample = !g_sOptions.bMultiSample; DeleteAssetData(); ShutdownDevice(); @@ -389,7 +388,7 @@ void ToggleUIState() { } //------------------------------------------------------------------------------- -// Load the background texture for the cviewer +// Load the background texture for the viewer //------------------------------------------------------------------------------- void LoadBGTexture() { char szFileName[MAX_PATH]; @@ -853,14 +852,53 @@ void OpenAsset() { strcpy(szCur,"*.*"); szCur[4] = 0; - OPENFILENAME sFilename1 = { + /*DWORD lStructSize; + HWND hwndOwner; + HINSTANCE hInstance; + LPCWSTR lpstrFilter; + LPWSTR lpstrCustomFilter; + DWORD nMaxCustFilter; + DWORD nFilterIndex; + LPWSTR lpstrFile; + DWORD nMaxFile; + LPWSTR lpstrFileTitle; + DWORD nMaxFileTitle; + LPCWSTR lpstrInitialDir; + LPCWSTR lpstrTitle; + DWORD Flags; + WORD nFileOffset; + WORD nFileExtension; + LPCWSTR lpstrDefExt; + LPARAM lCustData; + LPOFNHOOKPROC lpfnHook; + LPCWSTR lpTemplateName; +#ifdef _MAC + LPEDITMENU lpEditInfo; + LPCSTR lpstrPrompt;*/ + + + OPENFILENAME sFilename1; + ZeroMemory(&sFilename1, sizeof(sFilename1)); + sFilename1.lStructSize = sizeof(sFilename1); + sFilename1.hwndOwner = g_hDlg; + sFilename1.hInstance = GetModuleHandle(NULL); + sFilename1.lpstrFile = szFileName; + sFilename1.lpstrFile[0] = '\0'; + sFilename1.nMaxFile = sizeof(szList); + sFilename1.lpstrFilter = szList; + sFilename1.nFilterIndex = 1; + sFilename1.lpstrFileTitle = NULL; + sFilename1.nMaxFileTitle = 0; + sFilename1.lpstrInitialDir = NULL; + sFilename1.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR; + /*OPENFILENAME sFilename1 = { sizeof(OPENFILENAME), - g_hDlg,GetModuleHandle(NULL), szList, NULL, 0, 1, + g_hDlg, GetModuleHandle(NULL), szList, NULL, 0, 1, szFileName, MAX_PATH, NULL, 0, NULL, "Import Asset into ASSIMP", OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR, 0, 1, ".x", 0, NULL, NULL - }; + };*/ if (GetOpenFileName(&sFilename1) == 0) { return; } diff --git a/tools/assimp_view/assimp_view.cpp b/tools/assimp_view/assimp_view.cpp index d96e5ac97..355287e0d 100644 --- a/tools/assimp_view/assimp_view.cpp +++ b/tools/assimp_view/assimp_view.cpp @@ -47,9 +47,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #ifdef __MINGW32__ -#include +# include #else -#include +# include #endif using namespace std; @@ -310,9 +310,10 @@ int LoadAsset() // Delete the loaded asset // The function does nothing is no asset is loaded //------------------------------------------------------------------------------- -int DeleteAsset(void) -{ - if (!g_pcAsset)return 0; +int DeleteAsset(void) { + if (!g_pcAsset) { + return 0; + } // don't anymore know why this was necessary ... CDisplay::Instance().OnRender(); @@ -349,9 +350,7 @@ int DeleteAsset(void) // p_avOut Receives the min/max boundaries. Must point to 2 vec3s // piMatrix Transformation matrix of the graph at this position //------------------------------------------------------------------------------- -int CalculateBounds(aiNode* piNode, aiVector3D* p_avOut, - const aiMatrix4x4& piMatrix) -{ +int CalculateBounds(aiNode* piNode, aiVector3D* p_avOut, const aiMatrix4x4& piMatrix) { ai_assert(NULL != piNode); ai_assert(NULL != p_avOut); @@ -739,7 +738,7 @@ int DeleteAssetData(bool bNoMaterials) //------------------------------------------------------------------------------- -// Switch beetween zoom/rotate view and the standatd FPS view +// Switch between zoom/rotate view and the standard FPS view // g_bFPSView specifies the view mode to setup //------------------------------------------------------------------------------- int SetupFPSView() @@ -982,7 +981,7 @@ int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/) sParams.MultiSampleType = sMSOut; } - // preget the device capabilities. If the hardware vertex shader is too old, we prefer software vertex processing + // get the device capabilities. If the hardware vertex shader is too old, we prefer software vertex processing g_piD3D->GetDeviceCaps( 0, D3DDEVTYPE_HAL, &g_sCaps); DWORD creationFlags = D3DCREATE_MULTITHREADED; if( g_sCaps.VertexShaderVersion >= D3DVS_VERSION( 2, 0)) @@ -1099,17 +1098,13 @@ int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/) return 1; } - //------------------------------------------------------------------------------- -//------------------------------------------------------------------------------- -int CreateDevice (void) +int CreateDevice() { return CreateDevice(g_sOptions.bMultiSample, g_sOptions.bSuperSample); } - -//------------------------------------------------------------------------------- //------------------------------------------------------------------------------- int GetProjectionMatrix (aiMatrix4x4& p_mOut) {