-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameObject.h
68 lines (52 loc) · 1.89 KB
/
GameObject.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.h"
#include "SceneContext.h"
#include "PhysxManager.h"
#include <vector>
class GameScene;
class GameObject
{
public:
GameObject();
virtual ~GameObject();
GameObject(const GameObject& t) = delete;
GameObject& operator=(const GameObject& t) = delete;
const XMFLOAT3& GetPosition() const { return m_Position; }
const XMFLOAT3& GetScale() const { return m_Scale; }
const XMFLOAT4& GetRotation() const { return m_Rotation; }
const XMFLOAT4X4& GetWorldMatrix() const { return m_WorldMatrix; }
GameScene* GetScene() const;
GameObject* GetParent() const { return m_pParent; }
PxRigidActor* GetRigidActor() const { return m_pRigidActor; }
void AddChild(GameObject* pObject);
void AttachRigidActor(PxRigidActor* pRigidActor);
PxRigidActor* DetachRigidActor();
bool RemoveChild(GameObject* pObject, bool deleteObject = false);
void Translate(float x, float y, float z);
void Rotate(float x, float y, float z);
void RotateDegrees(float x, float y, float z);
void Scale(float x, float y, float z);
void CanDraw(bool canDraw) { m_CanDraw = canDraw; }
virtual void Initialize() = 0;
virtual void Draw(const SceneContext& sceneContext) = 0;
virtual void Update(const SceneContext& sceneContext) = 0;
protected:
bool m_IsInitialized;
std::vector<GameObject*> m_Children;
DirectX::XMFLOAT4X4 m_WorldMatrix;
DirectX::XMFLOAT3 m_Position, m_Scale;
DirectX::XMFLOAT4 m_Rotation;
DirectX::XMFLOAT3 m_WorldPosition, m_WorldScale;
DirectX::XMFLOAT4 m_WorldRotation;
PxRigidActor* m_pRigidActor;
private:
friend GameScene;
void RootInitialize();
void RootUpdate(const SceneContext& sceneContext);
void RootDraw(const SceneContext& sceneContext);
void CalculateWorldMatrix(const DirectX::XMMATRIX& parentWorld, bool updateChildren = true);
GameScene* m_pScene;
GameObject* m_pParent;
bool m_PositionChanged, m_RotationChanged, m_ScaleChanged, m_RigidActorAdded;
bool m_CanDraw;
};