-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathphys_object.h
54 lines (40 loc) · 965 Bytes
/
phys_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
#ifndef PHYS_OBJECT_H
#define PHYS_OBJECT_H
#include "transform.h"
#include "collider.h"
#include "mesh.h"
/* class PhysObject:
* a physical entithy if our virtual world.
* It has
* - a transform ("where it is"),
* - physical properties, like mass, speed, angular speed...
* - more components, including:
* * a physical estension (a Collider)
* * a way it looks (a MeshComponent)
*
* TODO: make a hierarchical structure, i.e. make it a node of a SceneGraph.
*/
class PhysObject{
public:
Transform t;
// components
Collider coll;
MeshComponent meshComponent;
vec3 vel;
quat angVel;
float mass;
void render() const;
void doPhysStep();
float drag;
float angDrag;
void reset(){
vel = vec3(0,0,0);
angVel = quat(1,0,0,0);
t.setIde();
}
void setCameraInside();
};
bool collides(const PhysObject &a ,
const PhysObject &b );
void enforceSeparate(PhysObject &a , PhysObject &b );
#endif // PHYS_OBJECT_H