background
i'm running vtk kiwiviewer source on mobile device , i'm using make vr scenes using point clouds user's phone acts vr goggles.
i'm getting attitude
cmdevicemotion provides me euler angles x, y, , z axes (respectively pitch, roll, , yaw).
i'm trying google cardboard experience without leveraging cardboard sdk. reason being because kiwi import models need testing.
scenario
kiwi uses xyz coordinate based system camera position , focal point. here 3 objects have work position vr view:
- focal point: xyz of point camera looking at
- camera position: xyz camera in 3d space
- camera up: relative xyz control rotation of camera
for i'm putting camera position @ 0,0,0
. use sin
/cos
euler angles * 10 place focal point 10 units away camera. setting camera position , focal point location automatically sets camera up useable correct value.
setting focal point
x = -(sin(roll) * cos(pitch)) * 10; y = cos(roll) * sin(pitch) * 10; z = sin(yaw); setcamerafocalpoint(x, y, z);
question
my current setup works okay has nasty quirks. how can tweak conversion more solid vr experience?
you need find out, convention euler angles made (x * y * z
common, sdk might use another). then, according rotation matrix. view direction last column of matrix (or inverse if use right-handed coordinate systems). direction second column.
if sdk allows set view matrix directly, can use transposed rotation matrix (and add fourth row , column of zeroes , m44=1
).