-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameObject.cpp
More file actions
44 lines (30 loc) · 1.04 KB
/
Copy pathGameObject.cpp
File metadata and controls
44 lines (30 loc) · 1.04 KB
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
#include "GameObject.h"
using namespace _GameObject;
GameObject::GameObject(const char* id, const char* dir) : Entity(id), Model(id, dir) {
}
GameObject::GameObject(const char* id, const char* dir, glm::vec3 position) : Entity(id, position), Model(id, dir) {
}
GameObject::~GameObject() {
}
void GameObject::add_force(glm::vec3 f , const float& delta) {
glm::vec3 force = (f * mass);
glm::vec3 acceleration = force / mass;
velocity += acceleration * delta;
std::cout << velocity.y << std::endl;
}
void GameObject::simulate(const float& delta) {
set_position(get_position() + velocity * delta);
}
void GameObject::add_velocity(glm::vec3 v) {
velocity += v;
}
void GameObject::set_velocity(glm::vec3 v) {
velocity = v;
}
glm::vec3 GameObject::get_velocity() {
return velocity;
}
AABB GameObject::get_AABB() const {
const glm::vec3 position = get_position();
return *new AABB(bounds_min.x + position.x, bounds_min.y + position.y, bounds_min.z + position.z, bounds_max.x + position.x, bounds_max.y + position.y, bounds_max.z + position.z);
}