Hi! I wonder how can i check collisions with non-simple objects. Being more precisly - i have 3d terrain map and i want to check if i am going through the ground or not. Any ways I could do it?
Thanks!!!
Hi! I wonder how can i check collisions with non-simple objects. Being more precisly - i have 3d terrain map and i want to check if i am going through the ground or not. Any ways I could do it?
Thanks!!!
Hi,
If it’s a heightmap, all you have to do is to check whether you’re above the ground. Something like
if myHeight < heightmap[myX, myZ] then damnIHitTheGround();
In general, collision detection isn’t opengl related, so you might more information on some game developement sites.
-Ilkka
Thanks. Indeed it is a way to that but it won’t be any precise method I think. Collisions would look like that :
X------------
| |
X------- X--------
|
|
X-------------
I mean that terrain isn’t usually flat. Meaby i am thinking in a wrong way. Whatever…
Although thanks. Meaby I should check some game development site.
linearly interpolate the ground height based upon the surrounding height map data
heightmap data ( 0 or 1):
0 0 0
0 1 0
A X B
0 0 0
if you are at position (0.5,2.5) as shown by X find the height of the ground under X
sub new X value into z = f(x) to find new Z value
im not sure if you need to repeat the process for the z=f(y) and average them. ive got a hunch that they will be the same in all cases. im not going to figure it out.
standard disclaimers for stupidity apply
I’ll check it out! Thanks