fix win32-build for assimp_viewer .

Signed-off-by: Kim Kulling <kim.kulling@googlemail.com>
pull/664/head
Kim Kulling 2015-04-17 20:02:55 +02:00
parent f435712273
commit 76dd9467b2
24 changed files with 4278 additions and 4158 deletions

1
.gitignore vendored
View File

@ -58,3 +58,4 @@ test/gtest/src/gtest-stamp/gtest-gitinfo.txt
test/gtest/src/gtest-stamp/gtest-gitclone-lastrun.txt
Assimp.opensdf
contrib/zlib/CTestTestfile.cmake
ipch/assimp_viewer-44bbbcd1/assimp_viewerd-ccc45335.ipch

View File

@ -51,6 +51,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define INCLUDED_AI_STRING_WORKERS_H
#include "../include/assimp/ai_assert.h"
#include "StringComparison.h"
#include <string.h>
#include <stdint.h>
#include <string>

View File

@ -39,7 +39,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "stdafx.h"
#include "assimp_view.h"
using namespace AssimpView;

View File

@ -43,195 +43,204 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if (!defined AV_ASSET_HELPER_H_INCLUDED)
#define AV_ASSET_HELPER_H_INCLUDED
class SceneAnimator;
#include <d3d9.h>
#include <d3dx9.h>
#include <d3dx9mesh.h>
//-------------------------------------------------------------------------------
/** \brief Class to wrap ASSIMP's asset output structures
*/
//-------------------------------------------------------------------------------
class AssetHelper
{
public:
enum
{
// the original normal set will be used
ORIGINAL = 0x0u,
#include <assimp/scene.h>
// a smoothed normal set will be used
SMOOTH = 0x1u,
namespace AssimpView {
// a hard normal set will be used
HARD = 0x2u,
};
class SceneAnimator;
// default constructor
AssetHelper()
: iNormalSet(ORIGINAL)
{
mAnimator = NULL;
apcMeshes = NULL;
pcScene = NULL;
}
//-------------------------------------------------------------------------------
/** \brief Class to wrap ASSIMP's asset output structures
*/
//-------------------------------------------------------------------------------
class AssetHelper
{
public:
enum
{
// the original normal set will be used
ORIGINAL = 0x0u,
//---------------------------------------------------------------
// default vertex data structure
// (even if tangents, bitangents or normals aren't
// required by the shader they will be committed to the GPU)
//---------------------------------------------------------------
struct Vertex
{
aiVector3D vPosition;
aiVector3D vNormal;
// a smoothed normal set will be used
SMOOTH = 0x1u,
D3DCOLOR dColorDiffuse;
aiVector3D vTangent;
aiVector3D vBitangent;
aiVector2D vTextureUV;
aiVector2D vTextureUV2;
unsigned char mBoneIndices[4];
unsigned char mBoneWeights[4]; // last Weight not used, calculated inside the vertex shader
// a hard normal set will be used
HARD = 0x2u,
};
/** Returns the vertex declaration elements to create a declaration from. */
static D3DVERTEXELEMENT9* GetDeclarationElements()
{
static D3DVERTEXELEMENT9 decl[] =
{
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },
{ 0, 24, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 },
{ 0, 28, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT, 0 },
{ 0, 40, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL, 0 },
{ 0, 52, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
{ 0, 60, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1 },
{ 0, 68, D3DDECLTYPE_UBYTE4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDINDICES, 0 },
{ 0, 72, D3DDECLTYPE_UBYTE4N, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDWEIGHT, 0 },
D3DDECL_END()
};
// default constructor
AssetHelper()
: iNormalSet( ORIGINAL )
{
mAnimator = NULL;
apcMeshes = NULL;
pcScene = NULL;
}
return decl;
}
};
//---------------------------------------------------------------
// default vertex data structure
// (even if tangents, bitangents or normals aren't
// required by the shader they will be committed to the GPU)
//---------------------------------------------------------------
struct Vertex
{
aiVector3D vPosition;
aiVector3D vNormal;
//---------------------------------------------------------------
// FVF vertex structure used for normals
//---------------------------------------------------------------
struct LineVertex
{
aiVector3D vPosition;
DWORD dColorDiffuse;
D3DCOLOR dColorDiffuse;
aiVector3D vTangent;
aiVector3D vBitangent;
aiVector2D vTextureUV;
aiVector2D vTextureUV2;
unsigned char mBoneIndices[ 4 ];
unsigned char mBoneWeights[ 4 ]; // last Weight not used, calculated inside the vertex shader
// retrieves the FVF code of the vertex type
static DWORD GetFVF()
{
return D3DFVF_DIFFUSE | D3DFVF_XYZ;
}
};
/** Returns the vertex declaration elements to create a declaration from. */
static D3DVERTEXELEMENT9* GetDeclarationElements()
{
static D3DVERTEXELEMENT9 decl[] =
{
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },
{ 0, 24, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 },
{ 0, 28, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT, 0 },
{ 0, 40, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL, 0 },
{ 0, 52, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
{ 0, 60, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1 },
{ 0, 68, D3DDECLTYPE_UBYTE4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDINDICES, 0 },
{ 0, 72, D3DDECLTYPE_UBYTE4N, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDWEIGHT, 0 },
D3DDECL_END()
};
//---------------------------------------------------------------
// Helper class to store GPU related resources created for
// a given aiMesh
//---------------------------------------------------------------
class MeshHelper
{
public:
return decl;
}
};
MeshHelper ()
:
piVB (NULL),
piIB (NULL),
piVBNormals (NULL),
piEffect (NULL),
bSharedFX (false),
piDiffuseTexture (NULL),
piSpecularTexture (NULL),
piAmbientTexture (NULL),
piEmissiveTexture (NULL),
piNormalTexture (NULL),
piOpacityTexture (NULL),
piShininessTexture (NULL),
piLightmapTexture (NULL),
twosided (false),
pvOriginalNormals (NULL)
{}
//---------------------------------------------------------------
// FVF vertex structure used for normals
//---------------------------------------------------------------
struct LineVertex
{
aiVector3D vPosition;
DWORD dColorDiffuse;
~MeshHelper ()
{
// NOTE: This is done in DeleteAssetData()
// TODO: Make this a proper d'tor
}
// retrieves the FVF code of the vertex type
static DWORD GetFVF()
{
return D3DFVF_DIFFUSE | D3DFVF_XYZ;
}
};
// shading mode to use. Either Lambert or otherwise phong
// will be used in every case
aiShadingMode eShadingMode;
//---------------------------------------------------------------
// Helper class to store GPU related resources created for
// a given aiMesh
//---------------------------------------------------------------
class MeshHelper
{
public:
// vertex buffer
IDirect3DVertexBuffer9* piVB;
MeshHelper()
:
piVB( NULL ),
piIB( NULL ),
piVBNormals( NULL ),
piEffect( NULL ),
bSharedFX( false ),
piDiffuseTexture( NULL ),
piSpecularTexture( NULL ),
piAmbientTexture( NULL ),
piEmissiveTexture( NULL ),
piNormalTexture( NULL ),
piOpacityTexture( NULL ),
piShininessTexture( NULL ),
piLightmapTexture( NULL ),
twosided( false ),
pvOriginalNormals( NULL )
{}
// index buffer. For partially transparent meshes
// created with dynamic usage to be able to update
// the buffer contents quickly
IDirect3DIndexBuffer9* piIB;
~MeshHelper()
{
// NOTE: This is done in DeleteAssetData()
// TODO: Make this a proper d'tor
}
// vertex buffer to be used to draw vertex normals
// (vertex normals are generated in every case)
IDirect3DVertexBuffer9* piVBNormals;
// shading mode to use. Either Lambert or otherwise phong
// will be used in every case
aiShadingMode eShadingMode;
// shader to be used
ID3DXEffect* piEffect;
bool bSharedFX;
// vertex buffer
IDirect3DVertexBuffer9* piVB;
// material textures
IDirect3DTexture9* piDiffuseTexture;
IDirect3DTexture9* piSpecularTexture;
IDirect3DTexture9* piAmbientTexture;
IDirect3DTexture9* piEmissiveTexture;
IDirect3DTexture9* piNormalTexture;
IDirect3DTexture9* piOpacityTexture;
IDirect3DTexture9* piShininessTexture;
IDirect3DTexture9* piLightmapTexture;
// index buffer. For partially transparent meshes
// created with dynamic usage to be able to update
// the buffer contents quickly
IDirect3DIndexBuffer9* piIB;
// material colors
D3DXVECTOR4 vDiffuseColor;
D3DXVECTOR4 vSpecularColor;
D3DXVECTOR4 vAmbientColor;
D3DXVECTOR4 vEmissiveColor;
// vertex buffer to be used to draw vertex normals
// (vertex normals are generated in every case)
IDirect3DVertexBuffer9* piVBNormals;
// opacity for the material
float fOpacity;
// shader to be used
ID3DXEffect* piEffect;
bool bSharedFX;
// shininess for the material
float fShininess;
// material textures
IDirect3DTexture9* piDiffuseTexture;
IDirect3DTexture9* piSpecularTexture;
IDirect3DTexture9* piAmbientTexture;
IDirect3DTexture9* piEmissiveTexture;
IDirect3DTexture9* piNormalTexture;
IDirect3DTexture9* piOpacityTexture;
IDirect3DTexture9* piShininessTexture;
IDirect3DTexture9* piLightmapTexture;
// strength of the specular highlight
float fSpecularStrength;
// material colors
D3DXVECTOR4 vDiffuseColor;
D3DXVECTOR4 vSpecularColor;
D3DXVECTOR4 vAmbientColor;
D3DXVECTOR4 vEmissiveColor;
// two-sided?
bool twosided;
// opacity for the material
float fOpacity;
// Stores a pointer to the original normal set of the asset
aiVector3D* pvOriginalNormals;
};
// shininess for the material
float fShininess;
// One instance per aiMesh in the globally loaded asset
MeshHelper** apcMeshes;
// strength of the specular highlight
float fSpecularStrength;
// Scene wrapper instance
aiScene* pcScene;
// two-sided?
bool twosided;
// Animation player to animate the scene if necessary
SceneAnimator* mAnimator;
// Stores a pointer to the original normal set of the asset
aiVector3D* pvOriginalNormals;
};
// Specifies the normal set to be used
unsigned int iNormalSet;
// One instance per aiMesh in the globally loaded asset
MeshHelper** apcMeshes;
// ------------------------------------------------------------------
// set the normal set to be used
void SetNormalSet(unsigned int iSet);
// Scene wrapper instance
aiScene* pcScene;
// ------------------------------------------------------------------
// flip all normal vectors
void FlipNormals();
void FlipNormalsInt();
};
// Animation player to animate the scene if necessary
SceneAnimator* mAnimator;
// Specifies the normal set to be used
unsigned int iNormalSet;
// ------------------------------------------------------------------
// set the normal set to be used
void SetNormalSet( unsigned int iSet );
// ------------------------------------------------------------------
// flip all normal vectors
void FlipNormals();
void FlipNormalsInt();
};
}
#endif // !! IG

View File

@ -39,12 +39,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "stdafx.h"
#include "assimp_view.h"
namespace AssimpView {
extern std::string g_szSkyboxShader;
// From: U3D build 1256 (src\kernel\graphic\scenegraph\SkyBox.cpp)
// ------------------------------------------------------------------------------

View File

@ -38,91 +38,91 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#pragma once
#if (!defined AV_BACKGROUND_H_INCLUDED)
#define AV_BACKGROUND_H_INCLUDED
namespace AssimpView
{
class CBackgroundPainter
{
CBackgroundPainter()
:
clrColor( D3DCOLOR_ARGB( 0xFF, 100, 100, 100 ) ),
pcTexture( NULL ),
piSkyBoxEffect( NULL ),
eMode( SIMPLE_COLOR )
{}
class CBackgroundPainter
{
CBackgroundPainter()
:
clrColor(D3DCOLOR_ARGB(0xFF,100,100,100)),
pcTexture(NULL),
piSkyBoxEffect(NULL),
eMode(SIMPLE_COLOR)
{}
public:
public:
// Supported background draw modi
enum MODE { SIMPLE_COLOR, TEXTURE_2D, TEXTURE_CUBE };
// Supported background draw modi
enum MODE {SIMPLE_COLOR, TEXTURE_2D, TEXTURE_CUBE};
// Singleton accessors
static CBackgroundPainter s_cInstance;
inline static CBackgroundPainter& Instance()
{
return s_cInstance;
}
// Singleton accessors
static CBackgroundPainter s_cInstance;
inline static CBackgroundPainter& Instance ()
{
return s_cInstance;
}
// set the current background color
// (this removes any textures loaded)
void SetColor( D3DCOLOR p_clrNew );
// set the current background color
// (this removes any textures loaded)
void SetColor (D3DCOLOR p_clrNew);
// Setup a cubemap/a 2d texture as background
void SetCubeMapBG( const char* p_szPath );
void SetTextureBG( const char* p_szPath );
// Setup a cubemap/a 2d texture as background
void SetCubeMapBG (const char* p_szPath);
void SetTextureBG (const char* p_szPath);
// Called by the render loop
void OnPreRender();
void OnPostRender();
// Called by the render loop
void OnPreRender();
void OnPostRender();
// Release any native resources associated with the instance
void ReleaseNativeResource();
// Release any native resources associated with the instance
void ReleaseNativeResource();
// Recreate any native resources associated with the instance
void RecreateNativeResource();
// Recreate any native resources associated with the instance
void RecreateNativeResource();
// Rotate the skybox
void RotateSB( const aiMatrix4x4* pm );
// Rotate the skybox
void RotateSB(const aiMatrix4x4* pm);
// Reset the state of the skybox
void ResetSB();
// Reset the state of the skybox
void ResetSB();
inline MODE GetMode() const
{
return this->eMode;
}
inline MODE GetMode() const
{
return this->eMode;
}
inline IDirect3DBaseTexture9* GetTexture()
{
return this->pcTexture;
}
inline IDirect3DBaseTexture9* GetTexture()
{
return this->pcTexture;
}
inline ID3DXBaseEffect* GetEffect()
{
return this->piSkyBoxEffect;
}
inline ID3DXBaseEffect* GetEffect()
{
return this->piSkyBoxEffect;
}
private:
private:
void RemoveSBDeps();
void RemoveSBDeps();
// current background color
D3DCOLOR clrColor;
// current background color
D3DCOLOR clrColor;
// current background texture
IDirect3DBaseTexture9* pcTexture;
ID3DXEffect* piSkyBoxEffect;
// current background texture
IDirect3DBaseTexture9* pcTexture;
ID3DXEffect* piSkyBoxEffect;
// current background mode
MODE eMode;
// current background mode
MODE eMode;
// path to the texture
std::string szPath;
// path to the texture
std::string szPath;
// transformation matrix for the skybox
aiMatrix4x4 mMatrix;
};
// transformation matrix for the skybox
aiMatrix4x4 mMatrix;
};
#endif // !! AV_BACKGROUND_H_INCLUDED
}

View File

@ -38,13 +38,16 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "stdafx.h"
#include "assimp_view.h"
#include "AnimEvaluator.h"
#include "SceneAnimator.h"
namespace AssimpView {
using namespace Assimp;
extern std::string g_szCheckerBackgroundShader;
struct SVertex
{
float x,y,z,w,u,v;
@ -2240,7 +2243,7 @@ int CDisplay::RenderTextureView()
const float ny = (float)sRect.bottom;
const float x = (float)sDesc.Width;
const float y = (float)sDesc.Height;
float f = std::min((nx-30) / x,(ny-30) / y) * (m_fTextureZoom/1000.0f);
float f = min((nx-30) / x,(ny-30) / y) * (m_fTextureZoom/1000.0f);
float fHalfX = (nx - (f * x)) / 2.0f;
float fHalfY = (ny - (f * y)) / 2.0f;

View File

@ -42,6 +42,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if (!defined AV_DISPLAY_H_INCLUDED)
#define AV_DISPLAY_H_INCLUDE
#include <windows.h>
#include <shellapi.h>
#include <commctrl.h>
// see CDisplay::m_aiImageList
#define AI_VIEW_IMGLIST_NODE 0x0
#define AI_VIEW_IMGLIST_MATERIAL 0x1
@ -49,486 +53,490 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AI_VIEW_IMGLIST_TEXTURE_INVALID 0x3
#define AI_VIEW_IMGLIST_MODEL 0x4
//-------------------------------------------------------------------------------
/* Corresponds to the "Display" combobox in the UI
*/
//-------------------------------------------------------------------------------
class CDisplay
{
private:
namespace AssimpView
{
// helper class
struct Info
{
Info( D3DXVECTOR4* p1,
AssetHelper::MeshHelper* p2,
const char* p3)
: pclrColor(p1),pMesh(p2),szShaderParam(p3) {}
//-------------------------------------------------------------------------------
/* Corresponds to the "Display" combobox in the UI
*/
//-------------------------------------------------------------------------------
class CDisplay
{
private:
D3DXVECTOR4* pclrColor;
AssetHelper::MeshHelper* pMesh;
const char* szShaderParam;
};
// helper class
struct Info
{
Info( D3DXVECTOR4* p1,
AssetHelper::MeshHelper* p2,
const char* p3 )
: pclrColor( p1 ), pMesh( p2 ), szShaderParam( p3 ) {}
// default constructor
CDisplay()
: m_iViewMode(VIEWMODE_FULL),
m_pcCurrentTexture(NULL),
m_pcCurrentNode(NULL),
m_pcCurrentMaterial(NULL),
m_hImageList(NULL),
m_hRoot(NULL),
m_fTextureZoom(1000.0f)
{
this->m_aiImageList[0] = 0;
this->m_aiImageList[1] = 1;
this->m_aiImageList[2] = 2;
this->m_aiImageList[3] = 3;
this->m_aiImageList[4] = 4;
D3DXVECTOR4* pclrColor;
AssetHelper::MeshHelper* pMesh;
const char* szShaderParam;
};
this->m_avCheckerColors[0].x = this->m_avCheckerColors[0].y = this->m_avCheckerColors[0].z = 0.4f;
this->m_avCheckerColors[1].x = this->m_avCheckerColors[1].y = this->m_avCheckerColors[1].z = 0.6f;
}
// default constructor
CDisplay()
: m_iViewMode( VIEWMODE_FULL ),
m_pcCurrentTexture( NULL ),
m_pcCurrentNode( NULL ),
m_pcCurrentMaterial( NULL ),
m_hImageList( NULL ),
m_hRoot( NULL ),
m_fTextureZoom( 1000.0f )
{
this->m_aiImageList[ 0 ] = 0;
this->m_aiImageList[ 1 ] = 1;
this->m_aiImageList[ 2 ] = 2;
this->m_aiImageList[ 3 ] = 3;
this->m_aiImageList[ 4 ] = 4;
public:
this->m_avCheckerColors[ 0 ].x = this->m_avCheckerColors[ 0 ].y = this->m_avCheckerColors[ 0 ].z = 0.4f;
this->m_avCheckerColors[ 1 ].x = this->m_avCheckerColors[ 1 ].y = this->m_avCheckerColors[ 1 ].z = 0.6f;
}
public:
//------------------------------------------------------------------
enum
{
// the full model is displayed
VIEWMODE_FULL,
//------------------------------------------------------------------
enum
{
// the full model is displayed
VIEWMODE_FULL,
// a material is displayed on a simple spjere as model
VIEWMODE_MATERIAL,
// a material is displayed on a simple spjere as model
VIEWMODE_MATERIAL,
// a texture with an UV set mapped on it is displayed
VIEWMODE_TEXTURE,
// a texture with an UV set mapped on it is displayed
VIEWMODE_TEXTURE,
// a single node in the scenegraph is displayed
VIEWMODE_NODE,
};
// a single node in the scenegraph is displayed
VIEWMODE_NODE,
};
//------------------------------------------------------------------
// represents a texture in the tree view
struct TextureInfo
{
// texture info
IDirect3DTexture9** piTexture;
//------------------------------------------------------------------
// represents a texture in the tree view
struct TextureInfo
{
// texture info
IDirect3DTexture9** piTexture;
// Blend factor of the texture
float fBlend;
// Blend factor of the texture
float fBlend;
// blend operation for the texture
aiTextureOp eOp;
// blend operation for the texture
aiTextureOp eOp;
// UV index for the texture
unsigned int iUV;
// UV index for the texture
unsigned int iUV;
// Associated tree item
HTREEITEM hTreeItem;
// Associated tree item
HTREEITEM hTreeItem;
// Original path to the texture
std::string szPath;
// Original path to the texture
std::string szPath;
// index of the corresponding material
unsigned int iMatIndex;
// index of the corresponding material
unsigned int iMatIndex;
// type of the texture
unsigned int iType;
};
// type of the texture
unsigned int iType;
};
//------------------------------------------------------------------
// represents a node in the tree view
struct NodeInfo
{
// node object
aiNode* psNode;
//------------------------------------------------------------------
// represents a node in the tree view
struct NodeInfo
{
// node object
aiNode* psNode;
// corresponding tree view item
HTREEITEM hTreeItem;
};
// corresponding tree view item
HTREEITEM hTreeItem;
};
//------------------------------------------------------------------
// represents a mesh in the tree view
struct MeshInfo
{
// the mesh object
aiMesh* psMesh;
//------------------------------------------------------------------
// represents a mesh in the tree view
struct MeshInfo
{
// the mesh object
aiMesh* psMesh;
// corresponding tree view item
HTREEITEM hTreeItem;
};
// corresponding tree view item
HTREEITEM hTreeItem;
};
//------------------------------------------------------------------
// represents a material in the tree view
struct MaterialInfo
{
// material index
unsigned int iIndex;
//------------------------------------------------------------------
// represents a material in the tree view
struct MaterialInfo
{
// material index
unsigned int iIndex;
// material object
aiMaterial* psMaterial;
// material object
aiMaterial* psMaterial;
// ID3DXEffect interface
ID3DXEffect* piEffect;
// ID3DXEffect interface
ID3DXEffect* piEffect;
// corresponding tree view item
HTREEITEM hTreeItem;
};
// corresponding tree view item
HTREEITEM hTreeItem;
};
//------------------------------------------------------------------
// Singleton accessors
static CDisplay s_cInstance;
inline static CDisplay& Instance ()
{
return s_cInstance;
}
//------------------------------------------------------------------
// Singleton accessors
static CDisplay s_cInstance;
inline static CDisplay& Instance()
{
return s_cInstance;
}
//------------------------------------------------------------------
// Called during the render loop. Renders the scene (including the
// HUD etc) in the current view mode
int OnRender();
//------------------------------------------------------------------
// Called during the render loop. Renders the scene (including the
// HUD etc) in the current view mode
int OnRender();
//------------------------------------------------------------------
// called when the user selects another item in the "Display" tree
// view the method determines the new view mode and performs all
// required operations
// \param p_hTreeItem Selected tree view item
int OnSetup(HTREEITEM p_hTreeItem);
//------------------------------------------------------------------
// called when the user selects another item in the "Display" tree
// view the method determines the new view mode and performs all
// required operations
// \param p_hTreeItem Selected tree view item
int OnSetup( HTREEITEM p_hTreeItem );
//------------------------------------------------------------------
// Variant 1: Render the full scene with the asset
int RenderFullScene();
//------------------------------------------------------------------
// Variant 1: Render the full scene with the asset
int RenderFullScene();
#if 0
//------------------------------------------------------------------
// Variant 2: Render only a part of the scene. One node to
// be exact
int RenderScenePart();
//------------------------------------------------------------------
// Variant 2: Render only a part of the scene. One node to
// be exact
int RenderScenePart();
#endif
//------------------------------------------------------------------
// Variant 3: Render a large sphere and map a given material on it
int RenderMaterialView();
//------------------------------------------------------------------
// Variant 3: Render a large sphere and map a given material on it
int RenderMaterialView();
//------------------------------------------------------------------
// Variant 4: Render a flat plane, map a texture on it and
// display the UV wire on it
int RenderTextureView();
//------------------------------------------------------------------
// Variant 4: Render a flat plane, map a texture on it and
// display the UV wire on it
int RenderTextureView();
//------------------------------------------------------------------
// Fill the UI combobox with a list of all supported view modi
//
// The display modes are added in order
int FillDisplayList(void);
//------------------------------------------------------------------
// Fill the UI combobox with a list of all supported view modi
//
// The display modes are added in order
int FillDisplayList( void );
//------------------------------------------------------------------
// Add a material and all sub textures to the display mode list
// hRoot - Handle to the root of the tree view
// iIndex - Material index
int AddMaterialToDisplayList(HTREEITEM hRoot,
unsigned int iIndex);
//------------------------------------------------------------------
// Add a material and all sub textures to the display mode list
// hRoot - Handle to the root of the tree view
// iIndex - Material index
int AddMaterialToDisplayList( HTREEITEM hRoot,
unsigned int iIndex );
//------------------------------------------------------------------
// Add a texture to the display list
// pcMat - material containing the texture
// hTexture - Handle to the material tree item
// szPath - Path to the texture
// iUVIndex - UV index to be used for the texture
// fBlendFactor - Blend factor to be used for the texture
// eTextureOp - texture operation to be used for the texture
int AddTextureToDisplayList(unsigned int iType,
unsigned int iIndex,
const aiString* szPath,
HTREEITEM hFX,
unsigned int iUVIndex = 0,
const float fBlendFactor = 0.0f,
aiTextureOp eTextureOp = aiTextureOp_Multiply,
unsigned int iMesh = 0);
//------------------------------------------------------------------
// Add a texture to the display list
// pcMat - material containing the texture
// hTexture - Handle to the material tree item
// szPath - Path to the texture
// iUVIndex - UV index to be used for the texture
// fBlendFactor - Blend factor to be used for the texture
// eTextureOp - texture operation to be used for the texture
int AddTextureToDisplayList( unsigned int iType,
unsigned int iIndex,
const aiString* szPath,
HTREEITEM hFX,
unsigned int iUVIndex = 0,
const float fBlendFactor = 0.0f,
aiTextureOp eTextureOp = aiTextureOp_Multiply,
unsigned int iMesh = 0 );
//------------------------------------------------------------------
// Add a node to the display list
// Recusrivly adds all subnodes as well
// iIndex - Index of the node in the parent's child list
// iDepth - Current depth of the node
// pcNode - Node object
// hRoot - Parent tree view node
int AddNodeToDisplayList(
unsigned int iIndex,
unsigned int iDepth,
aiNode* pcNode,
HTREEITEM hRoot);
//------------------------------------------------------------------
// Add a node to the display list
// Recusrivly adds all subnodes as well
// iIndex - Index of the node in the parent's child list
// iDepth - Current depth of the node
// pcNode - Node object
// hRoot - Parent tree view node
int AddNodeToDisplayList(
unsigned int iIndex,
unsigned int iDepth,
aiNode* pcNode,
HTREEITEM hRoot );
//------------------------------------------------------------------
// Add a mesh to the display list
// iIndex - Index of the mesh in the scene's mesh list
// hRoot - Parent tree view node
int AddMeshToDisplayList(
unsigned int iIndex,
HTREEITEM hRoot);
//------------------------------------------------------------------
// Add a mesh to the display list
// iIndex - Index of the mesh in the scene's mesh list
// hRoot - Parent tree view node
int AddMeshToDisplayList(
unsigned int iIndex,
HTREEITEM hRoot );
//------------------------------------------------------------------
// Load the image list for the tree view item
int LoadImageList(void);
//------------------------------------------------------------------
// Load the image list for the tree view item
int LoadImageList( void );
//------------------------------------------------------------------
// Expand all nodes in the tree
int ExpandTree();
//------------------------------------------------------------------
// Expand all nodes in the tree
int ExpandTree();
//------------------------------------------------------------------
// Fill the UI combobox with a list of all supported animations
// The animations are added in order
int FillAnimList(void);
//------------------------------------------------------------------
// Fill the UI combobox with a list of all supported animations
// The animations are added in order
int FillAnimList( void );
//------------------------------------------------------------------
// Clear the combox box containing the list of animations
int ClearAnimList(void);
//------------------------------------------------------------------
// Clear the combox box containing the list of animations
int ClearAnimList( void );
//------------------------------------------------------------------
// Clear the combox box containing the list of scenegraph items
int ClearDisplayList(void);
//------------------------------------------------------------------
// Clear the combox box containing the list of scenegraph items
int ClearDisplayList( void );
//------------------------------------------------------------------
// Fill in the default statistics
int FillDefaultStatistics(void);
//------------------------------------------------------------------
// Fill in the default statistics
int FillDefaultStatistics( void );
//------------------------------------------------------------------
// Called by LoadAsset()
// reset the class instance to the default values
int Reset(void);
//------------------------------------------------------------------
// Called by LoadAsset()
// reset the class instance to the default values
int Reset( void );
//------------------------------------------------------------------
// Replace the texture that is current selected with
// a new texture
int ReplaceCurrentTexture(const char* szPath);
//------------------------------------------------------------------
// Replace the texture that is current selected with
// a new texture
int ReplaceCurrentTexture( const char* szPath );
//------------------------------------------------------------------
// Display the context menu (if there) for the specified tree item
// hItem Valid tree view item handle
int ShowTreeViewContextMenu(HTREEITEM hItem);
//------------------------------------------------------------------
// Display the context menu (if there) for the specified tree item
// hItem Valid tree view item handle
int ShowTreeViewContextMenu( HTREEITEM hItem );
//------------------------------------------------------------------
// Event handling for pop-up menus displayed by th tree view
int HandleTreeViewPopup(WPARAM wParam,LPARAM lParam);
//------------------------------------------------------------------
// Event handling for pop-up menus displayed by th tree view
int HandleTreeViewPopup( WPARAM wParam, LPARAM lParam );
//------------------------------------------------------------------
// Enable animation-related parts of the UI
int EnableAnimTools(BOOL hm) ;
//------------------------------------------------------------------
// Enable animation-related parts of the UI
int EnableAnimTools( BOOL hm );
//------------------------------------------------------------------
// setter for m_iViewMode
inline void SetViewMode(unsigned int p_iNew)
{
this->m_iViewMode = p_iNew;
}
//------------------------------------------------------------------
// setter for m_iViewMode
inline void SetViewMode( unsigned int p_iNew )
{
this->m_iViewMode = p_iNew;
}
//------------------------------------------------------------------
// getter for m_iViewMode
inline unsigned int GetViewMode()
{
return m_iViewMode;
}
//------------------------------------------------------------------
// getter for m_iViewMode
inline unsigned int GetViewMode()
{
return m_iViewMode;
}
//------------------------------------------------------------------
// change the texture view's zoom factor
inline void SetTextureViewZoom(float f)
{
// FIX: Removed log(), seems to make more problems than it fixes
this->m_fTextureZoom += f* 15;
if (this->m_fTextureZoom < 0.05f)this->m_fTextureZoom = 0.05f;
}
//------------------------------------------------------------------
// change the texture view's zoom factor
inline void SetTextureViewZoom( float f )
{
// FIX: Removed log(), seems to make more problems than it fixes
this->m_fTextureZoom += f * 15;
if( this->m_fTextureZoom < 0.05f )this->m_fTextureZoom = 0.05f;
}
//------------------------------------------------------------------
// change the texture view's offset on the x axis
inline void SetTextureViewOffsetX(float f)
{
this->m_vTextureOffset.x += f;
}
//------------------------------------------------------------------
// change the texture view's offset on the x axis
inline void SetTextureViewOffsetX( float f )
{
this->m_vTextureOffset.x += f;
}
//------------------------------------------------------------------
// change the texture view's offset on the y axis
inline void SetTextureViewOffsetY(float f)
{
this->m_vTextureOffset.y += f;
}
//------------------------------------------------------------------
// change the texture view's offset on the y axis
inline void SetTextureViewOffsetY( float f )
{
this->m_vTextureOffset.y += f;
}
//------------------------------------------------------------------
// add a new texture to the list
inline void AddTexture(const TextureInfo& info)
{
this->m_asTextures.push_back(info);
}
//------------------------------------------------------------------
// add a new texture to the list
inline void AddTexture( const TextureInfo& info )
{
this->m_asTextures.push_back( info );
}
//------------------------------------------------------------------
// add a new node to the list
inline void AddNode(const NodeInfo& info)
{
this->m_asNodes.push_back(info);
}
//------------------------------------------------------------------
// add a new node to the list
inline void AddNode( const NodeInfo& info )
{
this->m_asNodes.push_back( info );
}
//------------------------------------------------------------------
// add a new mesh to the list
inline void AddMesh(const MeshInfo& info)
{
this->m_asMeshes.push_back(info);
}
//------------------------------------------------------------------
// add a new mesh to the list
inline void AddMesh( const MeshInfo& info )
{
this->m_asMeshes.push_back( info );
}
//------------------------------------------------------------------
// add a new material to the list
inline void AddMaterial(const MaterialInfo& info)
{
this->m_asMaterials.push_back(info);
}
//------------------------------------------------------------------
// add a new material to the list
inline void AddMaterial( const MaterialInfo& info )
{
this->m_asMaterials.push_back( info );
}
//------------------------------------------------------------------
// set the primary color of the checker pattern background
inline void SetFirstCheckerColor(D3DXVECTOR4 c)
{
this->m_avCheckerColors[0] = c;
}
//------------------------------------------------------------------
// set the primary color of the checker pattern background
inline void SetFirstCheckerColor( D3DXVECTOR4 c )
{
this->m_avCheckerColors[ 0 ] = c;
}
//------------------------------------------------------------------
// set the secondary color of the checker pattern background
inline void SetSecondCheckerColor(D3DXVECTOR4 c)
{
this->m_avCheckerColors[1] = c;
}
//------------------------------------------------------------------
// set the secondary color of the checker pattern background
inline void SetSecondCheckerColor( D3DXVECTOR4 c )
{
this->m_avCheckerColors[ 1 ] = c;
}
//------------------------------------------------------------------
// get the primary color of the checker pattern background
inline const D3DXVECTOR4* GetFirstCheckerColor() const
{
return &this->m_avCheckerColors[0];
}
//------------------------------------------------------------------
// get the primary color of the checker pattern background
inline const D3DXVECTOR4* GetFirstCheckerColor() const
{
return &this->m_avCheckerColors[ 0 ];
}
//------------------------------------------------------------------
// get the secondary color of the checker pattern background
inline const D3DXVECTOR4* GetSecondCheckerColor() const
{
return &this->m_avCheckerColors[1];
}
//------------------------------------------------------------------
// get the secondary color of the checker pattern background
inline const D3DXVECTOR4* GetSecondCheckerColor() const
{
return &this->m_avCheckerColors[ 1 ];
}
private:
private:
//------------------------------------------------------------------
// Render a screen-filling square using the checker pattern shader
int RenderPatternBG();
//------------------------------------------------------------------
// Render a screen-filling square using the checker pattern shader
int RenderPatternBG();
//------------------------------------------------------------------
// Render a given node in the scenegraph
// piNode Node to be rendered
// piMatrix Current transformation matrix
// bAlpha Render alpha or opaque objects only?
int RenderNode (aiNode* piNode,const aiMatrix4x4& piMatrix,
bool bAlpha = false);
//------------------------------------------------------------------
// Render a given node in the scenegraph
// piNode Node to be rendered
// piMatrix Current transformation matrix
// bAlpha Render alpha or opaque objects only?
int RenderNode( aiNode* piNode, const aiMatrix4x4& piMatrix,
bool bAlpha = false );
//------------------------------------------------------------------
// Setup the camera for the stereo view rendering mode
int SetupStereoView();
//------------------------------------------------------------------
// Setup the camera for the stereo view rendering mode
int SetupStereoView();
//------------------------------------------------------------------
// Render the second view (for the right eye) in stereo mod
// m - World matrix
int RenderStereoView(const aiMatrix4x4& m);
//------------------------------------------------------------------
// Render the second view (for the right eye) in stereo mod
// m - World matrix
int RenderStereoView( const aiMatrix4x4& m );
//------------------------------------------------------------------
// Handle user input
int HandleInput();
//------------------------------------------------------------------
// Handle user input
int HandleInput();
//------------------------------------------------------------------
// Handle user input for the texture viewer
int HandleInputTextureView();
//------------------------------------------------------------------
// Handle user input for the texture viewer
int HandleInputTextureView();
//------------------------------------------------------------------
// Handle user input if no asset is loaded
int HandleInputEmptyScene();
//------------------------------------------------------------------
// Handle user input if no asset is loaded
int HandleInputEmptyScene();
//------------------------------------------------------------------
// Draw the HUD (call only if FPS mode isn't active)
int DrawHUD();
//------------------------------------------------------------------
// Draw the HUD (call only if FPS mode isn't active)
int DrawHUD();
//------------------------------------------------------------------
// Used by OnSetup().
// Do everything necessary to switch to texture view mode
int OnSetupTextureView(TextureInfo* pcNew);
//------------------------------------------------------------------
// Used by OnSetup().
// Do everything necessary to switch to texture view mode
int OnSetupTextureView( TextureInfo* pcNew );
//------------------------------------------------------------------
// Used by OnSetup().
// Do everything necessary to switch to material view mode
int OnSetupMaterialView(MaterialInfo* pcNew);
//------------------------------------------------------------------
// Used by OnSetup().
// Do everything necessary to switch to material view mode
int OnSetupMaterialView( MaterialInfo* pcNew );
//------------------------------------------------------------------
// Used by OnSetup().
// Do everything necessary to switch to node view mode
int OnSetupNodeView(NodeInfo* pcNew);
//------------------------------------------------------------------
// Used by OnSetup().
// Do everything necessary to switch to node view mode
int OnSetupNodeView( NodeInfo* pcNew );
//------------------------------------------------------------------
// Used by OnSetup().
// Do everything necessary to switch back to normal view mode
int OnSetupNormalView();
//------------------------------------------------------------------
// Used by OnSetup().
// Do everything necessary to switch back to normal view mode
int OnSetupNormalView();
//------------------------------------------------------------------
// Used by HandleTreeViewPopup().
int HandleTreeViewPopup2(WPARAM wParam,LPARAM lParam);
//------------------------------------------------------------------
// Used by HandleTreeViewPopup().
int HandleTreeViewPopup2( WPARAM wParam, LPARAM lParam );
//------------------------------------------------------------------
// Render skeleton
int RenderSkeleton (aiNode* piNode,const aiMatrix4x4& piMatrix,
const aiMatrix4x4& parent);
//------------------------------------------------------------------
// Render skeleton
int RenderSkeleton( aiNode* piNode, const aiMatrix4x4& piMatrix,
const aiMatrix4x4& parent );
private:
// view mode
unsigned int m_iViewMode;
private:
// List of all textures in the display CB
std::vector<TextureInfo> m_asTextures;
// view mode
unsigned int m_iViewMode;
// current texture or NULL if no texture is active
TextureInfo* m_pcCurrentTexture;
// List of all textures in the display CB
std::vector<TextureInfo> m_asTextures;
// List of all node in the display CB
std::vector<NodeInfo> m_asNodes;
// current texture or NULL if no texture is active
TextureInfo* m_pcCurrentTexture;
// List of all node in the display CB
std::vector<MeshInfo> m_asMeshes;
// List of all node in the display CB
std::vector<NodeInfo> m_asNodes;
// current Node or NULL if no Node is active
NodeInfo* m_pcCurrentNode;
// List of all node in the display CB
std::vector<MeshInfo> m_asMeshes;
// List of all materials in the display CB
std::vector<MaterialInfo> m_asMaterials;
// current Node or NULL if no Node is active
NodeInfo* m_pcCurrentNode;
// current material or NULL if no material is active
MaterialInfo* m_pcCurrentMaterial;
// List of all materials in the display CB
std::vector<MaterialInfo> m_asMaterials;
// indices into the image list of the "display" tree view control
unsigned int m_aiImageList[5]; /* = {0,1,2,3,4};*/
// current material or NULL if no material is active
MaterialInfo* m_pcCurrentMaterial;
// Image list
HIMAGELIST m_hImageList;
// indices into the image list of the "display" tree view control
unsigned int m_aiImageList[ 5 ]; /* = {0,1,2,3,4};*/
// Root node of the tree, "Model"
HTREEITEM m_hRoot;
// Image list
HIMAGELIST m_hImageList;
// Current zoom factor of the texture viewer
float m_fTextureZoom;
// Root node of the tree, "Model"
HTREEITEM m_hRoot;
// Current offset (in pixels) of the texture viewer
aiVector2D m_vTextureOffset;
// Current zoom factor of the texture viewer
float m_fTextureZoom;
// Colors used to draw the checker pattern (for the
// texture viewer as background )
D3DXVECTOR4 m_avCheckerColors[2];
// Current offset (in pixels) of the texture viewer
aiVector2D m_vTextureOffset;
// View projection matrix
aiMatrix4x4 mViewProjection;
aiVector3D vPos;
};
// Colors used to draw the checker pattern (for the
// texture viewer as background )
D3DXVECTOR4 m_avCheckerColors[ 2 ];
// View projection matrix
aiMatrix4x4 mViewProjection;
aiVector3D vPos;
};
}
#endif // AV_DISPLAY_H_INCLUDE

View File

@ -39,14 +39,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "stdafx.h"
#include "assimp_view.h"
#include "richedit.h"
namespace AssimpView {
//-------------------------------------------------------------------------------
// Message procedure for the help dialog
//-------------------------------------------------------------------------------

View File

@ -39,10 +39,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "stdafx.h"
#include "assimp_view.h"
namespace AssimpView {
//-------------------------------------------------------------------------------

View File

@ -39,14 +39,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "stdafx.h"
#include "assimp_view.h"
namespace AssimpView {
/* extern */ CLogDisplay CLogDisplay::s_cInstance;
CLogDisplay CLogDisplay::s_cInstance;
//-------------------------------------------------------------------------------
void CLogDisplay::AddEntry(const std::string& szText,

View File

@ -38,59 +38,62 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#pragma once
#if (!defined AV_LOG_DISPLAY_H_INCLUDED)
#define AV_LOG_DISPLAY_H_INCLUDE
#include <list>
//-------------------------------------------------------------------------------
/** \brief Class to display log strings in the upper right corner of the view
*/
//-------------------------------------------------------------------------------
class CLogDisplay
{
private:
namespace AssimpView
{
CLogDisplay() {}
//-------------------------------------------------------------------------------
/** \brief Class to display log strings in the upper right corner of the view
*/
//-------------------------------------------------------------------------------
class CLogDisplay
{
private:
public:
CLogDisplay() {}
// data structure for an entry in the log queue
struct SEntry
{
SEntry ()
:
clrColor(D3DCOLOR_ARGB(0xFF,0xFF,0xFF,0x00)), dwStartTicks(0)
{}
public:
std::string szText;
D3DCOLOR clrColor;
DWORD dwStartTicks;
};
// data structure for an entry in the log queue
struct SEntry
{
SEntry()
:
clrColor( D3DCOLOR_ARGB( 0xFF, 0xFF, 0xFF, 0x00 ) ), dwStartTicks( 0 )
{}
// Singleton accessors
static CLogDisplay s_cInstance;
inline static CLogDisplay& Instance ()
{
return s_cInstance;
}
std::string szText;
D3DCOLOR clrColor;
DWORD dwStartTicks;
};
// Add an entry to the log queue
void AddEntry(const std::string& szText,
const D3DCOLOR clrColor = D3DCOLOR_ARGB(0xFF,0xFF,0xFF,0x00));
// Singleton accessors
static CLogDisplay s_cInstance;
inline static CLogDisplay& Instance()
{
return s_cInstance;
}
// Release any native resources associated with the instance
void ReleaseNativeResource();
// Add an entry to the log queue
void AddEntry( const std::string& szText,
const D3DCOLOR clrColor = D3DCOLOR_ARGB( 0xFF, 0xFF, 0xFF, 0x00 ) );
// Recreate any native resources associated with the instance
void RecreateNativeResource();
// Release any native resources associated with the instance
void ReleaseNativeResource();
// Called during the render loop
void OnRender();
// Recreate any native resources associated with the instance
void RecreateNativeResource();
private:
// Called during the render loop
void OnRender();
std::list<SEntry> asEntries;
ID3DXFont* piFont;
};
private:
#endif // AV_LOG_DISPLAY_H_INCLUDE
std::list<SEntry> asEntries;
ID3DXFont* piFont;
};
}

View File

@ -39,13 +39,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "stdafx.h"
#include "assimp_view.h"
#include "richedit.h"
namespace AssimpView {
/* extern */ CLogWindow CLogWindow::s_cInstance;
CLogWindow CLogWindow::s_cInstance;
extern HKEY g_hRegistry;
// header for the RTF log file

View File

@ -42,87 +42,92 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if (!defined AV_LOG_WINDOW_H_INCLUDED)
#define AV_LOG_WINDOW_H_INCLUDE
//-------------------------------------------------------------------------------
/** \brief Subclass of Assimp::LogStream used to add all log messages to the
* log window.
*/
//-------------------------------------------------------------------------------
class CMyLogStream : public Assimp::LogStream
namespace AssimpView
{
public:
/** @brief Implementation of the abstract method */
void write(const char* message);
};
//-------------------------------------------------------------------------------
/** \brief Class to display log strings in a separate window
*/
//-------------------------------------------------------------------------------
class CLogWindow
{
private:
friend class CMyLogStream;
friend INT_PTR CALLBACK LogDialogProc(HWND hwndDlg,UINT uMsg,
WPARAM wParam,LPARAM lParam);
CLogWindow() : hwnd(NULL), bIsVisible(false), bUpdate(true) {}
public:
//-------------------------------------------------------------------------------
/** \brief Subclass of Assimp::LogStream used to add all log messages to the
* log window.
*/
//-------------------------------------------------------------------------------
class CMyLogStream : public Assimp::LogStream
{
public:
/** @brief Implementation of the abstract method */
void write( const char* message );
};
// Singleton accessors
static CLogWindow s_cInstance;
inline static CLogWindow& Instance ()
{
return s_cInstance;
}
//-------------------------------------------------------------------------------
/** \brief Class to display log strings in a separate window
*/
//-------------------------------------------------------------------------------
class CLogWindow
{
private:
// initializes the log window
void Init ();
friend class CMyLogStream;
friend INT_PTR CALLBACK LogDialogProc( HWND hwndDlg, UINT uMsg,
WPARAM wParam, LPARAM lParam );
// Shows the log window
void Show();
CLogWindow() : hwnd( NULL ), bIsVisible( false ), bUpdate( true ) {}
// Clears the log window
void Clear();
// Save the log window to an user-defined file
void Save();
// write a line to the log window
void WriteLine(const char* message);
// Set the bUpdate member
inline void SetAutoUpdate(bool b)
{
this->bUpdate = b;
}
// updates the log file
void Update();
private:
// Window handle
HWND hwnd;
// current text of the window (contains RTF tags)
std::string szText;
std::string szPlainText;
// is the log window currently visible?
bool bIsVisible;
// Specified whether each new log message updates the log automatically
bool bUpdate;
public:
public:
// associated log stream
CMyLogStream* pcStream;
};
// Singleton accessors
static CLogWindow s_cInstance;
inline static CLogWindow& Instance()
{
return s_cInstance;
}
// initializes the log window
void Init();
// Shows the log window
void Show();
// Clears the log window
void Clear();
// Save the log window to an user-defined file
void Save();
// write a line to the log window
void WriteLine( const char* message );
// Set the bUpdate member
inline void SetAutoUpdate( bool b )
{
this->bUpdate = b;
}
// updates the log file
void Update();
private:
// Window handle
HWND hwnd;
// current text of the window (contains RTF tags)
std::string szText;
std::string szPlainText;
// is the log window currently visible?
bool bIsVisible;
// Specified whether each new log message updates the log automatically
bool bUpdate;
public:
// associated log stream
CMyLogStream* pcStream;
};
}
#endif // AV_LOG_DISPLA

File diff suppressed because it is too large Load Diff

View File

@ -39,164 +39,170 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#if (!defined AV_MATERIAL_H_INCLUDED)
#define AV_MATERIAL_H_INCLUDE
#pragma once
//-------------------------------------------------------------------------------
/* Helper class to create, access and destroy materials
*/
//-------------------------------------------------------------------------------
class CMaterialManager
#include <map>
#include "AssetHelper.h"
namespace AssimpView
{
private:
friend class CDisplay;
//-------------------------------------------------------------------------------
/* Helper class to create, access and destroy materials
*/
//-------------------------------------------------------------------------------
class CMaterialManager
{
private:
// default constructor
CMaterialManager()
: m_iShaderCount (0), sDefaultTexture() {}
friend class CDisplay;
~CMaterialManager() {
if (sDefaultTexture) {
sDefaultTexture->Release();
}
Reset();
}
// default constructor
CMaterialManager()
: m_iShaderCount( 0 ), sDefaultTexture() {}
public:
~CMaterialManager() {
if( sDefaultTexture ) {
sDefaultTexture->Release();
}
Reset();
}
//------------------------------------------------------------------
// Singleton accessors
static CMaterialManager s_cInstance;
inline static CMaterialManager& Instance ()
{
return s_cInstance;
}
public:
//------------------------------------------------------------------
// Delete all resources of a given material
//
// Must be called before CreateMaterial() to prevent memory leaking
void DeleteMaterial(AssetHelper::MeshHelper* pcIn);
//------------------------------------------------------------------
// Create the material for a mesh.
//
// The function checks whether an identical shader is already in use.
// A shader is considered to be identical if it has the same input
// signature and takes the same number of texture channels.
int CreateMaterial(AssetHelper::MeshHelper* pcMesh,
const aiMesh* pcSource);
//------------------------------------------------------------------
// Singleton accessors
static CMaterialManager s_cInstance;
inline static CMaterialManager& Instance()
{
return s_cInstance;
}
//------------------------------------------------------------------
// Setup the material for a given mesh
// pcMesh Mesh to be rendered
// pcProj Projection matrix
// aiMe Current world matrix
// pcCam Camera matrix
// vPos Position of the camera
// TODO: Extract camera position from matrix ...
//
int SetupMaterial (AssetHelper::MeshHelper* pcMesh,
const aiMatrix4x4& pcProj,
const aiMatrix4x4& aiMe,
const aiMatrix4x4& pcCam,
const aiVector3D& vPos);
//------------------------------------------------------------------
// Delete all resources of a given material
//
// Must be called before CreateMaterial() to prevent memory leaking
void DeleteMaterial( AssetHelper::MeshHelper* pcIn );
//------------------------------------------------------------------
// End the material for a given mesh
// Called after mesh rendering is complete
// pcMesh Mesh object
int EndMaterial (AssetHelper::MeshHelper* pcMesh);
//------------------------------------------------------------------
// Create the material for a mesh.
//
// The function checks whether an identical shader is already in use.
// A shader is considered to be identical if it has the same input
// signature and takes the same number of texture channels.
int CreateMaterial( AssetHelper::MeshHelper* pcMesh,
const aiMesh* pcSource );
//------------------------------------------------------------------
// Recreate all specular materials depending on the current
// specularity settings
//
// Diffuse-only materials are ignored.
// Must be called after specular highlights have been toggled
int UpdateSpecularMaterials();
//------------------------------------------------------------------
// Setup the material for a given mesh
// pcMesh Mesh to be rendered
// pcProj Projection matrix
// aiMe Current world matrix
// pcCam Camera matrix
// vPos Position of the camera
// TODO: Extract camera position from matrix ...
//
int SetupMaterial( AssetHelper::MeshHelper* pcMesh,
const aiMatrix4x4& pcProj,
const aiMatrix4x4& aiMe,
const aiMatrix4x4& pcCam,
const aiVector3D& vPos );
//------------------------------------------------------------------
// find a valid path to a texture file
//
// Handle 8.3 syntax correctly, search the environment of the
// executable and the asset for a texture with a name very similar
// to a given one
int FindValidPath(aiString* p_szString);
//------------------------------------------------------------------
// End the material for a given mesh
// Called after mesh rendering is complete
// pcMesh Mesh object
int EndMaterial( AssetHelper::MeshHelper* pcMesh );
//------------------------------------------------------------------
// Load a texture into memory and create a native D3D texture resource
//
// The function tries to find a valid path for a texture
int LoadTexture(IDirect3DTexture9** p_ppiOut,aiString* szPath);
//------------------------------------------------------------------
// Recreate all specular materials depending on the current
// specularity settings
//
// Diffuse-only materials are ignored.
// Must be called after specular highlights have been toggled
int UpdateSpecularMaterials();
//------------------------------------------------------------------
// find a valid path to a texture file
//
// Handle 8.3 syntax correctly, search the environment of the
// executable and the asset for a texture with a name very similar
// to a given one
int FindValidPath( aiString* p_szString );
//------------------------------------------------------------------
// Load a texture into memory and create a native D3D texture resource
//
// The function tries to find a valid path for a texture
int LoadTexture( IDirect3DTexture9** p_ppiOut, aiString* szPath );
//------------------------------------------------------------------
// Getter for m_iShaderCount
//
inline unsigned int GetShaderCount()
{
return this->m_iShaderCount;
}
//------------------------------------------------------------------
// Getter for m_iShaderCount
//
inline unsigned int GetShaderCount()
{
return this->m_iShaderCount;
}
//------------------------------------------------------------------
// Reset the state of the class
// Called whenever a new asset is loaded
inline void Reset()
{
this->m_iShaderCount = 0;
for (TextureCache::iterator it = sCachedTextures.begin(); it != sCachedTextures.end(); ++it) {
(*it).second->Release();
}
sCachedTextures.clear();
}
//------------------------------------------------------------------
// Reset the state of the class
// Called whenever a new asset is loaded
inline void Reset()
{
this->m_iShaderCount = 0;
for( TextureCache::iterator it = sCachedTextures.begin(); it != sCachedTextures.end(); ++it ) {
( *it ).second->Release();
}
sCachedTextures.clear();
}
private:
private:
//------------------------------------------------------------------
// find a valid path to a texture file
//
// Handle 8.3 syntax correctly, search the environment of the
// executable and the asset for a texture with a name very similar
// to a given one
bool TryLongerPath(char* szTemp,aiString* p_szString);
//------------------------------------------------------------------
// find a valid path to a texture file
//
// Handle 8.3 syntax correctly, search the environment of the
// executable and the asset for a texture with a name very similar
// to a given one
bool TryLongerPath( char* szTemp, aiString* p_szString );
//------------------------------------------------------------------
// Setup the default texture for a texture channel
//
// Generates a default checker pattern for a texture
int SetDefaultTexture(IDirect3DTexture9** p_ppiOut);
//------------------------------------------------------------------
// Setup the default texture for a texture channel
//
// Generates a default checker pattern for a texture
int SetDefaultTexture( IDirect3DTexture9** p_ppiOut );
//------------------------------------------------------------------
// Convert a height map to a normal map if necessary
//
// The function tries to detect the type of a texture automatically.
// However, this wont work in every case.
void HMtoNMIfNecessary(IDirect3DTexture9* piTexture,
IDirect3DTexture9** piTextureOut,
bool bWasOriginallyHM = true);
//------------------------------------------------------------------
// Convert a height map to a normal map if necessary
//
// The function tries to detect the type of a texture automatically.
// However, this wont work in every case.
void HMtoNMIfNecessary( IDirect3DTexture9* piTexture,
IDirect3DTexture9** piTextureOut,
bool bWasOriginallyHM = true );
//------------------------------------------------------------------
// Search for non-opaque pixels in a texture
//
// A pixel is considered to be non-opaque if its alpha value is
// less than 255
//------------------------------------------------------------------
bool HasAlphaPixels(IDirect3DTexture9* piTexture);
//------------------------------------------------------------------
// Search for non-opaque pixels in a texture
//
// A pixel is considered to be non-opaque if its alpha value is
// less than 255
//------------------------------------------------------------------
bool HasAlphaPixels( IDirect3DTexture9* piTexture );
private:
private:
//
// Specifies the number of different shaders generated for
// the current asset. This number is incremented by CreateMaterial()
// each time a shader isn't found in cache and needs to be created
//
unsigned int m_iShaderCount;
IDirect3DTexture9* sDefaultTexture;
//
// Specifies the number of different shaders generated for
// the current asset. This number is incremented by CreateMaterial()
// each time a shader isn't found in cache and needs to be created
//
unsigned int m_iShaderCount;
IDirect3DTexture9* sDefaultTexture;
typedef std::map<std::string,IDirect3DTexture9*> TextureCache;
TextureCache sCachedTextures;
};
typedef std::map<std::string, IDirect3DTexture9*> TextureCache;
TextureCache sCachedTextures;
};
#endif //!! include guard
}

View File

@ -39,7 +39,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "stdafx.h"
#include "assimp_view.h"
#include <map>
@ -47,7 +46,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace AssimpView {
CMeshRenderer CMeshRenderer::s_cInstance;
//-------------------------------------------------------------------------------

View File

@ -42,56 +42,58 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if (!defined AV_MESH_RENDERER_H_INCLUDED)
#define AV_MESH_RENDERER_H_INCLUDED
namespace AssimpView {
//-------------------------------------------------------------------------------
/* Helper class tp render meshes
*/
//-------------------------------------------------------------------------------
class CMeshRenderer
{
private:
//-------------------------------------------------------------------------------
/* Helper class tp render meshes
*/
//-------------------------------------------------------------------------------
class CMeshRenderer
{
private:
// default constructor
CMeshRenderer()
// default constructor
CMeshRenderer()
{
// no other members to initialize
}
{
// no other members to initialize
}
public:
public:
//------------------------------------------------------------------
// Singleton accessors
static CMeshRenderer s_cInstance;
inline static CMeshRenderer& Instance ()
{
return s_cInstance;
}
//------------------------------------------------------------------
// Singleton accessors
static CMeshRenderer s_cInstance;
inline static CMeshRenderer& Instance()
{
return s_cInstance;
}
//------------------------------------------------------------------
// Draw a mesh in the global mesh list using the current pipeline state
// iIndex Index of the mesh to be drawn
//
// The function draws all faces in order, regardless of their distance
int DrawUnsorted(unsigned int iIndex);
//------------------------------------------------------------------
// Draw a mesh in the global mesh list using the current pipeline state
// iIndex Index of the mesh to be drawn
//
// The function draws all faces in order, regardless of their distance
int DrawUnsorted( unsigned int iIndex );
//------------------------------------------------------------------
// Draw a mesh in the global mesh list using the current pipeline state
// iIndex Index of the mesh to be drawn
//
// The method sorts all vertices by their distance (back to front)
//
// mWorld World matrix for the node
int DrawSorted(unsigned int iIndex,
const aiMatrix4x4& mWorld);
//------------------------------------------------------------------
// Draw a mesh in the global mesh list using the current pipeline state
// iIndex Index of the mesh to be drawn
//
// The method sorts all vertices by their distance (back to front)
//
// mWorld World matrix for the node
int DrawSorted( unsigned int iIndex,
const aiMatrix4x4& mWorld );
private:
private:
};
};
}
#endif //!! include guard

View File

@ -39,12 +39,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "stdafx.h"
#include "assimp_view.h"
#include <assimp/Exporter.hpp>
#include <algorithm>
#include <windowsx.h>
namespace AssimpView {
using namespace Assimp;
// Static array to keep custom color values
COLORREF g_aclCustomColors[16] = {0};
@ -1044,9 +1048,9 @@ void DoExport(size_t formatId)
ai_assert(strlen(szFileName) <= MAX_PATH);
// invent a nice default file name
char* sz = std::max(strrchr(szFileName,'\\'),strrchr(szFileName,'/'));
char* sz = max(strrchr(szFileName,'\\'),strrchr(szFileName,'/'));
if (sz) {
strncpy(sz,std::max(strrchr(g_szFileName,'\\'),strrchr(g_szFileName,'/')),MAX_PATH);
strncpy(sz,max(strrchr(g_szFileName,'\\'),strrchr(g_szFileName,'/')),MAX_PATH);
}
}
else {

View File

@ -40,7 +40,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "stdafx.h"
#include "assimp_view.h"
// note: these are no longer part of the public API, but they are
@ -53,6 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace AssimpView {
using namespace Assimp;
bool g_bWasFlipped = false;
float g_smoothAngle = 80.f;

View File

@ -43,7 +43,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* @brief Implementation of the utility class SceneAnimator
*/
#include "stdafx.h"
#include "assimp_view.h"
using namespace AssimpView;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -47,6 +47,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// include resource definitions
#include "resource.h"
#include <assert.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <stdio.h>
#include <time.h>
// Include ASSIMP headers (XXX: do we really need all of them?)
#include <assimp/cimport.h>
#include <assimp/Importer.hpp>
@ -59,29 +67,23 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/LogStream.hpp>
#include <assimp/DefaultLogger.hpp>
#include "../../code/AssimpPCH.h" /* HACK */
#include "../../code/MaterialSystem.h" // aiMaterial class
#include "../../code/StringComparison.h" // ASSIMP_stricmp and ASSIMP_strincmp
// in order for std::min and std::max to behave properly
#ifdef min
/*#ifdef min
#undef min
#endif // min
#ifdef max
#undef max
#endif // min
#endif // min*/
#include <time.h>
// default movement speed
#define MOVE_SPEED 3.f
using namespace Assimp;
namespace AssimpView
{
#include "AssetHelper.h"
#include "Camera.h"
#include "RenderOptions.h"
@ -93,7 +95,6 @@ namespace AssimpView
#include "MeshRenderer.h"
#include "MaterialManager.h"
} // end of namespace AssimpView - for a while
// outside of namespace, to help Intellisense and solve boost::metatype_stuff_miracle
#include "AnimEvaluator.h"
@ -105,30 +106,30 @@ namespace AssimpView
//-------------------------------------------------------------------------------
// Function prototypes
//-------------------------------------------------------------------------------
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();
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();
aiVector3D GetCameraMatrix (aiMatrix4x4& p_mOut);
int CreateMaterial(AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSource);
aiVector3D GetCameraMatrix (aiMatrix4x4& p_mOut);
int CreateMaterial(AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSource);
void HandleMouseInputFPS( void );
void HandleMouseInputLightRotate( void );
void HandleMouseInputLocal( void );
void HandleKeyboardInputFPS( void );
void HandleMouseInputLightIntensityAndColor( void );
void HandleMouseInputSkyBox( void );
void HandleKeyboardInputTextureView( void );
void HandleMouseInputTextureView( void );
void HandleMouseInputFPS( void );
void HandleMouseInputLightRotate( void );
void HandleMouseInputLocal( void );
void HandleKeyboardInputFPS( void );
void HandleMouseInputLightIntensityAndColor( void );
void HandleMouseInputSkyBox( void );
void HandleKeyboardInputTextureView( void );
void HandleMouseInputTextureView( void );
//-------------------------------------------------------------------------------
@ -160,7 +161,7 @@ INT_PTR CALLBACK AboutMessageProc(HWND hwndDlg,UINT uMsg,
//-------------------------------------------------------------------------------
//
// Dialog prcoedure for the help dialog
// Dialog procedure for the help dialog
//
//-------------------------------------------------------------------------------
INT_PTR CALLBACK HelpDialogProc(HWND hwndDlg,UINT uMsg,
@ -182,7 +183,7 @@ type clamp(intype in)
{
// for unsigned types only ...
intype mask = (0x1u << (sizeof(type)*8))-1;
return (type)std::max((intype)0,std::min(in,mask));
return (type)max((intype)0,min(in,mask));
}