forked from AngelMonica126/GraphicAlgorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameObject.h
76 lines (64 loc) · 2.37 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
68
69
70
71
72
73
74
75
76
//--------------------------------------------------------------------------------------
// Copyright (c) Elay Pu. All rights reserved.
//--------------------------------------------------------------------------------------
#pragma once
#include <string>
#include <GLM/glm.hpp>
#include <memory>
#include <vector>
#include "FRAME_EXPORTS.h"
class CModel;
class CShader;
class CAABB;
class FRAME_DLLEXPORTS IGameObject
{
public:
IGameObject();
IGameObject(const std::string &vGameObjectName, int vExecutionOrder);
virtual ~IGameObject();
virtual void initV() = 0;
virtual void updateV() = 0;
void setPosition(const glm::vec3& vPosition);
void setRotationX(float vRotationAngle);
void setRotationY(float vRotationAngle);
void setRotationZ(float vRotationAngle);
void setScale(const glm::vec3& vScale);
void setExecutionOrder(int vExecutionOrder) { m_ExecutionOrder = vExecutionOrder; }
void setGameObjectName(const std::string &vName) { m_Name = vName; };
void setVAO(int vVAO) { m_VAO = vVAO; }
void setModel(const std::shared_ptr<CModel> &vModel) { m_pModel = vModel; }
int getVAO() const;
int getExecutationOrder() const { return m_ExecutionOrder; }
float getRotationX() const;
float getRotationY() const;
float getRotationZ() const;
const glm::vec3& getPosition() const;
const glm::vec3& getScale() const;
const glm::mat4& getModelMatrix() const;
const std::string& getGameObjectName() const { return m_Name; }
const std::shared_ptr<CModel>& getModel() { return m_pModel; }
void translate(const glm::vec3& vPositionOffset);
void rotateX(float vRotationOffset);
void rotateY(float vRotationOffset);
void rotateZ(float vRotationOffset);
void scale(const glm::vec3& vScaleOffset);
void initModel(CShader& vioShader) const;
void updateModel(const CShader& vShader) const;
std::shared_ptr<CAABB> getAABB() const;
std::vector<glm::vec3> getTriangle();
bool operator<(const IGameObject& vOtherPass) const;
private:
int m_VAO = -1;
int m_ExecutionOrder = -1;
std::string m_Name;
glm::vec3 m_Position;
glm::vec3 m_RotationAngle; //ÈÆxyzÖáµÄÐýת½Ç¶È
glm::vec3 m_Scale = glm::vec3(1, 1, 1);
glm::mat4 m_ModelMatrix;
glm::mat4 m_TranslationMatrix;
glm::mat4 m_RotationMatrix;
glm::mat4 m_ScaleMatrix;
std::shared_ptr<CModel> m_pModel;
void __updateModelMatrix();
void __setRotation(float vRotationAngleOffset, const glm::vec3& vRotateAxis);
};