oculus1

changeset 11:39ec672a5158

added simple head model to the VR camera
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 20 Sep 2013 07:00:18 +0300
parents b2abb08c8f94
children d797639e0234
files src/camera.cc src/camera.h src/main.cc
diffstat 3 files changed, 32 insertions(+), 1 deletions(-) [+]
line diff
     1.1 --- a/src/camera.cc	Fri Sep 20 06:49:39 2013 +0300
     1.2 +++ b/src/camera.cc	Fri Sep 20 07:00:18 2013 +0300
     1.3 @@ -195,6 +195,30 @@
     1.4  
     1.5  
     1.6  // --- VR additions ---
     1.7 +VRFpsCamera::VRFpsCamera()
     1.8 +{
     1.9 +	neck_eye_dist = 0.14;	// default neck->eye distance 14cm
    1.10 +}
    1.11 +
    1.12 +void VRFpsCamera::calc_matrix(Matrix4x4 *mat) const
    1.13 +{
    1.14 +	mat->reset_identity();
    1.15 +	mat->translate(Vector3(pos.x, pos.y, pos.z));
    1.16 +	mat->rotate(Vector3(0, theta, 0));
    1.17 +	mat->rotate(Vector3(phi, 0, 0));
    1.18 +	mat->rotate(Vector3(0, 0, roll));
    1.19 +	mat->translate(Vector3(0, neck_eye_dist, 0));
    1.20 +}
    1.21 +
    1.22 +void VRFpsCamera::calc_inv_matrix(Matrix4x4 *mat) const
    1.23 +{
    1.24 +	mat->reset_identity();
    1.25 +	mat->translate(Vector3(0, -neck_eye_dist, 0));
    1.26 +	mat->rotate(Vector3(0, 0, roll));
    1.27 +	mat->rotate(Vector3(phi, 0, 0));
    1.28 +	mat->rotate(Vector3(0, theta, 0));
    1.29 +	mat->translate(Vector3(-pos.x, -pos.y, -pos.z));
    1.30 +}
    1.31  
    1.32  void VRFpsCamera::track_vr()
    1.33  {
     2.1 --- a/src/camera.h	Fri Sep 20 06:49:39 2013 +0300
     2.2 +++ b/src/camera.h	Fri Sep 20 07:00:18 2013 +0300
     2.3 @@ -83,9 +83,15 @@
     2.4  
     2.5  class VRFpsCamera : public FpsCamera {
     2.6  private:
     2.7 +	float neck_eye_dist;
     2.8  	float prev_angles[3];
     2.9  
    2.10 +	void calc_matrix(Matrix4x4 *mat) const;
    2.11 +	void calc_inv_matrix(Matrix4x4 *mat) const;
    2.12 +
    2.13  public:
    2.14 +	VRFpsCamera();
    2.15 +
    2.16  	void track_vr();
    2.17  };
    2.18  
     3.1 --- a/src/main.cc	Fri Sep 20 06:49:39 2013 +0300
     3.2 +++ b/src/main.cc	Fri Sep 20 07:00:18 2013 +0300
     3.3 @@ -73,7 +73,8 @@
     3.4  	glEnable(GL_LIGHT0);
     3.5  	glEnable(GL_LIGHTING);
     3.6  
     3.7 -	cam.input_move(0, 1.75, 0);
     3.8 +	// y = height of neck
     3.9 +	cam.input_move(0, 1.65, 0);
    3.10  
    3.11  	if(vr_init(VR_INIT_OCULUS) == -1) {
    3.12  		return false;