Hi,
I'm trying to get the Rift view working with
Coin3D, based on an
"old" example by jherico.
Basically I'm building a simple Coin scene with a perspective camera, light and cube that I render with SoSceneManager. Also I replaced the GLFW window with a QGLWidget, but kept the original OpenGL Cube for comparison.
The rendering of the Coin scene happens in renderScene() with
SoSceneManager->setViewportRegion(vpRegion);
SoSceneManager->render(false, false);
In the original example, a shader named Simple.vs/Simple.fs is used to color the sides of the cube and correct its position/rotation for each eye, by calculating the translation*rotation matrix and setting gl_Position to it.
Applying the position manipulation of the shader to the scene didn't work for some reason, so I tried replicating this behavior with Coins camera, by extracting the translation and rotation from the calculated matrix with
SbMatrix.getTransform(translation, rotation, scaleFactor, scaleOrientation); and setting
SoPerspectiveCamera->position = translation;
SoPerspectiveCamera->orientation = rotation;
Also I'm setting the heightAngle, aspectRatio, nearDistance and farDistance of the camera, according to the values used in the example.
Unfortunately this doesn't create the results I was hoping for. Coins Cube is too wide apart so the two images won't align properly when viewed through the rift.
Anyway here's some quick & dirty (less quick and more dirty) adaption of Example00.cpp:
http://pastebin.com/tLPeGap2I'm in no way a Coin expert, so I'm sure that there are many better ways to do this, but I decided to stick closely to an already working example, because I realized from a previous attempt, that debbuging a slightly off view is a nightmare.
Just thought I'd share this with you guys.