[osg-users] Separate sub-graphs of the same scene

Robert Osfield robert.osfield at gmail.com
Tue Mar 17 02:02:28 PDT 2009


Hi Guy,

Have you trying used osg::AutoTransform?

Also osg::Camera allows you to disable clear of the either the depth or
colour buffer.  See osghud example.

Robert.


On Tue, Mar 17, 2009 at 6:14 AM, Guy <guy at dvp.co.il> wrote:

>
> Hi,
>  What I'm trying to accomplish is to draw a given pattern instead of the
> projected object, on special condition. That pattern is no longer
> 3DWorld oriented, but instead, screen pixels oriented, with the
> exception of keeping the 3D distance of the 3DWorld object.
>
>  Suppose I have a model of a 3D house and a model of a truck, and the
> condition is "The truck is more than 300 feet from the house", then when
> the condition is true, instead of drawing the truck, I want the pixel
> (30,35) to be drawn blue and pixel (78,90) to be drawn green.
>
>  The important thing is that if the truck ZBuffer value was 'Z' I want
> pixels ZBuffer value to be the same 'Z', now since the truck has many
> vertices and therefore many 'Z's I only refer to the 'Z' of the middle
> of the truck bounding sphere.
>
>  I hope it makes more sense now...
>
> I forgot to mention that in osg1.2 instead of 'Camera' for the
> orthographic projection I used 'osg::Projection' which as far as I
> understand only changes the projection-view matrices and doesn't harm
> the Z buffer, but the pixels were drawn above all other objects.
>
>  I also 4got to mention that in osg2.8 and the Camera, I tried to render
> it PRE_ORDER, IN_ORDER and POST_ORDER with no different results.
>
> I never used the stencil buffer for anything but if I understand
> correctly it just prevents masked pattern on the viewport from being
> drawn, which is not my goal. Anyway, I'm going to read about stencil in
> the Red book. It wouldn't hurt. :)
>
> Thanks,
>  Guy.
>
> >I'm not sure I entirely understand what you're trying to accomplish,
> but
> >perhaps you want to look into using a stencil buffer and/or pixel
> shader
> >to control what gets rendered?
>
> Guy wrote:
> >
> > Hello,
> >
> >
> >
> >  I'm trying to merge two sub-graphs to the same image. It doesn't work
>
> > so well, so I'll try to explain what in general I'm trying to achieve,
>
> > then my not working so well solutions, and then the questions J
> >
> >
> >
> > So, in general I want to replace an object (A) in the scene with
> > another object (B) on some condition. The object (B) is some pixels
> > which are lit up. The important thing is to keep the 3D scene distance
>
> > from the camera for both objects, so if the object is obscured by
> > another, then both (A) and (B) will be obscured, and if some other
> > object (C) is obscured by (A), it will still be obscured by (B).
> > Object (B) might be partially transparent.
> >
> >
> >
> > Not working so well solution 1:
> >
> > Have switch for (A)/(B).
> >
> > The position of (A) is multiplied by view-projection matrix, the
> > result is pos'. (B) is a set of points which their vertices are pos'
> > with (x,y) replaced by the pixels I want to lit, and the new positions
>
> > are multiplied by the inverse-projection invers-view matrices.
> >
> > This solution had problems with setting the right pixels.
> >
> >
> >
> > Not working so well solution 2:
> >
> > Object (B) is a set of pixel under ABSOLUTE_REF orthographic
> > projection with (x,y) of the pixels I want to lit and z is the
> > negative distance between (A) and the camera.
> >
> > This solution has the correct pattern of the lit pixels, but the Z
> > order doesn't seems to be correct.
> >
> >
> >
> > The implementation of solution 2 is to add camera with ABSOLUTE_RF and
>
> > orthographic projection. View is identity. I set the clear mask to 0
> > since I don't want the Z-Buffer to be cleared. (opposed to huds and
> > that kind of implementations).
> >
> >
> >
> > I used the osgviewer to put the cow at 0,0,-300 under absolute_rf, and
>
> > a point at 0,0,0 under separate camera with orthographic projection,
> > and the point was hidden by the cow (which is a mistake).
> >
> > I thought that I might need to set the zNear/zFar of both camera's to
> > be the same, but in this simple example it shouldn't matter since the
> > point Z is zero...
> >
> >
> >
> > So first, do I have to set the zNear/zFar of both camera's to be the
> same?
> >
> >
> >
> > Any ideas whats going wrong?
> >
> >
> >
> > Other solutions for the problem?
> >
> >
> >
> > Btw, I tried to replace the points by quads under orthographic
> > projection. The results were the same.
> >
> >
> >
> > Thanks,
> >
> >  Guy.
> >
> >
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20090317/538105ec/attachment-0003.htm>


More information about the osg-users mailing list