For over 2 years im learning directX in VB.

Now im able to create a small game that loads a terrain, skybox, objects, full camera movements, fog, light effects, particle engine, console with scripting engine.

The next step in the development process is something i dont know how to do, after days of research and testing, only a bad result came out. The colision detection code.

To know the height of the camera and object, i need to know the hieght point of the exact x, y location im at.

It all starts with a square. Lets say our square is 100 * 100 and starts at 0 * 0

All 4 corners of the square have and different heightpoint (Z).
This means the height somewhere inside the 100 * 100 square is dynamic and has to be calculated.

Now the real question.
If all 4 corners are at a different height, then what is the height point inside that square at 30 * 70 (x=30, y=70)

The following points of the square are:
Code:
P(0).X = 0
P(0).Y = 0
P(0).Z = 3
P(1).X = 100
P(1).Y = 0
P(1).Z = 5
P(2).X = 0
P(2).Y = 100
P(2).Z = -8
P(3).X = 100
P(3).Y = 100
P(3).Z = 7

Player.X = 30
Player.Y = 70
Player.Z = ???
I managed to work something out that works on squares with corners of 90degrees. I calculates with triangles.

Using the P(0).X -> P(1).X line as length
Using the diffence of height of P(0).Z and P(1).Z as the height of the traingle
Using the Player.X as the position.

Using (Height * Position) / Length gives the exact point of height at Player.X with player.Y = 0

The same can be done on the bottom of the square to calculate the height point on the other side of the square.

Doing the same with the two calculated height point and using Y as position this time, should give the exact heightpoint of the players location.

I tried this code and it seems to look good. Only sometimes i end up bollow the terrain. But maybe thats just a little error in my script, cant find it at the first moment. Also if this code do the trick, it will only work on squares or rectangles with corners of 90 degrees.
I will review this code later this week and come back with the result of it. If the bug is fixed i will add the code to this topic (dont have it with me now, cause im at work) There is a little extra code next to the triangle calculation. to create a triable, you first need to find out what are the highest coordinates to calculate the L, H, P values. We want to work only with positive numbers (or is this my bug)

Once this code work i need to be able to upgrade the code for square with dynamic corners (so not allways 90 degrees)

==========

If you know any other way to get the collision detection, pls let me know.
You can reply here, contact my by ICQ (59781659), MSN ([email protected]) or Mail ([email protected])

Greets Nightmare

p.s. If you think you can help us with the game on any other way, do not wait to contact us.