projects
/
laserbrain_demo
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
stash/unstash clunky as fuck
[laserbrain_demo]
/
src
/
avatar.cc
diff --git
a/src/avatar.cc
b/src/avatar.cc
index
737d3a6
..
456f269
100644
(file)
--- a/
src/avatar.cc
+++ b/
src/avatar.cc
@@
-1,4
+1,5
@@
#include "avatar.h"
#include "avatar.h"
+#include "logger.h"
Avatar::Avatar()
{
Avatar::Avatar()
{
@@
-30,6
+31,12
@@
const Vec3 &Avatar::get_position() const
void Avatar::set_body_rotation(float rot)
{
body_rot = rot;
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
}
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
{
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)
}
void Avatar::walk(float fwd, float right)