-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathObject.h
73 lines (44 loc) · 1.59 KB
/
Object.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
#ifndef PHYSICALENGINE_OBJECT_H
#define PHYSICALENGINE_OBJECT_H
#include "glm/glm.hpp"
#include "glm/gtc/type_ptr.hpp"
#include <vector>
enum class ObjectType {
Internal,
External
};
class Object {
public:
Object(float mass, ObjectType type);
void MoveTo(float x, float y, bool relative = false);
void SetLinearVelocity(float vx, float vy);
void SetForce(float fx, float fy);
void Rotate(float angle, bool relative = false);
virtual bool ContainsPoint(glm::vec2 v) = 0;
void SetAngularVelocity(float av);
void SetTorque(float torque);
inline glm::vec2 GetPosition() { return this->position; }
inline glm::vec2 GetLinearVelocity() { return this->linearVelocity; }
inline glm::vec2 GetForce() { return this->force; }
inline float GetAngle() const { return this->angle; }
inline float GetAngularVelocity() const { return this->angularVelocity; }
virtual glm::vec2 GetCentroid() = 0;
virtual void CalculateInertia();
inline ObjectType GetShapeType() { return this->shapeType; }
inline float GetTorque() const { return this->torque; }
inline float GetMass() const { return this->mass; }
void ChangeMass(float mass, bool relative);
inline float GetMomentOfInertia() const { return this->momentOfInertia; }
float GetAngularMass(glm::vec2 r, glm::vec2 n) const;
protected:
glm::vec2 position;
glm::vec2 linearVelocity;
glm::vec2 force;
float angle;
float angularVelocity;
float torque;
float mass;
float momentOfInertia;
ObjectType shapeType;
};
#endif //PHYSICALENGINE_OBJECT_H