Hi Torben,

the framecylce consists of 4 parts:

Code:

advance();
eventTraversal();
updateTraversal();
drawTraversal();

What you called "drawTraversal" is actually called renderingTraversals(), and consists of two phases: the cull phase, where OSG traverses the scene gathering things it needs to draw into a render graph, and the draw phase, where it dispatches the draw commands (OpenGL calls) required to render what is in the render graph.

But you got the high-level idea.

My question:
- The camera manipulators handle(); function is called by the the 
eventTraversal, right?
- is the manipulators handle() function called before or after the execution of 
the callback function?
- I would like to use the callback to catch some external camera data, then 
calculate the camera position/attitude immediately and send thsi resulting camera 
modelview to other hosts to apply this camerasetting to their cameras. ->  is 
it possible only be the viewmatrix or do I have to transfer other data?

From your questions, I think one important fact is missing for you to understand what's going on: the camera manipulator gets events during the update traversal, but the view gets the view matrix from it during the cull traversal.

Essentially, all the camera manipulator does during the event phase is get events and figure out what it should do with them. The actual calculation of the view matrix (which is what the camera needs to be able to position itself in the world) is calculated in the cull traversal, where the view will do:

if (cameraManipulator.valid())
{
    osg::Matrix viewMatrix = cameraManipulator->getInverseMatrix();
    camera->setViewMatrix(viewMatrix);
}

// Use the camera's view matrix as the start of the model view matrix.
osg::Matrix modelViewMatrix = camera->getViewMatrix();

// Start accumulating transforms down from the camera to form the
// model view matrix at each node.
// ...

(this is from memory, but you could place a breakpoint in TrackballManipulator::getInverseMatrix() and go up in the stack trace when your breakpoint is hit to see the whole code.

The point is, if you have a camera manipulator, it will overwrite whatever you set as your camera's view matrix in a callback. If you want to set the camera's view matrix yourself, just don't use a camera manipulator. As you can see from the code I wrote from memory above, if the view's cameraManipulator is NULL nothing will touch the values you set in your camera's view matrix.

Just so you know, calling viewer.run() adds a camera manipulator (TrackballManipulator) by default. If you do

while (!viewer.done)
    viewer.frame();

instead, there won't be a camera manipulator added (you can add the one you want, a custom one, or none at all).

I tried to get this information directly from the osg sources, but my knowledge 
is currently insufficient to unterstand the code at this aspect.. (yes, I'm one 
of these guys commenting code not to loose the overview, so I'm struggling at 
pure code..)

The code is not the only tool you have to try and understand things... As I said above, one good way is to set breakpoints and walk through the code that way.

Hope this helps,

J-S
--
______________________________________________________
Jean-Sebastien Guay    jean-sebastien.g...@cm-labs.com
                               http://www.cm-labs.com/
                        http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to