I'm writing a camera manipulator but have an issue where I need the manipulator
to be visited during the update traversal (& after the scene graph has been
updated). Without going into too much detail ... the basic reason I require
this is ... that my manipulator needs to set the orthographic projection matrix
extents based on the updated scene. I really need to set the orthographic
projection matrix extents at about the point where the camera view matrix is
applied (see point 2c below).
So as we all know the viewer performs:
1. event traversal
2. update traversal
3. rendering traversals
And my area of concern is the viewers update traversal (point 2) which does the
following:
2a. visits the scene graph
2b. visits the camera
2c. sets the cameras view matrix (using the camera manipulators inverse matrix)
BUT it does NOT visit the active manipulator or have any way for the active
manipulator to apply a projection matrix if it so wishes (specifically at point
2c). :(
I've considered and tested the following, but they all feel like hacks:
- set the orthographic projection matrix extents in
MyCameraManipulator::getInverseMatrix(), called at point 2c. But I think this
is a bad idea because this method is really used for other purposes.
- have my active camera manipulator add an update callback onto the current
camera and so therefore set my projection matrix extents when I'm visited at
point 2b. But then I must also have code to remove the update callback from the
camera when my manipulator is no longer active or removed. My implementation on
this works, but it feels dirty.
Does anyone have a simpler/cleaner solution?
The real question is why is there no mechanism in OSG to allow the camera
manipulator to update the projection matrix at the appropriate time? Maybe
something like the ideas below (++1) or (++2) could be considered?
Code:
void Viewer::updateTraversal()
{
if (_camera.valid() && _camera->getUpdateCallback())
_camera->accept(*_updateVisitor);
(++1) if (_cameraManipulator.valid() &&
_cameraManipulator->getUpdateCallback())
_cameraManipulator->accept(*_updateVisitor);
if (_cameraManipulator.valid())
{
_camera->setViewMatrix(_cameraManipulator->getInverseMatrix());
(++2) _cameraManipulator->updateProjectionMatrix();
}
}
Thoughts?
Cheers,
Nick[/code]
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=55232#55232
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org