00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 #pragma once
00052
00053 #include "RenderOptions.h"
00054 #include "AssetHelper.h"
00055 #include "Camera.h"
00056 #include "aiVector3D.h"
00057 #include "aiScene.h"
00058 #include <LogStream.h>
00059
00060
00061
00062
00063
00064
00065 #define USE_EXTERNAL_SHADER_FILE // auskommentieren, falls als Source für die Shader die externe .fx Datei (FILENAME_EXTERNAL_EFFECT) benutzt werden soll
00066
00067 #define FILENAME_EXTERNAL_EFFECT L"MaterialShader.fx" //wird nur benutzt, wenn USE_EXTERNAL_SHADER_FILE #definiert ist
00068
00069
00070 namespace AssimpRendererD3d
00071 {
00073
00076 class AssimpRenderer
00077 {
00078 friend class AssetHelper;
00079 friend class CMaterialManager;
00080 friend class CMeshRenderer;
00081
00082 public:
00083
00084 static AssimpRenderer* Instance();
00085 static AssetHelper* ImportAsset(const char* pFile, unsigned int aiImportFlags);
00086 static AssetHelper* ImportAsset(const char* pFile, unsigned int aiImportFlags, const D3DXMATRIX& matTransform);
00087
00088 AssetHelper* LoadAssetFromFile(aiString filename);
00089 int SaveAssetToFile(const AssetHelper& asset, aiString filename);
00090
00091 LPDIRECT3DDEVICE9 CreateD3dDevice( LPDIRECT3D9 d3d,
00092 D3DPRESENT_PARAMETERS* d3dpp,
00093 const RenderOptions& renderOptions);
00094
00095 void RenderAsset(const AssetHelper& assetHelper, aiMatrix4x4 argMatrix);
00096 void RenderAsset(const AssetHelper& assetHelper, const aiVector3D& vPos, const aiVector3D& vRot, const aiVector3D& vScale);
00097 void SetCamera(const Camera& sourceCamera);
00098 int AttachLogStream(Assimp::LogStream* logstr, unsigned int severity);
00099 int DetachLogStream( Assimp::LogStream* logstr, unsigned int severity );
00100 static D3DXMATRIX CreateTransformMatrix(float rotX, float rotY, float rotZ, float scaleFactor);
00101
00102
00103 private:
00104 AssimpRenderer(void);
00105 ~AssimpRenderer(void);
00106
00107 static AssimpRenderer* sInstance;
00108 static void ConvertMatrixDxToAi(aiMatrix4x4& aiDest, const D3DXMATRIX& dxSource);
00109 static void ConvertMatrixAiToDx(D3DXMATRIX& dxDest, const aiMatrix4x4& aiSource);
00110 static AssetHelper* ImportAssetInternal(const char* pFile, unsigned int aiImportFlags, const D3DXMATRIX* matTransform);
00111 static int CreateAssetData(AssetHelper* g_pcAsset, const aiScene* scene);
00112 static void TransformVector(aiVector3D* aiVec, const D3DXMATRIX& matrix);
00113 static int SendMeshDataToDx(AssetHelper::MeshHelper* meshHelper);
00114 int RenderNode(const AssetHelper& g_pcAsset, aiNode* piNode,const aiMatrix4x4& piMatrix, bool bAlpha);
00115 int CreateD3dDevice(bool p_bMultiSample, bool bHW = true);
00116 int GetProjectionMatrix(aiMatrix4x4& p_mOut);
00117 aiVector3D GetCameraMatrix(aiMatrix4x4& p_mOut);
00118 std::string GetCurrentDir();
00119
00120
00121 LPDIRECT3D9 d3d;
00122 LPDIRECT3DDEVICE9 d3ddev;
00123 D3DPRESENT_PARAMETERS* d3dpp;
00124 IDirect3DVertexDeclaration9* gDefaultVertexDecl;
00125
00126 TCHAR* applicationBaseDirectory;
00127 RenderOptions renderOptions;
00128
00129 ID3DXEffect* g_piDefaultEffect;
00130 ID3DXEffect* g_piPassThroughEffect;
00131 ID3DXEffect* g_piPatternEffect;
00132
00133 D3DCAPS9 g_sCaps;
00134
00135 Camera m_Camera;
00136 };
00137
00138 }