You didn't really provide much detail on how the code is failing, so we can
really only hazard a few wild guesses.

One potential problem area is that the osg::BoundingBox is axis-aligned. As
a result, rotating a BB just a few degrees will subtend a much larger area
than the unrotated box.

As Robert suggests, it might be better to transform the world location of
the eye into the local coordinate space of your ship node BB. To do this,
transform the eye by the ship node's world-to-local matrix. If OSG v1.2
doesn't give you direct access to that matrix, then simply take the inverse
of the getWorldMatrix() you're already using.


On Mon, Mar 25, 2013 at 9:34 AM, Robert Osfield <robert.osfi...@gmail.com>wrote:

> Hi Todd,
>
> OSG-1.2 oh boy, that be a little out of date know.  You have my
> sympathies.  Being stuck on OSG-1.2 will limit the communities ability
> to help a bit as most will be on 3.x or later 2.x series releases.  On
> the positive side the core scene graph in OSG-1.2 is pretty similar to
> that in OSG-3.x, the really big differences are in the viewer and
> extensions to the core OSG.
>
> In terms of collision detection, the OSG even these days doesn't
> directly provide collision detection.  in OSG-1.2 there is only view
> frustum culling and line intersection testing available.  You can use
> the bounding volume classes osg::BoundingSphere (attached to Node) and
> osg::BoundBox (attached to Drawable/Geometry) that you can do tests
> with, and an osg::Polytope class that is used for view frustum culling
> that could potentially be reused.
>
> With all these different tools the key is getting point/line/volume
> tests in the same coordinate frames, usually this is done by
> transforming a world point into a local coordinate frame, or
> visa-versa.  Traverses like the PickVisitor and CullVisitor do the
> accumulation of transforms through the scene graph so have a look at
> how they are managed.  My guess is you will probably want to create
> your own custom visitor to do something similar.
>
> Robert.
>
> On 12 March 2013 05:08, Todd Baniak <tmban...@rockwellcollins.com> wrote:
> > Hello all,
> >
> > Unfortunately my organization has made the decision to stick with OSG
> 1.2.  At this point it is not an option to upgrade, so the question
> pertains to how to solve a particular problem in 1.2.  I am a newbie to OSG
> and 3D in general, so please be patient with me!
> >
> > I have a window that displays a scene.  The scene is comprised of a
> series of Nodes, one of which I'll call a Ship Node.  All of the Nodes
> (including the Ship Node) are added to a single Root Node, which is then
> added to the SceneView.
> >
> > I believe I have successfully created a BoundingBox around this Ship
> Node.  What I'm trying to do is detect when the camera eye point intersects
> with this BoundingBox.
> >
> > The camera can move in and out (using setViewMatrixAsLookAt and changing
> the eye parameter).  I also have the ability to rotate up, down, left, and
> right.  This is done by applying the rotations to the Root Node.
> >
> > I have tried to obtain the world coordinates of the Ship Node at any
> given time via getBound() * getWorldMatrix()[0].  The camera eye point
> seems far more difficult.  No matter what I do, I can't get the camera to
> intersect with the BoundingBox properly.  Is the eye considered part of the
> 'world'?  And if so, does it need to be translated to world coordinates to
> make this work?
> >
> > I suspect I am going about this problem completely wrong.  I can post
> snippets of code if necessary.  Any ideas?
> >
> > Thank you for your time,
> >
> > Todd
> >
> > ------------------
> > Read this topic online here:
> > http://forum.openscenegraph.org/viewtopic.php?p=53046#53046
> >
> >
> >
> >
> >
> > _______________________________________________
> > osg-users mailing list
> > osg-users@lists.openscenegraph.org
> >
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 
Paul Martz
Skew Matrix Software LLC
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to