From 3a3ac4fea27c20b99eea814e65c25321f6b031cd Mon Sep 17 00:00:00 2001 From: Hiroyuki Inoue Date: Tue, 12 Nov 2013 23:25:40 +0900 Subject: [PATCH 01/17] Fix to support FBX 2011 (7100) --- code/FBXDocument.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/FBXDocument.cpp b/code/FBXDocument.cpp index 5dab5bd0c..cff52e542 100644 --- a/code/FBXDocument.cpp +++ b/code/FBXDocument.cpp @@ -292,16 +292,16 @@ void Document::ReadHeader() // while we maye have some success with newer files, we don't support // the older 6.n fbx format - if(fbxVersion < 7200) { - DOMError("unsupported, old format version, supported are only FBX 2012 and FBX 2013"); + if(fbxVersion < 7100) { + DOMError("unsupported, old format version, supported are only FBX 2011, FBX 2012 and FBX 2013"); } if(fbxVersion > 7300) { if(Settings().strictMode) { - DOMError("unsupported, newer format version, supported are only FBX 2012 and FBX 2013" + DOMError("unsupported, newer format version, supported are only FBX 2011, FBX 2012 and FBX 2013" " (turn off strict mode to try anyhow) "); } else { - DOMWarning("unsupported, newer format version, supported are only FBX 2012 and FBX 2013," + DOMWarning("unsupported, newer format version, supported are only FBX 2011, FBX 2012 and FBX 2013," " trying to read it nevertheless"); } } From f1e43f560ab7685d7878dbaf316e16a55710fa92 Mon Sep 17 00:00:00 2001 From: Michael Dawson-Haggerty Date: Tue, 12 Nov 2013 22:06:42 -0500 Subject: [PATCH 02/17] added additional search paths for dll on windows --- port/PyAssimp/pyassimp/helper.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/port/PyAssimp/pyassimp/helper.py b/port/PyAssimp/pyassimp/helper.py index 2e1b41954..1cff1b0c8 100644 --- a/port/PyAssimp/pyassimp/helper.py +++ b/port/PyAssimp/pyassimp/helper.py @@ -30,7 +30,11 @@ if os.name=='posix': elif os.name=='nt': ext_whitelist.append('.dll') - + path_dirs = os.environ['PATH'].split(';') + for dir_candidate in path_dirs: + if 'assimp' in dir_candidate.lower(): + additional_dirs.append(dir_candidate) + #print(additional_dirs) def vec2tuple(x): """ Converts a VECTOR3D to a Tuple """ From f2997a562b1d858a1233fe0e1ba46a11de0ea0ac Mon Sep 17 00:00:00 2001 From: Eric Haines Date: Thu, 14 Nov 2013 10:09:10 -0800 Subject: [PATCH 03/17] typo fix: loose -> lose --- code/MS3DLoader.cpp | 2 +- doc/dox.h | 2 +- samples/glut/README-win32.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/code/MS3DLoader.cpp b/code/MS3DLoader.cpp index f24aa1382..455446bce 100644 --- a/code/MS3DLoader.cpp +++ b/code/MS3DLoader.cpp @@ -563,7 +563,7 @@ void MS3DImporter::InternReadFile( const std::string& pFile, } // ... add dummy nodes under a single root, each holding a reference to one - // mesh. If we didn't do this, we'd loose the group name. + // mesh. If we didn't do this, we'd lose the group name. aiNode* rt = pScene->mRootNode = new aiNode(""); #ifdef ASSIMP_BUILD_MS3D_ONE_NODE_PER_MESH diff --git a/doc/dox.h b/doc/dox.h index 4a128ceb1..fb5866c2c 100644 --- a/doc/dox.h +++ b/doc/dox.h @@ -191,7 +191,7 @@ can use a comfortable installer from . It consists of very small -implementations of the various boost utility classes used. However, you'll loose functionality (e.g. threading) by doing this. +implementations of the various boost utility classes used. However, you'll lose functionality (e.g. threading) by doing this. So, if you can use boost, you should use boost. Otherwise, See the @link use_noboost NoBoost-Section @endlink later on this page for the details of the workaround. diff --git a/samples/glut/README-win32.txt b/samples/glut/README-win32.txt index 67c8d413e..5e22e9789 100644 --- a/samples/glut/README-win32.txt +++ b/samples/glut/README-win32.txt @@ -139,7 +139,7 @@ IMPLEMENTATION DEPENDENT DIFFERENCES: Specifically, the "window manager" in Win32 uses a "click to focus" policy. That is, in order for a window to receive focus, a mouse button must be clicked in it. Likewise, in - order for a window to loose focus, a mouse button must be + order for a window to lose focus, a mouse button must be clicked outside the window (or in another window). Therefore, the Enter and Leave notification provided by GLUT may behave differently in the Win32 and in X11 versions. From 93fd1133ffb3ceee960f4692b59a41bc52021397 Mon Sep 17 00:00:00 2001 From: Marcel Metz Date: Wed, 20 Nov 2013 14:40:20 +0100 Subject: [PATCH 04/17] Fixed mingw cross compiler issues. --- CMakeLists.txt | 2 +- include/assimp/types.h | 1 + tools/assimp_view/CMakeLists.txt | 9 ++++++--- tools/assimp_view/HelpDialog.cpp | 2 +- tools/assimp_view/LogWindow.cpp | 2 +- tools/assimp_view/MessageProc.cpp | 2 +- tools/assimp_view/stdafx.h | 4 ++-- 7 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 98fb8c62d..b0f6b88af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ set(LIBASSIMP-DEV_COMPONENT "libassimp${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_M set(CPACK_COMPONENTS_ALL assimp-bin ${LIBASSIMP_COMPONENT} ${LIBASSIMP-DEV_COMPONENT} assimp-dev) set(ASSIMP_LIBRARY_SUFFIX "" CACHE STRING "Suffix to append to library names") -if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) +if( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX AND NOT MINGW ) add_definitions(-fPIC) # this is a very important switch and some libraries seem now to have it.... # hide all not-exported symbols add_definitions( -fvisibility=hidden -Wall ) diff --git a/include/assimp/types.h b/include/assimp/types.h index 22ca7abdc..604591402 100644 --- a/include/assimp/types.h +++ b/include/assimp/types.h @@ -50,6 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include // Our compile configuration diff --git a/tools/assimp_view/CMakeLists.txt b/tools/assimp_view/CMakeLists.txt index 655a38571..ebca500b3 100644 --- a/tools/assimp_view/CMakeLists.txt +++ b/tools/assimp_view/CMakeLists.txt @@ -43,8 +43,11 @@ ADD_EXECUTABLE( assimp_viewer WIN32 SET_PROPERTY(TARGET assimp_viewer PROPERTY DEBUG_POSTFIX ${ASSIMP_DEBUG_POSTFIX}) -ADD_DEFINITIONS( -D_SCL_SECURE_NO_WARNINGS ) -ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS ) + +IF ( MSVC ) + ADD_DEFINITIONS( -D_SCL_SECURE_NO_WARNINGS ) + ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS ) +ENDIF ( MSVC ) # @@ -54,7 +57,7 @@ ADD_CUSTOM_COMMAND(TARGET assimp_viewer MAIN_DEPENDENCY assimp) # Link the executable to the assimp + dx libs. -TARGET_LINK_LIBRARIES ( assimp_viewer assimp ${DirectX_LIBRARY} ${DirectX_D3DX9_LIBRARY} comctl32.lib Winmm.lib ) +TARGET_LINK_LIBRARIES ( assimp_viewer assimp ${DirectX_LIBRARY} ${DirectX_D3DX9_LIBRARY} comctl32.lib winmm.lib ) INSTALL( TARGETS assimp_viewer DESTINATION "${ASSIMP_BIN_INSTALL_DIR}" COMPONENT assimp-dev diff --git a/tools/assimp_view/HelpDialog.cpp b/tools/assimp_view/HelpDialog.cpp index a7e700ab8..7e0e5ddfe 100644 --- a/tools/assimp_view/HelpDialog.cpp +++ b/tools/assimp_view/HelpDialog.cpp @@ -42,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "stdafx.h" #include "assimp_view.h" -#include "RICHEDIT.H" +#include "richedit.h" namespace AssimpView { diff --git a/tools/assimp_view/LogWindow.cpp b/tools/assimp_view/LogWindow.cpp index ad6b235cd..c073028eb 100644 --- a/tools/assimp_view/LogWindow.cpp +++ b/tools/assimp_view/LogWindow.cpp @@ -41,7 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "stdafx.h" #include "assimp_view.h" -#include "RichEdit.h" +#include "richedit.h" namespace AssimpView { diff --git a/tools/assimp_view/MessageProc.cpp b/tools/assimp_view/MessageProc.cpp index 44d38568d..54976f2b3 100644 --- a/tools/assimp_view/MessageProc.cpp +++ b/tools/assimp_view/MessageProc.cpp @@ -41,7 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "stdafx.h" #include "assimp_view.h" -#include +#include namespace AssimpView { diff --git a/tools/assimp_view/stdafx.h b/tools/assimp_view/stdafx.h index c6d14ceb4..0fda71111 100644 --- a/tools/assimp_view/stdafx.h +++ b/tools/assimp_view/stdafx.h @@ -44,14 +44,14 @@ #include #include -#include +#include // ShellExecute() #include #include // GetOpenFileName() -#include +#include #include #include From 07ab616644710a431d757cf10503466d4ab1df2c Mon Sep 17 00:00:00 2001 From: Marcel Metz Date: Sun, 11 Mar 2012 22:08:47 +0100 Subject: [PATCH 05/17] Fixed building simple opengl texture example with mingw. --- samples/SimpleTexturedOpenGL/CMakeLists.txt | 2 -- .../SimpleTexturedOpenGL/src/model_loading.cpp | 10 +++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/samples/SimpleTexturedOpenGL/CMakeLists.txt b/samples/SimpleTexturedOpenGL/CMakeLists.txt index 33edd38ce..083e22e6e 100644 --- a/samples/SimpleTexturedOpenGL/CMakeLists.txt +++ b/samples/SimpleTexturedOpenGL/CMakeLists.txt @@ -22,8 +22,6 @@ INCLUDE_DIRECTORIES( LINK_DIRECTORIES( ${Assimp_BINARY_DIR} ${Assimp_BINARY_DIR}/lib/ - ${Assimp_SOURCE_DIR}/samples/glut/ - ${Assimp_SOURCE_DIR}/samples/DevIL/lib/ ) ADD_EXECUTABLE( assimp_simpletexturedogl WIN32 diff --git a/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp b/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp index 42f468ea1..e0d0a629c 100644 --- a/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp +++ b/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp @@ -17,9 +17,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include @@ -30,8 +30,8 @@ // assimp include files. These three are usually needed. #include "assimp/Importer.hpp" //OO version Header! -#include "assimp/PostProcess.h" -#include "assimp/Scene.h" +#include "assimp/postprocess.h" +#include "assimp/scene.h" #include "assimp/DefaultLogger.hpp" #include "assimp/LogStream.hpp" From c1b28ff1ce6164cf7063fdae6b0ef7a54d72cee1 Mon Sep 17 00:00:00 2001 From: Marcel Metz Date: Mon, 12 Mar 2012 15:47:48 +0100 Subject: [PATCH 06/17] Removed unreferenced variables. --- .../SimpleTexturedOpenGL/src/model_loading.cpp | 1 - tools/assimp_view/Display.cpp | 4 ---- 2 files changed, 5 deletions(-) diff --git a/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp b/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp index e0d0a629c..253387509 100644 --- a/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp +++ b/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp @@ -177,7 +177,6 @@ int LoadGLTextures(const aiScene* scene) /* Before calling ilInit() version should be checked. */ if (ilGetInteger(IL_VERSION_NUM) < IL_VERSION) { - ILint test = ilGetInteger(IL_VERSION_NUM); /// wrong DevIL version /// std::string err_msg = "Wrong DevIL version. Old devil.dll in system32/SysWow64?"; char* cErr_msg = (char *) err_msg.c_str(); diff --git a/tools/assimp_view/Display.cpp b/tools/assimp_view/Display.cpp index 98ca794ec..380d7b2fb 100644 --- a/tools/assimp_view/Display.cpp +++ b/tools/assimp_view/Display.cpp @@ -287,10 +287,6 @@ int CDisplay::ReplaceCurrentTexture(const char* szPath) TreeView_SetItem(GetDlgItem(g_hDlg,IDC_TREE1), m_pcCurrentTexture->hTreeItem); - // change this in the old aiMaterial structure, too - aiMaterial* pcMat = (aiMaterial*) - g_pcAsset->pcScene->mMaterials[m_pcCurrentTexture->iMatIndex]; - // update all meshes referencing this material for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i) { From 846a8959f8ecd160b94ad42a02cbda2e2422f80f Mon Sep 17 00:00:00 2001 From: Marcel Metz Date: Mon, 12 Mar 2012 15:49:11 +0100 Subject: [PATCH 07/17] Fixed class attribute initialization order. --- tools/assimp_view/AssetHelper.h | 11 ++++++----- tools/assimp_view/Background.h | 6 +++--- tools/assimp_view/Camera.h | 2 +- tools/assimp_view/RenderOptions.h | 6 +++--- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/tools/assimp_view/AssetHelper.h b/tools/assimp_view/AssetHelper.h index 10ebf9eea..837cf3aab 100644 --- a/tools/assimp_view/AssetHelper.h +++ b/tools/assimp_view/AssetHelper.h @@ -139,19 +139,20 @@ class AssetHelper : piVB (NULL), piIB (NULL), - piEffect (NULL), piVBNormals (NULL), + piEffect (NULL), + bSharedFX (false), piDiffuseTexture (NULL), piSpecularTexture (NULL), piAmbientTexture (NULL), - piNormalTexture (NULL), piEmissiveTexture (NULL), + piNormalTexture (NULL), piOpacityTexture (NULL), piShininessTexture (NULL), piLightmapTexture (NULL), - pvOriginalNormals (NULL), - bSharedFX(false), - twosided (false){} + twosided (false), + pvOriginalNormals (NULL) + {} ~MeshHelper () { diff --git a/tools/assimp_view/Background.h b/tools/assimp_view/Background.h index 54c5de0b3..9908babf3 100644 --- a/tools/assimp_view/Background.h +++ b/tools/assimp_view/Background.h @@ -47,10 +47,10 @@ class CBackgroundPainter { CBackgroundPainter() : - pcTexture(NULL), clrColor(D3DCOLOR_ARGB(0xFF,100,100,100)), - eMode(SIMPLE_COLOR), - piSkyBoxEffect(NULL) + pcTexture(NULL), + piSkyBoxEffect(NULL), + eMode(SIMPLE_COLOR) {} public: diff --git a/tools/assimp_view/Camera.h b/tools/assimp_view/Camera.h index 020b7602f..264ab19cb 100644 --- a/tools/assimp_view/Camera.h +++ b/tools/assimp_view/Camera.h @@ -55,8 +55,8 @@ class Camera : vPos(0.0f,0.0f,-10.0f), - vLookAt(0.0f,0.0f,1.0f), vUp(0.0f,1.0f,0.0f), + vLookAt(0.0f,0.0f,1.0f), vRight(0.0f,1.0f,0.0f) { diff --git a/tools/assimp_view/RenderOptions.h b/tools/assimp_view/RenderOptions.h index 558de66fb..863064d72 100644 --- a/tools/assimp_view/RenderOptions.h +++ b/tools/assimp_view/RenderOptions.h @@ -60,16 +60,16 @@ class RenderOptions bSuperSample (false), bRenderMats (true), bRenderNormals (false), - eDrawMode (NORMAL), b3Lights (false), bLightRotate (false), bRotate (true), bLowQuality (false), bNoSpecular (false), bStereoView (false), + bNoAlphaBlending(false), + eDrawMode (NORMAL), bCulling (false), - bSkeleton (false), - bNoAlphaBlending(false) + bSkeleton (false) {} From c6297ec333e0eb926d6fbcee5d5ca3f2023a715e Mon Sep 17 00:00:00 2001 From: Marcel Metz Date: Mon, 12 Mar 2012 15:50:49 +0100 Subject: [PATCH 08/17] Fixed variable assignment values. --- tools/assimp_view/Display.cpp | 4 ++-- tools/assimp_view/MeshRenderer.cpp | 2 +- tools/assimp_view/MessageProc.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/assimp_view/Display.cpp b/tools/assimp_view/Display.cpp index 380d7b2fb..9927fbe58 100644 --- a/tools/assimp_view/Display.cpp +++ b/tools/assimp_view/Display.cpp @@ -1183,7 +1183,7 @@ int CDisplay::HandleTreeViewPopup(WPARAM wParam,LPARAM lParam) { // get the current selected material std::vector apclrOut; - const char* szMatKey; + const char* szMatKey = ""; switch (LOWORD(wParam)) { @@ -1251,7 +1251,7 @@ int CDisplay::HandleTreeViewPopup(WPARAM wParam,LPARAM lParam) clr.lpCustColors = g_aclCustomColors; clr.lpfnHook = NULL; clr.lpTemplateName = NULL; - clr.lCustData = NULL; + clr.lCustData = 0; ChooseColor(&clr); diff --git a/tools/assimp_view/MeshRenderer.cpp b/tools/assimp_view/MeshRenderer.cpp index c835f9b0f..d17bd2f8d 100644 --- a/tools/assimp_view/MeshRenderer.cpp +++ b/tools/assimp_view/MeshRenderer.cpp @@ -61,7 +61,7 @@ int CMeshRenderer::DrawUnsorted(unsigned int iIndex) g_piDevice->SetIndices(g_pcAsset->apcMeshes[iIndex]->piIB); - D3DPRIMITIVETYPE type; + D3DPRIMITIVETYPE type = D3DPT_POINTLIST; switch (g_pcAsset->pcScene->mMeshes[iIndex]->mPrimitiveTypes) { case aiPrimitiveType_POINT: type = D3DPT_POINTLIST;break; diff --git a/tools/assimp_view/MessageProc.cpp b/tools/assimp_view/MessageProc.cpp index 54976f2b3..14bf0a446 100644 --- a/tools/assimp_view/MessageProc.cpp +++ b/tools/assimp_view/MessageProc.cpp @@ -522,7 +522,7 @@ void DisplayColorDialog(D3DCOLOR* pclrResult) clr.lpCustColors = g_aclCustomColors; clr.lpfnHook = NULL; clr.lpTemplateName = NULL; - clr.lCustData = NULL; + clr.lCustData = 0; ChooseColor(&clr); @@ -549,7 +549,7 @@ void DisplayColorDialog(D3DXVECTOR4* pclrResult) clr.lpCustColors = g_aclCustomColors; clr.lpfnHook = NULL; clr.lpTemplateName = NULL; - clr.lCustData = NULL; + clr.lCustData = 0; ChooseColor(&clr); From c3852c474344228ebe1170f8dfe12458b586dca4 Mon Sep 17 00:00:00 2001 From: Marcel Metz Date: Wed, 20 Nov 2013 14:42:18 +0100 Subject: [PATCH 09/17] Removed noops and warnings on unused variables. --- tools/assimp_view/HelpDialog.cpp | 3 +-- tools/assimp_view/LogWindow.cpp | 2 +- tools/assimp_view/assimp_view.cpp | 4 ---- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/tools/assimp_view/HelpDialog.cpp b/tools/assimp_view/HelpDialog.cpp index 7e0e5ddfe..3fb09f0c1 100644 --- a/tools/assimp_view/HelpDialog.cpp +++ b/tools/assimp_view/HelpDialog.cpp @@ -53,7 +53,7 @@ namespace AssimpView { INT_PTR CALLBACK HelpDialogProc(HWND hwndDlg,UINT uMsg, WPARAM wParam,LPARAM lParam) { - lParam; + (void)lParam; switch (uMsg) { case WM_INITDIALOG: @@ -70,7 +70,6 @@ INT_PTR CALLBACK HelpDialogProc(HWND hwndDlg,UINT uMsg, SendDlgItemMessage(hwndDlg,IDC_RICHEDIT21, EM_SETTEXTEX,(WPARAM)&sInfo,( LPARAM) pData); - UnlockResource(hg); FreeResource(hg); return TRUE; } diff --git a/tools/assimp_view/LogWindow.cpp b/tools/assimp_view/LogWindow.cpp index c073028eb..7fd4a6179 100644 --- a/tools/assimp_view/LogWindow.cpp +++ b/tools/assimp_view/LogWindow.cpp @@ -70,7 +70,7 @@ static const char* AI_VIEW_RTF_LOG_HEADER = INT_PTR CALLBACK LogDialogProc(HWND hwndDlg,UINT uMsg, WPARAM wParam,LPARAM lParam) { - lParam; + (void)lParam; switch (uMsg) { case WM_INITDIALOG: diff --git a/tools/assimp_view/assimp_view.cpp b/tools/assimp_view/assimp_view.cpp index 5af9cf547..27bc8083a 100644 --- a/tools/assimp_view/assimp_view.cpp +++ b/tools/assimp_view/assimp_view.cpp @@ -872,12 +872,10 @@ int CreateHUDTexture() g_pcTexture = NULL; g_szImageMask = NULL; - UnlockResource(hg); FreeResource(hg); return 0; } - UnlockResource(hg); FreeResource(hg); D3DSURFACE_DESC sDesc; @@ -909,12 +907,10 @@ int CreateHUDTexture() D3DCOLOR_ARGB(0xFF,0xFF,0,0)); g_szImageMask = NULL; - UnlockResource(hg); FreeResource(hg); return 0; } - UnlockResource(hg); FreeResource(hg); // lock the texture and copy it to get a pointer From 9e579324d09e519da5639d31545d588b7b127154 Mon Sep 17 00:00:00 2001 From: Marcel Metz Date: Mon, 12 Mar 2012 15:53:28 +0100 Subject: [PATCH 10/17] Added conditions for compiler oder build mode dependend code. --- tools/assimp_view/stdafx.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tools/assimp_view/stdafx.h b/tools/assimp_view/stdafx.h index 0fda71111..f60fe0069 100644 --- a/tools/assimp_view/stdafx.h +++ b/tools/assimp_view/stdafx.h @@ -60,13 +60,15 @@ #include #include +#if defined _MSC_VER // Windows CommonControls 6.0 Manifest Extensions -#if defined _M_IX86 -# pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_IA64 -# pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -# pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -# pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +# if defined _M_IX86 +# pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") +# elif defined _M_IA64 +# pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") +# elif defined _M_X64 +# pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") +# else +# pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +# endif #endif From 8d0b76a5359f5cc3d3a91b97aadf5d82d79e495e Mon Sep 17 00:00:00 2001 From: Marcel Metz Date: Mon, 12 Mar 2012 16:04:08 +0100 Subject: [PATCH 11/17] Added parenthesis for explicit operator evaluation priority. --- tools/assimp_view/Material.cpp | 2 +- tools/assimp_view/MessageProc.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/assimp_view/Material.cpp b/tools/assimp_view/Material.cpp index 3abef7b15..6f9aac341 100644 --- a/tools/assimp_view/Material.cpp +++ b/tools/assimp_view/Material.cpp @@ -299,7 +299,7 @@ int CMaterialManager::FindValidPath(aiString* p_szString) if( !q ) q=strrchr( tmp2,'\\' ); if( q ){ strcpy( q+1,p+1 ); - if(pFile=fopen( tmp2,"r" ) ){ + if((pFile=fopen( tmp2,"r" ))){ fclose( pFile ); strcpy(p_szString->data,tmp2); p_szString->length = strlen(tmp2); diff --git a/tools/assimp_view/MessageProc.cpp b/tools/assimp_view/MessageProc.cpp index 14bf0a446..e4ecd0448 100644 --- a/tools/assimp_view/MessageProc.cpp +++ b/tools/assimp_view/MessageProc.cpp @@ -99,7 +99,7 @@ void MakeFileAssociations() RegSetValueEx(g_hRegistry,"",0,REG_SZ,(const BYTE*)"ASSIMPVIEW_CLASS",(DWORD)strlen("ASSIMPVIEW_CLASS")+1); RegCloseKey(g_hRegistry); } - while (sz = strtok(NULL,";")); + while ((sz = strtok(NULL,";"))); RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\ASSIMPVIEW_CLASS",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &g_hRegistry,NULL); RegCloseKey(g_hRegistry); From c4d797ef58464e9ac994af12b06eda9e5dfc1fc6 Mon Sep 17 00:00:00 2001 From: Marcel Metz Date: Mon, 12 Mar 2012 16:04:56 +0100 Subject: [PATCH 12/17] Replaced function parameters with correct literals. --- tools/assimp_view/MessageProc.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/assimp_view/MessageProc.cpp b/tools/assimp_view/MessageProc.cpp index e4ecd0448..26753f846 100644 --- a/tools/assimp_view/MessageProc.cpp +++ b/tools/assimp_view/MessageProc.cpp @@ -95,16 +95,16 @@ void MakeFileAssociations() ai_assert(sz[0] == '*'); sprintf(buf,"Software\\Classes\\%s",sz+1); - RegCreateKeyEx(HKEY_CURRENT_USER,buf,NULL,NULL,0,KEY_ALL_ACCESS, NULL, &g_hRegistry,NULL); + RegCreateKeyEx(HKEY_CURRENT_USER,buf,0,NULL,0,KEY_ALL_ACCESS, NULL, &g_hRegistry,NULL); RegSetValueEx(g_hRegistry,"",0,REG_SZ,(const BYTE*)"ASSIMPVIEW_CLASS",(DWORD)strlen("ASSIMPVIEW_CLASS")+1); RegCloseKey(g_hRegistry); } while ((sz = strtok(NULL,";"))); - RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\ASSIMPVIEW_CLASS",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &g_hRegistry,NULL); + RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\ASSIMPVIEW_CLASS",0,NULL,0,KEY_ALL_ACCESS, NULL, &g_hRegistry,NULL); RegCloseKey(g_hRegistry); - RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\ASSIMPVIEW_CLASS\\shell\\open\\command",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &g_hRegistry,NULL); + RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\ASSIMPVIEW_CLASS\\shell\\open\\command",0,NULL,0,KEY_ALL_ACCESS, NULL, &g_hRegistry,NULL); RegSetValueEx(g_hRegistry,"",0,REG_SZ,(const BYTE*)szTemp,(DWORD)strlen(szTemp)+1); RegCloseKey(g_hRegistry); @@ -1120,7 +1120,7 @@ void InitUI() // store the key in a global variable for later use RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\ASSIMP\\Viewer", - NULL,NULL,0,KEY_ALL_ACCESS, NULL, &g_hRegistry,NULL); + 0,NULL,0,KEY_ALL_ACCESS, NULL, &g_hRegistry,NULL); if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"LastUIState",NULL,NULL, (BYTE*)&dwValue,&dwTemp)) @@ -2411,7 +2411,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, }; DWORD dwTemp = MAX_PATH; RegCreateKeyEx(HKEY_CURRENT_USER, - "Software\\ASSIMP\\Viewer",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &g_hRegistry,NULL); + "Software\\ASSIMP\\Viewer",0,NULL,0,KEY_ALL_ACCESS, NULL, &g_hRegistry,NULL); if(ERROR_SUCCESS == RegQueryValueEx(g_hRegistry,"LastSkyBoxSrc",NULL,NULL, (BYTE*)szFileName,&dwTemp) && '\0' != szFileName[0]) { From 6b5b3c64e65088adfa03185d12a0553fca3688e9 Mon Sep 17 00:00:00 2001 From: Marcel Metz Date: Mon, 12 Mar 2012 16:06:00 +0100 Subject: [PATCH 13/17] Removed invalid extern keyword. --- tools/assimp_view/assimp_view.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/assimp_view/assimp_view.cpp b/tools/assimp_view/assimp_view.cpp index 27bc8083a..f3c261e92 100644 --- a/tools/assimp_view/assimp_view.cpp +++ b/tools/assimp_view/assimp_view.cpp @@ -106,7 +106,7 @@ aiVector3D g_vRotateSpeed = aiVector3D(0.5f,0.5f,0.5f); aiVector3D g_avLightDirs[1] = { aiVector3D(-0.5f,0.6f,0.2f) }; -extern D3DCOLOR g_avLightColors[3] = +D3DCOLOR g_avLightColors[3] = { D3DCOLOR_ARGB(0xFF,0xFF,0xFF,0xFF), D3DCOLOR_ARGB(0xFF,0xFF,0x00,0x00), From 01a6ec90599c300bf943051cb304a1ab6e0eb1b7 Mon Sep 17 00:00:00 2001 From: Alice Date: Sun, 27 Oct 2013 14:56:01 +0000 Subject: [PATCH 14/17] Adding tessellation support for new Blender 2.6 polygons - Added BlenderBMesh.cpp/h which contains a class to convert a BMesh to an old style tri/quad mesh - Added BlenderTessellator.cpp/h which contains a class to tessellate the poly loops contained within a BMesh --- code/BlenderBMesh.cpp | 176 ++++++++++++ code/BlenderBMesh.h | 93 +++++++ code/BlenderLoader.cpp | 7 + code/BlenderTessellator.cpp | 517 +++++++++++++++++++++++++++++++++++ code/BlenderTessellator.h | 199 ++++++++++++++ workspaces/vc9/assimp.vcproj | 16 ++ 6 files changed, 1008 insertions(+) create mode 100644 code/BlenderBMesh.cpp create mode 100644 code/BlenderBMesh.h create mode 100644 code/BlenderTessellator.cpp create mode 100644 code/BlenderTessellator.h diff --git a/code/BlenderBMesh.cpp b/code/BlenderBMesh.cpp new file mode 100644 index 000000000..83ccd37fb --- /dev/null +++ b/code/BlenderBMesh.cpp @@ -0,0 +1,176 @@ +/* +Open Asset Import Library (assimp) +---------------------------------------------------------------------- + +Copyright (c) 2006-2013, assimp team +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the +following conditions are met: + +* Redistributions of source code must retain the above + copyright notice, this list of conditions and the + following disclaimer. + +* Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the + following disclaimer in the documentation and/or other + materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its + contributors may be used to endorse or promote products + derived from this software without specific prior + written permission of the assimp team. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +---------------------------------------------------------------------- +*/ + +/** @file BlenderBMesh.cpp + * @brief Conversion of Blender's new BMesh stuff + */ + +#include "AssimpPCH.h" + +#ifndef ASSIMP_BUILD_NO_BLEND_IMPORTER + +#include "BlenderDNA.h" +#include "BlenderScene.h" +#include "BlenderBMesh.h" +#include "BlenderTessellator.h" + +namespace Assimp +{ + template< > const std::string LogFunctions< BlenderBMeshConverter >::log_prefix = "BLEND_BMESH: "; +} + +using namespace Assimp; +using namespace Assimp::Blender; +using namespace Assimp::Formatter; + +// ------------------------------------------------------------------------------------------------ +BlenderBMeshConverter::BlenderBMeshConverter( const Mesh* mesh ): + BMesh( mesh ), + triMesh( NULL ) +{ + AssertValidMesh( ); +} + +// ------------------------------------------------------------------------------------------------ +BlenderBMeshConverter::~BlenderBMeshConverter( ) +{ + DestroyTriMesh( ); +} + +// ------------------------------------------------------------------------------------------------ +bool BlenderBMeshConverter::ContainsBMesh( ) const +{ + // TODO - Should probably do some additional verification here + return BMesh->totpoly && BMesh->totloop && BMesh->totvert; +} + +// ------------------------------------------------------------------------------------------------ +const Mesh* BlenderBMeshConverter::TriangulateBMesh( ) +{ + AssertValidMesh( ); + AssertValidSizes( ); + PrepareTriMesh( ); + + for ( int i = 0; i < BMesh->totpoly; ++i ) + { + const MPoly& poly = BMesh->mpoly[ i ]; + ConvertPolyToFaces( poly ); + } + + return triMesh; +} + +// ------------------------------------------------------------------------------------------------ +void BlenderBMeshConverter::AssertValidMesh( ) +{ + if ( !ContainsBMesh( ) ) + { + ThrowException( "BlenderBMeshConverter requires a BMesh with \"polygons\" - please call BlenderBMeshConverter::ContainsBMesh to check this first" ); + } +} + +// ------------------------------------------------------------------------------------------------ +void BlenderBMeshConverter::AssertValidSizes( ) +{ + if ( BMesh->totpoly != BMesh->mpoly.size( ) ) + { + ThrowException( "BMesh poly array has incorrect size" ); + } + if ( BMesh->totloop != BMesh->mloop.size( ) ) + { + ThrowException( "BMesh loop array has incorrect size" ); + } +} + +// ------------------------------------------------------------------------------------------------ +void BlenderBMeshConverter::PrepareTriMesh( ) +{ + if ( triMesh ) + { + DestroyTriMesh( ); + } + + triMesh = new Mesh( *BMesh ); + triMesh->totface = 0; + triMesh->mface.clear( ); +} + +// ------------------------------------------------------------------------------------------------ +void BlenderBMeshConverter::DestroyTriMesh( ) +{ + delete triMesh; + triMesh = NULL; +} + +// ------------------------------------------------------------------------------------------------ +void BlenderBMeshConverter::ConvertPolyToFaces( const MPoly& poly ) +{ + const MLoop* polyLoop = &BMesh->mloop[ poly.loopstart ]; + if ( poly.totloop == 3 || poly.totloop == 4 ) + { + AddFace( polyLoop[ 0 ].v, polyLoop[ 1 ].v, polyLoop[ 2 ].v, poly.totloop == 4 ? polyLoop[ 3 ].v : 0 ); + } + else if ( poly.totloop > 4 ) + { +#if ASSIMP_BLEND_WITH_GLU_TESSELLATE + BlenderTessellatorGL tessGL( *this ); + tessGL.Tessellate( polyLoop, poly.totloop, triMesh->mvert ); +#elif ASSIMP_BLEND_WITH_POLY_2_TRI + BlenderTessellatorP2T tessP2T( *this ); + tessP2T.Tessellate( polyLoop, poly.totloop, triMesh->mvert ); +#endif + } +} + +// ------------------------------------------------------------------------------------------------ +void BlenderBMeshConverter::AddFace( int v1, int v2, int v3, int v4 ) +{ + MFace face; + face.v1 = v1; + face.v2 = v2; + face.v3 = v3; + face.v4 = v4; + // TODO - Work out how materials work + face.mat_nr = 0; + triMesh->mface.push_back( face ); + triMesh->totface = triMesh->mface.size( ); +} + +#endif // ASSIMP_BUILD_NO_BLEND_IMPORTER diff --git a/code/BlenderBMesh.h b/code/BlenderBMesh.h new file mode 100644 index 000000000..47afbf437 --- /dev/null +++ b/code/BlenderBMesh.h @@ -0,0 +1,93 @@ +/* +Open Asset Import Library (assimp) +---------------------------------------------------------------------- + +Copyright (c) 2006-2013, assimp team +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the +following conditions are met: + +* Redistributions of source code must retain the above + copyright notice, this list of conditions and the + following disclaimer. + +* Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the + following disclaimer in the documentation and/or other + materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its + contributors may be used to endorse or promote products + derived from this software without specific prior + written permission of the assimp team. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +---------------------------------------------------------------------- +*/ + +/** @file BlenderBMesh.h + * @brief Conversion of Blender's new BMesh stuff + */ +#ifndef INCLUDED_AI_BLEND_BMESH_H +#define INCLUDED_AI_BLEND_BMESH_H + +#include "LogAux.h" + +namespace Assimp +{ + // TinyFormatter.h + namespace Formatter + { + template < typename T,typename TR, typename A > class basic_formatter; + typedef class basic_formatter< char, std::char_traits< char >, std::allocator< char > > format; + } + + // BlenderScene.h + namespace Blender + { + struct Mesh; + struct MPoly; + struct MLoop; + } + + class BlenderBMeshConverter: public LogFunctions< BlenderBMeshConverter > + { + public: + BlenderBMeshConverter( const Blender::Mesh* mesh ); + ~BlenderBMeshConverter( ); + + bool ContainsBMesh( ) const; + + const Blender::Mesh* TriangulateBMesh( ); + + private: + void AssertValidMesh( ); + void AssertValidSizes( ); + void PrepareTriMesh( ); + void DestroyTriMesh( ); + void ConvertPolyToFaces( const Blender::MPoly& poly ); + void AddFace( int v1, int v2, int v3, int v4 = 0 ); + + const Blender::Mesh* BMesh; + Blender::Mesh* triMesh; + + friend class BlenderTessellatorGL; + friend class BlenderTessellatorP2T; + }; + +} // end of namespace Assimp + +#endif // INCLUDED_AI_BLEND_BMESH_H diff --git a/code/BlenderLoader.cpp b/code/BlenderLoader.cpp index 9fe93fd2a..4bbf5f9f6 100644 --- a/code/BlenderLoader.cpp +++ b/code/BlenderLoader.cpp @@ -51,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "BlenderIntermediate.h" #include "BlenderModifier.h" +#include "BlenderBMesh.h" #include "StreamReader.h" #include "MemoryIOWrapper.h" @@ -658,6 +659,12 @@ void BlenderImporter::ConvertMesh(const Scene& /*in*/, const Object* /*obj*/, co ConversionData& conv_data, TempArray& temp ) { + BlenderBMeshConverter BMeshConverter( mesh ); + if ( BMeshConverter.ContainsBMesh( ) ) + { + mesh = BMeshConverter.TriangulateBMesh( ); + } + typedef std::pair MyPair; if ((!mesh->totface && !mesh->totloop) || !mesh->totvert) { return; diff --git a/code/BlenderTessellator.cpp b/code/BlenderTessellator.cpp new file mode 100644 index 000000000..e2d51cf25 --- /dev/null +++ b/code/BlenderTessellator.cpp @@ -0,0 +1,517 @@ +/* +Open Asset Import Library (assimp) +---------------------------------------------------------------------- + +Copyright (c) 2006-2013, assimp team +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the +following conditions are met: + +* Redistributions of source code must retain the above + copyright notice, this list of conditions and the + following disclaimer. + +* Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the + following disclaimer in the documentation and/or other + materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its + contributors may be used to endorse or promote products + derived from this software without specific prior + written permission of the assimp team. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +---------------------------------------------------------------------- +*/ + +/** @file BlenderTessellator.cpp + * @brief A simple tessellation wrapper + */ + +#include "AssimpPCH.h" + +#ifndef ASSIMP_BUILD_NO_BLEND_IMPORTER + +#include "BlenderDNA.h" +#include "BlenderScene.h" +#include "BlenderBMesh.h" +#include "BlenderTessellator.h" + +#define BLEND_TESS_MAGIC ( 0x83ed9ac3 ) + +#if ASSIMP_BLEND_WITH_GLU_TESSELLATE + +namespace Assimp +{ + template< > const std::string LogFunctions< BlenderTessellatorGL >::log_prefix = "BLEND_TESS_GL: "; +} + +using namespace Assimp; +using namespace Assimp::Blender; + +#ifndef CALLBACK +#define CALLBACK +#endif + +// ------------------------------------------------------------------------------------------------ +BlenderTessellatorGL::BlenderTessellatorGL( BlenderBMeshConverter& converter ): + converter( &converter ) +{ +} + +// ------------------------------------------------------------------------------------------------ +BlenderTessellatorGL::~BlenderTessellatorGL( ) +{ +} + +// ------------------------------------------------------------------------------------------------ +void BlenderTessellatorGL::Tessellate( const MLoop* polyLoop, int vertexCount, const std::vector< MVert >& vertices ) +{ + AssertVertexCount( vertexCount ); + + std::vector< VertexGL > polyLoopGL; + GenerateLoopVerts( polyLoopGL, polyLoop, vertexCount, vertices ); + + TessDataGL tessData; + Tesssellate( polyLoopGL, tessData ); + + TriangulateDrawCalls( tessData ); +} + +// ------------------------------------------------------------------------------------------------ +void BlenderTessellatorGL::AssertVertexCount( int vertexCount ) +{ + if ( vertexCount <= 4 ) + { + ThrowException( "Expected more than 4 vertices for tessellation" ); + } +} + +// ------------------------------------------------------------------------------------------------ +void BlenderTessellatorGL::GenerateLoopVerts( std::vector< VertexGL >& polyLoopGL, const MLoop* polyLoop, int vertexCount, const std::vector< MVert >& vertices ) +{ + for ( int i = 0; i < vertexCount; ++i ) + { + const MLoop& loopItem = polyLoop[ i ]; + const MVert& vertex = vertices[ loopItem.v ]; + polyLoopGL.push_back( VertexGL( vertex.co[ 0 ], vertex.co[ 1 ], vertex.co[ 2 ], loopItem.v, BLEND_TESS_MAGIC ) ); + } +} + +// ------------------------------------------------------------------------------------------------ +void BlenderTessellatorGL::Tesssellate( std::vector< VertexGL >& polyLoopGL, TessDataGL& tessData ) +{ + GLUtesselator* tessellator = gluNewTess( ); + gluTessCallback( tessellator, GLU_TESS_BEGIN_DATA, reinterpret_cast< void ( CALLBACK * )( ) >( TessellateBegin ) ); + gluTessCallback( tessellator, GLU_TESS_END_DATA, reinterpret_cast< void ( CALLBACK * )( ) >( TessellateEnd ) ); + gluTessCallback( tessellator, GLU_TESS_VERTEX_DATA, reinterpret_cast< void ( CALLBACK * )( ) >( TessellateVertex ) ); + gluTessCallback( tessellator, GLU_TESS_COMBINE_DATA, reinterpret_cast< void ( CALLBACK * )( ) >( TessellateCombine ) ); + gluTessCallback( tessellator, GLU_TESS_EDGE_FLAG_DATA, reinterpret_cast< void ( CALLBACK * )( ) >( TessellateEdgeFlag ) ); + gluTessCallback( tessellator, GLU_TESS_ERROR_DATA, reinterpret_cast< void ( CALLBACK * )( ) >( TessellateError ) ); + gluTessProperty( tessellator, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_NONZERO ); + + gluTessBeginPolygon( tessellator, &tessData ); + gluTessBeginContour( tessellator ); + + for ( unsigned int i = 0; i < polyLoopGL.size( ); ++i ) + { + gluTessVertex( tessellator, reinterpret_cast< GLdouble* >( &polyLoopGL[ i ] ), &polyLoopGL[ i ] ); + } + + gluTessEndContour( tessellator ); + gluTessEndPolygon( tessellator ); +} + +// ------------------------------------------------------------------------------------------------ +void BlenderTessellatorGL::TriangulateDrawCalls( const TessDataGL& tessData ) +{ + // NOTE - Because we are supplying a callback to GLU_TESS_EDGE_FLAG_DATA we don't technically + // need support for GL_TRIANGLE_STRIP and GL_TRIANGLE_FAN but we'll keep it here in case + // GLU tessellate changes or tristrips and fans are wanted. + // See: http://www.opengl.org/sdk/docs/man2/xhtml/gluTessCallback.xml + for ( unsigned int i = 0; i < tessData.drawCalls.size( ); ++i ) + { + const DrawCallGL& drawCallGL = tessData.drawCalls[ i ]; + const VertexGL* vertices = &tessData.vertices[ drawCallGL.baseVertex ]; + if ( drawCallGL.drawMode == GL_TRIANGLES ) + { + MakeFacesFromTris( vertices, drawCallGL.vertexCount ); + } + else if ( drawCallGL.drawMode == GL_TRIANGLE_STRIP ) + { + MakeFacesFromTriStrip( vertices, drawCallGL.vertexCount ); + } + else if ( drawCallGL.drawMode == GL_TRIANGLE_FAN ) + { + MakeFacesFromTriFan( vertices, drawCallGL.vertexCount ); + } + } +} + +// ------------------------------------------------------------------------------------------------ +void BlenderTessellatorGL::MakeFacesFromTris( const VertexGL* vertices, int vertexCount ) +{ + int triangleCount = vertexCount / 3; + for ( int i = 0; i < triangleCount; ++i ) + { + int vertexBase = i * 3; + converter->AddFace( vertices[ vertexBase + 0 ].index, vertices[ vertexBase + 1 ].index, vertices[ vertexBase + 2 ].index ); + } +} + +// ------------------------------------------------------------------------------------------------ +void BlenderTessellatorGL::MakeFacesFromTriStrip( const VertexGL* vertices, int vertexCount ) +{ + int triangleCount = vertexCount - 2; + for ( int i = 0; i < triangleCount; ++i ) + { + int vertexBase = i; + converter->AddFace( vertices[ vertexBase + 0 ].index, vertices[ vertexBase + 1 ].index, vertices[ vertexBase + 2 ].index ); + } +} + +// ------------------------------------------------------------------------------------------------ +void BlenderTessellatorGL::MakeFacesFromTriFan( const VertexGL* vertices, int vertexCount ) +{ + int triangleCount = vertexCount - 2; + for ( int i = 0; i < triangleCount; ++i ) + { + int vertexBase = i; + converter->AddFace( vertices[ 0 ].index, vertices[ vertexBase + 1 ].index, vertices[ vertexBase + 2 ].index ); + } +} + +// ------------------------------------------------------------------------------------------------ +void BlenderTessellatorGL::TessellateBegin( GLenum drawModeGL, void* userData ) +{ + TessDataGL& tessData = *reinterpret_cast< TessDataGL* >( userData ); + tessData.drawCalls.push_back( DrawCallGL( drawModeGL, tessData.vertices.size( ) ) ); +} + +// ------------------------------------------------------------------------------------------------ +void BlenderTessellatorGL::TessellateEnd( void* ) +{ + // Do nothing +} + +// ------------------------------------------------------------------------------------------------ +void BlenderTessellatorGL::TessellateVertex( const void* vtxData, void* userData ) +{ + TessDataGL& tessData = *reinterpret_cast< TessDataGL* >( userData ); + + const VertexGL& vertex = *reinterpret_cast< const VertexGL* >( vtxData ); + if ( vertex.magic != BLEND_TESS_MAGIC ) + { + ThrowException( "Point returned by GLU Tessellate was probably not one of ours. This indicates we need a new way to store vertex information" ); + } + tessData.vertices.push_back( vertex ); + if ( tessData.drawCalls.size( ) == 0 ) + { + ThrowException( "\"Vertex\" callback received before \"Begin\"" ); + } + ++( tessData.drawCalls.back( ).vertexCount ); +} + +// ------------------------------------------------------------------------------------------------ +void BlenderTessellatorGL::TessellateCombine( const GLdouble intersection[ 3 ], const GLdouble* [ 4 ], const GLfloat [ 4 ], GLdouble** out, void* userData ) +{ + ThrowException( "Intersected polygon loops are not yet supported" ); +} + +// ------------------------------------------------------------------------------------------------ +void BlenderTessellatorGL::TessellateEdgeFlag( GLboolean, void* ) +{ + // Do nothing +} + +// ------------------------------------------------------------------------------------------------ +void BlenderTessellatorGL::TessellateError( GLenum errorCode, void* ) +{ + ThrowException( reinterpret_cast< const char* >( gluErrorString( errorCode ) ) ); +} + +#endif // ASSIMP_BLEND_WITH_GLU_TESSELLATE + +#if ASSIMP_BLEND_WITH_POLY_2_TRI + +namespace Assimp +{ + template< > const std::string LogFunctions< BlenderTessellatorP2T >::log_prefix = "BLEND_TESS_P2T: "; +} + +using namespace Assimp; +using namespace Assimp::Blender; + +// ------------------------------------------------------------------------------------------------ +BlenderTessellatorP2T::BlenderTessellatorP2T( BlenderBMeshConverter& converter ): + converter( &converter ) +{ +} + +// ------------------------------------------------------------------------------------------------ +BlenderTessellatorP2T::~BlenderTessellatorP2T( ) +{ +} + +// ------------------------------------------------------------------------------------------------ +void BlenderTessellatorP2T::Tessellate( const MLoop* polyLoop, int vertexCount, const std::vector< MVert >& vertices ) +{ + AssertVertexCount( vertexCount ); + + // NOTE - We have to hope that points in a Blender polygon are roughly on the same plane. + // There may be some triangulation artifacts if they are wildly different. + + std::vector< PointP2T > points; + Copy3DVertices( polyLoop, vertexCount, vertices, points ); + + PlaneP2T plane = FindLLSQPlane( points ); + + aiMatrix4x4 transform = GeneratePointTransformMatrix( plane ); + + TransformAndFlattenVectices( transform, points ); + + std::vector< p2t::Point* > pointRefs; + ReferencePoints( points, pointRefs ); + + p2t::CDT cdt( pointRefs ); + + cdt.Triangulate( ); + std::vector< p2t::Triangle* > triangles = cdt.GetTriangles( ); + + MakeFacesFromTriangles( triangles ); +} + +// ------------------------------------------------------------------------------------------------ +void BlenderTessellatorP2T::AssertVertexCount( int vertexCount ) +{ + if ( vertexCount <= 4 ) + { + ThrowException( "Expected more than 4 vertices for tessellation" ); + } +} + +// ------------------------------------------------------------------------------------------------ +void BlenderTessellatorP2T::Copy3DVertices( const MLoop* polyLoop, int vertexCount, const std::vector< MVert >& vertices, std::vector< PointP2T >& points ) const +{ + points.resize( vertexCount ); + for ( int i = 0; i < vertexCount; ++i ) + { + const MLoop& loop = polyLoop[ i ]; + const MVert& vert = vertices[ loop.v ]; + + PointP2T& point = points[ i ]; + point.point3D.Set( vert.co[ 0 ], vert.co[ 1 ], vert.co[ 2 ] ); + point.index = loop.v; + point.magic = BLEND_TESS_MAGIC; + } +} + +// ------------------------------------------------------------------------------------------------ +aiMatrix4x4 BlenderTessellatorP2T::GeneratePointTransformMatrix( const Blender::PlaneP2T& plane ) const +{ + aiVector3D sideA( 1.0f, 0.0f, 0.0f ); + if ( fabs( plane.normal * sideA ) > 0.999f ) + { + sideA = aiVector3D( 0.0f, 1.0f, 0.0f ); + } + + aiVector3D sideB( plane.normal ^ sideA ); + sideB.Normalize( ); + sideA = sideB ^ plane.normal; + + aiMatrix4x4 result; + result.a1 = sideA.x; + result.a2 = sideA.y; + result.a3 = sideA.z; + result.b1 = sideB.x; + result.b2 = sideB.y; + result.b3 = sideB.z; + result.c1 = plane.normal.x; + result.c2 = plane.normal.y; + result.c3 = plane.normal.z; + result.a4 = plane.centre.x; + result.b4 = plane.centre.y; + result.c4 = plane.centre.z; + result.Inverse( ); + + return result; +} + +// ------------------------------------------------------------------------------------------------ +void BlenderTessellatorP2T::TransformAndFlattenVectices( const aiMatrix4x4& transform, std::vector< Blender::PointP2T >& vertices ) const +{ + for ( unsigned int i = 0; i < vertices.size( ); ++i ) + { + PointP2T& point = vertices[ i ]; + point.point3D = transform * point.point3D; + point.point2D.set( point.point3D.y, point.point3D.z ); + } +} + +// ------------------------------------------------------------------------------------------------ +void BlenderTessellatorP2T::ReferencePoints( std::vector< Blender::PointP2T >& points, std::vector< p2t::Point* >& pointRefs ) const +{ + pointRefs.resize( points.size( ) ); + for ( unsigned int i = 0; i < points.size( ); ++i ) + { + pointRefs[ i ] = &points[ i ].point2D; + } +} + +// ------------------------------------------------------------------------------------------------ +// Yes this is filthy... but we have no choice +#define OffsetOf( Class, Member ) ( reinterpret_cast< unsigned int >( &( reinterpret_cast< Class* >( NULL )->*( &Class::Member ) ) ) ) +inline PointP2T& BlenderTessellatorP2T::GetActualPointStructure( p2t::Point& point ) const +{ + int pointOffset = OffsetOf( PointP2T, point2D ); + PointP2T& pointStruct = *reinterpret_cast< PointP2T* >( reinterpret_cast< char* >( &point ) - pointOffset ); + if ( pointStruct.magic != BLEND_TESS_MAGIC ) + { + ThrowException( "Point returned by poly2tri was probably not one of ours. This indicates we need a new way to store vertex information" ); + } + return pointStruct; +} + +// ------------------------------------------------------------------------------------------------ +void BlenderTessellatorP2T::MakeFacesFromTriangles( std::vector< p2t::Triangle* >& triangles ) const +{ + for ( unsigned int i = 0; i < triangles.size( ); ++i ) + { + p2t::Triangle& Triangle = *triangles[ i ]; + + PointP2T& pointA = GetActualPointStructure( *Triangle.GetPoint( 0 ) ); + PointP2T& pointB = GetActualPointStructure( *Triangle.GetPoint( 1 ) ); + PointP2T& pointC = GetActualPointStructure( *Triangle.GetPoint( 2 ) ); + + converter->AddFace( pointA.index, pointB.index, pointC.index ); + } +} + +// ------------------------------------------------------------------------------------------------ +inline float p2tMax( float a, float b ) +{ + return a > b ? a : b; +} + +// ------------------------------------------------------------------------------------------------ +// Adapted from: http://missingbytes.blogspot.co.uk/2012/06/fitting-plane-to-point-cloud.html +float BlenderTessellatorP2T::FindLargestMatrixElem( const aiMatrix3x3& mtx ) const +{ + float result = 0.0f; + + for ( int x = 0; x < 3; ++x ) + { + for ( int y = 0; y < 3; ++y ) + { + result = p2tMax( fabs( mtx[ x ][ y ] ), result ); + } + } + + return result; +} + +// ------------------------------------------------------------------------------------------------ +// Aparently Assimp doesn't have matrix scaling +aiMatrix3x3 BlenderTessellatorP2T::ScaleMatrix( const aiMatrix3x3& mtx, float scale ) const +{ + aiMatrix3x3 result; + + for ( int x = 0; x < 3; ++x ) + { + for ( int y = 0; y < 3; ++y ) + { + result[ x ][ y ] = mtx[ x ][ y ] * scale; + } + } + + return result; +} + + +// ------------------------------------------------------------------------------------------------ +// Adapted from: http://missingbytes.blogspot.co.uk/2012/06/fitting-plane-to-point-cloud.html +aiVector3D BlenderTessellatorP2T::GetEigenVectorFromLargestEigenValue( const aiMatrix3x3& mtx ) const +{ + float scale = FindLargestMatrixElem( mtx ); + aiMatrix3x3 mc = ScaleMatrix( mtx, 1.0f / scale ); + mc = mc * mc * mc; + + aiVector3D v( 1.0f ); + aiVector3D lastV = v; + for ( int i = 0; i < 100; ++i ) + { + v = mc * v; + v.Normalize( ); + if ( ( v - lastV ).SquareLength( ) < 1e-16f ) + { + break; + } + lastV = v; + } + return v; +} + +// ------------------------------------------------------------------------------------------------ +// Adapted from: http://missingbytes.blogspot.co.uk/2012/06/fitting-plane-to-point-cloud.html +PlaneP2T BlenderTessellatorP2T::FindLLSQPlane( const std::vector< PointP2T >& points ) const +{ + PlaneP2T result; + + aiVector3D sum( 0.0f ); + for ( unsigned int i = 0; i < points.size( ); ++i ) + { + sum += points[ i ].point3D; + } + result.centre = sum * ( 1.0f / points.size( ) ); + + float sumXX = 0.0f; + float sumXY = 0.0f; + float sumXZ = 0.0f; + float sumYY = 0.0f; + float sumYZ = 0.0f; + float sumZZ = 0.0f; + for ( unsigned int i = 0; i < points.size( ); ++i ) + { + aiVector3D offset = points[ i ].point3D - result.centre; + sumXX += offset.x * offset.x; + sumXY += offset.x * offset.y; + sumXZ += offset.x * offset.z; + sumYY += offset.y * offset.y; + sumYZ += offset.y * offset.z; + sumZZ += offset.z * offset.z; + } + + aiMatrix3x3 mtx( sumXX, sumXY, sumXZ, sumXY, sumYY, sumYZ, sumXZ, sumYZ, sumZZ ); + + float det = mtx.Determinant( ); + if ( det == 0.0f ) + { + result.normal = aiVector3D( 0.0f ); + } + else + { + aiMatrix3x3 invMtx = mtx; + invMtx.Inverse( ); + result.normal = GetEigenVectorFromLargestEigenValue( invMtx ); + } + + return result; +} + +#endif // ASSIMP_BLEND_WITH_POLY_2_TRI + +#endif // ASSIMP_BUILD_NO_BLEND_IMPORTER diff --git a/code/BlenderTessellator.h b/code/BlenderTessellator.h new file mode 100644 index 000000000..53c560594 --- /dev/null +++ b/code/BlenderTessellator.h @@ -0,0 +1,199 @@ +/* +Open Asset Import Library (assimp) +---------------------------------------------------------------------- + +Copyright (c) 2006-2013, assimp team +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the +following conditions are met: + +* Redistributions of source code must retain the above + copyright notice, this list of conditions and the + following disclaimer. + +* Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the + following disclaimer in the documentation and/or other + materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its + contributors may be used to endorse or promote products + derived from this software without specific prior + written permission of the assimp team. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +---------------------------------------------------------------------- +*/ + +/** @file BlenderTessellator.h + * @brief A simple tessellation wrapper + */ +#ifndef INCLUDED_AI_BLEND_TESSELLATOR_H +#define INCLUDED_AI_BLEND_TESSELLATOR_H + +// Use these to toggle between GLU Tessellate or poly2tri +#define ASSIMP_BLEND_WITH_GLU_TESSELLATE 1 +#define ASSIMP_BLEND_WITH_POLY_2_TRI 1 + +#include "LogAux.h" + +#if ASSIMP_BLEND_WITH_GLU_TESSELLATE + +#if defined( WIN32 ) || defined( _WIN32 ) || defined( _MSC_VER ) +#include +#endif +#include + +namespace Assimp +{ + class BlenderBMeshConverter; + + // TinyFormatter.h + namespace Formatter + { + template < typename T,typename TR, typename A > class basic_formatter; + typedef class basic_formatter< char, std::char_traits< char >, std::allocator< char > > format; + } + + // BlenderScene.h + namespace Blender + { + struct MLoop; + struct MVert; + + struct VertexGL + { + GLdouble X; + GLdouble Y; + GLdouble Z; + int index; + int magic; + + VertexGL( GLdouble X, GLdouble Y, GLdouble Z, int index, int magic ): X( X ), Y( Y ), Z( Z ), index( index ), magic( magic ) { } + }; + + struct DrawCallGL + { + GLenum drawMode; + int baseVertex; + int vertexCount; + + DrawCallGL( GLenum drawMode, int baseVertex ): drawMode( drawMode ), baseVertex( baseVertex ), vertexCount( 0 ) { } + }; + + struct TessDataGL + { + std::vector< DrawCallGL > drawCalls; + std::vector< VertexGL > vertices; + }; + } + + class BlenderTessellatorGL: public LogFunctions< BlenderTessellatorGL > + { + public: + BlenderTessellatorGL( BlenderBMeshConverter& converter ); + ~BlenderTessellatorGL( ); + + void Tessellate( const Blender::MLoop* polyLoop, int vertexCount, const std::vector< Blender::MVert >& vertices ); + + private: + void AssertVertexCount( int vertexCount ); + void GenerateLoopVerts( std::vector< Blender::VertexGL >& polyLoopGL, const Blender::MLoop* polyLoop, int vertexCount, const std::vector< Blender::MVert >& vertices ); + void Tesssellate( std::vector< Blender::VertexGL >& polyLoopGL, Blender::TessDataGL& tessData ); + void TriangulateDrawCalls( const Blender::TessDataGL& tessData ); + void MakeFacesFromTris( const Blender::VertexGL* vertices, int vertexCount ); + void MakeFacesFromTriStrip( const Blender::VertexGL* vertices, int vertexCount ); + void MakeFacesFromTriFan( const Blender::VertexGL* vertices, int vertexCount ); + + static void TessellateBegin( GLenum drawModeGL, void* userData ); + static void TessellateEnd( void* userData ); + static void TessellateVertex( const void* vtxData, void* userData ); + static void TessellateCombine( const GLdouble intersection[ 3 ], const GLdouble* [ 4 ], const GLfloat [ 4 ], GLdouble** out, void* userData ); + static void TessellateEdgeFlag( GLboolean edgeFlag, void* userData ); + static void TessellateError( GLenum errorCode, void* userData ); + + BlenderBMeshConverter* converter; + }; +} // end of namespace Assimp + +#endif // ASSIMP_BLEND_WITH_GLU_TESSELLATE + +#if ASSIMP_BLEND_WITH_POLY_2_TRI + +#include "../contrib/poly2tri/poly2tri/poly2tri.h" + +namespace Assimp +{ + class BlenderBMeshConverter; + + // TinyFormatter.h + namespace Formatter + { + template < typename T,typename TR, typename A > class basic_formatter; + typedef class basic_formatter< char, std::char_traits< char >, std::allocator< char > > format; + } + + // BlenderScene.h + namespace Blender + { + struct MLoop; + struct MVert; + + struct PointP2T + { + aiVector3D point3D; + p2t::Point point2D; + int magic; + int index; + }; + + struct PlaneP2T + { + aiVector3D centre; + aiVector3D normal; + }; + } + + class BlenderTessellatorP2T: public LogFunctions< BlenderTessellatorP2T > + { + public: + BlenderTessellatorP2T( BlenderBMeshConverter& converter ); + ~BlenderTessellatorP2T( ); + + void Tessellate( const Blender::MLoop* polyLoop, int vertexCount, const std::vector< Blender::MVert >& vertices ); + + private: + void AssertVertexCount( int vertexCount ); + void Copy3DVertices( const Blender::MLoop* polyLoop, int vertexCount, const std::vector< Blender::MVert >& vertices, std::vector< Blender::PointP2T >& targetVertices ) const; + aiMatrix4x4 GeneratePointTransformMatrix( const Blender::PlaneP2T& plane ) const; + void TransformAndFlattenVectices( const aiMatrix4x4& transform, std::vector< Blender::PointP2T >& vertices ) const; + void ReferencePoints( std::vector< Blender::PointP2T >& points, std::vector< p2t::Point* >& pointRefs ) const; + inline Blender::PointP2T& GetActualPointStructure( p2t::Point& point ) const; + void MakeFacesFromTriangles( std::vector< p2t::Triangle* >& triangles ) const; + + // Adapted from: http://missingbytes.blogspot.co.uk/2012/06/fitting-plane-to-point-cloud.html + float FindLargestMatrixElem( const aiMatrix3x3& mtx ) const; + aiMatrix3x3 ScaleMatrix( const aiMatrix3x3& mtx, float scale ) const; + aiVector3D GetEigenVectorFromLargestEigenValue( const aiMatrix3x3& mtx ) const; + Blender::PlaneP2T FindLLSQPlane( const std::vector< Blender::PointP2T >& points ) const; + + BlenderBMeshConverter* converter; + }; +} // end of namespace Assimp + +#endif // ASSIMP_BLEND_WITH_POLY_2_TRI + +#endif // INCLUDED_AI_BLEND_TESSELLATOR_H diff --git a/workspaces/vc9/assimp.vcproj b/workspaces/vc9/assimp.vcproj index 724944074..120577b67 100644 --- a/workspaces/vc9/assimp.vcproj +++ b/workspaces/vc9/assimp.vcproj @@ -1867,6 +1867,14 @@ + + + + @@ -1911,6 +1919,14 @@ RelativePath="..\..\code\BlenderSceneGen.h" > + + + + Date: Fri, 22 Nov 2013 13:57:50 +0100 Subject: [PATCH 15/17] Update CMakeLists --- code/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 1ae8efd38..7e18f2a75 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -362,6 +362,10 @@ SET(BLENDER_SRCS BlenderIntermediate.h BlenderModifier.h BlenderModifier.cpp + BlenderBMesh.h + BlenderBMesh.cpp + BlenderTessellator.h + BlenderTessellator.cpp ) SOURCE_GROUP( BLENDER FILES ${BLENDER_SRCS}) From 857e50ba40437a3ae5494f6f35da7cbfd5c38285 Mon Sep 17 00:00:00 2001 From: acgessler Date: Fri, 22 Nov 2013 13:58:40 +0100 Subject: [PATCH 16/17] BlenderTesselator: disable GLU tesselation code by default. --- code/BlenderTessellator.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/code/BlenderTessellator.h b/code/BlenderTessellator.h index 53c560594..0d85e404b 100644 --- a/code/BlenderTessellator.h +++ b/code/BlenderTessellator.h @@ -45,8 +45,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define INCLUDED_AI_BLEND_TESSELLATOR_H // Use these to toggle between GLU Tessellate or poly2tri -#define ASSIMP_BLEND_WITH_GLU_TESSELLATE 1 -#define ASSIMP_BLEND_WITH_POLY_2_TRI 1 +// Note (acg) keep GLU Tesselate disabled by default - if it is turned on, +// assimp needs to be linked against GLU, which is currently not yet +// made configurable in CMake and potentially not wanted by most users +// as it requires a Gl environment. +#ifndef ASSIMP_BLEND_WITH_GLU_TESSELLATE +# define ASSIMP_BLEND_WITH_GLU_TESSELLATE 0 +#endif + +#ifndef ASSIMP_BLEND_WITH_POLY_2_TRI +# define ASSIMP_BLEND_WITH_POLY_2_TRI 1 +#endif #include "LogAux.h" From d080f922414a80e0f35a313ba62d823a81415e98 Mon Sep 17 00:00:00 2001 From: acgessler Date: Fri, 22 Nov 2013 19:54:47 +0100 Subject: [PATCH 17/17] BlenderTesselator: Fix OffsetOf() macro --- code/BlenderTessellator.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/code/BlenderTessellator.cpp b/code/BlenderTessellator.cpp index e2d51cf25..150183519 100644 --- a/code/BlenderTessellator.cpp +++ b/code/BlenderTessellator.cpp @@ -374,10 +374,13 @@ void BlenderTessellatorP2T::ReferencePoints( std::vector< Blender::PointP2T >& p // ------------------------------------------------------------------------------------------------ // Yes this is filthy... but we have no choice -#define OffsetOf( Class, Member ) ( reinterpret_cast< unsigned int >( &( reinterpret_cast< Class* >( NULL )->*( &Class::Member ) ) ) ) +#define OffsetOf( Class, Member ) ( static_cast< unsigned int >( \ + reinterpret_cast(&( reinterpret_cast< Class* >( NULL )->*( &Class::Member ) )) - \ + static_cast(NULL) ) ) + inline PointP2T& BlenderTessellatorP2T::GetActualPointStructure( p2t::Point& point ) const { - int pointOffset = OffsetOf( PointP2T, point2D ); + unsigned int pointOffset = OffsetOf( PointP2T, point2D ); PointP2T& pointStruct = *reinterpret_cast< PointP2T* >( reinterpret_cast< char* >( &point ) - pointOffset ); if ( pointStruct.magic != BLEND_TESS_MAGIC ) {