Added the camera class

Added the DDS Texture Loading for future use
Added the gamepad class for future use
Added first child method to the scenegraph
Added RGB to intensity and lerp methods to the shared methods class
Added the terrain node class with normals
Fixed issue with submeshnode not passing the world transform to the actual meshes
This commit is contained in:
iDunnoDev
2022-04-18 22:33:15 +01:00
committed by iDunnoDev
parent 65255f1321
commit 7a57c73ac3
47 changed files with 4323 additions and 91 deletions

85
Graphics2/TerrainNode.h Normal file
View File

@ -0,0 +1,85 @@
#pragma once
#include <fstream>
#include <vector>
#include "WICTextureLoader.h"
#include "SharedMethods.h"
#include "SceneNode.h"
#include "Vector3D.h"
class TerrainNode : public SceneNode
{
public:
TerrainNode(wstring name, wstring heightMap, int widthX = 1023, int widthZ = 1023, int rows = 10, int cols = 10);
bool Initialise(void);
void Render(void);
void Shutdown(void);
private:
int _widthX;
int _widthZ;
UINT _gridRows;
UINT _gridCols;
int _cellSizeX;
int _cellSizeZ;
bool _usedHeightMap;
UINT _polygonsCount;
UINT _indiciesCount;
UINT _vertexCount;
float _terrainStartX;
float _terrainStartZ;
float _terrainEndX;
float _terrainEndZ;
wstring _heightMap;
wstring _textureName;
vector<VERTEX> _terrainVerts;
vector<int> _indices;
vector<float> _heightValues;
vector<Vector3D> _terrainNormals;
XMFLOAT4 _ambientLight;
XMFLOAT4 _directionalLightVector;
XMFLOAT4 _directionalLightColor;
XMFLOAT4 _cameraPosition;
ComPtr<ID3D11Device> _device;
ComPtr<ID3D11DeviceContext> _deviceContext;
ComPtr<ID3D11Buffer> _vertexBuffer;
ComPtr<ID3D11Buffer> _indexBuffer;
ComPtr<ID3DBlob> _vertexShaderByteCode = nullptr;
ComPtr<ID3DBlob> _pixelShaderByteCode = nullptr;
ComPtr<ID3D11VertexShader> _vertexShader;
ComPtr<ID3D11PixelShader> _pixelShader;
ComPtr<ID3D11InputLayout> _layout;
ComPtr<ID3D11Buffer> _constantBuffer;
ComPtr<ID3D11ShaderResourceView> _texture;
ComPtr<ID3D11BlendState> _transparentBlendState;
ComPtr<ID3D11RasterizerState> _defaultRasteriserState;
ComPtr<ID3D11RasterizerState> _wireframeRasteriserState;
void GenerateTerrainData();
void GenerateBuffers();
void BuildShaders();
void BuildVertexLayout();
void BuildConstantBuffer();
void BuildBlendState();
void BuildRendererStates();
void BuildTexture();
bool LoadHeightMap(wstring heightMapFilename);
float GetHeightMapValueAt(int index);
void AddNormalToVertex(int row, int col, int vertexIndex, Vector3D normal);
};