Background
I'm running VTK KiwiViewer source on my mobile device and I'm using it to make VR scenes using point clouds where the user's phone acts as the VR goggles.
I'm getting attitude
from CMDeviceMotion which provides me with Euler Angles for the x, y, and z axes (respectively pitch, roll, and yaw).
I'm trying to get a Google Cardboard Experience without leveraging the Cardboard SDK. Reason being because Kiwi will already import all the models I need for testing.
Scenario
Kiwi uses a XYZ coordinate based system for Camera Position and Focal Point. Here are the three objects you have to work with to position the VR view:
- Focal Point: xyz of the point the camera is looking at
- Camera Position: xyz where the camera is in 3d space
- Camera Up: relative xyz to control the rotation of the camera
For now I'm always putting the Camera Position at 0,0,0
. I use sin
/cos
with Euler Angles * 10 to place the Focal Point 10 units away from the camera. Setting the Camera Position and Focal Point location automatically sets Camera Up to a useable correct value.
Setting the 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 but it has some nasty quirks. How can I tweak my conversion to get a more solid VR experience?