I'm cheating quite a lot because in my application I don't need much crossrange capability, so one big thing I do is take my earth centered terrain and positionAttitudeTransform it so that the place on the planet where I want to be is at 0,0,0 in the root coordinates and straight up is aligned with the negative y-axis- and the way I got it to be correct is because I already knew the elevation of my origin and also trial and error. That's an ugly and inflexible approach but it seems to avoid some precision problems.
Originally I didn't have a lot of entities (just a few structures scattered around within a few miles of the origin), so I was placing them more or less by trial and error to make sure they aren't floating or buried underground. But now I'd like to place bush and tree billboards randomly all over the place in the thousands, so the manual method doesn't work. I also want to add vehicles that will have to be moving and still firmly on the ground. Yesterday I tried to implement the double intersect visitor, and it seemed a little more involved than just replacing float with doubles and vec3 with vec3d because it was doing pointer arithmetic in one part- can you upload your version of a double intersect visitor? For the mean time even though the intersection point is imprecise, the imprecision seems a consistent enough I can offset the results by 12 (12 meters in my case) and have the bushes etc. more or less appear from a distance to be planted in the ground. Does that answer your question or were you asking something else? -lucasw On 6/9/06, David Lascombe <[EMAIL PROTECTED]> wrote:
Hi, I think I am close to find the solution. I am in the very same case as Lucas as my terrain db is generated with osgdem. However I just found that the Drive Manipulator is capable of putting the camera precisely on the ground! And if it can do that, then I should be able to use the same technique (wether it uses an intersect visitor or not...). I just figured that out and I wanted to let you know. Now I'm going to explore the code of the Drive Manipulator and find out how it manages to do that. One little question for Lucas : I know you generate your terrain with osgdem, but how do you manage to put entities on the same frame? I mean, are you using OSG to compute new coordinates, an external toolkit, or even your own functions ? David >This question may be a little remedial, but how is the first solution >implemented? > >In my case I load an osgdem generated terrain database with >osgDB::readNodeFile, I get a Node back: how do I get all its children >tiles below any earth center transform and run the intersectVisitor on >them? > >An osgforest2 example would be great to have in a future release- put >a small section of the osgdem generated earth-centered terrain in the >osg data set, and populate with trees like the osgforest example but >also demonstrate how to traverse the osgdem generated tiles and get >precise intersections. (I'll submit something myself if I get it >working) > >Thanks, > >lucasw >> >>Hi David, >> >>The problem is most likely that the IntersectVisitor is implemented >>using floats. >> >>The two solutions are: >> >> 1) Do the intersect in local coordinates of the terrain, i.e. below >>the tiles matrix transform, >> and then transform the local intersection into global coords >> >> 2) Implement a double intersect visitor. >> >>Robert.
_______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
