cancel
Showing results for 
Search instead for 
Did you mean: 

Coin3D Integration - WIP

Afuerg
Level 2
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 12

jriegel
Level 2
Hi,
in case some one is interested....

In the process of integrating the Rift into FreeCAD (http://freecadweb.org/) I port the example to the DK2 and the SDK 4.2. Also there is some position and light handling added and some bug fixes.

The code you will find here:
http://sourceforge.net/p/free-cad/code/ci/jriegel/Rift/~/tree/src/Gui/CoinRiftWidget.cpp
http://sourceforge.net/p/free-cad/code/ci/jriegel/Rift/~/tree/src/Gui/CoinRiftWidget.h
At the moment a branch, but later it will be in the master branch...

Many thanks to Bastian Veelo and the others pioneer the integration!

Since it seams I'm not allowed to post or link pictures, you have to look here for one:
http://forum.freecadweb.org/viewtopic.php?f=9&t=7715

Have fun
Jürgen

RicksonNL
Level 2
Jurgen, Can you give me an instruction how to get the rift support working in Freecad?

jriegel
Level 2
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.