continuing the avatar class
[laserbrain_demo] / src / avatar.cc
1 #include "avatar.h"
2
3 Avatar::Avatar()
4 {
5         mode = 0;
6         body_rot = 0;
7         head_alt = 0;
8 }
9
10 void Avatar::set_tracking_mode(unsigned int mode)
11 {
12         this->mode = mode;
13 }
14
15 unsigned int Avatar::get_tracking_mode() const
16 {
17         return mode;
18 }
19
20 void Avatar::set_position(const Vec3 &p)
21 {
22         pos = p;
23 }
24
25 const Vec3 &Avatar::get_position() const
26 {
27         return pos;
28 }
29
30 void Avatar::set_body_rotation(float rot)
31 {
32         body_rot = rot;
33 }
34
35 float Avatar::get_body_rotation() const
36 {
37         return body_rot;
38 }
39
40 const Vec3 &Avatar::get_body_fwd() const
41 {
42         return fwd;
43 }
44
45 const Vec3 &Avatar::get_body_right() const
46 {
47         return right;
48 }
49
50 const Quat &Avatar::get_head_rotation() const
51 {
52         return head_rot;
53 }
54
55 void Avatar::tracked_head_rotation(const Quat &q)
56 {
57         head_rot = q;
58 }
59
60 // TODO maybe transform from head-relative first
61 void Avatar::tracked_hand_position(int hand, const Vec3 &p)
62 {
63         hand_pos[hand] = p;
64 }
65
66 // TODO maybe transform from head-relative first
67 void Avatar::tracked_hand_rotation(int hand, const Quat &q)
68 {
69         hand_rot[hand] = q;
70 }
71
72 void Avatar::mouselook(float horiz, float vert)
73 {
74         body_rot += horiz;
75         head_alt += vert;
76         if(head_alt > M_PI / 2.0) head_alt = M_PI / 2.0;
77         if(head_alt < -M_PI / 2.0) head_alt = -M_PI / 2.0;
78 }
79
80 Vec3 Avatar::calc_walk_dir(float fwd, float right) const
81 {
82         // TODO
83         return Vec3(0, 0, 0);
84 }
85
86 void Avatar::walk(float fwd, float right)
87 {
88         Vec3 wdir = calc_walk_dir(fwd, right);
89         pos += wdir;
90 }