Render terrain ok

This commit is contained in:
CatChow0 2024-04-03 12:46:49 +02:00
parent cdf3dd9fb8
commit ea57d1ab9d
4 changed files with 7 additions and 9 deletions

View File

@ -57,6 +57,8 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd)
return false; return false;
} }
GenerateTerrain();
// Create the camera object. // Create the camera object.
m_Camera = new CameraClass; m_Camera = new CameraClass;
if (!m_Camera) if (!m_Camera)
@ -690,21 +692,18 @@ int ApplicationClass::GetScreenHeight() const
void ApplicationClass::GenerateTerrain() void ApplicationClass::GenerateTerrain()
{ {
// Set the file name of the model.
char modelFilename[128]; char modelFilename[128];
// Set the name of the texture file that we will be loading.
char textureFilename[128]; char textureFilename[128];
char textureFilename2[128]; char textureFilename2[128];
// Set the file name of the model.
// check if a chunk file already exists
strcpy_s(modelFilename, "plane.txt"); strcpy_s(modelFilename, "plane.txt");
strcpy_s(textureFilename, "stone01.tga"); strcpy_s(textureFilename, "stone01.tga");
strcpy_s(textureFilename2, "moss01.tga"); strcpy_s(textureFilename2, "moss01.tga");
// for loop to generate terrain chunks for a 10x10 grid // for loop to generate terrain chunks for a 10x10 grid
for (int i = -10; i < 10; i++) for (int i = -5; i < 5; i++)
{ {
for (int j = -10; j < 10; j++) for (int j = -5; j < 5; j++)
{ {
Object* newTerrain = new Object(); Object* newTerrain = new Object();
newTerrain->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, textureFilename, textureFilename2); newTerrain->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, textureFilename, textureFilename2);

View File

@ -61,7 +61,6 @@ public:
void GenerateTerrain(); void GenerateTerrain();
void DeleteTerrain(); void DeleteTerrain();
private: private:
bool Render(float, float, float, float); bool Render(float, float, float, float);

View File

@ -19,7 +19,7 @@ ModelClass::~ModelClass()
{ {
} }
bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* modelFilename, char* textureFilename1, char* textureFilename2) bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, const char* modelFilename, const char* textureFilename1, const char* textureFilename2)
{ {
bool result; bool result;

View File

@ -17,7 +17,7 @@ TextureClass::~TextureClass()
{ {
} }
bool TextureClass::Initialize(ID3D11Device * device, ID3D11DeviceContext * deviceContext, char* filename) bool TextureClass::Initialize(ID3D11Device * device, ID3D11DeviceContext * deviceContext,const char* filename)
{ {
bool result; bool result;
int height, width; int height, width;