diff --git a/enginecustom/applicationclass.cpp b/enginecustom/applicationclass.cpp index 563a6e1..aead749 100644 --- a/enginecustom/applicationclass.cpp +++ b/enginecustom/applicationclass.cpp @@ -4,7 +4,6 @@ ApplicationClass::ApplicationClass() { m_Direct3D = 0; m_Camera = 0; - m_MultiTextureShader = 0; m_AlphaMapShader = 0; m_Model = 0; m_LightShader = 0; @@ -48,7 +47,7 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd) { char mouseString1[32], mouseString2[32], mouseString3[32]; char testString1[32], testString2[32], testString3[32]; - char modelFilename[128], textureFilename1[128], textureFilename2[128], textureFilename3[128], renderString[32]; + char modelFilename[128], textureFilename1[128], textureFilename2[128], textureFilename3[128], textureFilename4[128], textureFilename5[128], textureFilename6[128], renderString[32]; char bitmapFilename[128]; char spriteFilename[128]; char fpsString[32]; @@ -235,15 +234,6 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd) return false; } - // Create and initialize the multitexture shader object. - m_MultiTextureShader = new MultiTextureShaderClass; - - result = m_MultiTextureShader->Initialize(m_Direct3D->GetDevice(), hwnd); - if (!result) - { - MessageBox(hwnd, L"Could not initialize the multitexture shader object.", L"Error", MB_OK); - return false; - } // Set the file name of the model. strcpy_s(modelFilename, "cube.txt"); @@ -251,13 +241,17 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd) // Set the file name of the textures. strcpy_s(textureFilename1, "stone01.tga"); strcpy_s(textureFilename2, "normal01.tga"); - strcpy_s(textureFilename3, "alpha01.tga"); + strcpy_s(textureFilename3, "spec02.tga"); + strcpy_s(textureFilename4, "alpha01.tga"); + strcpy_s(textureFilename5, "light01.tga"); + strcpy_s(textureFilename6, "moss01.tga"); // A FAIRE: Ajouter une nouvelle texture pour le multitexturing // Create and initialize the model object. m_Model = new ModelClass; - result = m_Model->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, textureFilename1, textureFilename2, textureFilename3); + result = m_Model->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, textureFilename1, textureFilename2, textureFilename3, textureFilename4, + textureFilename5, textureFilename6); if (!result) { MessageBox(hwnd, L"Could not initialize the model object.", L"Error", MB_OK); @@ -321,6 +315,7 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd) { return false; } + // Create and initialize the light map shader object. m_LightMapShader = new LightMapShaderClass; @@ -546,7 +541,7 @@ void ApplicationClass::Shutdown() m_Sprite = 0; } - // Release the light objects. + // Release the lights objects. if (m_Lights) { delete[] m_Lights; @@ -592,46 +587,6 @@ void ApplicationClass::Shutdown() m_Model = 0; } - // Release the multitexture shader object. - if (m_MultiTextureShader) - { - m_MultiTextureShader->Shutdown(); - delete m_MultiTextureShader; - m_MultiTextureShader = 0; - // Release the bitmap object. - if (m_Bitmap) - { - m_Bitmap->Shutdown(); - delete m_Bitmap; - m_Bitmap = 0; - } - - // Release the texture shader object. - if (m_TextureShader) - { - m_TextureShader->Shutdown(); - delete m_TextureShader; - m_TextureShader = 0; - } - - // Release the camera object. - if (m_Camera) - { - delete m_Camera; - m_Camera = 0; - } - - // Release the D3D object. - if (m_Direct3D) - { - m_Direct3D->Shutdown(); - delete m_Direct3D; - m_Direct3D = 0; - } - - return; - } - // Release the alpha map shader object. if (m_AlphaMapShader) { @@ -1054,6 +1009,14 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t //// Render the model using the multitexture shader. //m_Model->Render(m_Direct3D->GetDeviceContext()); + // Setup matrices. + rotateMatrix = XMMatrixRotationY(rotation); + translateMatrix = XMMatrixTranslation(0.0f, 4.0f, 0.0f); + worldMatrix = XMMatrixMultiply(rotateMatrix, translateMatrix); + + // Render the model using the texture shader. + m_Model->Render(m_Direct3D->GetDeviceContext()); + result = m_ShaderManager->RenderTextureShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0)); if (!result) @@ -1063,7 +1026,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t // Setup matrices. rotateMatrix = XMMatrixRotationY(rotation); - translateMatrix = XMMatrixTranslation(-1.5f, -1.0f, 0.0f); + translateMatrix = XMMatrixTranslation(0.0f, 1.0f, 0.0f); worldMatrix = XMMatrixMultiply(rotateMatrix, translateMatrix); // Render the model using the light shader. @@ -1078,7 +1041,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t // Setup matrices. rotateMatrix = XMMatrixRotationY(rotation); - translateMatrix = XMMatrixTranslation(1.5f, -1.0f, 0.0f); + translateMatrix = XMMatrixTranslation(0.0f, -2.0f, 0.0f); worldMatrix = XMMatrixMultiply(rotateMatrix, translateMatrix); // Render the model using the normal map shader. @@ -1091,6 +1054,21 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t return false; } + // Setup matrices. + rotateMatrix = XMMatrixRotationY(rotation); + translateMatrix = XMMatrixTranslation(0.0f, -5.0f, 0.0f); + worldMatrix = XMMatrixMultiply(rotateMatrix, translateMatrix); + + // Render the model using the Multitexture shader. + m_Model->Render(m_Direct3D->GetDeviceContext()); + + result = m_ShaderManager->RenderMultitextureShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, + m_Model->GetTexture(0), m_Model->GetTexture(5)); + if (!result) + { + return false; + } + // Lighting, utilise plusieurs lights donc Multiple Points Lighting //result = m_LightShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0), // diffuseColor, lightPosition); diff --git a/enginecustom/applicationclass.h b/enginecustom/applicationclass.h index 865123c..729cd0e 100644 --- a/enginecustom/applicationclass.h +++ b/enginecustom/applicationclass.h @@ -11,7 +11,6 @@ #include "lightshaderclass.h" #include "lightclass.h" #include "lightmapshaderclass.h" -#include "multitextureshaderclass.h" #include "alphamapshaderclass.h" #include "bitmapclass.h" #include "spriteclass.h" @@ -70,7 +69,6 @@ private: LightClass* m_Light; LightClass* m_Lights; LightMapShaderClass* m_LightMapShader; - MultiTextureShaderClass* m_MultiTextureShader; AlphaMapShaderClass* m_AlphaMapShader; ModelClass* m_Model; TextureShaderClass* m_TextureShader; diff --git a/enginecustom/enginecustom.vcxproj b/enginecustom/enginecustom.vcxproj index e520d7a..ab85b85 100644 --- a/enginecustom/enginecustom.vcxproj +++ b/enginecustom/enginecustom.vcxproj @@ -125,6 +125,7 @@ + diff --git a/enginecustom/enginecustom.vcxproj.filters b/enginecustom/enginecustom.vcxproj.filters index ad0862c..c30fa7f 100644 --- a/enginecustom/enginecustom.vcxproj.filters +++ b/enginecustom/enginecustom.vcxproj.filters @@ -1,323 +1,109 @@  - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {b016e481-576e-4d99-bdde-34cc10c55b1d} - - - {f76f9761-bbbe-42a8-935d-01f1b9172c38} - - - {741e1efe-db9b-48a7-9ecb-4c34a696f40e} - - - {51e14ebb-4f58-488f-8d0f-04935f51efda} - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - + + + + + + + + + + - - fonts - - - assets - - - assets - - - assets - - - assets - - - assets - - - assets - - - assets - - - assets - + + + + + + + + + + + + + + + + + + + + - - - fonts - - - fonts - - - shader - - - shader - - - shader - - - texture - - - texture - - - texture - - - texture - - - shader - - - shader - - - shader - - - texture - - - texture - - - shader - - - shader - - - shader - - - shader - - - - - fonts - - - assets - - - assets - - - assets - - - assets - - - - - shader - - - shader - + + + + + \ No newline at end of file diff --git a/enginecustom/modelclass.cpp b/enginecustom/modelclass.cpp index 38dcfa7..c47f3b1 100644 --- a/enginecustom/modelclass.cpp +++ b/enginecustom/modelclass.cpp @@ -19,7 +19,8 @@ ModelClass::~ModelClass() { } -bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* modelFilename, char* textureFilename1, char* textureFilename2, char* textureFilename3) +bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* modelFilename, char* textureFilename1, char* textureFilename2, char* textureFilename3, + char* textureFilename4, char* textureFilename5, char* textureFilename6) { bool result; @@ -40,7 +41,7 @@ bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceCon return false; } // Load the textures for this model. - result = LoadTextures(device, deviceContext, textureFilename1, textureFilename2, textureFilename3); + result = LoadTextures(device, deviceContext, textureFilename1, textureFilename2, textureFilename3, textureFilename4, textureFilename5, textureFilename6); if (!result) { return false; @@ -206,13 +207,14 @@ void ModelClass::RenderBuffers(ID3D11DeviceContext* deviceContext) } -bool ModelClass::LoadTextures(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* filename1, char* filename2, char* filename3) +bool ModelClass::LoadTextures(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* filename1, char* filename2, char* filename3, char* filename4, char* filename5, + char* filename6) { bool result; // Create and initialize the texture object array. - m_Textures = new TextureClass[3]; + m_Textures = new TextureClass[6]; result = m_Textures[0].Initialize(device, deviceContext, filename1); if (!result) @@ -232,6 +234,24 @@ bool ModelClass::LoadTextures(ID3D11Device* device, ID3D11DeviceContext* deviceC return false; } + result = m_Textures[3].Initialize(device, deviceContext, filename4); + if (!result) + { + return false; + } + + result = m_Textures[4].Initialize(device, deviceContext, filename5); + if (!result) + { + return false; + } + + result = m_Textures[5].Initialize(device, deviceContext, filename6); + if (!result) + { + return false; + } + return true; } @@ -244,6 +264,9 @@ void ModelClass::ReleaseTextures() m_Textures[0].Shutdown(); m_Textures[1].Shutdown(); m_Textures[2].Shutdown(); + m_Textures[3].Shutdown(); + m_Textures[4].Shutdown(); + m_Textures[5].Shutdown(); delete[] m_Textures; m_Textures = 0; diff --git a/enginecustom/modelclass.h b/enginecustom/modelclass.h index 7116f9d..702c3a6 100644 --- a/enginecustom/modelclass.h +++ b/enginecustom/modelclass.h @@ -80,7 +80,7 @@ public: ModelClass(const ModelClass&); ~ModelClass(); - bool Initialize(ID3D11Device*, ID3D11DeviceContext*, char*, char*, char*, char*); + bool Initialize(ID3D11Device*, ID3D11DeviceContext*, char*, char*, char*, char*, char*, char*, char*); void Shutdown(); void Render(ID3D11DeviceContext*); @@ -91,7 +91,7 @@ private: bool InitializeBuffers(ID3D11Device*); void ShutdownBuffers(); void RenderBuffers(ID3D11DeviceContext*); - bool LoadTextures(ID3D11Device*, ID3D11DeviceContext*, char*, char*, char*); + bool LoadTextures(ID3D11Device*, ID3D11DeviceContext*, char*, char*, char*, char*, char*, char*); void ReleaseTextures(); bool LoadModel(char*); diff --git a/enginecustom/papier.tga b/enginecustom/papier.tga deleted file mode 100644 index 4f0b9b9..0000000 Binary files a/enginecustom/papier.tga and /dev/null differ diff --git a/enginecustom/spec02.tga b/enginecustom/spec02.tga new file mode 100644 index 0000000..b5085a7 Binary files /dev/null and b/enginecustom/spec02.tga differ