-
Notifications
You must be signed in to change notification settings - Fork 0
/
DrawableGameObject.h
68 lines (52 loc) · 2.06 KB
/
DrawableGameObject.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
#pragma once
#include <d3d11_1.h>
#include <d3dcompiler.h>
#include <directxcolors.h>
#include <DirectXCollision.h>
#include "DDSTextureLoader.h"
#include "resource.h"
#include <iostream>
#include "structures.h"
#include "Vector2D.h"
using namespace DirectX;
class DrawableGameObject
{
public:
DrawableGameObject();
virtual ~DrawableGameObject();
void release();
virtual HRESULT initMesh(ID3D11Device* pd3dDevice);
virtual void update(const float t);
void draw(ID3D11DeviceContext* pContext);
ID3D11ShaderResourceView** getTextureResourceView() { return &m_pTextureResourceView; }
XMFLOAT4X4* getTransform() { return &m_world; }
ID3D11SamplerState** getTextureSamplerState() { return &m_pSamplerLinear; }
void setXMPosition(DirectX::XMFLOAT3 position);
DirectX::XMFLOAT3* getXMPosition() { return &m_position; }
DirectX::XMFLOAT3* getDirection() { return &m_direction; }
// AI framework friendly functions
void setPosition(Vector2D position);
Vector2D getPosition();
protected:
void setDirection(DirectX::XMFLOAT3 direction);
void setTextureName(wstring texName) { m_textureName = texName; }
// helper functions
DirectX::XMFLOAT3 addFloat3(DirectX::XMFLOAT3& f1, DirectX::XMFLOAT3& f2);
DirectX::XMFLOAT3 subtractFloat3(DirectX::XMFLOAT3& f1, DirectX::XMFLOAT3& f2);
DirectX::XMFLOAT3 normaliseFloat3(DirectX::XMFLOAT3& f1);
float magnitudeFloat3(DirectX::XMFLOAT3& f1);
DirectX::XMFLOAT3 multiplyFloat3(DirectX::XMFLOAT3& f1, const float scalar);
DirectX::XMFLOAT3 divideFloat3(DirectX::XMFLOAT3& f1, const float scalar);
protected: // protected variables
XMFLOAT3 m_scale;
float m_radianRotation;
private: // private variables
XMFLOAT4X4 m_world;
ID3D11Buffer* m_pVertexBuffer;
ID3D11Buffer* m_pIndexBuffer;
ID3D11ShaderResourceView* m_pTextureResourceView;
ID3D11SamplerState * m_pSamplerLinear;
DirectX::XMFLOAT3 m_position;
DirectX::XMFLOAT3 m_direction;
wstring m_textureName;
};