Re: [osg-users] Intersection with 2d plane embedded in 3d

2019-05-21 Thread Chris Hanson
I'll chime in and say that if the plane is not moving around in the world
coordinate system, doing the intersection outside of OSG's intersection
code is probably simpler.

On Tue, May 21, 2019 at 1:08 PM Robert Osfield 
wrote:

> Hi Steve.
>
> On Tue, 21 May 2019 at 10:55, Steve Hardy  wrote:
> > Thanks for the reply.  I take it that quad intersection is the right
> approach for this problem.
>
> Well it's a simple approach.
>
> The "right" way would probably be to compute the ray to plane
> intersection separately, though I don't know how it would tie into the
> rest of your application code/usage.
>
> > So follow-up question: what would be a good way to improve efficiency?
> I know exactly which quad to intersect, but don't want intersection to test
> against all the other zillions of geodes in the scene.  It looks like the
> same node mask trick can be used with the intersection visitor, so
> hopefully I can use another node bit for that - although it looks like I
> have to turn off that bit in all except the node path from camera to quad.
>
> The OSG's IntersectionVisitor does tests against the bounding sphere's
> of the nodes in the scene graph to know whether it's worth traversing
> the subgraph or not, this avoids testing much of the scene graph.  If
> this isn't sufficient then you can assign KdTree's to the Geometry
> leaves to accelerate intersection testing.  See the osgkdtree example.
>
> Doing the ray to plane intersection separately from the OSG's
> IntersectionVisitor would be the most efficient solution, might even
> be less work given the above steps.
>
> Robert.
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>


-- 
Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com
http://www.alphapixel.com/
Training • Consulting • Contracting
3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 •
GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
Legal/IP • Forensics • Imaging • UAVs • GIS • GPS •
osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile •
iPhone/iPad/iOS • Android
@alphapixel  facebook.com/alphapixel (775)
623-PIXL [7495]
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Intersection with 2d plane embedded in 3d

2019-05-21 Thread Robert Osfield
Hi Steve.

On Tue, 21 May 2019 at 10:55, Steve Hardy  wrote:
> Thanks for the reply.  I take it that quad intersection is the right approach 
> for this problem.

Well it's a simple approach.

The "right" way would probably be to compute the ray to plane
intersection separately, though I don't know how it would tie into the
rest of your application code/usage.

> So follow-up question: what would be a good way to improve efficiency?  I 
> know exactly which quad to intersect, but don't want intersection to test 
> against all the other zillions of geodes in the scene.  It looks like the 
> same node mask trick can be used with the intersection visitor, so hopefully 
> I can use another node bit for that - although it looks like I have to turn 
> off that bit in all except the node path from camera to quad.

The OSG's IntersectionVisitor does tests against the bounding sphere's
of the nodes in the scene graph to know whether it's worth traversing
the subgraph or not, this avoids testing much of the scene graph.  If
this isn't sufficient then you can assign KdTree's to the Geometry
leaves to accelerate intersection testing.  See the osgkdtree example.

Doing the ray to plane intersection separately from the OSG's
IntersectionVisitor would be the most efficient solution, might even
be less work given the above steps.

Robert.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Intersection with 2d plane embedded in 3d

2019-05-21 Thread Steve Hardy
Hi Robert,

Thanks for the reply.  I take it that quad intersection is the right approach 
for this problem.
So follow-up question: what would be a good way to improve efficiency?  I know 
exactly which quad to intersect, but don't want intersection to test against 
all the other zillions of geodes in the scene.  It looks like the same node 
mask trick can be used with the intersection visitor, so hopefully I can use 
another node bit for that - although it looks like I have to turn off that bit 
in all except the node path from camera to quad.

Cheers,
Steve

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=76123#76123





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Intersection with 2d plane embedded in 3d

2019-05-21 Thread Robert Osfield
Hi Steve,

You can use NodeMask's to have subgraph only work in selected
traversals.  So if you want something that isn't rendered you'd set
the something like bit 0 to 1 so it's rendered, but have this set to 0
when you don't want it rendered, then tell the cull traversal to
require bit 0 to be on by setting the Camera CullMask to 0x1 which is
logically AND'd with the NodeMask during the cull traversal.

Robert.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Intersection with 2d plane embedded in 3d

2019-05-20 Thread Steve Hardy
Trying to answer my own question by using the form of 
View::computeIntersections() which takes a node path parameter.  The following 
code (as a member of my View subclass) doesn't seem to work (even though the 
simpler deprecated form works)...


Code:

  osg::Geode* geode = ...;
  osgUtil::LineSegmentIntersector::Intersections intersections;
  osg::NodePathList npl = geode->getParentalNodePaths(getCamera());
  npl[0].push_back(geode);  // Not sure if this req'd, but it fails either way
  if (computeIntersections(getCamera(), osgUtil::Intersector::WINDOW, x,y, 
npl[0], intersections)) {
printf("\n");
  }




It never gets to the printf.  (Yeah sorry but too late to teach this old dog to 
use cout).

Can't find any examples of creating node paths like this, so I'm probably not 
understanding how it works.  Do I need to push the camera node to the front?  
The geode to the end?


Cheers,
Steve

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=76121#76121





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Intersection with 2d plane embedded in 3d

2019-05-20 Thread Steve Hardy
Hi,

Is there any way to create a "virtual infinite" quad (i.e. plane) that 
satisfies the intersection test, but without being rendered itself?

Or is there a good way of converting screen coordinates to "local" embedded 2d 
model coordinates?

Motivation:

My application has line strips and other 'skinny' geometry which are all 
defined with a zero Z value hence are basically 2d, but are embedded in a 3d 
model under some DOF transforms.  I wish to find the 2d local coordinate 
corresponding to a mouse click.

I can do this by defining a quad then using a line intersector, but if I hide 
the quad behind, say, a switch node which is turned off, then the intersection 
does not work.  Maybe that's because I don't know how to restrict 
computeIntersections() to start at a particular node in the tree.  Anyway, a 
quad needs a particular size, but I really want the plane intersection, not 
just part of it.

Ultimately, though, I am happy to define a big quad provided I can avoid 
rendering it.

Thank you!

Cheers,
Steve

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=76120#76120





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] intersection tests

2017-02-19 Thread Trajce Nikolov NICK
Hi Robert, Julien,

it is my bad :( .. Again, and I apologize for the noise.

I studied the code, understood it, and it is just perfect and works great.
The story is that in the system setup there is a HOT Server (with a copy of
the database) and IG channels (with their own copy of the databases). The
IG channels have the terrain rotated and the HOT server does not, thus
inconsistency leading me to wrong assumptions and chasing a ghost

Please ignore and thanks for the patience with me

Good thing is, this lead me to learn a bit of more OSG code :)

Cheers!
Nick

On Sun, Feb 19, 2017 at 9:15 AM, Robert Osfield 
wrote:

> On 18 February 2017 at 21:25, Trajce Nikolov NICK
>  wrote:
> > yes ...
> >
> > Now, digging into the bits of the IntersectionVisitor::apply(
> osg::Transform&
> > transform) I am seeing it it keeps a stack of the ModelMatrices and they
> are
> > correct, as the visitor traverse the scene it premult the matrices from
> the
> > MatrixTransforms, to this is ok  the code (the osg code) looks just
> > perfect to me just there is a small bug sitting somewhere :)
>
> Could it simply be a precision issue?
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 
trajce nikolov nick
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] intersection tests

2017-02-19 Thread Robert Osfield
On 18 February 2017 at 21:25, Trajce Nikolov NICK
 wrote:
> yes ...
>
> Now, digging into the bits of the IntersectionVisitor::apply(osg::Transform&
> transform) I am seeing it it keeps a stack of the ModelMatrices and they are
> correct, as the visitor traverse the scene it premult the matrices from the
> MatrixTransforms, to this is ok  the code (the osg code) looks just
> perfect to me just there is a small bug sitting somewhere :)

Could it simply be a precision issue?
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] intersection tests

2017-02-18 Thread Trajce Nikolov NICK
yes ...

Now, digging into the bits of the
IntersectionVisitor::apply(osg::Transform& transform) I am seeing it it
keeps a stack of the ModelMatrices and they are correct, as the visitor
traverse the scene it premult the matrices from the MatrixTransforms, to
this is ok  the code (the osg code) looks just perfect to me just there
is a small bug sitting somewhere :)

On Sat, Feb 18, 2017 at 10:19 PM, Julien Valentin <
julienvalenti...@gmail.com> wrote:

> Hi nick
> okay you're casting ray in world coordinates on model in world
> coordinates...
> I haven't understood
> Then You should not consider the CoordinateFrames as matrix are the same.
> After a look at osgViewer::View::comuteIntersections i noticed
> intersecrionvisitor is created by this  line
>
> Code:
> osg::ref_ptr< osgUtil::LineSegmentIntersector > picker = new osgUtil::
> LineSegmentIntersector(osgUtil::Intersector::MODEL, startVertex,
> endVertex);
>
>
> Perhaps your problem came from here...
>
> cheers
>
>
> Trajce Nikolov NICK wrote:
> > Thanks Julien for your time to give it a look
> >
> > I went further, debugging view->computeIntersections(). The osgpick is
> my starting point and my code is only a mimic of what 
> osgViewer::View::computeIntersection
> is doing, using the IntersectionVisitor
> >
> >
> > A good sample for reproduction is to have some code (I will post it here
> soon) that will load two models (terrain and building - can be the lz.osg
> and the cow.osg from the dataset) place the model somewhere on the terrain
> and rotate the root (the terrain) a bit, and use the osgpick sample. This
> is fast that come to me minds now, although it might not work the same
> since picking from the screen coords and picking in "world space" have
> different CoordinateFrames for the LineSegmentIntersector used that is
> managed differently
> >
> >
> > On Sat, Feb 18, 2017 at 9:33 PM, Julien Valentin < ()> wrote:
> >
> > > Hi nick
> > > At first glance, I don't see any problem with your code...
> > > If you just want to code a mousepicker
> > > osgViewer::View::computeIntersections(screenx,
> screeny,outintersections))
> > >  would fit your needs.
> > >
> > > Code:
> > > // class to handle events with a pick
> > > class PickHandler : public osgGA::GUIEventHandler
> > > {
> > > public:
> > > bool PickHandler::handle(const osgGA::GUIEventAdapter&
> ea,osgGA::GUIActionAdapter& aa)
> > > {
> > > switch(ea.getEventType())
> > > {
> > > case(osgGA::GUIEventAdapter::DOUBLECLICK):
> > > {
> > > osgViewer::View* view = dynamic_cast();
> > > if (view){
> > > osgUtil::LineSegmentIntersector::Intersections inter;
> > > if(view->computeIntersections(ea.getX(),ea.gety(),inter){
> > > ...blablabla...
> > > }
> > > }
> > > }
> > >
> > >
> > >
> > >
> > > Perhaps you should try it before debugging deeper
> > >
> > > Further, I would recommend the polytopeintersector for general purpose
> picking (it works for points primitives too)
> > >
> > > Hope it helps
> > >
> > >
> > > Cheers
> > >
> > >
> > >
> > > Trajce Nikolov NICK wrote:
> > >
> > > > It has to do with MatrixTransforms and probably the
> IntersectionVisitor. I had my scene rotated a bit and it was buggy. With
> identity matrix on top works well ... Trying to debug if I can find
> something
> > > >
> > > > On Thu, Feb 16, 2017 at 8:31 PM, Trajce Nikolov NICK < ()> wrote:
> > > >
> > > >
> > > > > Hi Community,
> > > > >
> > > > > I am experiencing some bad results from various intersection
> tests. I have a database with buildings and for some reason the
> intersection tests are failing to get me the roofs of the buildings ...
> > > > >
> > > > >
> > > > > Here some snippets of my tries:
> > > > >
> > > > >
> > > > > http://pastebin.com/s7aZk8wA (http://pastebin.com/s7aZk8wA) (
> http://pastebin.com/s7aZk8wA (http://pastebin.com/s7aZk8wA))
> > > > >
> > > > > http://pastebin.com/1s99SGZc (http://pastebin.com/1s99SGZc) (
> http://pastebin.com/1s99SGZc (http://pastebin.com/1s99SGZc))
> > > > >
> > > > > http://pastebin.com/UtkqPRce (http://pastebin.com/UtkqPRce) (
> http://pastebin.com/UtkqPRce (http://pastebin.com/UtkqPRce))
> > > > >
> > > > >
> > > > >
> > > > > What I am missing here?
> > > > >
> > > > >
> > > > > Thanks for every hint as always!
> > > > > Cheers!
> > > > >
> > > > > --
> > > > > trajce nikolov nick
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > trajce nikolov nick
> > > >
> > > >   --
> > > > Post generated by Mail2Forum
> > > >
> > >
> > >
> > > --
> > > Read this topic online here:
> > > http://forum.openscenegraph.org/viewtopic.php?p=70269#70269 (
> http://forum.openscenegraph.org/viewtopic.php?p=70269#70269)
> > >
> > >
> > >
> > >
> > >
> > > ___
> > > osg-users mailing list
> > >  ()
> > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-
> openscenegraph.org 

Re: [osg-users] intersection tests

2017-02-18 Thread Julien Valentin
Hi nick 
okay you're casting ray in world coordinates on model in world coordinates...
I haven't understood
Then You should not consider the CoordinateFrames as matrix are the same.
After a look at osgViewer::View::comuteIntersections i noticed 
intersecrionvisitor is created by this  line

Code:
osg::ref_ptr< osgUtil::LineSegmentIntersector > picker = new 
osgUtil::LineSegmentIntersector(osgUtil::Intersector::MODEL, startVertex, 
endVertex);


Perhaps your problem came from here...

cheers


Trajce Nikolov NICK wrote:
> Thanks Julien for your time to give it a look
> 
> I went further, debugging view->computeIntersections(). The osgpick is my 
> starting point and my code is only a mimic of what 
> osgViewer::View::computeIntersection is doing, using the IntersectionVisitor
> 
> 
> A good sample for reproduction is to have some code (I will post it here 
> soon) that will load two models (terrain and building - can be the lz.osg and 
> the cow.osg from the dataset) place the model somewhere on the terrain and 
> rotate the root (the terrain) a bit, and use the osgpick sample. This is fast 
> that come to me minds now, although it might not work the same since picking 
> from the screen coords and picking in "world space" have different 
> CoordinateFrames for the LineSegmentIntersector used that is managed 
> differently
> 
> 
> On Sat, Feb 18, 2017 at 9:33 PM, Julien Valentin < ()> wrote:
> 
> > Hi nick
> > At first glance, I don't see any problem with your code...
> > If you just want to code a mousepicker
> > osgViewer::View::computeIntersections(screenx,screeny,outintersections))
> >  would fit your needs.
> > 
> > Code:
> > // class to handle events with a pick
> > class PickHandler : public osgGA::GUIEventHandler
> > {
> > public:
> > bool PickHandler::handle(const osgGA::GUIEventAdapter& 
> > ea,osgGA::GUIActionAdapter& aa)
> > {
> >     switch(ea.getEventType())
> >     {
> >     case(osgGA::GUIEventAdapter::DOUBLECLICK):
> >     {
> >         osgViewer::View* view = dynamic_cast();
> >         if (view){
> > osgUtil::LineSegmentIntersector::Intersections inter;
> > if(view->computeIntersections(ea.getX(),ea.gety(),inter){
> > ...blablabla...
> > }
> > }
> > }
> > 
> > 
> > 
> > 
> > Perhaps you should try it before debugging deeper
> > 
> > Further, I would recommend the polytopeintersector for general purpose 
> > picking (it works for points primitives too)
> > 
> > Hope it helps
> > 
> > 
> > Cheers
> > 
> > 
> > 
> > Trajce Nikolov NICK wrote:
> > 
> > > It has to do with MatrixTransforms and probably the IntersectionVisitor. 
> > > I had my scene rotated a bit and it was buggy. With identity matrix on 
> > > top works well ... Trying to debug if I can find something
> > > 
> > > On Thu, Feb 16, 2017 at 8:31 PM, Trajce Nikolov NICK < ()> wrote:
> > > 
> > > 
> > > > Hi Community,
> > > > 
> > > > I am experiencing some bad results from various intersection tests. I 
> > > > have a database with buildings and for some reason the intersection 
> > > > tests are failing to get me the roofs of the buildings ...
> > > > 
> > > > 
> > > > Here some snippets of my tries:
> > > > 
> > > > 
> > > > http://pastebin.com/s7aZk8wA (http://pastebin.com/s7aZk8wA) 
> > > > (http://pastebin.com/s7aZk8wA (http://pastebin.com/s7aZk8wA))
> > > > 
> > > > http://pastebin.com/1s99SGZc (http://pastebin.com/1s99SGZc) 
> > > > (http://pastebin.com/1s99SGZc (http://pastebin.com/1s99SGZc))
> > > > 
> > > > http://pastebin.com/UtkqPRce (http://pastebin.com/UtkqPRce) 
> > > > (http://pastebin.com/UtkqPRce (http://pastebin.com/UtkqPRce))
> > > > 
> > > > 
> > > > 
> > > > What I am missing here?
> > > > 
> > > > 
> > > > Thanks for every hint as always!
> > > > Cheers!
> > > > 
> > > > --
> > > > trajce nikolov nick
> > > > 
> > > > 
> > > > 
> > > > 
> > > > 
> > > 
> > > 
> > > 
> > > 
> > > --
> > > trajce nikolov nick
> > > 
> > >   --
> > > Post generated by Mail2Forum
> > > 
> > 
> > 
> > --
> > Read this topic online here:
> > http://forum.openscenegraph.org/viewtopic.php?p=70269#70269 
> > (http://forum.openscenegraph.org/viewtopic.php?p=70269#70269)
> > 
> > 
> > 
> > 
> > 
> > ___
> > osg-users mailing list
> >  ()
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org 
> > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
> > 
> 
> 
> 
> 
> -- 
> trajce nikolov nick
> 
>  --
> Post generated by Mail2Forum


--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=70272#70272





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] intersection tests

2017-02-18 Thread Trajce Nikolov NICK
Thanks Julien for your time to give it a look

I went further, debugging view->computeIntersections(). The osgpick is my
starting point and my code is only a mimic of what
osgViewer::View::computeIntersection is doing, using the IntersectionVisitor

A good sample for reproduction is to have some code (I will post it here
soon) that will load two models (terrain and building - can be the lz.osg
and the cow.osg from the dataset) place the model somewhere on the terrain
and rotate the root (the terrain) a bit, and use the osgpick sample. This
is fast that come to me minds now, although it might not work the same
since picking from the screen coords and picking in "world space" have
different CoordinateFrames for the LineSegmentIntersector used that is
managed differently

On Sat, Feb 18, 2017 at 9:33 PM, Julien Valentin  wrote:

> Hi nick
> At first glance, I don't see any problem with your code...
> If you just want to code a mousepicker
> osgViewer::View::computeIntersections(screenx,screeny,outintersections))
>  would fit your needs.
>
> Code:
> // class to handle events with a pick
> class PickHandler : public osgGA::GUIEventHandler
> {
> public:
> bool PickHandler::handle(const osgGA::GUIEventAdapter&
> ea,osgGA::GUIActionAdapter& aa)
> {
> switch(ea.getEventType())
> {
> case(osgGA::GUIEventAdapter::DOUBLECLICK):
> {
> osgViewer::View* view = dynamic_cast();
> if (view){
> osgUtil::LineSegmentIntersector::Intersections inter;
> if(view->computeIntersections(ea.getX(),ea.gety(),inter){
> ...blablabla...
> }
> }
> }
>
>
>
>
> Perhaps you should try it before debugging deeper
>
> Further, I would recommend the polytopeintersector for general purpose
> picking (it works for points primitives too)
>
> Hope it helps
>
>
> Cheers
>
>
>
> Trajce Nikolov NICK wrote:
> > It has to do with MatrixTransforms and probably the IntersectionVisitor.
> I had my scene rotated a bit and it was buggy. With identity matrix on top
> works well ... Trying to debug if I can find something
> >
> > On Thu, Feb 16, 2017 at 8:31 PM, Trajce Nikolov NICK < ()> wrote:
> >
> > > Hi Community,
> > >
> > > I am experiencing some bad results from various intersection tests. I
> have a database with buildings and for some reason the intersection tests
> are failing to get me the roofs of the buildings ...
> > >
> > >
> > > Here some snippets of my tries:
> > >
> > >
> > > http://pastebin.com/s7aZk8wA (http://pastebin.com/s7aZk8wA)
> > >
> > > http://pastebin.com/1s99SGZc (http://pastebin.com/1s99SGZc)
> > >
> > > http://pastebin.com/UtkqPRce (http://pastebin.com/UtkqPRce)
> > >
> > >
> > >
> > > What I am missing here?
> > >
> > >
> > > Thanks for every hint as always!
> > > Cheers!
> > >
> > > --
> > > trajce nikolov nick
> > >
> > >
> > >
> > >
> >
> >
> >
> >
> > --
> > trajce nikolov nick
> >
> >  --
> > Post generated by Mail2Forum
>
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=70269#70269
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 
trajce nikolov nick
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] intersection tests

2017-02-18 Thread Julien Valentin
Hi nick
At first glance, I don't see any problem with your code...
If you just want to code a mousepicker
osgViewer::View::computeIntersections(screenx,screeny,outintersections))
 would fit your needs.

Code:
// class to handle events with a pick
class PickHandler : public osgGA::GUIEventHandler
{
public:
bool PickHandler::handle(const osgGA::GUIEventAdapter& 
ea,osgGA::GUIActionAdapter& aa)
{
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::DOUBLECLICK):
{
osgViewer::View* view = dynamic_cast();
if (view){
osgUtil::LineSegmentIntersector::Intersections inter;
if(view->computeIntersections(ea.getX(),ea.gety(),inter){
...blablabla...
}
}
}




Perhaps you should try it before debugging deeper

Further, I would recommend the polytopeintersector for general purpose picking 
(it works for points primitives too)

Hope it helps


Cheers



Trajce Nikolov NICK wrote:
> It has to do with MatrixTransforms and probably the IntersectionVisitor. I 
> had my scene rotated a bit and it was buggy. With identity matrix on top 
> works well ... Trying to debug if I can find something
> 
> On Thu, Feb 16, 2017 at 8:31 PM, Trajce Nikolov NICK < ()> wrote:
> 
> > Hi Community,
> > 
> > I am experiencing some bad results from various intersection tests. I have 
> > a database with buildings and for some reason the intersection tests are 
> > failing to get me the roofs of the buildings ...
> > 
> > 
> > Here some snippets of my tries:
> > 
> > 
> > http://pastebin.com/s7aZk8wA (http://pastebin.com/s7aZk8wA)
> > 
> > http://pastebin.com/1s99SGZc (http://pastebin.com/1s99SGZc)
> > 
> > http://pastebin.com/UtkqPRce (http://pastebin.com/UtkqPRce)
> > 
> > 
> > 
> > What I am missing here?
> > 
> > 
> > Thanks for every hint as always!
> > Cheers!
> > 
> > -- 
> > trajce nikolov nick
> > 
> > 
> > 
> > 
> 
> 
> 
> 
> -- 
> trajce nikolov nick
> 
>  --
> Post generated by Mail2Forum


--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=70269#70269





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] intersection tests

2017-02-17 Thread Trajce Nikolov NICK
It has to do with MatrixTransforms and probably the IntersectionVisitor. I
had my scene rotated a bit and it was buggy. With identity matrix on top
works well ... Trying to debug if I can find something

On Thu, Feb 16, 2017 at 8:31 PM, Trajce Nikolov NICK <
trajce.nikolov.n...@gmail.com> wrote:

> Hi Community,
>
> I am experiencing some bad results from various intersection tests. I have
> a database with buildings and for some reason the intersection tests are
> failing to get me the roofs of the buildings ...
>
> Here some snippets of my tries:
>
> http://pastebin.com/s7aZk8wA
> http://pastebin.com/1s99SGZc
> http://pastebin.com/UtkqPRce
>
> What I am missing here?
>
> Thanks for every hint as always!
> Cheers!
>
> --
> trajce nikolov nick
>



-- 
trajce nikolov nick
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] intersection tests

2017-02-16 Thread Trajce Nikolov NICK
Hi Community,

I am experiencing some bad results from various intersection tests. I have
a database with buildings and for some reason the intersection tests are
failing to get me the roofs of the buildings ...

Here some snippets of my tries:

http://pastebin.com/s7aZk8wA
http://pastebin.com/1s99SGZc
http://pastebin.com/UtkqPRce

What I am missing here?

Thanks for every hint as always!
Cheers!

-- 
trajce nikolov nick
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Intersection returning a surface

2015-10-15 Thread Tony Vasile
Hi,
Is it is possible to have an intersection query return the surface or triangle 
that has been hit rather than a point? I have seen PlaneIntersector but it 
seems to return a list of points rather than the surface that contains those 
points. Correct me if I am wrong. Any help would be appreciated.


Tony V

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=65364#65364





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Intersection visitor and osg::Viewport

2013-08-08 Thread Aurelien Albert
Hi,

I'm experiencing some problems to get correct intersections in following 
situation :

I have a group in my scene graph which have a Viewport StateAttribute to modify 
its rendering frame on screen.

All is works well for render, but intersector seems lost wih nodes below my 
group.

Is there any viewport change management in osg::Intersector ? I didn't find any 
(except when traversing camera).

Thank you!

Cheers,
Aurelien

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=55808#55808





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Intersection visitor and osg::Viewport

2013-08-08 Thread Aurelien Albert
Hi,

I've tried the following and it seems to solve my problem :


Code:
void IntersectionVisitor::apply(osg::Group group)
{
if (!enter(group)) return;

osg::Viewport* pViewport = NULL;
if (group.getStateSet() != NULL)
{
pViewport = 
dynamic_castosg::Viewport*(group.getStateSet()-getAttribute(osg::StateAttribute::VIEWPORT));
}

if (pViewport != NULL)
{
pushWindowMatrix(pViewport);
push_clone();
traverse(group);
pop_clone();
popWindowMatrix();
}
else
{
traverse(group);
}

leave();
}




This modification was just a test, but I wonder if this should not be in every 
apply method of IntersectionVisitor, maybe with these modifications :
- take care of the override value (do not push window matrix if the attribute 
is overriden)
- push the window matrix and the intersector clone BEFORE the enter test to 
ensure the enter test is done with correct coordinates frame

Or am I wrong with that and I've missed something ?

Thanks.

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=55809#55809





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] intersection of lines: line widths?

2012-10-23 Thread Peter Hrenka
Hi Andy,

Am 22.10.2012 21:05, schrieb Andy Skinner:
 I know that intersections are about 3d world coordinates, and line widths are 
 about pixels.  But is there a way to use line widths in calculating 
 intersections with the polytope intersector?
 
There is currently no code in PolytopeIntersector which takes line widths (or 
point sizes) into account.
While it would be possible to implement it I doubt that it would be worth the 
effort.

 
 In other words, I want a wider line to be easier to pick.

I think this could be accomplished by a post-processing step
on the results: Normally you would use the nearest intersection
but in your case you could also check the line width and prefer
thicker lines over nearer lines.

 I could just expand the polytope a bit, except that the lines are just one 
 kind of thing in the scene, and they could have different line widths.

I think your expanded polytope-idea should also work.
You could use differently sized polytopes for different 
line widths.

As for your other kinds of thinks in the scene you should
be aware that the performance of PolytopeIntersector for
2d-geometries is rather bad. It is much faster to use
LineSegementIntersector for those and combine the results
afterwards.

 
 thanks,
 
 andy
 

Cheers,

Peter

  
 
 
 
 ___
 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


Re: [osg-users] intersection of lines: line widths?

2012-10-23 Thread Andy Skinner
Thanks for comments, Peter.

By easier to pick, I didn't mean relative to other lines in the scene, but 
that I wouldn't have to be as close to the actual line geometry.  It is a 
question of whether the line will be in the list of intersections, rather than 
which intersection I choose.

I suspect the same thing about whether it is worth the effort.

 As for your other kinds of thinks in the scene you should be aware that the 
 performance of PolytopeIntersector for 2d-geometries is rather bad. It is 
 much faster to use LineSegementIntersector for those and combine the results 
 afterwards.

By 2d-geometries, do you mean triangles and quads (and not 2D scenes)?  And 
that it would be better to run the polytope intersector for points and lines, 
and a separate line intersector for triangles and quads, and combine 
intersections?  I know all of that is pretty much what you said, but I wanted 
to be sure.  That's using two intersection traversals.  Sounds interesting if 
it is really faster.

thanks,
andy

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] intersection of lines: line widths?

2012-10-23 Thread Peter Hrenka
Hi Andy,

Am 23.10.2012 15:03, schrieb Andy Skinner:
 Thanks for comments, Peter.
 
 By easier to pick, I didn't mean relative to other lines in the scene, but 
 that I wouldn't have to be as close to the actual line geometry.  It is a 
 question of whether the line will be in the list of intersections, rather 
 than which intersection I choose.
 
 I suspect the same thing about whether it is worth the effort.
 
 As for your other kinds of thinks in the scene you should be aware that 
 the performance of PolytopeIntersector for 2d-geometries is rather bad. It 
 is much faster to use LineSegementIntersector for those and combine the 
 results afterwards.
 
 By 2d-geometries, do you mean triangles and quads (and not 2D scenes)?  And 
 that it would be better to run the polytope intersector for points and lines, 
 and a separate line intersector for triangles and quads, and combine 
 intersections?  I know all of that is pretty much what you said, but I wanted 
 to be sure.  That's using two intersection traversals.  Sounds interesting if 
 it is really faster.

Yes, I did mean triangles and quads.
I haven't done performance measurements but I did implement the 
PolytopeIntersector
for triangles and quads. There are quite a few cases to cover to get it correct.

The IntersectionVisitor has the additional advantage that it can use a kd-tree 
for speedup
(which unfortunately is totally geared towards triangles, and hence unsuitable 
for the PolytopeIntersector).

But, yes, I do mean performing two separate intersections, where you can turn 
off 
the PolytopeIntersector checks for 2d-elements by using 
setDimensionMask(DimZero|DimOne)
and merging those results with the results from a LineSegmentIntersector.

 thanks,
 andy

Cheers,

Peter


 ___
 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


[osg-users] intersection of lines: line widths?

2012-10-22 Thread Andy Skinner
I know that intersections are about 3d world coordinates, and line widths are 
about pixels.  But is there a way to use line widths in calculating 
intersections with the polytope intersector?

In other words, I want a wider line to be easier to pick.

I could just expand the polytope a bit, except that the lines are just one kind 
of thing in the scene, and they could have different line widths.

thanks,
andy

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Intersection of two lines

2011-09-07 Thread Andreas Roth
Hi,

this maybe a stupid and simple question. I have two lines and i want to 
calculate the intersection point of the two lines.
For both lines is have a starting point and the direction. Is there a function 
to calculate the intersection point?

Thank you!

Cheers,
Andreas

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=42478#42478





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Intersection of two lines

2011-09-07 Thread Vincent Bourdier

Hi,

Using a simple system equation you should find it.
Just google it...

Regards,
   Vincent.

Le 07/09/2011 11:32, Andreas Roth a écrit :

Hi,

this maybe a stupid and simple question. I have two lines and i want to 
calculate the intersection point of the two lines.
For both lines is have a starting point and the direction. Is there a function 
to calculate the intersection point?

Thank you!

Cheers,
Andreas

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=42478#42478





___
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


Re: [osg-users] Intersection of two lines

2011-09-07 Thread Shayne Tueller
I am not aware of a function in OSG to do this, however, you can do it yourself.

If you have a starting point and direction for each line, you can define each 
line parametrically as

Line 1: P + rA
Line 2: Q + sB

where P,Q are the starting points and A,B are the unit direction vectors. The 
scalars r,s are what we want to solve for. This can be done by equating the two 
lines

P + rA = Q + sB or rA - sB = Q - P

For 2D, this is a simple 2x2 linear system. The scalars r,s can be uniquely 
solved for by using Cramer's rule (stable for small systems). Of course, this 
assumes that the lines are not parallel or on top of each other (check for this 
first). Once the scalars r,s are solved for, plug them back into Line 1 or Line 
2 to get the point of intersection in your coordinate system.

For 3D, the system above turns into an overdetermined system of equations (i.e. 
3 equations and 2 unknowns) which does not have a solution except when the 
system contains linearly dependent equations.

For the case where there is no solution, you can solve for a point of 
intersection in a least squares sense using the method of normal equations. 
This method is numerically stable for small systems. To do this, write the 
system above as

Cx = d

where C is a 3x2 matrix, x is a 2x1 column vector containing the scalars r,s we 
want to solve for, and d is 3x1 column vector. Using the method of normal 
equations, we can rewrite the system to be

CtCx = Ctd

where Ct is the transpose of C. This new system now becomes a 2x2 linear system 
which can be solved like the 2D case above.

Hope this helps...

-Shayne

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=42509#42509





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] intersection with quad mesh: only 3 vertices returned

2011-08-06 Thread Torben Dannhauer
Hi all

Thanks for your feedback, that turns my vague idea into basic knowledge I can 
build on to learn more :)

I'll continue as soon I'm back from my trip.

Thank you!

Best regards,
Torben ( currently sitting in a peruvian long distance
bus with more comfort than many aircrafts - entertainment, ac, hot meal, wifi 
for free - for only 4$ each 100km :D )

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=41912#41912





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] intersection with quad mesh: only 3 verticesreturned

2011-08-04 Thread Mike Garrity
 From: osg-users-boun...@lists.openscenegraph.org 
 [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Tueller, 
 Shayne R Civ USAF AFMC 519 SMXS/MXDEC
 Sent: Tuesday, August 02, 2011 4:49 PM
 To: osg-users@lists.openscenegraph.org
 Subject: Re: [osg-users] intersection with quad mesh: only 3 verticesreturned

 It is true that QUAD is an OpenGL primitive but the GL driver tessellates it 
 into two triangles 
 underneath the hood.

Most (all?) cards today do break them into 2 tris, but nothing in the OpenGL 
spec 
says that they have to, or specifies exactly how they should do it. The reason 
is 
that the original SGI geometry engine did not split them. It drew quads 
directly 
with an odd algorithm for interpolating values across the interior. Quad lives 
on 
as a historical quirk, like the panda's thumb.

-Mike Garrity
-The MathWorks


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] intersection with quad mesh: only 3 verticesreturned

2011-08-04 Thread Tueller, Shayne R Civ USAF AFMC 519 SMXS/MXDEC
The odd algorithm you're referring to is bilinear interpolation which
essentially defines a hyperbolic paraboloid (the simplest surface)
through 4 non-coplanar points (i.e. the infamous quad).

For intersection purposes in OSG, it's good that it breaks the quad up
into two triangles. Planes are easier to intersect than bilinear
surfaces...

-Shayne

-Original Message-
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Mike
Garrity
Sent: Thursday, August 04, 2011 8:24 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] intersection with quad mesh: only 3
verticesreturned

 From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of
Tueller, Shayne R Civ USAF AFMC 519 SMXS/MXDEC
 Sent: Tuesday, August 02, 2011 4:49 PM
 To: osg-users@lists.openscenegraph.org
 Subject: Re: [osg-users] intersection with quad mesh: only 3
verticesreturned

 It is true that QUAD is an OpenGL primitive but the GL driver
tessellates it into two triangles 
 underneath the hood.

Most (all?) cards today do break them into 2 tris, but nothing in the
OpenGL spec 
says that they have to, or specifies exactly how they should do it. The
reason is 
that the original SGI geometry engine did not split them. It drew quads
directly 
with an odd algorithm for interpolating values across the interior. Quad
lives on 
as a historical quirk, like the panda's thumb.

-Mike Garrity
-The MathWorks


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] intersection with quad mesh: only 3 vertices returned

2011-08-02 Thread Torben Dannhauer
Hi,

I have a mesh of quads. If i intersect them, it hits the face and returns me 
the results (osgUtil::LineSegmentIntersector::Intersection result)

As I tried to access the indices I realized that it only returns 3 vertices.
( result.indexList.size() == 3 ) 
Is this a bug or do I miss something?
I would like to acces the 4 vertices of the quad to manipulate the vertex I 
intersect next to.

Thank you!

Cheers,
Torben

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=41801#41801





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] intersection with quad mesh: only 3 vertices returned

2011-08-02 Thread Tueller, Shayne R Civ USAF AFMC 519 SMXS/MXDEC
Torben,

My guess is that the quads are geometrically represented by two
triangles with a shared edge. I believe the intersector is returning a
ray/triangle intersection so one (that is hit) of the two triangles that
make up the quad is being returned.

This probably doesn't solve your problem but it may explain why you're
getting only 3 vertexes on return...

-Shayne

-Original Message-
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Torben
Dannhauer
Sent: Tuesday, August 02, 2011 12:39 PM
To: osg-users@lists.openscenegraph.org
Subject: [osg-users] intersection with quad mesh: only 3 vertices
returned

Hi,

I have a mesh of quads. If i intersect them, it hits the face and
returns me the results (osgUtil::LineSegmentIntersector::Intersection
result)

As I tried to access the indices I realized that it only returns 3
vertices.
( result.indexList.size() == 3 ) 
Is this a bug or do I miss something?
I would like to acces the 4 vertices of the quad to manipulate the
vertex I intersect next to.

Thank you!

Cheers,
Torben

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=41801#41801





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] intersection with quad mesh: only 3 vertices returned

2011-08-02 Thread Torben Dannhauer
Hi S2LR,

I thought QUAD is a OpenGL primitive. Your statement make sence to me. But then 
OSG hides the substitution by 2 triangles quite good, also in the wiremode of 
osgViewer the quads are displayed.

I thought (even when not to often used as triangles) that quads are natively 
supported and would work with intersections.

Cheers,
Torben

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=41804#41804





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] intersection with quad mesh: only 3 verticesreturned

2011-08-02 Thread Tueller, Shayne R Civ USAF AFMC 519 SMXS/MXDEC
It is true that QUAD is an OpenGL primitive but the GL driver
tessellates it into two triangles underneath the hood.

As for how OSG handles quads relative to intersections, it is my
understanding that the intersector works with line/triangle
intersections. If you're trying to intersect a quad, however, it would
seem that if either of the two triangles is hit, 4 vertexes would/should
be returned. I haven't looked at the code to really know for sure.

-Shayne

-Original Message-
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Torben
Dannhauer
Sent: Tuesday, August 02, 2011 1:14 PM
To: osg-users@lists.openscenegraph.org
Subject: Re: [osg-users] intersection with quad mesh: only 3
verticesreturned

Hi S2LR,

I thought QUAD is a OpenGL primitive. Your statement make sence to me.
But then OSG hides the substitution by 2 triangles quite good, also in
the wiremode of osgViewer the quads are displayed.

I thought (even when not to often used as triangles) that quads are
natively supported and would work with intersections.

Cheers,
Torben

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=41804#41804





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] intersection with quad mesh: only 3 verticesreturned

2011-08-02 Thread Chris 'Xenon' Hanson
On 8/2/2011 2:49 PM, Tueller, Shayne R Civ USAF AFMC 519 SMXS/MXDEC wrote:
 It is true that QUAD is an OpenGL primitive but the GL driver
 tessellates it into two triangles underneath the hood.
 As for how OSG handles quads relative to intersections, it is my
 understanding that the intersector works with line/triangle
 intersections. If you're trying to intersect a quad, however, it would
 seem that if either of the two triangles is hit, 4 vertexes would/should
 be returned. I haven't looked at the code to really know for sure.

  OSG's intersection code decomposes QUADs into triangles. Your result should be
interpreted as triangles, created in pairs from the original QUADs.

 -Shayne

-- 
Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com 
http://www.alphapixel.com/
  Digital Imaging. OpenGL. Scene Graphs. GIS. GPS. Training. Consulting. 
Contracting.
There is no Truth. There is only Perception. To Perceive is to Exist. - 
Xen
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Intersection testing in a separate thread

2011-05-13 Thread Craig S. Bosma
J-S, Shayne,

Thanks for the help. The threaded/shared scenegraph is the approach I had in 
mind, but there are still a few kinks in my understanding that I'm trying to 
work out. The current serial render loop looks something like:

databasePager-signalBeginFrame(...);
databasePager-updateSceneGraph(...);
scene-accept(updateVisitor);
// process sim logic here
sceneView-cull();
sceneView-draw();
databasePager-signalEndFrame();
databasePager-compileGLObjects(...);

So as you can see, the scene will be changing due to the database pager 
adding/removing nodes, and part of the simulation will be moving subgraphs 
around in world space (e.g. changing matrix transforms). Would it be possible 
to leave most everything -- update, cull, etc. on the main thread, but push the 
drawing off to a separate thread? Basically I want the update and sim logic to 
run as fast as possible and not wait on the draw(). If a mutex is used to 
prevent the main thread from being in cull() while the draw thread is in 
draw(), would that work? Would it be possible to run cull() on the draw thread 
and use a mutex to prevent cull() and the updates from happening 
simultaneously? Finally, where does the database pager fit in -- should it 
signal begin/end frames on each update, or each draw?

Thanks,
Craig

On Thursday, May 12, 2011 at 3:50 PM, Tueller, Shayne R Civ USAF AFMC 519 
SMXS/MXDEC wrote: 
 J-S,
 
 Yes, a great point I failed to bring up about the mutex. Thanks for 
 mentioning that. We did have to do that to protect the shared resource when 
 we used threading. 
 
 For our stuff, one process (out-the-window) does the usual traversal (via 
 viewer.frame) while the other sits idle until a request comes in for either 
 HAT/HOT or LOS. Once a request comes in, it just computes the intersection 
 with the terrain via the osgSim class and sends the scalar result back. Both 
 processes load the same PagedLOD terrain node but they're using completely 
 different graphs. We only check for intersection with terrain and nothing 
 else...
 
 -Shayne
 
 -Original Message-
 From: osg-users-boun...@lists.openscenegraph.org 
 [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of 
 Jean-Sébastien Guay
 Sent: Thursday, May 12, 2011 2:37 PM
 To: OpenSceneGraph Users
 Subject: Re: [osg-users] Intersection testing in a separate thread
 
 Hi Shayne, Craig,
 
  Bottom line is that it can be done. It basically amounts to having 
  asynchronous traversal of the same scenegraph, one for rendering traversal 
  and the other for intersections. These traversals can either be done in 
  different threads or different processes.
 
 But the case of a different thread vs a different process is not the 
 same. In his case, there will be (optimally) one copy of the scene 
 graph, and both the rendering and the intersection thread will access 
 it. He will need a mutex which would be held by the rendering thread 
 while it's in the update phase, and by the intersection thread while it 
 does an intersection. In your case, you have two copies of the scene 
 graph, so there are no threading issues. (how did you update the scene 
 graph between processes?)
 
 But that doesn't mean it can't be done, just that it's not quite as 
 simple as that.
 
 Hope this helps,
 
 J-S
 -- 
 __
 Jean-Sebastien Guay jean-sebastien.g...@cm-labs.com
 http://www.cm-labs.com/
 http://whitestar02.dyndns-web.com/
 ___
 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
 
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Intersection testing in a separate thread

2011-05-12 Thread Craig S. Bosma
Hi, 

I have an OSG-based simulation that I'm considering retrofitting to decouple 
the actual simulation rate from the render frame rate. It's not viewer-based. A 
simplified example would be and application that listens for a network message 
identifying two world positions, performs and intersection test, and returns a 
response, while rendering/updating the scene. Currently this happens serially, 
but I want to put the network listener and intersection testing on a separate 
thread. Obviously the shared data here is (a portion of) the scenegraph, which 
may be modified by the render/update thread. I want the network/query thread to 
be able to respond as quickly as possible, and not depend on how fast the scene 
can be drawn, as it is currently. 

Does anyone have any advice/experience/examples for how to best approach this 
kind problem? Is it even feasible?

Thanks,
Craig

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Intersection testing in a separate thread

2011-05-12 Thread Tueller, Shayne R Civ USAF AFMC 519 SMXS/MXDEC
Craig,

We've done something similar to what you want to do but in a separate process 
rather than a separate thread. We have done it in an asynchronous thread as 
well. The reason we chose to go with a process is that it allows us to run it 
on a remote machine away from the rendering process if need be. The process has 
a listening thread that receives two world positions (e.g. line of sight from 
ownship to target) over the network. Upon reception, it computes the 
intersection with a terrain database (i.e. node read into a scenegraph) and 
returns the closest intersection distance back over the network to the other 
process that made the request via a sending thread. 

Bottom line is that it can be done. It basically amounts to having asynchronous 
traversal of the same scenegraph, one for rendering traversal and the other for 
intersections. These traversals can either be done in different threads or 
different processes.

-Shayne

-Original Message-
From: osg-users-boun...@lists.openscenegraph.org 
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Craig S. Bosma
Sent: Thursday, May 12, 2011 1:14 PM
To: OpenSceneGraph Users
Subject: [osg-users] Intersection testing in a separate thread

Hi, 


I have an OSG-based simulation that I'm considering retrofitting to decouple 
the actual simulation rate from the render frame rate. It's not viewer-based. A 
simplified example would be and application that listens for a network message 
identifying two world positions, performs and intersection test, and returns a 
response, while rendering/updating the scene. Currently this happens serially, 
but I want to put the network listener and intersection testing on a separate 
thread. Obviously the shared data here is (a portion of) the scenegraph, which 
may be modified by the render/update thread. I want the network/query thread to 
be able to respond as quickly as possible, and not depend on how fast the scene 
can be drawn, as it is currently. 


Does anyone have any advice/experience/examples for how to best approach this 
kind problem? Is it even feasible?


Thanks,
Craig
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Intersection testing in a separate thread

2011-05-12 Thread Jean-Sébastien Guay

Hi Shayne, Craig,


Bottom line is that it can be done. It basically amounts to having asynchronous 
traversal of the same scenegraph, one for rendering traversal and the other for 
intersections. These traversals can either be done in different threads or 
different processes.


But the case of a different thread vs a different process is not the 
same. In his case, there will be (optimally) one copy of the scene 
graph, and both the rendering and the intersection thread will access 
it. He will need a mutex which would be held by the rendering thread 
while it's in the update phase, and by the intersection thread while it 
does an intersection. In your case, you have two copies of the scene 
graph, so there are no threading issues. (how did you update the scene 
graph between processes?)


But that doesn't mean it can't be done, just that it's not quite as 
simple as that.


Hope this helps,

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.dyndns-web.com/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Intersection testing in a separate thread

2011-05-12 Thread Tueller, Shayne R Civ USAF AFMC 519 SMXS/MXDEC
J-S,

Yes, a great point I failed to bring up about the mutex. Thanks for mentioning 
that. We did have to do that to protect the shared resource when we used 
threading. 

For our stuff, one process (out-the-window) does the usual traversal (via 
viewer.frame) while the other sits idle until a request comes in for either 
HAT/HOT or LOS. Once a request comes in, it just computes the intersection with 
the terrain via the osgSim class and sends the scalar result back. Both 
processes load the same PagedLOD terrain node but they're using completely 
different graphs. We only check for intersection with terrain and nothing 
else...

-Shayne

-Original Message-
From: osg-users-boun...@lists.openscenegraph.org 
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Jean-Sébastien 
Guay
Sent: Thursday, May 12, 2011 2:37 PM
To: OpenSceneGraph Users
Subject: Re: [osg-users] Intersection testing in a separate thread

Hi Shayne, Craig,

 Bottom line is that it can be done. It basically amounts to having 
 asynchronous traversal of the same scenegraph, one for rendering traversal 
 and the other for intersections. These traversals can either be done in 
 different threads or different processes.

But the case of a different thread vs a different process is not the 
same. In his case, there will be (optimally) one copy of the scene 
graph, and both the rendering and the intersection thread will access 
it. He will need a mutex which would be held by the rendering thread 
while it's in the update phase, and by the intersection thread while it 
does an intersection. In your case, you have two copies of the scene 
graph, so there are no threading issues. (how did you update the scene 
graph between processes?)

But that doesn't mean it can't be done, just that it's not quite as 
simple as that.

Hope this helps,

J-S
-- 
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
http://www.cm-labs.com/
 http://whitestar02.dyndns-web.com/
___
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


Re: [osg-users] Intersection tests on paged PagedLODs

2011-03-31 Thread Trystan Larey-Williams
I finally got some time to try this and it's exactly what I needed. Another 
point I was missing was setting the range on the PagedLODs. I had a bounding 
vol defined but not the range. 

Thanks for the tip!

-Trystan

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=38143#38143





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Intersection tests on paged PagedLODs

2011-03-13 Thread Trystan Larey-Williams
Hi all,

I'm looking for a way to selectively load PagedLODs saved to files on an 
intersection test. I've built up an Octree represented by a PagedLOD node for 
each subdivision (similar to the quad-tree example in the 3.0 beginner's 
guide). Given an arbitrary point or line, I want to be able to test the 
PagedLODs it intersects with without having unnecessary ones loaded into 
memory. 

I gather that intersection visitors will only traverse loaded PagedLODs but 
won't automatically trigger the database pager to load additional levels (is 
that correct?). Would I need to create a custom visitor to do this or is there 
an easier way that I'm missing? 

Thanks in advance,
Trystan

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=37568#37568





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Intersection tests on paged PagedLODs

2011-03-13 Thread Wang Rui
Hi Trystan,

Try using IntersectionVisitor::setReadCallback() to set a custom
callback for reading paged files into memory (or any other operation
you wish). The node loaded at runtime will automatically be removed
after the traversal of the subgraph.

BTW, thanks for supporting the 3.0 Beginners Guide book. :-)

Cheers,

Wang Rui


2011/3/13 Trystan Larey-Williams trys...@trystan.org:
 Hi all,

 I'm looking for a way to selectively load PagedLODs saved to files on an 
 intersection test. I've built up an Octree represented by a PagedLOD node for 
 each subdivision (similar to the quad-tree example in the 3.0 beginner's 
 guide). Given an arbitrary point or line, I want to be able to test the 
 PagedLODs it intersects with without having unnecessary ones loaded into 
 memory.

 I gather that intersection visitors will only traverse loaded PagedLODs but 
 won't automatically trigger the database pager to load additional levels (is 
 that correct?). Would I need to create a custom visitor to do this or is 
 there an easier way that I'm missing?

 Thanks in advance,
 Trystan

 --
 Read this topic online here:
 http://forum.openscenegraph.org/viewtopic.php?p=37568#37568





 ___
 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


Re: [osg-users] Intersection with a ray

2011-02-11 Thread Geoff Rhodes
Hi,

I know this is old, but I was wondering what your solution was? I need to do a 
similar task.

... 

Thank you!

Cheers,
Geoff

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=36571#36571





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] intersection and threading problem

2010-08-12 Thread Jean-Sébastien Guay

Hello Markus,


Yes, this does make sense. I am using the delta3d game engine as well so maybe 
what I'm asking is if there is any general way the check if osg is currently in 
a state where it is unsafe to act upon the scene? For instance, Is there any 
mutex that belongs to osg that I can wait on ?


Not in OSG itself, but I don't know about Delta3D.

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] intersection and threading problem

2010-08-11 Thread Markus Lacay

Skylark wrote:
 Hi Markus,
 
 
  I'm using osg 2.9.8 and trying to do intersection tests in a thread. The 
  code is real straightforwards and works well when not threaded:
  
 
 [...]
 
 
  Is this a known issue?
  
 
 Err, you say what you want to do, that it works when not threaded, but 
 not what happens when you try to do it in a thread. Do you get crashes? 
 Do you get error messages? Do you get erroneous results?
 
 Without this info it's hard to help you out...
 
 I don't see why it wouldn't work /a priori/, unless your thread is 
 running while some other part of your app is modifying the scene graph. 
 That might invalidate iterators that the IntersectionVisitor is using or 
 things like that, which might lead to crashes.
 
 J-S
 -- 
 __
 Jean-Sebastien Guay
 http://www.cm-labs.com/
 http://whitestar02.webhop.org/
 ___
 osg-users mailing list
 
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 
  --
 Post generated by Mail2Forum

Thanks for addressing this Skylark. Yes, the application crashes due to what I 
think you described (accessing the scene graph while it is being modified) I am 
using osgEarth and running threads concurrently that need to intersect with the 
surface of the earth model. Is there any thread-safe way to achieve this 
without running everything on the main thread?

More generally, is there a way to ensure that you only traverse the scene 
graph's nodes when you're supposed to?

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30698#30698





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] intersection and threading problem

2010-08-11 Thread Jean-Sébastien Guay

Hello Markus,


Thanks for addressing this Skylark. Yes, the application crashes due to what I 
think you described (accessing the scene graph while it is being modified) I am 
using osgEarth and running threads concurrently that need to intersect with the 
surface of the earth model. Is there any thread-safe way to achieve this 
without running everything on the main thread?

More generally, is there a way to ensure that you only traverse the scene 
graph's nodes when you're supposed to?


You're in control of your application's main loop, so you can 
synchronize things the way you want. You can set a mutex that will make 
it safe to run intersections at given times, and then unlock the mutex 
to let the viewer run its update and cull phases safely. That's just an 
example.


Hope this helps,

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] intersection and threading problem

2010-08-11 Thread Markus Lacay
[quote=Skylark]Hello Markus,


 
 You're in control of your application's main loop, so you can 
 synchronize things the way you want. You can set a mutex that will make 
 it safe to run intersections at given times, and then unlock the mutex 
 to let the viewer run its update and cull phases safely. 

Yes, this does make sense. I am using the delta3d game engine as well so maybe 
what I'm asking is if there is any general way the check if osg is currently in 
a state where it is unsafe to act upon the scene? For instance, Is there any 
mutex that belongs to osg that I can wait on ?

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30707#30707





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Intersection with a ray

2010-07-26 Thread lucie lemonnier
Hi,
I use osgUtil::LineSegmentIntersector to obtain the intersections between a 
mouse or a ray starting from a wand and a terrain generated with 
VirtualPlanetBuilder and to display the latitude, longitude and height of the 
intersection point. 
When I use the LineSegmentIntersector with the mouse and I use the camera which 
accept the IntersectionVisitor, the values of latitude, longitude and height 
are correct.
Here is my code : 


 osg::ref_ptr osgUtil::LineSegmentIntersector  picker = new 
osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, x, y);
osgUtil::IntersectionVisitor iv(picker.get());
view-getCamera()-accept(iv); 
if (picker-containsIntersections())
{
intersections = picker-getIntersections();


for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr = 
intersections.begin();
hitr != intersections.end();
++hitr)
{

osg::CoordinateSystemNode* csn = new osg::CoordinateSystemNode;
csn-setEllipsoidModel(new osg::EllipsoidModel());
csn-addChild(group);


point = hitr-getWorldIntersectPoint();


double latitude;
double longitude;
double height;



csn-getEllipsoidModel()-convertXYZToLatLongHeight(point.x(),point.y(),point.z(),latitude,longitude,height);

latitude = osg::RadiansToDegrees(latitude);
longitude = osg::RadiansToDegrees(longitude);

std::cout lat,long,height( latitude  ,  
longitude  ,  height  )  std::endl;

}
}

But, my goal is to obtain the intersections of the terrain with a ray starting 
from a wand. I use here LineSegmentIntersector with the start point of a wand 
and the end point and I use the rootNode which accept the IntersectionVisitor. 
But in this case, the values of latitude, longitude and height are false.
Here is my code : 

osg::Vec3 wandp1;
osg::Vec3 wandp2;

osg::ref_ptr osgUtil::LineSegmentIntersector  picker = new 
osgUtil::LineSegmentIntersector(wandp1,wandp2);

osgUtil::LineSegmentIntersector::Intersections intersections;
osgUtil::IntersectionVisitor iv(line.get());
rootNode-accept(iv);

if(picker-containsIntersections()){
//same code as before

}

In red are the differences between the two methods.
I don't understand what is the problem.
Can you help me, please?

Thank you!

Cheers,
lucie

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30262#30262





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Intersection with a ray

2010-07-26 Thread Tom Pearce
Hi Lucie,

When you make a line segment intersector with just two Vec3s as input 
arguments, the line segment runs from one point to the other in model 
coordinates.  How are you finding wandp1 and wandp2?  In your code it looks 
like they are uninitialized in which case they are both (0, 0, 0).  If you 
actually do have the values for the two points, would you expect that line to 
intersect your terrain?

Cheers,
Tom

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30273#30273





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Intersection with a ray

2010-07-26 Thread lucie lemonnier
Hi,

Thank you for your reply. I have initialized my two points depending on the 
position of my wand into space so the error was not this. In fact, I found an 
error in my code and now it works.

Cheers,
lucie

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30283#30283





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] intersection and threading problem

2010-07-22 Thread Markus Lacay
Hey all,

I'm using osg 2.9.8 and trying to do intersection tests in a thread. The code 
is real straightforwards and works well when not threaded: 
Code:
osg::ref_ptrosgUtil::LineSegmentIntersector intersector = new 
osgUtil::LineSegmentIntersector(start, end);

  osgUtil::IntersectionVisitor visitor(intersector);
  
visitor.setLODSelectionMode(osgUtil::IntersectionVisitor::LODSelectionMode::USE_HIGHEST_LEVEL_OF_DETAIL
 );
  osgEarthNode-accept(visitor);

if(intersector-containsIntersections())
{
osgUtil::LineSegmentIntersector::Intersections::const_iterator firstHit 
= intersector-getIntersections().begin();

worldIntersectionPosition = firstHit-getWorldIntersectPoint();
worldIntersectionNormal = firstHit-getWorldIntersectNormal();

return true;
 }

Is this a known issue?

-Markus

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30183#30183





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] intersection and threading problem

2010-07-22 Thread Jean-Sébastien Guay

Hi Markus,


I'm using osg 2.9.8 and trying to do intersection tests in a thread. The code 
is real straightforwards and works well when not threaded:


[...]


Is this a known issue?


Err, you say what you want to do, that it works when not threaded, but 
not what happens when you try to do it in a thread. Do you get crashes? 
Do you get error messages? Do you get erroneous results?


Without this info it's hard to help you out...

I don't see why it wouldn't work /a priori/, unless your thread is 
running while some other part of your app is modifying the scene graph. 
That might invalidate iterators that the IntersectionVisitor is using or 
things like that, which might lead to crashes.


J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Intersection with a boundingBox

2010-07-07 Thread Baptiste Souli
Hello,

I have a scene  and i would like to clip considering a bounding box (i.e
cut the polygon at the border and eliminate the outside elements). 
Does there already exist in osg an implementation to calculate the 
interesection with a boudingbox (or a plane) or must I implement it? 
I have found PolytopeIntersector but I don't know if it calculate the 
intersection or just return the vertex in the boundingbox).

Thanks.
Aerkis.

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=29772#29772





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Intersection with a boundingBox

2010-07-07 Thread Robert Osfield
Hi Aerkis,

There is a osgUtil::PlaneIntersector that gives you the intersection
polygon between a plane and a scene, there is also the
PolytopIntersector but this tells you whether the scene contains any
geometry that has at least part of it in the polytop - it doesn't give
the intersection.

However, given your email I'm not sure either of these is what you are
after, and if you actually want to cut the polygons and create a whole
new geometry from the result then the OSG doesn't support this.
However, if you just want to do this for rendering then there is
OpenGL support for clip planes in the OSG so perhaps this is
sufficient.

Might I suggest explaining what you are after as a result rather than
focusing too much on the low level as doing so doesn't give us an idea
of what you are trying to do and why - advice for you will be much
more useful if you can provide a clearer to others.

Robert.

On Wed, Jul 7, 2010 at 9:14 AM, Baptiste Souli aer...@hotmail.fr wrote:
 Hello,

 I have a scene  and i would like to clip considering a bounding box (i.e
 cut the polygon at the border and eliminate the outside elements).
 Does there already exist in osg an implementation to calculate the 
 interesection with a boudingbox (or a plane) or must I implement it?
 I have found PolytopeIntersector but I don't know if it calculate the 
 intersection or just return the vertex in the boundingbox).

 Thanks.
 Aerkis.

 --
 Read this topic online here:
 http://forum.openscenegraph.org/viewtopic.php?p=29772#29772





 ___
 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


Re: [osg-users] Intersection with a boundingBox

2010-07-07 Thread Riccardo Corsi
Hi Aerkis,

all the intersection routines you find under osgUtil are meant just to
find intersection (picking being the most common usage), not to clip
polygons.
For that purpose you should instead look at osg::ClipPlane/ClipNode
which implement GL clipping.

I don't think there's a routine which clips by a bb extents, you
should implement that by using 6 different clipping planes yourself.
See osgClip example for a reference.

HTH,
Ricky

On Wed, Jul 7, 2010 at 10:14, Baptiste Souli aer...@hotmail.fr wrote:
 Hello,

 I have a scene  and i would like to clip considering a bounding box (i.e
 cut the polygon at the border and eliminate the outside elements).
 Does there already exist in osg an implementation to calculate the 
 interesection with a boudingbox (or a plane) or must I implement it?
 I have found PolytopeIntersector but I don't know if it calculate the 
 intersection or just return the vertex in the boundingbox).

 Thanks.
 Aerkis.

 --
 Read this topic online here:
 http://forum.openscenegraph.org/viewtopic.php?p=29772#29772





 ___
 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


Re: [osg-users] Intersection precision loss?

2010-03-30 Thread Robert Osfield
Hi Adrian,

The intersection tests are double in singles, but the intersection ray
is transformed into local space using doubles so this should help
avoid most of the precision issues.  There were still some precisions
problems with the bounding box intersection test that was causing
premature rejection of the drawable and KdTree based intersections, in
svn/trunk there are fixes that address these.

Could you try svn/trunk and see how you get on?

Robert.

On Mon, Mar 29, 2010 at 8:36 PM, Adrian Lindberg osgfo...@tevs.eu wrote:
 I'm doing some large terrain rendering using OSG where I put small bulletins 
 (billboards) which I wan't to make clickable. For this I found the osgPicker 
 example and implemented it and all worked well.

 However in an extension of this I moved the camera to a bulletin to supply 
 additional clickable billboards (ie move inside a clicked house and look in 
 the drawer inside the house). These additional billboards are relatively 
 small compared to my world (several kilometers, the small billboard being 
 about a meter in radius) and my intersection fails 95% of the time. If I move 
 the camera out and make the larger (so that I can see them from a distance) 
 everything works again. No change in code or scenegraph structure except the 
 position set by the camera manipulator.

 I'm wondering if there are any known issues with intersection tests since I 
 presume these are done in single precision. Does it do double calculations 
 for MatrixTransforms (I tried putting a matrix transform having local 
 coordinates for the smaller objects as well with no luck).

 Any other ideas as how to tackle this?

 Cheers,
 Adrian

 --
 Read this topic online here:
 http://forum.openscenegraph.org/viewtopic.php?p=26250#26250





 ___
 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


[osg-users] Intersection precision loss?

2010-03-29 Thread Adrian Lindberg
I'm doing some large terrain rendering using OSG where I put small bulletins 
(billboards) which I wan't to make clickable. For this I found the osgPicker 
example and implemented it and all worked well.

However in an extension of this I moved the camera to a bulletin to supply 
additional clickable billboards (ie move inside a clicked house and look in the 
drawer inside the house). These additional billboards are relatively small 
compared to my world (several kilometers, the small billboard being about a 
meter in radius) and my intersection fails 95% of the time. If I move the 
camera out and make the larger (so that I can see them from a distance) 
everything works again. No change in code or scenegraph structure except the 
position set by the camera manipulator.

I'm wondering if there are any known issues with intersection tests since I 
presume these are done in single precision. Does it do double calculations for 
MatrixTransforms (I tried putting a matrix transform having local coordinates 
for the smaller objects as well with no luck).

Any other ideas as how to tackle this?  

Cheers,
Adrian

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=26250#26250





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Intersection precision loss?

2010-03-29 Thread Simon Hammett
On 29 March 2010 20:36, Adrian Lindberg osgfo...@tevs.eu wrote:

 I'm doing some large terrain rendering using OSG where I put small
 bulletins (billboards) which I wan't to make clickable. For this I found the
 osgPicker example and implemented it and all worked well.

 However in an extension of this I moved the camera to a bulletin to supply
 additional clickable billboards (ie move inside a clicked house and look in
 the drawer inside the house). These additional billboards are relatively
 small compared to my world (several kilometers, the small billboard being
 about a meter in radius) and my intersection fails 95% of the time. If I
 move the camera out and make the larger (so that I can see them from a
 distance) everything works again. No change in code or scenegraph structure
 except the position set by the camera manipulator.

 I'm wondering if there are any known issues with intersection tests since I
 presume these are done in single precision. Does it do double calculations
 for MatrixTransforms (I tried putting a matrix transform having local
 coordinates for the smaller objects as well with no luck).

 Any other ideas as how to tackle this?

 Cheers,
 Adrian


Yeah, there (are/were) some problems with line intersection picker:

http://thread.gmane.org/gmane.comp.graphics.openscenegraph.user/52331/focus=52577

-- 
http://www.ssTk.co.uk
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] intersection point and the right triangle

2009-06-22 Thread Großer Martin
Hello Robert,

now, I use the osgUtil::IntersectionVisitor. The example was very
helpfully. But I have a new little problem. I get the first
intersection:

const osgUtil::LineSegmentIntersector::Intersection hit =
_ray-getFirstIntersection();

After this, I get the intersection point in world coordinates:

osg::Vec3 intersectionPoint = hit.getWorldIntersectPoint();

This vector is right. But the index list and the ratio list are empty.

// get the vertex indices.
const osgUtil::LineSegmentIntersector::Intersection::IndexList indices
= hit.indexList;
// bary coords
const osgUtil::LineSegmentIntersector::Intersection::RatioList ratios =
hit.ratioList;
if (indices.size()==3  ratios.size()==3) // is always false
{
// TO DO
}

What is my mistake? Have you an idea?

Cheers,

Martin



Am Freitag, den 19.06.2009, 15:18 +0100 schrieb Robert Osfield:

 Hi Martin,
 
 I would recommend using the osgUtil::IntersectionVisitor rather than
 the osgUtil::IntersectVisitor as the later is deprecated and only kept
 around for backwards compatibility.
 
 As for examples of getting the texture coords of a ray intersections
 have a look at the osgViewer::InteractiveImageHandler implementation
 in src/osgViewer/ViewerEventHandlers.cpp as it does just this.
 
 Robert.
 
 2009/6/19 Großer Martin grosser.mar...@gmx.de:
  Hello all,
 
  i use the intersectVisitor to get the intersection between a ray and a
  geode. It works fine and I'm very happy, because it is very comfortable.
  Now I have the point (vector) of intersection, but I need the triangle
  of the drawable what I hit. I would like calculate the barycentric
  coordinates of the point. With this coordinates I want to calculate the
  texture coordinates of my intersection point.
 
  There are a comfortable way in osg? Or have anyone a idea for a nice
  solution? I think the intersectVisitor find the triangle, but i can't
  get this information.
 
 
  Cheers
 
  Martin
 
  ___
  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
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] intersection point and the right triangle

2009-06-22 Thread Großer Martin
Hello Robert,

I dig into the LineSegmentIntersector code and I found the lines 391 -
399:

if (geometry) // it is true
{
  osg::Vec3Array* vertices = dynamic_castosg::Vec3Array*
(geometry-getVertexArray());

  if (vertices) // it is always false
  {
 osg::Vec3* first = (vertices-front());
 if (triHit._v1)
 {
 hit.indexList.push_back(triHit._v1-first);
 hit.ratioList.push_back(triHit._r1);
 }

[...]

if (vertices) is always false, but the geometry has a vertices. In my
application I wrote the following code:

const osgUtil::LineSegmentIntersector::Intersection hit =
_ray-getFirstIntersection();
::osg::Drawable* drawable = hit.drawable.get();
::osg::Geometry* geometry = drawable ? drawable-asGeometry() : 0;
::osg::Vec3Array* vertices = geometry ?
dynamic_cast ::osg::Vec3Array*(geometry-getVertexArray()) : 0;

Here is the test if (vertices) true. It is for me irreproducible.
There are not the same geometries with the same vertices in the
LineSegementIntersector and in my 

Cheers,


Martin



Am Montag, den 22.06.2009, 08:53 +0100 schrieb Robert Osfield:

 Hi Martin,
 
 You'll need to dig into the LineSegmentIntersector code to answer this 
 question.
 
 Robert.
 
 2009/6/22 Großer Martin grosser.mar...@gmx.de:
  Hello Robert,
 
  now, I use the osgUtil::IntersectionVisitor. The example was very helpfully.
  But I have a new little problem. I get the first intersection:
 
  const osgUtil::LineSegmentIntersector::Intersection hit =
  _ray-getFirstIntersection();
 
  After this, I get the intersection point in world coordinates:
 
  osg::Vec3 intersectionPoint = hit.getWorldIntersectPoint();
 
  This vector is right. But the index list and the ratio list are empty.
 
  // get the vertex indices.
  const osgUtil::LineSegmentIntersector::Intersection::IndexList indices =
  hit.indexList;
  // bary coords
  const osgUtil::LineSegmentIntersector::Intersection::RatioList ratios =
  hit.ratioList;
  if (indices.size()==3  ratios.size()==3) // is always false
  {
  // TO DO
  }
 
  What is my mistake? Have you an idea?
 
  Cheers,
 
  Martin
 
 
 
  Am Freitag, den 19.06.2009, 15:18 +0100 schrieb Robert Osfield:
 
  Hi Martin,
 
  I would recommend using the osgUtil::IntersectionVisitor rather than
  the osgUtil::IntersectVisitor as the later is deprecated and only kept
  around for backwards compatibility.
 
  As for examples of getting the texture coords of a ray intersections
  have a look at the osgViewer::InteractiveImageHandler implementation
  in src/osgViewer/ViewerEventHandlers.cpp as it does just this.
 
  Robert.
 
  2009/6/19 Großer Martin grosser.mar...@gmx.de:
  Hello all,
 
  i use the intersectVisitor to get the intersection between a ray and a
  geode. It works fine and I'm very happy, because it is very comfortable.
  Now I have the point (vector) of intersection, but I need the triangle
  of the drawable what I hit. I would like calculate the barycentric
  coordinates of the point. With this coordinates I want to calculate the
  texture coordinates of my intersection point.
 
  There are a comfortable way in osg? Or have anyone a idea for a nice
  solution? I think the intersectVisitor find the triangle, but i can't
  get this information.
 
 
  Cheers
 
  Martin
 
  ___
  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
 
  ___
  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
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] intersection point and the right triangle

2009-06-22 Thread Robert Osfield
Hi Martin,

A perplexing result for which I have no answer.

Robert.

2009/6/22 Großer Martin grosser.mar...@gmx.de:
 Hello Robert,

 I dig into the LineSegmentIntersector code and I found the lines 391 - 399:

 if (geometry) // it is true
 {
   osg::Vec3Array* vertices = dynamic_castosg::Vec3Array*
 (geometry-getVertexArray());

   if (vertices) // it is always false
   {
  osg::Vec3* first = (vertices-front());
  if (triHit._v1)
  {
  hit.indexList.push_back(triHit._v1-first);
  hit.ratioList.push_back(triHit._r1);
  }

 [...]

 if (vertices) is always false, but the geometry has a vertices. In my
 application I wrote the following code:

 const osgUtil::LineSegmentIntersector::Intersection hit =
 _ray-getFirstIntersection();
 ::osg::Drawable* drawable = hit.drawable.get();
 ::osg::Geometry* geometry = drawable ? drawable-asGeometry() : 0;
 ::osg::Vec3Array* vertices = geometry ? dynamic_cast
 ::osg::Vec3Array*(geometry-getVertexArray()) : 0;

 Here is the test if (vertices) true. It is for me irreproducible. There
 are not the same geometries with the same vertices in the
 LineSegementIntersector and in my

 Cheers,


 Martin



 Am Montag, den 22.06.2009, 08:53 +0100 schrieb Robert Osfield:

 Hi Martin,

 You'll need to dig into the LineSegmentIntersector code to answer this
 question.

 Robert.

 2009/6/22 Großer Martin grosser.mar...@gmx.de:
 Hello Robert,

 now, I use the osgUtil::IntersectionVisitor. The example was very
 helpfully.
 But I have a new little problem. I get the first intersection:

 const osgUtil::LineSegmentIntersector::Intersection hit =
 _ray-getFirstIntersection();

 After this, I get the intersection point in world coordinates:

 osg::Vec3 intersectionPoint = hit.getWorldIntersectPoint();

 This vector is right. But the index list and the ratio list are empty.

 // get the vertex indices.
 const osgUtil::LineSegmentIntersector::Intersection::IndexList indices =
 hit.indexList;
 // bary coords
 const osgUtil::LineSegmentIntersector::Intersection::RatioList ratios =
 hit.ratioList;
 if (indices.size()==3  ratios.size()==3) // is always false
 {
     // TO DO
 }

 What is my mistake? Have you an idea?

 Cheers,

 Martin



 Am Freitag, den 19.06.2009, 15:18 +0100 schrieb Robert Osfield:

 Hi Martin,

 I would recommend using the osgUtil::IntersectionVisitor rather than
 the osgUtil::IntersectVisitor as the later is deprecated and only kept
 around for backwards compatibility.

 As for examples of getting the texture coords of a ray intersections
 have a look at the osgViewer::InteractiveImageHandler implementation
 in src/osgViewer/ViewerEventHandlers.cpp as it does just this.

 Robert.

 2009/6/19 Großer Martin grosser.mar...@gmx.de:
 Hello all,

 i use the intersectVisitor to get the intersection between a ray and a
 geode. It works fine and I'm very happy, because it is very comfortable.
 Now I have the point (vector) of intersection, but I need the triangle
 of the drawable what I hit. I would like calculate the barycentric
 coordinates of the point. With this coordinates I want to calculate the
 texture coordinates of my intersection point.

 There are a comfortable way in osg? Or have anyone a idea for a nice
 solution? I think the intersectVisitor find the triangle, but i can't
 get this information.


 Cheers

 Martin

 ___
 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

 ___
 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

 ___
 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


Re: [osg-users] intersection point and the right triangle

2009-06-22 Thread Großer Martin
Hello Robert,

i find out something. I try to print out the adress of the geometry
object and the vertices like the following lines:

std::cout  Adresse Geometry:   (*geometry)  std::endl;
std::cout  Adresse Vertices:   (*vertices)  std::endl;

The result was...

In LineSegmentIntersector:
---
Adresse Geometry: 0x90de2f8
Adresse Vertices: 0

In my application:
---
Adresse Geometry: 0x90de2f8
Adresse Vertices: 0x90df848

Also my idea was, the cast is faild. Now, I change the dynamic_cast to
the reinterpret_cast and now it works fine!

I use Fedora10 and the gcc compiler version 4.3.1.

Cheers,

Martin


Am Montag, den 22.06.2009, 13:33 +0100 schrieb Robert Osfield:
 Hi Martin,
 
 A perplexing result for which I have no answer.
 
 Robert.
 
 2009/6/22 Großer Martin grosser.mar...@gmx.de:
  Hello Robert,
 
  I dig into the LineSegmentIntersector code and I found the lines 391 - 399:
 
  if (geometry) // it is true
  {
osg::Vec3Array* vertices = dynamic_castosg::Vec3Array*
  (geometry-getVertexArray());
 
if (vertices) // it is always false
{
   osg::Vec3* first = (vertices-front());
   if (triHit._v1)
   {
   hit.indexList.push_back(triHit._v1-first);
   hit.ratioList.push_back(triHit._r1);
   }
 
  [...]
 
  if (vertices) is always false, but the geometry has a vertices. In my
  application I wrote the following code:
 
  const osgUtil::LineSegmentIntersector::Intersection hit =
  _ray-getFirstIntersection();
  ::osg::Drawable* drawable = hit.drawable.get();
  ::osg::Geometry* geometry = drawable ? drawable-asGeometry() : 0;
  ::osg::Vec3Array* vertices = geometry ? dynamic_cast
  ::osg::Vec3Array*(geometry-getVertexArray()) : 0;
 
  Here is the test if (vertices) true. It is for me irreproducible. There
  are not the same geometries with the same vertices in the
  LineSegementIntersector and in my
 
  Cheers,
 
 
  Martin
 
 
 
  Am Montag, den 22.06.2009, 08:53 +0100 schrieb Robert Osfield:
 
  Hi Martin,
 
  You'll need to dig into the LineSegmentIntersector code to answer this
  question.
 
  Robert.
 
  2009/6/22 Großer Martin grosser.mar...@gmx.de:
  Hello Robert,
 
  now, I use the osgUtil::IntersectionVisitor. The example was very
  helpfully.
  But I have a new little problem. I get the first intersection:
 
  const osgUtil::LineSegmentIntersector::Intersection hit =
  _ray-getFirstIntersection();
 
  After this, I get the intersection point in world coordinates:
 
  osg::Vec3 intersectionPoint = hit.getWorldIntersectPoint();
 
  This vector is right. But the index list and the ratio list are empty.
 
  // get the vertex indices.
  const osgUtil::LineSegmentIntersector::Intersection::IndexList indices =
  hit.indexList;
  // bary coords
  const osgUtil::LineSegmentIntersector::Intersection::RatioList ratios =
  hit.ratioList;
  if (indices.size()==3  ratios.size()==3) // is always false
  {
  // TO DO
  }
 
  What is my mistake? Have you an idea?
 
  Cheers,
 
  Martin
 
 
 
  Am Freitag, den 19.06.2009, 15:18 +0100 schrieb Robert Osfield:
 
  Hi Martin,
 
  I would recommend using the osgUtil::IntersectionVisitor rather than
  the osgUtil::IntersectVisitor as the later is deprecated and only kept
  around for backwards compatibility.
 
  As for examples of getting the texture coords of a ray intersections
  have a look at the osgViewer::InteractiveImageHandler implementation
  in src/osgViewer/ViewerEventHandlers.cpp as it does just this.
 
  Robert.
 
  2009/6/19 Großer Martin grosser.mar...@gmx.de:
  Hello all,
 
  i use the intersectVisitor to get the intersection between a ray and a
  geode. It works fine and I'm very happy, because it is very comfortable.
  Now I have the point (vector) of intersection, but I need the triangle
  of the drawable what I hit. I would like calculate the barycentric
  coordinates of the point. With this coordinates I want to calculate the
  texture coordinates of my intersection point.
 
  There are a comfortable way in osg? Or have anyone a idea for a nice
  solution? I think the intersectVisitor find the triangle, but i can't
  get this information.
 
 
  Cheers
 
  Martin
 
  ___
  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
 
  ___
  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
 
  

Re: [osg-users] intersection point and the right triangle

2009-06-22 Thread Robert Osfield
Hi Martin,

Something really odd is going on your system.  It kinda looks like a
compiler bug or a build error.  I have g++ 4.3.3 on my Kubuntu system.

It might be useful to put together an example code that illustrate
this problem in way that others (like myself) can pick up and
reproduce the same error as your seeing.

Robert.

2009/6/22 Großer Martin grosser.mar...@gmx.de:
 Hello Robert,

 i find out something. I try to print out the adress of the geometry
 object and the vertices like the following lines:

 std::cout  Adresse Geometry:   (*geometry)  std::endl;
 std::cout  Adresse Vertices:   (*vertices)  std::endl;

 The result was...

 In LineSegmentIntersector:
 ---
        Adresse Geometry: 0x90de2f8
        Adresse Vertices: 0

 In my application:
 ---
        Adresse Geometry: 0x90de2f8
        Adresse Vertices: 0x90df848

 Also my idea was, the cast is faild. Now, I change the dynamic_cast to
 the reinterpret_cast and now it works fine!

 I use Fedora10 and the gcc compiler version 4.3.1.

 Cheers,

 Martin


 Am Montag, den 22.06.2009, 13:33 +0100 schrieb Robert Osfield:
 Hi Martin,

 A perplexing result for which I have no answer.

 Robert.

 2009/6/22 Großer Martin grosser.mar...@gmx.de:
  Hello Robert,
 
  I dig into the LineSegmentIntersector code and I found the lines 391 - 399:
 
  if (geometry) // it is true
  {
    osg::Vec3Array* vertices = dynamic_castosg::Vec3Array*
  (geometry-getVertexArray());
 
    if (vertices) // it is always false
    {
       osg::Vec3* first = (vertices-front());
       if (triHit._v1)
       {
           hit.indexList.push_back(triHit._v1-first);
           hit.ratioList.push_back(triHit._r1);
       }
 
  [...]
 
  if (vertices) is always false, but the geometry has a vertices. In my
  application I wrote the following code:
 
  const osgUtil::LineSegmentIntersector::Intersection hit =
  _ray-getFirstIntersection();
  ::osg::Drawable* drawable = hit.drawable.get();
  ::osg::Geometry* geometry = drawable ? drawable-asGeometry() : 0;
  ::osg::Vec3Array* vertices = geometry ? dynamic_cast
  ::osg::Vec3Array*(geometry-getVertexArray()) : 0;
 
  Here is the test if (vertices) true. It is for me irreproducible. There
  are not the same geometries with the same vertices in the
  LineSegementIntersector and in my
 
  Cheers,
 
 
  Martin
 
 
 
  Am Montag, den 22.06.2009, 08:53 +0100 schrieb Robert Osfield:
 
  Hi Martin,
 
  You'll need to dig into the LineSegmentIntersector code to answer this
  question.
 
  Robert.
 
  2009/6/22 Großer Martin grosser.mar...@gmx.de:
  Hello Robert,
 
  now, I use the osgUtil::IntersectionVisitor. The example was very
  helpfully.
  But I have a new little problem. I get the first intersection:
 
  const osgUtil::LineSegmentIntersector::Intersection hit =
  _ray-getFirstIntersection();
 
  After this, I get the intersection point in world coordinates:
 
  osg::Vec3 intersectionPoint = hit.getWorldIntersectPoint();
 
  This vector is right. But the index list and the ratio list are empty.
 
  // get the vertex indices.
  const osgUtil::LineSegmentIntersector::Intersection::IndexList indices =
  hit.indexList;
  // bary coords
  const osgUtil::LineSegmentIntersector::Intersection::RatioList ratios =
  hit.ratioList;
  if (indices.size()==3  ratios.size()==3) // is always false
  {
      // TO DO
  }
 
  What is my mistake? Have you an idea?
 
  Cheers,
 
  Martin
 
 
 
  Am Freitag, den 19.06.2009, 15:18 +0100 schrieb Robert Osfield:
 
  Hi Martin,
 
  I would recommend using the osgUtil::IntersectionVisitor rather than
  the osgUtil::IntersectVisitor as the later is deprecated and only kept
  around for backwards compatibility.
 
  As for examples of getting the texture coords of a ray intersections
  have a look at the osgViewer::InteractiveImageHandler implementation
  in src/osgViewer/ViewerEventHandlers.cpp as it does just this.
 
  Robert.
 
  2009/6/19 Großer Martin grosser.mar...@gmx.de:
  Hello all,
 
  i use the intersectVisitor to get the intersection between a ray and a
  geode. It works fine and I'm very happy, because it is very comfortable.
  Now I have the point (vector) of intersection, but I need the triangle
  of the drawable what I hit. I would like calculate the barycentric
  coordinates of the point. With this coordinates I want to calculate the
  texture coordinates of my intersection point.
 
  There are a comfortable way in osg? Or have anyone a idea for a nice
  solution? I think the intersectVisitor find the triangle, but i can't
  get this information.
 
 
  Cheers
 
  Martin
 
  ___
  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
 
  

[osg-users] intersection point and the right triangle

2009-06-19 Thread Großer Martin
Hello all,

i use the intersectVisitor to get the intersection between a ray and a
geode. It works fine and I'm very happy, because it is very comfortable.
Now I have the point (vector) of intersection, but I need the triangle
of the drawable what I hit. I would like calculate the barycentric
coordinates of the point. With this coordinates I want to calculate the
texture coordinates of my intersection point.

There are a comfortable way in osg? Or have anyone a idea for a nice
solution? I think the intersectVisitor find the triangle, but i can't
get this information.


Cheers

Martin

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] intersection point and the right triangle

2009-06-19 Thread Robert Osfield
Hi Martin,

I would recommend using the osgUtil::IntersectionVisitor rather than
the osgUtil::IntersectVisitor as the later is deprecated and only kept
around for backwards compatibility.

As for examples of getting the texture coords of a ray intersections
have a look at the osgViewer::InteractiveImageHandler implementation
in src/osgViewer/ViewerEventHandlers.cpp as it does just this.

Robert.

2009/6/19 Großer Martin grosser.mar...@gmx.de:
 Hello all,

 i use the intersectVisitor to get the intersection between a ray and a
 geode. It works fine and I'm very happy, because it is very comfortable.
 Now I have the point (vector) of intersection, but I need the triangle
 of the drawable what I hit. I would like calculate the barycentric
 coordinates of the point. With this coordinates I want to calculate the
 texture coordinates of my intersection point.

 There are a comfortable way in osg? Or have anyone a idea for a nice
 solution? I think the intersectVisitor find the triangle, but i can't
 get this information.


 Cheers

 Martin

 ___
 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


Re: [osg-users] intersection point and the right triangle

2009-06-19 Thread Daniel Trstenjak

Hi Martin,

 I think the intersectVisitor find the triangle, but i can't
 get this information.

osgUtil::Hit::getPrimitiveIndex == triangle index in vertex array   


Greetings,
Daniel

-- 

   
 Daniel Trstenjak Tel   : +49 (0)7071-9457-264
 science + computing ag   FAX   : +49 (0)7071-9457-511
 Hagellocher Weg 73   mailto: daniel.trsten...@science-computing.de
 D-72070 Tübingen WWW   : http://www.science-computing.de/  

-- 
Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Roland Niemeier, 
Dr. Arno Steitz, Dr. Ingrid Zech
Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Michel Lepert
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196 


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Intersection question

2009-05-14 Thread Cristina Paponi
Hi,

I am using a LineSegmentIntersector to determine all the intersections in my 
scene. In the osgUtil::LineSegmentIntersector::Intersections multiset, is the 
first intersection in the set the closest to the startPoint?

Thank you!

Cheers,
Cristina

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=12122#12122





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Intersection question

2009-05-14 Thread Jean-Sébastien Guay

Hello Cristina,


I am using a LineSegmentIntersector to determine all the intersections in my 
scene. In the osgUtil::LineSegmentIntersector::Intersections multiset, is the 
first intersection in the set the closest to the startPoint?


Yes. The set automatically orders based on Intersection's operator(), 
which returns the ratio variable, which is 0.0 at the start point and 
1.0 at the end point, so the first intersection in the set will be the 
closest to the start.


J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Intersection

2009-04-30 Thread Cristina
Hi all, 

What I'm trying to do is to intersect with humans.
In our scene humans are bilboards and only one bilboard is active at one 
time(the one that is facing the camera). If my LineSegment intersects the human 
on the side, the default intersection visitor will intersect the bounding 
sphere, but not the side polygon(because is not active). So what I was trying 
to do was to set a callback on the group node and be called if the bounding 
sphere is hit. After, I would probably have to do the  intersection myself with 
all the children(active or not) to see if any of the bilboards are hit.
From your answers it seems that I need to create my own visitor and do my own 
intersection for that specific node.

Thank you,
Regards,
Cristina

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=11102#11102





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Intersection

2009-04-29 Thread Cristina
Hi,

Is there any intersection callback that we can assign to a node, to be able to 
perform intersection with custom render drawables ?

Regards,
Cristina

Thank you.

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=11055#11055





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Intersection

2009-04-29 Thread Alberto Luaces
Hi Cristina,

El Miércoles 29 Abril 2009ES 18:37:16 Cristina escribió:
 Hi,

 Is there any intersection callback that we can assign to a node, to be able
 to perform intersection with custom render drawables ?

You have to subclass your own class for that kind of drawables, since you are 
the only one that knows how they are built.

For example, if I had a custom drawable that drew a sphere, I should subclass 
the intersectionvisitor to take advantage of its equation x^2+y^2+z^2=r^2 
when it arrives to my special drawable.

Regards,

Alberto
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Intersection

2009-04-29 Thread Robert Osfield
Hi Cristima,

You'll need to implement the Drawable::accept(PrimtiveFunctor) method
to enable the standard intersection routes etc. to be able to query
your geometry.  Have a look at the Geometry::accept(PrimitiveFunctor)
and ShapeDrawable::accept(PrimitiveFunctor) to how it's done.

Robert.

On Wed, Apr 29, 2009 at 5:37 PM, Cristina cristina.pap...@meggitt.com wrote:
 Hi,

 Is there any intersection callback that we can assign to a node, to be able 
 to perform intersection with custom render drawables ?

 Regards,
 Cristina

 Thank you.

 --
 Read this topic online here:
 http://forum.openscenegraph.org/viewtopic.php?p=11055#11055





 ___
 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


[osg-users] Intersection Node Comparison

2008-12-30 Thread Ryan Morris
I've been looking for a solution here for a few days and can't come up
with one. I have a scene with several nodes loaded with
osgDB::readNodeFile. I can run an intersection check and get results,
but I can't seem to come up with a way to compare the selected nodes
(from the nodePath of the intersection results) to nodes in my vector
of nodes. It appears to me that the results are geodes, please correct
me if I am wrong. Anyone know how to solve this?

-Rusty
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Intersection Node Comparison

2008-12-30 Thread Sukender
Hi Rusty,

This is a normal behaviour of the intersection computation, as far as I know. 
My guess is that you should flag your nodes that you want to condider (root 
nodes for each model), and simply look for node's ascendants until you find 
the flag.
Ex: If a model is 1 MatrixTransform on top, 2 MatrixTransforms under, and 2 
geodes as 3rd layer, then when a gode is hit you go up until you find the 
first MatrixTransform.

Sukender
PVLE - Lightweight cross-platform game engine - http://pvle.sourceforge.net/


Le Tue, 30 Dec 2008 18:50:10 +0100, Ryan Morris russell.co...@gmail.com a 
écrit:

 I've been looking for a solution here for a few days and can't come up
 with one. I have a scene with several nodes loaded with
 osgDB::readNodeFile. I can run an intersection check and get results,
 but I can't seem to come up with a way to compare the selected nodes
 (from the nodePath of the intersection results) to nodes in my vector
 of nodes. It appears to me that the results are geodes, please correct
 me if I am wrong. Anyone know how to solve this?

 -Rusty
 ___
 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


Re: [osg-users] Intersection Node Comparison

2008-12-30 Thread Ryan Morris
Interesting, I am comparing each object in the intersections nodepath
to the node i want to check against (using node == _node) and I'm not
getting any positive results. If there is a better way to compare them
I'm all ears! I didn't see a .compareTo or .equals in the
osg::Node/Object/Geode api. Thanks in advance!
-Russ
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Intersection Node Comparison

2008-12-30 Thread Ryan Morris
Ok, one problem I am running into is that when I loop through the
LineSegmentIntersector iterator and I look at the names of all of the
nodes, they do not represent what I have set the node's names to. I'm
not sure how to solve this. When I load the .osg files i do a
node-setName(newName); but when the intersector returns it's
results i get the name of the Geode specified in the .osg file. Any
ideas?

-Russ
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Intersection destroy - memory errors

2008-10-02 Thread Jesper D. Thomsen
Hi again, I have integrated an OSG viewer in an existing application and have 
gotten the viewer to display a model correctly. I now wanted to implement some 
picking, and I have been using the osgkeyboardmouse example for this.
My problem is that whenever I click on something the deconstructor for 
intersection causes a Heap pointer out of local error when intersection 
goes out of scope.

The code snippet is the following (from osgkeyboardmouse):
---

osgUtil::IntersectionVisitor iv(picker);

viewer-getCamera()-accept(iv);

if (picker-containsIntersections())

{

osgUtil::LineSegmentIntersector::Intersection intersection = 
picker-getFirstIntersection();

osg::notify(osg::NOTICE)Picked 
intersection.localIntersectionPointstd::endl;

osg::NodePath nodePath = intersection.nodePath;

node = (nodePath.size()=1)?nodePath[nodePath.size()-1]:0;

parent = 
(nodePath.size()=2)?dynamic_castosg::Group*(nodePath[nodePath.size()-2]):0;

if (node) std::cout Hits node-className() nodePath 
sizenodePath.size()std::endl;

toggleScribe(parent, node);

}

-
I have tried integrating the osgkeyboardmouse in the osgviewermfc example, and 
there it works fine, so I'm mostly suspecting that the problem lies with my 
existing application, but if anyone have tried anything similar I would like to 
hear any ideas you might have.

Regards,

Jesper D. Thomsen
mailto:[EMAIL PROTECTED]
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Intersection

2008-08-28 Thread Jean-Sébastien Guay

Hello weihe,


i just want to know hoe did you do
 this:I think I may be able to help a bit regarding the higher-level setup
and bookkeeping changes needed to speed things up on that regard,can you
explain it in detail,thanks very much!


I was referring to *future* benchmarking, profiling and optimization. I 
have not started on this yet.


And did you compared Robert's kdtree 
and Adrian's?If you know how did Adrian's data(below) get,please tell me 
too!


Not yet. I was using intersections heavily in my Masters project, but 
now that it's over, I have to work at my paid job (which does not use 
intersection testing that much) and hopefully I'll get some free time to 
work on this in the near future.


Sorry I can't help more. Also, in the future, please write to the 
osg-users mailing list for subjects like this, since others might be 
able to help too.


J-S
--
__
Jean-Sebastien Guay[EMAIL PROTECTED]
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Intersection using C#

2008-01-10 Thread Ke Li
Hi all,
 
I'm using C# to implement picking in OSG for my project.
 
I created a OsgUtil.PolytopeIntersector object (picker) in my pick method and 
registered it to a OsgUtil.IntersectionVisitor. The picker seems to work when I 
called OsgUtil.PolytopeIntersector.Intersection intersection = 
picker.getFirstIntersection(). But I'm stuck here, because I couldn't see any 
methods that obtain the picked nodes from the intersection object.
 
In C++, it is simple to do so:
osgUtil::LineSegmentIntersector::Intersection intersection = 
picker-getFirstIntersection();
osg::NodePath nodePath = intersection.nodePath;
osg::Node* node = (nodePath.size()=1)?nodePath[nodePath.size()-1]:0;
osg::Group* parent = 
(nodePath.size()=2)?dynamic_castosg::Group*(nodePath[nodePath.size()-2]):0;
 
 
If anyone knows how to obtain picked nodes using C#, please give me some 
advice. Your help is highly appreciated!
 
 
Regards,
 
 
Ke Li
_
Make distant family not so distant with Windows Vista® + Windows Live™.
http://www.microsoft.com/windows/digitallife/keepintouch.mspx?ocid=TXT_TAGLM_CPC_VideoChat_distantfamily_012008___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Intersection with osgUtil::PolytopeIntersector

2007-10-29 Thread Peter Hrenka
Daniel Moos wrote:
 Hi everybody

Hi Daniel,

 I have a question about intersection. I try to intersect lines with the 
 osgUtil::PolytopeIntersector class. This works fine.
 Now how can i get the picked line from the picked geometry? I want to have 
 the 
 two vertices from the picked line...

I do have a version that has an enhanced Intersection structure.
I'll try to submit that version today.

 Thanks a lot!
 Daniel

Peter


 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 


-- 
creating IT solutions
Peter Hrenkascience + computing ag
Software Solutions  Hagellocher Weg 73
phone +49 7071 9457 263 72070 Tuebingen, Germany
fax   +49 7071 9457 511
[EMAIL PROTECTED]   www.science-computing.de
-- 
Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Florian Geyer,
Dr. Roland Niemeier, Dr. Arno Steitz, Dr. Ingrid Zech
Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Prof. Dr. Hanns Ruder
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196 

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Intersection with osgUtil::PolytopeIntersector

2007-10-28 Thread Daniel Moos
Hi everybody

I have a question about intersection. I try to intersect lines with the 
osgUtil::PolytopeIntersector class. This works fine.
Now how can i get the picked line from the picked geometry? I want to have the 
two vertices from the picked line...

Thanks a lot!
Daniel


My Code for intersection;

osg::NodePath nodePath = intersection.nodePath;
node = nodePath.back();

if ( node.valid() ) {
std::coutHits ;
std::cout  node-className();
std::cout   - NodePath size: ;
std::cout  nodePath.size();
std::cout  std::endl;

osg::ref_ptrosg::Geode pickedGeode =

dynamic_castosg::Geode *(node.get());
osg::ref_ptrosg::Drawable pickedDrawable =

pickedGeode-getDrawable(0);
osg::ref_ptrosg::Geometry pickedGeometry =

dynamic_castosg::Geometry* (pickedDrawable.get());
osg::ref_ptrosg::Vec3Array pickedVertexArray =

dynamic_castosg::Vec3Array* (pickedGeometry-getVertexArray());

std::cout - Num of Triangles: ;
std::cout  
pickedGeometry-getPrimitiveSet(0)-getNumPrimitives();
std::cout  std::endl;

std::cout - Used Vertices: ;
std::cout  
pickedGeometry-getPrimitiveSet(0)-getNumIndices();
std::cout  std::endl;

std::cout - Number of Vertices from the Geometry: ;
std::cout  pickedVertexArray-getNumElements();
std::cout  std::endl;
}
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org