AssimpRenderer: V:/ponx/dev/Visual Studio/AssimpRenderer/include/assimprenderer.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List

# V:/ponx/dev/Visual Studio/AssimpRenderer/include/assimprenderer.h

    00001 /*
    00002 ---------------------------------------------------------------------------
    00003 Direct3D AssimpRenderer by ponx
    00004 ---------------------------------------------------------------------------
    00005
    00006 This code is heavily based on the "AssimpView" project of the Open Asset Import Library (ASSIMP).
    00007 http://assimp.sourceforge.net
    00008
    00009 /*
    00010 ---------------------------------------------------------------------------
    00011 Open Asset Import Library (ASSIMP)
    00012 ---------------------------------------------------------------------------
    00013
    00014 Copyright (c) 2006-2008, ASSIMP Development Team
    00015
    00016 All rights reserved.
    00017
    00018 Redistribution and use of this software in source and binary forms,
    00019 with or without modification, are permitted provided that the following
    00020 conditions are met:
    00021
    00022 * Redistributions of source code must retain the above
    00023 copyright notice, this list of conditions and the
    00024 following disclaimer.
    00025
    00026 * Redistributions in binary form must reproduce the above
    00027 copyright notice, this list of conditions and the
    00028 following disclaimer in the documentation and/or other
    00029 materials provided with the distribution.
    00030
    00031 * Neither the name of the ASSIMP team, nor the names of its
    00032 contributors may be used to endorse or promote products
    00033 derived from this software without specific prior
    00034 written permission of the ASSIMP Development Team.
    00035
    00036 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    00037 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    00038 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    00039 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    00040 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    00041 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    00042 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    00043 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    00044 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    00045 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    00046 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    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 //#define DEBUG_VS                            // vertex shader debuggen ...macht nur Sinn, wenn eine externe Datei .fx benutzt wird, weil man sich sonst im PIX Debugger nur den Asm code angucken kann
    00062 //#define DEBUG_PS                            // pixel shader debuggen ... s.o.
    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);                                                      //PNX
    00089                 int SaveAssetToFile(const AssetHelper& asset, aiString filename);                                                                               //PNX
    00090
    00091                 LPDIRECT3DDEVICE9 CreateD3dDevice(      LPDIRECT3D9 d3d,
    00092                                                                                                 D3DPRESENT_PARAMETERS* d3dpp,
    00093                                                                                                 const RenderOptions& renderOptions);
    00094
    00095                 void RenderAsset(const AssetHelper& assetHelper, aiMatrix4x4 argMatrix);        // PNX
    00096                 void RenderAsset(const AssetHelper& assetHelper, const aiVector3D& vPos, const aiVector3D& vRot, const aiVector3D& vScale);             //PNX
    00097                 void SetCamera(const Camera& sourceCamera);
    00098                 int AttachLogStream(Assimp::LogStream* logstr, unsigned int severity);                                                  //PNX
    00099                 int DetachLogStream( Assimp::LogStream* logstr, unsigned int severity );                                                //PNX
    00100                 static D3DXMATRIX CreateTransformMatrix(float rotX, float rotY, float rotZ, float scaleFactor);                                         //PNX
    00101
    00102
    00103         private:
    00104                 AssimpRenderer(void);
    00105                 ~AssimpRenderer(void);
    00106
    00107                 static AssimpRenderer* sInstance;
    00108                 static void ConvertMatrixDxToAi(aiMatrix4x4& aiDest, const D3DXMATRIX& dxSource);       //PNX
    00109                 static void ConvertMatrixAiToDx(D3DXMATRIX& dxDest, const aiMatrix4x4& aiSource);       //PNX
    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);               //PNX
    00113                 static int SendMeshDataToDx(AssetHelper::MeshHelper* meshHelper);                       //PNX
    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);                                                                // achtung, davon gibts zwei versionen. Fehlt bei meiner was ? andere erstmal auskommentiert
    00118                 std::string GetCurrentDir();
    00119
    00120                 // Direct 3D
    00121                 LPDIRECT3D9 d3d;
    00122                 LPDIRECT3DDEVICE9 d3ddev;
    00123                 D3DPRESENT_PARAMETERS* d3dpp;
    00124                 IDirect3DVertexDeclaration9* gDefaultVertexDecl;
    00125
    00126                 TCHAR* applicationBaseDirectory;                        // this will be set to the current active directory at the point of time when the Singleton is created
    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;                        //das sollte lieber noch nen setter oder sowas kriegen;
    00136         };
    00137
    00138 }  // namespace