Forum Discussion
Matlock
12 years agoHonored Guest
GetPredictedOrientation() causes shear on roll
Quatf hmdOrient = poculussensor->GetPredictedOrientation(); Matrix4f View = Matrix4f(hmdOrient); If you use this matrix to render, yaw, and pitch work as intended, but of you roll(twist) your head...
jherico
12 years agoAdventurer
"matlock" wrote:
I still have some other problem.
Now the camera seemingly moves on roll, even though the [12][13][14] elements of the view matrix are fixed(pre invert). Ill repost it as a different question if I cant figure it out.
if your camera is moving when you roll the device, there's probably an issue with how you're applying the modelview offset and or the Rift orientation to the modelview matrix. Typically this means you're doing a post-multiplication where you should be doing pre-multiplication, or you're compounding the matrices in the wrong order.
Suppose you have a matrix which represents the player position:
glm::mat4 player;
This represents the player's position and the direction they're facing, best thought of as the direction their torso is facing really. In order to convert that to a view matrix, you have to invert it:
glm::mat4 view = glm::inverse(player);
In order to apply the Rift orientation to that, you have to pre-multiply it by the rift orientation. Pre-multiplying means that the Rotation is applied in the coordinate system of the existing matrix. If you post-multiply instead, you end up rotating the player position around the world axis.
view = riftOrientation * view;
In order to get stereo seperation, you have to apply the per-eye modelview offset on top of that. Again, this is a pre-multiplication, which should occur after you've already applied the Rift orientation to the view matrix:
view = perEyeModelviewOffset * view;
At this point, you've completely set up the view matrix. If you draw a cube at the origin of the world, it will appear there relative to wherever the player is. Subsequent operations of the matrix will move things around relative to that world origin, hence the view matrix is now the modelview matrix, because operations applied to it have an effect on the models in the world.
I've written up a blog post on how to do the setup of the projection and modelview matrices, and a (hopefully) easy way to test to make sure that you're getting the correct results.
"matlock" wrote:
anyways, oculus should hire jherico. :!:
Heh. Well, in lieu of that, you can always support me directly by buying my book. :D
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 4 years ago