2008-05-09 17:24:28 +00:00
|
|
|
/*
|
|
|
|
---------------------------------------------------------------------------
|
2012-02-03 03:38:30 +00:00
|
|
|
Open Asset Import Library (assimp)
|
2008-05-09 17:24:28 +00:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
2012-02-03 03:38:30 +00:00
|
|
|
Copyright (c) 2006-2012, assimp team
|
2008-05-09 17:24:28 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2012-02-03 03:38:30 +00:00
|
|
|
* Neither the name of the assimp team, nor the names of its
|
2008-05-09 17:24:28 +00:00
|
|
|
contributors may be used to endorse or promote products
|
|
|
|
derived from this software without specific prior
|
2012-02-03 03:38:30 +00:00
|
|
|
written permission of the assimp team.
|
2008-05-09 17:24:28 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
---------------------------------------------------------------------------
|
2008-05-05 12:36:31 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#if (!defined AV_MAIN_H_INCLUDED)
|
|
|
|
#define AV_MAIN_H_INCLUDED
|
|
|
|
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
#define AI_SHADER_COMPILE_FLAGS D3DXSHADER_USE_LEGACY_D3DX9_31_DLL
|
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// include resource definitions
|
|
|
|
#include "resource.h"
|
|
|
|
|
2015-04-17 18:02:55 +00:00
|
|
|
#include <assert.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <malloc.h>
|
|
|
|
#include <memory.h>
|
|
|
|
#include <tchar.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
2010-02-05 22:32:19 +00:00
|
|
|
// Include ASSIMP headers (XXX: do we really need all of them?)
|
2012-02-03 17:04:06 +00:00
|
|
|
#include <assimp/cimport.h>
|
|
|
|
#include <assimp/Importer.hpp>
|
2012-04-22 23:14:39 +00:00
|
|
|
#include <assimp/ai_assert.h>
|
2012-02-03 17:04:06 +00:00
|
|
|
#include <assimp/cfileio.h>
|
|
|
|
#include <assimp/postprocess.h>
|
|
|
|
#include <assimp/scene.h>
|
|
|
|
#include <assimp/IOSystem.hpp>
|
|
|
|
#include <assimp/IOStream.hpp>
|
|
|
|
#include <assimp/LogStream.hpp>
|
|
|
|
#include <assimp/DefaultLogger.hpp>
|
2009-04-11 14:31:57 +00:00
|
|
|
|
2008-06-15 10:27:08 +00:00
|
|
|
|
2012-02-03 16:26:11 +00:00
|
|
|
#include "../../code/MaterialSystem.h" // aiMaterial class
|
|
|
|
#include "../../code/StringComparison.h" // ASSIMP_stricmp and ASSIMP_strincmp
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// in order for std::min and std::max to behave properly
|
2015-04-28 13:16:53 +00:00
|
|
|
#ifndef max
|
|
|
|
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
|
|
|
#endif // max
|
|
|
|
#ifndef min
|
|
|
|
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
2008-05-05 12:36:31 +00:00
|
|
|
#endif // min
|
|
|
|
|
2008-10-30 19:51:01 +00:00
|
|
|
#include <time.h>
|
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// default movement speed
|
2008-10-27 00:36:26 +00:00
|
|
|
#define MOVE_SPEED 3.f
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
#include "AssetHelper.h"
|
|
|
|
#include "Camera.h"
|
|
|
|
#include "RenderOptions.h"
|
|
|
|
#include "Shaders.h"
|
|
|
|
#include "Background.h"
|
|
|
|
#include "LogDisplay.h"
|
2008-05-09 17:24:28 +00:00
|
|
|
#include "LogWindow.h"
|
2008-05-13 23:26:52 +00:00
|
|
|
#include "Display.h"
|
|
|
|
#include "MeshRenderer.h"
|
|
|
|
#include "MaterialManager.h"
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-10-29 17:08:03 +00:00
|
|
|
|
|
|
|
// outside of namespace, to help Intellisense and solve boost::metatype_stuff_miracle
|
|
|
|
#include "AnimEvaluator.h"
|
|
|
|
#include "SceneAnimator.h"
|
|
|
|
|
|
|
|
namespace AssimpView
|
|
|
|
{
|
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
// Function prototypes
|
|
|
|
//-------------------------------------------------------------------------------
|
2015-04-17 18:02:55 +00:00
|
|
|
int InitD3D(void);
|
|
|
|
int ShutdownD3D(void);
|
|
|
|
int CreateDevice (bool p_bMultiSample,bool p_bSuperSample, bool bHW = true);
|
|
|
|
int CreateDevice (void);
|
|
|
|
int ShutdownDevice(void);
|
|
|
|
int GetProjectionMatrix (aiMatrix4x4& p_mOut);
|
|
|
|
int LoadAsset(void);
|
|
|
|
int CreateAssetData(void);
|
|
|
|
int DeleteAssetData(bool bNoMaterials = false);
|
|
|
|
int ScaleAsset(void);
|
|
|
|
int DeleteAsset(void);
|
|
|
|
int SetupFPSView();
|
2008-05-13 23:26:52 +00:00
|
|
|
|
2015-04-17 18:02:55 +00:00
|
|
|
aiVector3D GetCameraMatrix (aiMatrix4x4& p_mOut);
|
|
|
|
int CreateMaterial(AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSource);
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2015-04-17 18:02:55 +00:00
|
|
|
void HandleMouseInputFPS( void );
|
|
|
|
void HandleMouseInputLightRotate( void );
|
|
|
|
void HandleMouseInputLocal( void );
|
|
|
|
void HandleKeyboardInputFPS( void );
|
|
|
|
void HandleMouseInputLightIntensityAndColor( void );
|
|
|
|
void HandleMouseInputSkyBox( void );
|
|
|
|
void HandleKeyboardInputTextureView( void );
|
|
|
|
void HandleMouseInputTextureView( void );
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Dialog procedure for the progress bar window
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
INT_PTR CALLBACK ProgressMessageProc(HWND hwndDlg,UINT uMsg,
|
|
|
|
WPARAM wParam,LPARAM lParam);
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
// Main message procedure of the application
|
|
|
|
//
|
|
|
|
// The function handles all incoming messages for the main window.
|
|
|
|
// However, if does not directly process input commands.
|
|
|
|
// NOTE: Due to the impossibility to process WM_CHAR messages in dialogs
|
|
|
|
// properly the code for all hotkeys has been moved to the WndMain
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
INT_PTR CALLBACK MessageProc(HWND hwndDlg,UINT uMsg,
|
|
|
|
WPARAM wParam,LPARAM lParam);
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Dialog procedure for the about dialog
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
INT_PTR CALLBACK AboutMessageProc(HWND hwndDlg,UINT uMsg,
|
|
|
|
WPARAM wParam,LPARAM lParam);
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
//
|
2015-04-17 18:02:55 +00:00
|
|
|
// Dialog procedure for the help dialog
|
2008-05-05 12:36:31 +00:00
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
INT_PTR CALLBACK HelpDialogProc(HWND hwndDlg,UINT uMsg,
|
|
|
|
WPARAM wParam,LPARAM lParam);
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
// Handle command line parameters
|
|
|
|
//
|
|
|
|
// The function loads an asset specified on the command line as first argument
|
|
|
|
// Other command line parameters are not handled
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
void HandleCommandLine(char* p_szCommand);
|
|
|
|
|
|
|
|
|
2008-05-25 22:29:05 +00:00
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
template <class type, class intype>
|
|
|
|
type clamp(intype in)
|
|
|
|
{
|
|
|
|
// for unsigned types only ...
|
|
|
|
intype mask = (0x1u << (sizeof(type)*8))-1;
|
2015-04-17 18:02:55 +00:00
|
|
|
return (type)max((intype)0,min(in,mask));
|
2008-05-25 22:29:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
// Position of the cursor relative to the 3ds max' like control circle
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
enum EClickPos
|
2008-05-09 17:24:28 +00:00
|
|
|
{
|
|
|
|
// The click was inside the inner circle (x,y axis)
|
2008-05-05 12:36:31 +00:00
|
|
|
EClickPos_Circle,
|
2008-05-09 17:24:28 +00:00
|
|
|
// The click was inside one of tghe vertical snap-ins
|
2008-05-05 12:36:31 +00:00
|
|
|
EClickPos_CircleVert,
|
2008-05-09 17:24:28 +00:00
|
|
|
// The click was inside onf of the horizontal snap-ins
|
2008-05-05 12:36:31 +00:00
|
|
|
EClickPos_CircleHor,
|
2008-05-09 17:24:28 +00:00
|
|
|
// the cklick was outside the circle (z-axis)
|
2008-05-05 12:36:31 +00:00
|
|
|
EClickPos_Outside
|
2008-05-09 17:24:28 +00:00
|
|
|
};
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-05-09 17:24:28 +00:00
|
|
|
#if (!defined AI_VIEW_CAPTION_BASE)
|
2009-02-11 20:56:05 +00:00
|
|
|
# define AI_VIEW_CAPTION_BASE "Open Asset Import Library : Viewer "
|
2008-05-09 17:24:28 +00:00
|
|
|
#endif // !! AI_VIEW_CAPTION_BASE
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
// Evil globals
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
extern HINSTANCE g_hInstance /*= NULL*/;
|
|
|
|
extern HWND g_hDlg /*= NULL*/;
|
|
|
|
extern IDirect3D9* g_piD3D /*= NULL*/;
|
|
|
|
extern IDirect3DDevice9* g_piDevice /*= NULL*/;
|
2008-10-29 17:08:03 +00:00
|
|
|
extern IDirect3DVertexDeclaration9* gDefaultVertexDecl /*= NULL*/;
|
2008-05-05 12:36:31 +00:00
|
|
|
extern double g_fFPS /*= 0.0f*/;
|
|
|
|
extern char g_szFileName[MAX_PATH];
|
|
|
|
extern ID3DXEffect* g_piDefaultEffect /*= NULL*/;
|
|
|
|
extern ID3DXEffect* g_piNormalsEffect /*= NULL*/;
|
|
|
|
extern ID3DXEffect* g_piPassThroughEffect /*= NULL*/;
|
2008-05-13 23:26:52 +00:00
|
|
|
extern ID3DXEffect* g_piPatternEffect /*= NULL*/;
|
2008-05-05 12:36:31 +00:00
|
|
|
extern bool g_bMousePressed /*= false*/;
|
|
|
|
extern bool g_bMousePressedR /*= false*/;
|
|
|
|
extern bool g_bMousePressedM /*= false*/;
|
|
|
|
extern bool g_bMousePressedBoth /*= false*/;
|
|
|
|
extern float g_fElpasedTime /*= 0.0f*/;
|
|
|
|
extern D3DCAPS9 g_sCaps;
|
|
|
|
extern bool g_bLoadingFinished /*= false*/;
|
|
|
|
extern HANDLE g_hThreadHandle /*= NULL*/;
|
|
|
|
extern float g_fWheelPos /*= -10.0f*/;
|
|
|
|
extern bool g_bLoadingCanceled /*= false*/;
|
|
|
|
extern IDirect3DTexture9* g_pcTexture /*= NULL*/;
|
|
|
|
|
|
|
|
extern aiMatrix4x4 g_mWorld;
|
|
|
|
extern aiMatrix4x4 g_mWorldRotate;
|
|
|
|
extern aiVector3D g_vRotateSpeed /*= aiVector3D(0.5f,0.5f,0.5f)*/;
|
|
|
|
|
|
|
|
extern aiVector3D g_avLightDirs[1] /* =
|
|
|
|
{ aiVector3D(-0.5f,0.6f,0.2f) ,
|
|
|
|
aiVector3D(-0.5f,0.5f,0.5f)} */;
|
|
|
|
|
|
|
|
|
|
|
|
extern POINT g_mousePos /*= {0,0};*/;
|
|
|
|
extern POINT g_LastmousePos /*= {0,0}*/;
|
|
|
|
extern bool g_bFPSView /*= false*/;
|
|
|
|
extern bool g_bInvert /*= false*/;
|
|
|
|
extern EClickPos g_eClick;
|
|
|
|
extern unsigned int g_iCurrentColor /*= 0*/;
|
|
|
|
|
2008-05-13 23:26:52 +00:00
|
|
|
// NOTE: The light intensity is separated from the color, it can
|
|
|
|
// directly be manipulated using the middle mouse button.
|
|
|
|
// When the user chooses a color from the palette the intensity
|
|
|
|
// is reset to 1.0
|
|
|
|
// index[2] is the ambient color
|
2008-05-05 12:36:31 +00:00
|
|
|
extern float g_fLightIntensity /*=0.0f*/;
|
2008-05-13 23:26:52 +00:00
|
|
|
extern D3DCOLOR g_avLightColors[3];
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
extern RenderOptions g_sOptions;
|
|
|
|
extern Camera g_sCamera;
|
|
|
|
extern AssetHelper *g_pcAsset /*= NULL*/;
|
2008-10-29 17:08:03 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Contains the mask image for the HUD
|
|
|
|
// (used to determine the position of a click)
|
|
|
|
//
|
|
|
|
// The size of the image is identical to the size of the main
|
|
|
|
// HUD texture
|
|
|
|
//
|
|
|
|
extern unsigned char* g_szImageMask /*= NULL*/;
|
2008-07-22 22:52:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
extern float g_fACMR /*= 3.0f*/;
|
|
|
|
extern IDirect3DQuery9* g_piQuery;
|
2009-02-11 20:56:05 +00:00
|
|
|
|
|
|
|
extern bool g_bPlay /*= false*/;
|
|
|
|
|
|
|
|
extern double g_dCurrent;
|
2009-05-09 23:27:48 +00:00
|
|
|
extern float g_smoothAngle /*= 80.f*/;
|
|
|
|
|
|
|
|
extern unsigned int ppsteps,ppstepsdefault;
|
|
|
|
extern bool nopointslines;
|
2008-10-22 15:36:54 +00:00
|
|
|
}
|
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
#endif // !! AV_MAIN_H_INCLUDED
|