diff --git a/KhaoticDemo/KhaoticDemo.vcxproj b/KhaoticDemo/KhaoticDemo.vcxproj
new file mode 100644
index 0000000..d17dbb5
--- /dev/null
+++ b/KhaoticDemo/KhaoticDemo.vcxproj
@@ -0,0 +1,140 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ 17.0
+ Win32Proj
+ {9e5ef415-5337-4eed-ae23-edc4b1fff455}
+ KhaoticDemo
+ 10.0
+
+
+
+ Application
+ true
+ v143
+ Unicode
+
+
+ Application
+ false
+ v143
+ true
+ Unicode
+
+
+ Application
+ true
+ v143
+ Unicode
+
+
+ Application
+ false
+ v143
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Level3
+ true
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+ Level3
+ true
+ _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+ {92cf56c4-76bb-40d4-8fe5-36c15f5f127a}
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/KhaoticDemo/KhaoticDemo.vcxproj.filters b/KhaoticDemo/KhaoticDemo.vcxproj.filters
new file mode 100644
index 0000000..5d997ac
--- /dev/null
+++ b/KhaoticDemo/KhaoticDemo.vcxproj.filters
@@ -0,0 +1,22 @@
+
+
+
+
+ {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
+
+
+
+
+ Fichiers sources
+
+
+
\ No newline at end of file
diff --git a/KhaoticDemo/main.cpp b/KhaoticDemo/main.cpp
new file mode 100644
index 0000000..e69de29
diff --git a/enginecustom.sln b/enginecustom.sln
index 1ae2734..1248089 100644
--- a/enginecustom.sln
+++ b/enginecustom.sln
@@ -5,6 +5,8 @@ VisualStudioVersion = 17.9.34607.119
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "enginecustom", "enginecustom\enginecustom.vcxproj", "{92CF56C4-76BB-40D4-8FE5-36C15F5F127A}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KhaoticDemo", "KhaoticDemo\KhaoticDemo.vcxproj", "{9E5EF415-5337-4EED-AE23-EDC4B1FFF455}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -21,6 +23,14 @@ Global
{92CF56C4-76BB-40D4-8FE5-36C15F5F127A}.Release|x64.Build.0 = Release|x64
{92CF56C4-76BB-40D4-8FE5-36C15F5F127A}.Release|x86.ActiveCfg = Release|Win32
{92CF56C4-76BB-40D4-8FE5-36C15F5F127A}.Release|x86.Build.0 = Release|Win32
+ {9E5EF415-5337-4EED-AE23-EDC4B1FFF455}.Debug|x64.ActiveCfg = Debug|x64
+ {9E5EF415-5337-4EED-AE23-EDC4B1FFF455}.Debug|x64.Build.0 = Debug|x64
+ {9E5EF415-5337-4EED-AE23-EDC4B1FFF455}.Debug|x86.ActiveCfg = Debug|Win32
+ {9E5EF415-5337-4EED-AE23-EDC4B1FFF455}.Debug|x86.Build.0 = Debug|Win32
+ {9E5EF415-5337-4EED-AE23-EDC4B1FFF455}.Release|x64.ActiveCfg = Release|x64
+ {9E5EF415-5337-4EED-AE23-EDC4B1FFF455}.Release|x64.Build.0 = Release|x64
+ {9E5EF415-5337-4EED-AE23-EDC4B1FFF455}.Release|x86.ActiveCfg = Release|Win32
+ {9E5EF415-5337-4EED-AE23-EDC4B1FFF455}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/enginecustom/applicationclass.cpp b/enginecustom/applicationclass.cpp
index 31e80bd..5cfad25 100644
--- a/enginecustom/applicationclass.cpp
+++ b/enginecustom/applicationclass.cpp
@@ -153,12 +153,12 @@ void ApplicationClass::Shutdown()
m_cubes.clear();
// Liberez la memoire pour chaque cube du terrain
- for (auto cube : m_terrainCubes)
+ for (auto cube : m_terrainChunk)
{
cube->Shutdown();
delete cube;
}
- m_terrainCubes.clear();
+ m_terrainChunk.clear();
return;
}
@@ -236,7 +236,7 @@ bool ApplicationClass::Render(float rotation)
srMatrix = XMMatrixMultiply(scaleMatrix, rotateMatrix);
worldMatrix = XMMatrixMultiply(srMatrix, translateMatrix);
- result = m_LightShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(),
+ result = m_LightShader->Render(m_Direct3D->GetDeviceContext(), cube->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, cube->GetTexture(),
diffuseColor, lightPosition);
if (!result)
{
@@ -244,14 +244,15 @@ bool ApplicationClass::Render(float rotation)
}
}
- // Render terrainCube after all the cubes have been combined
- for (auto cube : m_terrainCubes)
+ // Render terrain
+ for (auto chunk : m_terrainChunk)
{
- cube->Render(m_Direct3D->GetDeviceContext());
+ chunk->Render(m_Direct3D->GetDeviceContext());
+
+ scaleMatrix = chunk->GetScaleMatrix();
+ rotateMatrix = chunk->GetRotateMatrix();
+ translateMatrix = chunk->GetTranslateMatrix();
- scaleMatrix = cube->GetScaleMatrix();
- rotateMatrix = cube->GetRotateMatrix();
- translateMatrix = cube->GetTranslateMatrix();
srMatrix = XMMatrixMultiply(scaleMatrix, rotateMatrix);
worldMatrix = XMMatrixMultiply(srMatrix, translateMatrix);
@@ -264,7 +265,6 @@ bool ApplicationClass::Render(float rotation)
}
-
// Present the rendered scene to the screen.
m_Direct3D->EndScene();
@@ -288,33 +288,28 @@ int ApplicationClass::GetScreenHeight() const
void ApplicationClass::GenerateTerrain()
{
- char modelFilename[128];
- char textureFilename[128];
-
// Set the file name of the model.
- strcpy_s(modelFilename, "cube.txt");
+ char modelFilename[128];
+
+ // check if a chunk file already exists
+ strcpy_s(modelFilename, "chunk.txt");
// Set the name of the texture file that we will be loading.
+ char textureFilename[128];
strcpy_s(textureFilename, "stone01.tga");
- // Create cube objects to fill a 10x10 grid of cubes
- for (int i = -10; i < 10; i++)
- {
- for (int j = -10; j < 10; j++)
- {
- Object* newCube = new Object();
- newCube->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, textureFilename);
+ Object* newTerrain = new Object();
+ newTerrain->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, textureFilename);
- newCube->SetTranslateMatrix(XMMatrixTranslation(i * 2.0f, -4.0f, j * 2.0f));
+ newTerrain->SetTranslateMatrix(XMMatrixTranslation(0.0f, -1.0f, 0.0f));
+ newTerrain->SetRotateMatrix(XMMatrixRotationY(180.0f));
- m_terrainCubes.push_back(newCube);
- }
- }
+ m_cubes.push_back(newTerrain);
-
-
}
+
+
void ApplicationClass::AddCube()
{
char modelFilename[128];
@@ -347,10 +342,10 @@ void ApplicationClass::DeleteCube(int index)
void ApplicationClass::DeleteTerrain()
{
- for (auto cube : m_terrainCubes)
+ for (auto cube : m_terrainChunk)
{
cube->Shutdown();
delete cube;
}
- m_terrainCubes.clear();
+ m_terrainChunk.clear();
}
\ No newline at end of file
diff --git a/enginecustom/applicationclass.h b/enginecustom/applicationclass.h
index 787539f..a78e80d 100644
--- a/enginecustom/applicationclass.h
+++ b/enginecustom/applicationclass.h
@@ -12,6 +12,7 @@
#include "lightclass.h"
#include
+
/////////////
// GLOBALS //
/////////////
@@ -45,9 +46,9 @@ public:
void AddCube();
void DeleteCube(int index);
int GetCubeCount() const { return m_cubes.size(); };
- int GetTerrainCubeCount() const { return m_terrainCubes.size(); };
+ int GetTerrainCubeCount() const { return m_terrainChunk.size(); };
std::vector