From d61a5b7f5f813069b56debebcf08e8690e67a1b3 Mon Sep 17 00:00:00 2001
From: GolfOcean334 <130740013+GolfOcean334@users.noreply.github.com>
Date: Sun, 7 Apr 2024 01:27:30 +0200
Subject: [PATCH] Minor: Ajout du Multitexturing dans le shader manager
Actuellement envie de DCD, JPP des Lights :angry:
---
enginecustom/applicationclass.cpp | 90 ++---
enginecustom/applicationclass.h | 2 -
enginecustom/enginecustom.vcxproj | 1 +
enginecustom/enginecustom.vcxproj.filters | 406 +++++-----------------
enginecustom/modelclass.cpp | 31 +-
enginecustom/modelclass.h | 4 +-
enginecustom/papier.tga | Bin 1044186 -> 0 bytes
enginecustom/spec02.tga | Bin 0 -> 1048620 bytes
8 files changed, 160 insertions(+), 374 deletions(-)
delete mode 100644 enginecustom/papier.tga
create mode 100644 enginecustom/spec02.tga
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 4f0b9b948c583c642d6ae39c98f2589eb80ab4c3..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1044186
zcmc%SS(arva;0fjj-(!Id^Mw*OOY%_-+JFS;n6Y3AT!BFtMeVxU%4H5)!aNX$n>>j
z2_O&v0$__kF0NklzxkX0_BZ|afB(1t=l}RW|F7Tw=Id9#`}(U_zxm?xS6_bm$*ZqE
z`}8iWE0cZw`Dd@b`SOcbzy0dVSM>k!cfWo0&wu>GP5<98b`m%*hfBwfmzWSFx{o|{D{ii=Y6B)bpZEkCi);8lc
zW@S8`__qD;C|i$p;%u^(_JBRkEYkLp-StgZz4g?l-u{!(4HxxmFW;6Mr@5R-XB?(F
ztJ+SUJ>=O-1_Sm4uMO8`>}3CV$^Pl8|M}8I%73(P7v8_Qd;lp||LXFGFFyY0)n^}m
z@aoeK-hU?bFF*PC)z_ELAZ2>!^N&7!^~wA1z54jQcW-@lbhlr6pIzmTul7%`F}`@J
ze{|`ReSY=N50rGP-2Q7&u?G57v#^pZ24*i+c(M{hz*-!j8V$9QCr{^60ax`yU3<83mai=pmvM6X
z>yvLQyJNVx3sct~H#g3o`Kh>oqyK*8Bmd){|LNw%h}urRF-=?gVuP`rZE+{;!v*|=
zk?Q$C_ciRm7vIXi!Y9l{>l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