From: Allan Schaffer (allan++at++sgi.com)
Date: 06/29/2004 17:59:07
Hello Mr. Rajesh,
I'm not 100% sure about what you've already implemented, so this may be
redundant. The intersection result of a long straight-down line segment
should be all that's necessary here.
If there is an intersection result the PFQHIT_POINT and PFQHIT_XFORM results
will give you the intersection point (and you can check that your channel
eyepoint is always at least some amount above this point in Z); this alone
should generally prevent the eye from going below the terrain. And if there
is no intersection then the eyepoint has in fact gone under the terrain and
can be moved back above.
You'll want a very long segment (more than your elevation will ever be) so
that there is always a result.
The intersect.c example is a good starting point for this. Also, Chapter 4
of the programming guide has information about intersection detection.
To directly answer your question, there isn't a reasonable (real-time) way to
just query the "closest" triangle or point on a triangle to a given point in
world coordinates. You'd have to calculate intersections for too many line
segments for this to be really practical. It seems just one straight-down
segment could do the trick instead. Or to be more fancy, one straight down
and one pointing along the craft's heading..
Good luck,
Allan
(Back from vacation)
Mr. Rajesh R wrote:
> I am developing a small Flight simulator. It consists of a Terrain.While
> flying over the terrain, I want to make sure that I always fly
> above the ground. If I get the closest point, I can fly little above that
> point.Intersection checking has alreay been done and got HAT. Now When I
> fly low, It is touching the terrain.I don't want that to happen
>
-- Allan Schaffer allan++at++sgi.com Engr. Dept. Manager, Visual Systems Group 1-650-933-2160 Silicon Graphics http://www.sgi.com
This archive was generated by hypermail 2b29 : Tue Jun 29 2004 - 17:59:29 PDT