Skip to main content
Up and Coming
February 26, 2014

Coin3D Integration - WIP

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/tLPeGap2

I'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.

    12 replies

    Participant
    September 18, 2014
    Jurgen, Can you give me an instruction how to get the rift support working in Freecad?
    New Participant
    September 25, 2014
    At the moment you have to compile FreeCAD from the source with BUILD_FREECAD-VR enabled in cMake.

    I thought of releasing in our unstable builds, but till the Rift direct render mode with OpenGl is not resolved I will postpone it.