-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApplication.h
180 lines (133 loc) · 3.55 KB
/
Application.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#pragma once
#include <windows.h>
#include <d3d11_1.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <directxcolors.h>
#include "DDSTextureLoader.h"
#include "resource.h"
#include "Camera.h"
#include "Structures.h"
#include "OBJLoader.h"
#include <vector>
/*
//#include <SpriteFont.h>
#include "CommonStates.h"
//#include "DDSTextureLoader.h"
#include "Effects.h"
#include "GeometricPrimitive.h"
#include "Model.h"
#include "PrimitiveBatch.h"
#include "ScreenGrab.h"
#include "SpriteBatch.h"
#include "SpriteFont.h"
#include "VertexTypes.h"
*/
#include "GameObject.h"
#include "AI.h"
using namespace DirectX;
//struct SimpleVertex
//{
// XMFLOAT3 PosL;
// XMFLOAT3 NormL;
// XMFLOAT2 Tex;
//};
struct SurfaceInfo
{
XMFLOAT4 AmbientMtrl;
XMFLOAT4 DiffuseMtrl;
XMFLOAT4 SpecularMtrl;
};
struct Light
{
XMFLOAT4 AmbientLight;
XMFLOAT4 DiffuseLight;
XMFLOAT4 SpecularLight;
float SpecularPower;
XMFLOAT3 LightVecW;
};
struct ConstantBuffer
{
XMMATRIX World;
XMMATRIX View;
XMMATRIX Projection;
SurfaceInfo surface;
Light light;
XMFLOAT3 EyePosW;
float HasTexture;
};
class Application
{
private:
HINSTANCE _hInst;
HWND _hWnd;
D3D_DRIVER_TYPE _driverType;
D3D_FEATURE_LEVEL _featureLevel;
ID3D11Device* _pd3dDevice;
ID3D11DeviceContext* _pImmediateContext;
IDXGISwapChain* _pSwapChain;
ID3D11RenderTargetView* _pRenderTargetView;
ID3D11VertexShader* _pVertexShader;
ID3D11PixelShader* _pPixelShader;
ID3D11InputLayout* _pVertexLayout;
ID3D11Buffer* _pVertexBuffer;
ID3D11Buffer* _pIndexBuffer;
ID3D11Buffer* _pPlaneVertexBuffer;
ID3D11Buffer* _pPlaneIndexBuffer;
ID3D11Buffer* _pConstantBuffer;
ID3D11DepthStencilView* _depthStencilView = nullptr;
ID3D11Texture2D* _depthStencilBuffer = nullptr;
ID3D11ShaderResourceView * _pTextureRV = nullptr;
ID3D11ShaderResourceView * _pGroundTextureRV = nullptr;
ID3D11ShaderResourceView* _pHerculesTextureRV = nullptr;
ID3D11SamplerState * _pSamplerLinear = nullptr;
MeshData objMeshData;
Light basicLight;
vector<GameObject *> _gameObjects;
Camera * _camera = nullptr;
float _cameraOrbitRadius = 7.0f;
float _cameraOrbitRadiusMin = 2.0f;
float _cameraOrbitRadiusMax = 50.0f;
float _cameraOrbitAngleXZ = -90.0f;
float _cameraSpeed = 2.0f;
UINT _WindowHeight;
UINT _WindowWidth;
// Render dimensions - Change here to alter screen resolution
UINT _renderHeight = 1080;
UINT _renderWidth = 1920;
ID3D11DepthStencilState* DSLessEqual;
ID3D11RasterizerState* RSCullNone;
ID3D11RasterizerState* CCWcullMode;
ID3D11RasterizerState* CWcullMode;
Geometry herculesGeometry;
Geometry cubeGeometry;
Geometry planeGeometry;
Material shinyMaterial;
Material noSpecMaterial;
AI autonomousAgent;
float speed = 4.0f;
private:
HRESULT InitWindow(HINSTANCE hInstance, int nCmdShow);
HRESULT InitDevice();
void Cleanup();
HRESULT CompileShaderFromFile(WCHAR* szFileName, LPCSTR szEntryPoint, LPCSTR szShaderModel, ID3DBlob** ppBlobOut);
HRESULT InitShadersAndInputLayout();
HRESULT InitVertexBuffer();
HRESULT InitIndexBuffer();
void moveForward(int objectNumber);
void moveBackward(int objectNumber);
void moveRight(int objectNumber);
Debug debug;
bool keyPressed = false;
public:
#define NUMBER_OF_CUBES 3
#define FPS_60 1.0f/60.0f
//#define FPS_60 25.0f
Application();
~Application();
HRESULT Initialise(HINSTANCE hInstance, int nCmdShow);
bool HandleKeyboard(MSG msg);
void moveLeft(int objectNumber);
void Update();
void Draw();
};