> So... I would have though just passing the view matrix as is would the
> appropriate thing to do.

Yes, thats right.
The problem for me in this case was that I expected, and required the
OpenGL view states to be set at the point of the preDrawCallback for a
camera.
The reason for this is that OpenHaptics, the haptic rendering toolkit
which Im depending on is reading the OpenGL modelview matrix during
its "pre-haptic-draw".

This gets event more complicated as one need to follow the below described loop:

Each haptic device is associated to a Camera (due to that one need the
View/projection matrices setup before rendering).

0. Draw Haptic Scene
1. for each haptic_device:
   1.1 Apply view/projection for associated osg::Camera
  1.1 haptic_device->makeCurrent()
  1.2 haptic_device->beginDraw()
2. render opengl (any valid geometry call will be caught by haptic API
as haptic geometry)
3. Finished: for each camera
  3.1 haptic_device->endDraw()

Now if the modelview matrix is applied within the renderbin, just
before a Leaf is about to be rendered, one has to initialize the
haptic rendering there.
I do have a HaptiCrenderbin, and HapticRenderLeaf already so that
structure is working.

The problem is now that the ModelViewMatrix can be pushed/popped
several times due to the accumulated state for a RenderLeaf, so there
is nowhere I can put my haptic_device->beginDraw() where I know that:
Here is where the ModelView matrix is applied to OpenGL.

In osg1.x together with Producer, the OpenGL states were applied
before the PreDrawCallback, but as you pointed out, that state-change
was effectively ignored by OSG.

Now I have to decorate the scene with a mechanism that before the
haptic part of a scene-graph is rendered, it has to begin the haptic
rendering WITH a valid OpenGL context and the correct ModelView matrix
applied.

I cant really see how I am going to achieve that with callbacks, or
even my own RenderBin...

I could try to collect all the haptic devices to the HapticRenderBin
and try to initialize them there. But thats not really what I am
after, I want to associate the HapticDevice to the camera, so that
when the scene for a specific camera is about to be drawn, the
hapticdevice is properly initialized and used too.
I thought preDrawCallback would work like that, but I realize that it
doesnt anymore, which is probably a good thing for performance, but
less good for me ;-)

Does anything of this make sense? Im not sure how to hook the haptic
rendering into osg2.0 as it is right now.....
Any input is appreciated,

cheers,
Anders




>
> > I can get the ViewMatrix, I can also get the MatrixList (of all
> > matrices above the camera in the scenegraph), but to match osg and to
> > make it as flexible as the rest of osg, how would do this?
>
> With Viewer cameras there aren't any nodes above it so this should
> just be an empty lists.
>
> > 2. Regarding GraphicsContext, assume that I do need access to a
> > graphicsContext in a PreRender, how can I take control of that Context
> > avoiding any race condition?
> > Now, Im not sure where I get the hang, but it does have something to
> > do with the fact that Im accessing OpenGL when I should not...
> > Eventhough, when I get into the PreRender callback the Context is
> > active. so a simple makeCurrent() would not work.
>
> The Camera pre draw callback will have the graphics context already
> made current so there won't be any need to call makeCurrent yourself.
>
> If you are finding problems doing OpenGL calls in a Camera pre or post
> draw callback then there must be something else wider that is amiss -
> the OSG itself should be having the same problems too.
>
> As for hangs or race conditions on your own code, I can't really comment.
>
> Robert.
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>


-- 


________________________________________________________________
 Anders Backman               Email:    [EMAIL PROTECTED]
 HPC2N/VRlab                  Phone:    +46 (0)90-786 9936
 Umea university              Cellular: +46 (0)70-392 64 67
 S-901 87 UMEA SWEDEN         Fax:      +46 90-786 6126
                               http://www.cs.umu.se/~andersb
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to