forked from PrototypeX29A/norbit
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgame_object.cpp
More file actions
105 lines (86 loc) · 1.53 KB
/
game_object.cpp
File metadata and controls
105 lines (86 loc) · 1.53 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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "malloc.h"
#include "string.h"
#include "physics.h"
//#include "object.h"
#include "shadow.h"
#include "game_object.h"
#include <assert.h>
simulation_world *
game_object::world = NULL;
using namespace
std;
game_object::game_object(){
id =(int)this; //quick n dirty
}
void
game_object::set_position (float x, float y, float z)
{
assert (body);
assert (world);
body->aConfigurations[body->SourceConfigurationIndex].CMPosition =
vector_2 (r (x), r (y));
}
float
game_object::posx ()
{
assert (world);
return body->aConfigurations[body->SourceConfigurationIndex].CMPosition.X;
}
float
game_object::posy ()
{
assert (world);
return body->aConfigurations[body->SourceConfigurationIndex].CMPosition.Y;
}
float
game_object::posz ()
{
return 0.0f;
}
/**
* Return orientation in degrees
*/
float
game_object::orientation ()
{
return body->aConfigurations[body->SourceConfigurationIndex].Orientation *
180.0 / PI;
}
void
game_object::set_simulation_world (simulation_world * w)
{
assert (w);
world = w;
}
void
game_object::set_rigid_body (rigid_body * b)
{
assert (world);
assert (b);
body = b;
}
// specified in local coords
void
game_object::apply_force (vector_2 const &F, vector_2 const &Pl)
{
assert (body);
body->apply_force (F, Pl);
}
//apply force, specified in global coords
void
game_object::apply_force_G (vector_2 const &F, vector_2 const &Pl)
{
assert (body);
body->apply_force_G (F, Pl);
}
float
game_object::mass ()
{
return body->Mass;
}
shape::shape ()
{
}
shape::~shape ()
{
}