# HG changeset patch # User John Tsiombikas # Date 1379649618 -10800 # Node ID 39ec672a51583c40d85dc2e7a371c6f480fcaadb # Parent b2abb08c8f9492f3c288af46c0e35374bb662165 added simple head model to the VR camera diff -r b2abb08c8f94 -r 39ec672a5158 src/camera.cc --- a/src/camera.cc Fri Sep 20 06:49:39 2013 +0300 +++ b/src/camera.cc Fri Sep 20 07:00:18 2013 +0300 @@ -195,6 +195,30 @@ // --- VR additions --- +VRFpsCamera::VRFpsCamera() +{ + neck_eye_dist = 0.14; // default neck->eye distance 14cm +} + +void VRFpsCamera::calc_matrix(Matrix4x4 *mat) const +{ + mat->reset_identity(); + mat->translate(Vector3(pos.x, pos.y, pos.z)); + mat->rotate(Vector3(0, theta, 0)); + mat->rotate(Vector3(phi, 0, 0)); + mat->rotate(Vector3(0, 0, roll)); + mat->translate(Vector3(0, neck_eye_dist, 0)); +} + +void VRFpsCamera::calc_inv_matrix(Matrix4x4 *mat) const +{ + mat->reset_identity(); + mat->translate(Vector3(0, -neck_eye_dist, 0)); + mat->rotate(Vector3(0, 0, roll)); + mat->rotate(Vector3(phi, 0, 0)); + mat->rotate(Vector3(0, theta, 0)); + mat->translate(Vector3(-pos.x, -pos.y, -pos.z)); +} void VRFpsCamera::track_vr() { diff -r b2abb08c8f94 -r 39ec672a5158 src/camera.h --- a/src/camera.h Fri Sep 20 06:49:39 2013 +0300 +++ b/src/camera.h Fri Sep 20 07:00:18 2013 +0300 @@ -83,9 +83,15 @@ class VRFpsCamera : public FpsCamera { private: + float neck_eye_dist; float prev_angles[3]; + void calc_matrix(Matrix4x4 *mat) const; + void calc_inv_matrix(Matrix4x4 *mat) const; + public: + VRFpsCamera(); + void track_vr(); }; diff -r b2abb08c8f94 -r 39ec672a5158 src/main.cc --- a/src/main.cc Fri Sep 20 06:49:39 2013 +0300 +++ b/src/main.cc Fri Sep 20 07:00:18 2013 +0300 @@ -73,7 +73,8 @@ glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); - cam.input_move(0, 1.75, 0); + // y = height of neck + cam.input_move(0, 1.65, 0); if(vr_init(VR_INIT_OCULUS) == -1) { return false;