X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=blobdiff_plain;f=src%2Favatar.cc;h=456f269b56241eccdd7d93f6b1c6c23a746b53e6;hp=737d3a6e07cccbc2f0bd6cfed56f6389115e25bf;hb=5c69b226e45df981db338dd859ef1d95e9be8f96;hpb=3f4b2a6d036159ecab23337202ea48a240cc1ff0 diff --git a/src/avatar.cc b/src/avatar.cc index 737d3a6..456f269 100644 --- a/src/avatar.cc +++ b/src/avatar.cc @@ -1,4 +1,5 @@ #include "avatar.h" +#include "logger.h" Avatar::Avatar() { @@ -30,6 +31,12 @@ const Vec3 &Avatar::get_position() const void Avatar::set_body_rotation(float rot) { body_rot = rot; + + float theta = deg_to_rad(body_rot); + fwd.x = sin(theta); + fwd.y = 0; + fwd.z = -cos(theta); + right = Vec3(-fwd.z, 0, fwd.x); } float Avatar::get_body_rotation() const @@ -79,8 +86,10 @@ void Avatar::mouselook(float horiz, float vert) Vec3 Avatar::calc_walk_dir(float fwd, float right) const { - // TODO - return Vec3(0, 0, 0); + float theta = M_PI * body_rot / 180.0f; + float dx = cos(theta) * right - sin(theta) * fwd; + float dz = sin(theta) * right + cos(theta) * fwd; + return Vec3(dx, 0, dz); } void Avatar::walk(float fwd, float right)