r/oculusdev • • Feb 05 '14

Unable to program mouse look and head-tracking

Hi, I'm an amateur VR developer and I've hit a strange road block. I'm unable to program both mouse look AND head-tracking (though I can get one or the other).

Here is a download link to my game. It is almost unplayable with only head-tracking so this download contains mouse look.

https://docs.google.com/a/umail.iu.edu/file/d/0B8Eclgcxxx1RY3A2UFYtMVlfTkU/edit

Any advice would be incredibly helpful! Thanks!

6 Upvotes

2 comments sorted by

1

u/Devlin1991 Feb 06 '14

Just about to pop off to Uni so I can't look at the code but here is how I do it in C++, you should be able to adapt the steps for whatever language you are using.

// get headtracking as a quaternion
OVR::Quatf orientationQuartention = pSFusion->GetOrientation();

// cast it into a Matrix4f
OVR::Matrix4f headTrackedViewMatrix = orientationQuartention;

// cast it into a glm::mat4(it's what I use in my programs, you can probably skip this step if your mouse look viewMatrix is also an OVR::Matrix4f
glm::mat4 orientationMatrix;
memcpy( glm::value_ptr( orientationMatrix ), headTrackedViewMatrix.M,sizeof(headTrackedViewMatrix.M));

// multiply the matrices to get one final viewMatrix which contains both the mouse look and head tracking.
viewMatrix = orientationMatrix * mouseLookMatrix;

If you had something like a cockpit which the user was riding in you would probably want a 3rd matrix in that multiplication that accounts for the cars orientation as well.

1

u/oculoid9 Feb 11 '14

Thanks for this! Haven't gotten a chance to try it but I'll let you know.

And please let me know if you think of anything else.