continuing the avatar class
[laserbrain_demo] / src / avatar.cc
index 0986d8a..737d3a6 100644 (file)
@@ -2,6 +2,89 @@
 
 Avatar::Avatar()
 {
+       mode = 0;
        body_rot = 0;
        head_alt = 0;
 }
+
+void Avatar::set_tracking_mode(unsigned int mode)
+{
+       this->mode = mode;
+}
+
+unsigned int Avatar::get_tracking_mode() const
+{
+       return mode;
+}
+
+void Avatar::set_position(const Vec3 &p)
+{
+       pos = p;
+}
+
+const Vec3 &Avatar::get_position() const
+{
+       return pos;
+}
+
+void Avatar::set_body_rotation(float rot)
+{
+       body_rot = rot;
+}
+
+float Avatar::get_body_rotation() const
+{
+       return body_rot;
+}
+
+const Vec3 &Avatar::get_body_fwd() const
+{
+       return fwd;
+}
+
+const Vec3 &Avatar::get_body_right() const
+{
+       return right;
+}
+
+const Quat &Avatar::get_head_rotation() const
+{
+       return head_rot;
+}
+
+void Avatar::tracked_head_rotation(const Quat &q)
+{
+       head_rot = q;
+}
+
+// TODO maybe transform from head-relative first
+void Avatar::tracked_hand_position(int hand, const Vec3 &p)
+{
+       hand_pos[hand] = p;
+}
+
+// TODO maybe transform from head-relative first
+void Avatar::tracked_hand_rotation(int hand, const Quat &q)
+{
+       hand_rot[hand] = q;
+}
+
+void Avatar::mouselook(float horiz, float vert)
+{
+       body_rot += horiz;
+       head_alt += vert;
+       if(head_alt > M_PI / 2.0) head_alt = M_PI / 2.0;
+       if(head_alt < -M_PI / 2.0) head_alt = -M_PI / 2.0;
+}
+
+Vec3 Avatar::calc_walk_dir(float fwd, float right) const
+{
+       // TODO
+       return Vec3(0, 0, 0);
+}
+
+void Avatar::walk(float fwd, float right)
+{
+       Vec3 wdir = calc_walk_dir(fwd, right);
+       pos += wdir;
+}