Johannes Scholz wrote:
Hi Paul,
well, I just opened an issue at the osgWorks wiki.
Thanks for opening that issue. It's good to have a record of these types of
problems. Copying osgworks-users on this reply...
AbsoluteModelTransform can't work unless it has the view matrix.
AbsoluteModelTransform gets the current Camera from the CullVisitor, and obtains
the view matrix from that Camera. In stereo, we expect there are two different
Cameras with two different views, one for left eye and one for right eye.
I ran the amt test under the debugger. By stopping in computeLocalToWorld(), I
noticed that the CullVisitor's current Camera is the same, regardless of whether
we're processing the left or right eye. Subsequently, the view queried from that
Camera is always the same. The visual result is zero eye separation for anything
under an AbsoluteModelTransform.
I tracked this down to SceneView's cull() method. SceneView has only one Camera,
and it is set up as a master view. To render the left eye, SceneView computes an
offset for that eye, then pushes the view matrix onto the CullVisitor's
modelview stack, then does the cull traversal. Sequentially, it follows that
with the same operation for the right eye. So, the view matrix that
AbsoluteModelTransform needs isn't in a Camera at all. It's the first entry in
the CullVisitor's modelview stack. Unfortunately, the modelview stack is
protected and therefore not accessible, nor is there an accessor for the stack,
nor is there a way to obtain an arbitrary entry in the stack. As a result,
AbsoluteModelTransform is unable to obtain the view matrix that it needs.
This seems like a flaw in OSG. Cameras and Views are prevalent concepts
throughout the OSG API, and it seems contrary for SceneView to make the view so
inaccessible. This is perhaps one reason why Robert has often mentioned
deprecating SceneView. However, it seems like this issue could be addressed
simply by adding an accessor to CullVisitor for the modelview matrix stack, so
that AbsoluteModelTransform could retrieve the view matrix by accessing
_modelStack.front().
I do have some workarounds available:
1) Reparent the visual representation subgraph of your rigid body to your scene
root Group node. Instead of using an AbsoluteModelTransform, use a MatrixTransform.
2) Use VR Juggler instead of osgViewer. VR Juggler uses one SceneView for each
eye. We know AbsoluteModelTransform works in this situation, as this is the
usage employed by VE-Suite.
3) Submit a patch to OSG so that SceneView uses two Cameras for stereo, one for
each eye.
4) It is possible to grab the view matrix from the CullVisitor modelview stack
with a root Group node CullCallback, and then pass that matrix to the
AbsoluteModelTransform. AbsoluteModelTransform would need to be modified to
have a “user specified view” mode of operation in order for this to work. Also,
since this involves writing data during cull, this would only work for single
display scenarios, and only if right/left eye cull are guaranteed to be
sequential. If these conditions aren't met, then this might still be possible
using a mutex.
Option 1 is the most straightforward solution. Option 2 is also known to work,
but would probably require a significant porting effort on your part.
While I believe option 3 is feasible, ultimately it's up to Robert whether such
a submission would be accepted or not.
I'm reluctant to implement option 4 because this amounts to modifying osgWorks
to be compatible with a part of OSG that Robert has already declared to be
deprecated.
While I don't think this is a bug in osgWorks that merits a fix, I'm open to
other ideas and suggestions on how to make this work, including changes that
would facilitate a workaround.
--
-Paul Martz Skew Matrix Software
http://www.skew-matrix.com/
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org