Terrain cube séparé des autres objects
This commit is contained in:
parent
08b04afe1c
commit
9e7e33494c
@ -144,7 +144,7 @@ void ApplicationClass::Shutdown()
|
|||||||
m_Direct3D = 0;
|
m_Direct3D = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lib<EFBFBD>rez la m<>moire pour chaque cube
|
// Liberez la memoire pour chaque cube
|
||||||
for (auto cube : m_cubes)
|
for (auto cube : m_cubes)
|
||||||
{
|
{
|
||||||
cube->Shutdown();
|
cube->Shutdown();
|
||||||
@ -152,6 +152,14 @@ void ApplicationClass::Shutdown()
|
|||||||
}
|
}
|
||||||
m_cubes.clear();
|
m_cubes.clear();
|
||||||
|
|
||||||
|
// Liberez la memoire pour chaque cube du terrain
|
||||||
|
for (auto cube : m_terrainCubes)
|
||||||
|
{
|
||||||
|
cube->Shutdown();
|
||||||
|
delete cube;
|
||||||
|
}
|
||||||
|
m_terrainCubes.clear();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +236,7 @@ bool ApplicationClass::Render(float rotation)
|
|||||||
srMatrix = XMMatrixMultiply(scaleMatrix, rotateMatrix);
|
srMatrix = XMMatrixMultiply(scaleMatrix, rotateMatrix);
|
||||||
worldMatrix = XMMatrixMultiply(srMatrix, translateMatrix);
|
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(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(),
|
||||||
diffuseColor, lightPosition);
|
diffuseColor, lightPosition);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
@ -236,6 +244,25 @@ bool ApplicationClass::Render(float rotation)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Render terrainCube
|
||||||
|
for (auto cube : m_terrainCubes)
|
||||||
|
{
|
||||||
|
cube->Render(m_Direct3D->GetDeviceContext());
|
||||||
|
|
||||||
|
scaleMatrix = cube->GetScaleMatrix();
|
||||||
|
rotateMatrix = cube->GetRotateMatrix();
|
||||||
|
translateMatrix = cube->GetTranslateMatrix();
|
||||||
|
srMatrix = XMMatrixMultiply(scaleMatrix, rotateMatrix);
|
||||||
|
worldMatrix = XMMatrixMultiply(srMatrix, translateMatrix);
|
||||||
|
|
||||||
|
result = m_LightShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(),
|
||||||
|
diffuseColor, lightPosition);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Present the rendered scene to the screen.
|
// Present the rendered scene to the screen.
|
||||||
m_Direct3D->EndScene();
|
m_Direct3D->EndScene();
|
||||||
|
|
||||||
@ -278,9 +305,13 @@ void ApplicationClass::GenerateTerrain()
|
|||||||
|
|
||||||
newCube->SetTranslateMatrix(XMMatrixTranslation(i * 2.0f, -4.0f, j * 2.0f));
|
newCube->SetTranslateMatrix(XMMatrixTranslation(i * 2.0f, -4.0f, j * 2.0f));
|
||||||
|
|
||||||
m_cubes.push_back(newCube);
|
m_terrainCubes.push_back(newCube);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Combine all the cubes into a single model
|
||||||
|
// TODO: Uncomment this line when you have implemented the CombineModels function in ModelClass
|
||||||
|
//m_Model->CombineModels(m_terrainCubes);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +61,7 @@ private:
|
|||||||
LightClass* m_Light;
|
LightClass* m_Light;
|
||||||
float speed = 0.1f;
|
float speed = 0.1f;
|
||||||
std::vector<Object*> m_cubes;
|
std::vector<Object*> m_cubes;
|
||||||
|
std::vector<Object*> m_terrainCubes;
|
||||||
Object* m_SelectedObject;
|
Object* m_SelectedObject;
|
||||||
LightClass* m_Lights;
|
LightClass* m_Lights;
|
||||||
int m_numLights;
|
int m_numLights;
|
||||||
|
@ -3,10 +3,10 @@ Pos=60,60
|
|||||||
Size=400,400
|
Size=400,400
|
||||||
|
|
||||||
[Window][Khaotic Engine]
|
[Window][Khaotic Engine]
|
||||||
Pos=765,20
|
Pos=1196,6
|
||||||
Size=694,366
|
Size=694,366
|
||||||
|
|
||||||
[Window][Objects]
|
[Window][Objects]
|
||||||
Pos=69,21
|
Pos=11,7
|
||||||
Size=492,353
|
Size=492,353
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <d3d11.h>
|
#include <d3d11.h>
|
||||||
#include <directxmath.h>
|
#include <directxmath.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <vector>
|
||||||
using namespace DirectX;
|
using namespace DirectX;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user