X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=blobdiff_plain;f=src%2Favatar.h;h=e604177f1c60afaf0f139e309bb91c7e878ef74a;hp=6c3aa41a7614d0416fdc9918cc904971809fe39a;hb=01d6ef175190e649ecf7deb298f34f0e9bd3233e;hpb=2829b50d6b3d9e97fc9399f5b6929f7d64021366 diff --git a/src/avatar.h b/src/avatar.h index 6c3aa41..e604177 100644 --- a/src/avatar.h +++ b/src/avatar.h @@ -5,19 +5,67 @@ #include -/* when head-tracking is available, head_tilt is ignored, and the - * body_rot (controlled by mouse/gamepad) is independent of head_rot. +enum { + AVATAR_NO_TRACKING = 0, + AVATAR_HEAD_TRACKING = 1, + AVATAR_HAND_TRACKING = 2 +}; + +/* when head tracking is available, head_alt is ignored * - * without head-tracking, head_rot is derived from body_rot and head_tilt + * if HAND tracking is available, body_rot is derived from the hand + * orientation during the last call to walk(). + * + * without head-tracking, head_rot is derived from body_rot and head_alt */ class Avatar { +//private: public: + unsigned int mode; // tracking mode + Vec3 pos; - float body_rot; + float body_rot; // walk direction basically Quat head_rot; // used when head-tracking - float head_alt; // used for mouselook + float head_alt; // used for mouselook + Vec3 hand_pos[2]; + Quat hand_rot[2]; + + // body forward and right vectors + Vec3 fwd, right; + +public: Avatar(); + + void set_tracking_mode(unsigned int mode); + unsigned int get_tracking_mode() const; + + void set_position(const Vec3 &p); + const Vec3 &get_position() const; + + void set_body_rotation(float rot); + float get_body_rotation() const; + const Vec3 &get_body_fwd() const; + const Vec3 &get_body_right() const; + + const Quat &get_head_rotation() const; + + // set current head orientation when head-tracking + void tracked_head_rotation(const Quat &q); + + // set current hand position/orientation when hand-tracking + void tracked_hand_position(int hand, const Vec3 &p); + void tracked_hand_rotation(int hand, const Quat &q); + + // mouselook, or gamepad right-stick input + void mouselook(float horiz, float vert); + + // calculate absolute walk direction based on forward and right + // magnituted, and the current mode and body orientation data + Vec3 calc_walk_dir(float fwd, float right) const; + + // uses calc_walk_dir, then updates pos + void walk(float fwd, float right); }; #endif // AVATAR_H_