Actually the problem is that I don't have any transform node. I give my
tank's Lattitude Longitude Altitude coordinates (like 43.5°N 5.2°E 0.0m) and
I use a toolkit to convert these coordinates to earth centered ones. Then I
can directly create the scene with my earth centered tile and my tank being
in the same frame.
The code to compute intersection looks like this :
osg::LineSegment* tankLocationSeg=new osg::LineSegment();
osg::Vec3d coords(tank->getCoords());
tankLocationSeg->set(coords,osg::Vec3d(0.0,0.0,0.0)); // segment between
tank's position and Earth's center
osgUtil::IntersectVisitor findTankElevationVisitor;
findTankElevationVisitor.addLineSegment(tankLocationSeg);
terrainNode->accept(findTankElevationVisitor);
osgUtil::IntersectVisitor::HitList tankElevationLocatorHits;
tankElevationLocatorHits=findTankElevationVisitor.getHitList(tankLocationSeg);
osgUtil::Hit heightTestResults;
osg::Vec3d ground(tankElevationLocatorHits.front().getWorldInterectPoint());
tank->setPosition(ground);
I get a flying or underground tank depending on where on the map it is. And
this is a real problem...
Is there another way of getting the good intersection point?
Tanks again,
david
Well, the idea is that you have surface tiles below a transform node, where
the transform node is just a translation from the earth centered coordinate
frame to a tile centered coordinate frame. That transformation should be
done with doubles.
In this case you need to transform your intersection start point to that
tile centered coordinate frame (still in double values).
If you have reasonable tile sizes, you should be near enough to continue
with floats. At this point you can take the intersect visitor and use its
hit values.
Greetings
Mathias
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/