Application Class
Enviado por gearfried12 • 11 de Mayo de 2019 • Informe • 1.488 Palabras (6 Páginas) • 88 Visitas
////////////////////////////////////////////////////////////////////////////////
// Filename: applicationclass.cpp
////////////////////////////////////////////////////////////////////////////////
#include "applicationclass.h"
ApplicationClass::ApplicationClass()
{
m_Input = 0;
m_Direct3D = 0;
m_Camera = 0;
m_Terrain = 0;
m_Timer = 0;
m_Position = 0;
m_Fps = 0;
m_Cpu = 0;
m_FontShader = 0;
m_Text = 0;
m_TerrainShader = 0;
m_Light = 0;
m_projectileCount = 0;
}
ApplicationClass::ApplicationClass(const ApplicationClass& other)
{
}
ApplicationClass::~ApplicationClass()
{
}
bool ApplicationClass::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, int screenHeight)
{
bool result;
float cameraX, cameraY, cameraZ;
D3DXMATRIX baseViewMatrix;
char videoCard[128];
int videoMemory;
// Create the input object. The input object will be used to handle reading the keyboard and mouse input from the user.
m_Input = new InputClass;
if(!m_Input)
{
return false;
}
// Initialize the input object.
result = m_Input->Initialize(hinstance, hwnd, screenWidth, screenHeight);
if(!result)
{
MessageBox(hwnd, L"Could not initialize the input object.", L"Error", MB_OK);
return false;
}
// Create the Direct3D object.
m_Direct3D = new D3DClass;
if(!m_Direct3D)
{
return false;
}
// Initialize the Direct3D object.
result = m_Direct3D->Initialize(screenWidth, screenHeight, VSYNC_ENABLED, hwnd, FULL_SCREEN, SCREEN_DEPTH, SCREEN_NEAR);
if(!result)
{
MessageBox(hwnd, L"Could not initialize DirectX 11.", L"Error", MB_OK);
return false;
}
// Create the camera object.
m_Camera = new CameraClass;
if(!m_Camera)
{
return false;
}
// Initialize a base view matrix with the camera for 2D user interface rendering.
m_Camera->SetPosition(0.0f, 0.0f, -1.0f);
m_Camera->Render();
m_Camera->GetViewMatrix(baseViewMatrix);
// Set the initial position of the camera.
cameraX = 50.0f;
cameraY = 2.0f;
cameraZ = -7.0f;
m_Camera->SetPosition(cameraX, cameraY, cameraZ);
// Create the terrain object.
m_Terrain = new TerrainClass;
if (!m_Terrain)
{
return false;
}
// Initialize the terrain object.
int textureCount = 5;
WCHAR** filenames = new WCHAR*[textureCount];
filenames[0] = L"../Engine/data/sand.jpg";
filenames[1] = L"../Engine/data/sand_conchas.jpg";
filenames[2] = L"../Engine/data/rock.jpg";
filenames[3] = L"../Engine/data/snow.jpg";
filenames[4] = L"../Engine/data/alpha.jpg";
result = m_Terrain->Initialize(m_Direct3D->GetDevice(), "../Engine/data/heightmap.bmp", filenames, textureCount);
if (!result)
{
MessageBox(hwnd, L"Could not initialize the terrain object.", L"Error", MB_OK);
return false;
}
// Create the terrain object.
m_Water = new TerrainClass;
if (!m_Water)
{
return false;
}
// Initialize the terrain object.
textureCount = 3;
filenames = new WCHAR*[textureCount];
filenames[0] = L"../Engine/data/waterDiffuse.jpg";
filenames[1] = L"../Engine/data/waterNormal.png";
filenames[2] = L"../Engine/data/waterSpecular.png";
result = m_Water->Initialize(m_Direct3D->GetDevice(), "../Engine/data/waterHeightmap.bmp", filenames, textureCount);
if (!result)
{
MessageBox(hwnd, L"Could not initialize the terrain object.", L"Error", MB_OK);
return false;
}
// Create the model object.
m_Skydome = new SkydomeClass;
if (!m_Skydome)
{
return false;
}
textureCount = 2;
filenames = new WCHAR*[textureCount];
filenames[0] = L"../Engine/data/skydomeDay.jpg";
filenames[1] = L"../Engine/data/skydomeNight.jpg";
// Initialize the model object.
result = m_Skydome->Initialize(m_Direct3D->GetDevice(), filenames, textureCount);
if (!result)
{
MessageBox(hwnd, L"Could not initialize the model object.", L"Error", MB_OK);
return false;
}
m_Billboard[0] = new BillboardClass;
if (!m_Billboard[0])
{
return false;
}
textureCount = 2;
filenames = new WCHAR*[textureCount];
filenames[0] = L"../Engine/data/tree.png";
filenames[1] = L"../Engine/data/treeNormal.png";
// Initialize the model object.
result = m_Billboard[0]->Initialize(m_Direct3D->GetDevice(), filenames, textureCount);
if (!result)
{
MessageBox(hwnd, L"Could not initialize the model object.", L"Error", MB_OK);
return false;
}
m_Billboard[1] = new BillboardClass;
if (!m_Billboard[1])
{
return false;
}
textureCount = 2;
filenames = new WCHAR*[textureCount];
filenames[0] = L"../Engine/data/tree2.png";
filenames[1] = L"../Engine/data/tree2Normal.png";
// Initialize the model object.
result = m_Billboard[1]->Initialize(m_Direct3D->GetDevice(), filenames, textureCount);
if (!result)
{
MessageBox(hwnd, L"Could not initialize the model object.", L"Error", MB_OK);
return false;
}
m_Billboard[2] = new BillboardClass;
if (!m_Billboard[2])
{
return false;
}
textureCount = 2;
filenames = new WCHAR*[textureCount];
...