#include "avatar.h"
+#include "logger.h"
Avatar::Avatar()
{
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
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)