|
Author Topic:   Getting A height from a point...
DjAttitude
Member
posted December 04, 2000 04:07 PM            
I've been working on an Landscape engine, (very much like Treadmarks engine). but the only thing that is bugging me is that. I need some generic algorithm or code so I can retreive the height of a giving point within a 4 sides area. eg

P1 P2
*--------------*
| |
| |
| Ix,Iy |
| . |
| |
*--------------*
P3 P4


P(n) contain the height for that corner.
Ix,Iy is the require point.

Is this possible or do I need super Advance maths here ?

IP:

Dreamer
Member
posted December 04, 2000 05:44 PM         
Let's have a look at this...
As a matter of fact, 4 points won't usually fit into the same plane. 3 do, but, well, 4 only under very specific circumstances.
This means that using flat polygons, you will have to subdivide your quad into triangles, giving us at least 4 possible height values for your point. (1 for each possible triangle config).
To determine the exact height of that point, "shoot a ray" from one corner of the triangle the point is contained in, passing through the point's coordinates (we're still in the x-y-plane) in order to determine where the "ray" hits the opposite side of the triangle. The height value of that point can be interpolated between the adjacent corners of the triangle and then all there's left to do is to interpolate between that height and that of the original corner, right back to the point we're looking at.
That gives us about 5 linear equations, all in 2 dimensions (if you try hard, might be easier in 3 for the last one, but you can it leave out for the sake of speed); should be a pretty short bit in assembler, given the fact that you reuse lots of code in all equations. Should be, anyway.

IP:

Dreamer
Member
posted December 08, 2000 10:56 AM         
did this help?

IP:

DjAttitude
Member
posted December 08, 2000 02:36 PM            
It did help, but firing a ray is a little slow for the engine Im developing. But it is a start. thanx Dreamer.

Im developing a free-roaming Racing-Rally game out of this, so the function is going to be called around 1000 times for the civilian AI cars, racers cars and you. But Its one way of doing it.

thanx!

IP:

Dreamer
Member
posted December 08, 2000 02:48 PM         
Well, the speed of any algorithm depends on the mathematical methods used...

IP: