Posts: 193
Threads: 20
Joined: Jun 2005
I have a terrain, and I want the player to walk smoothly across the terrain, smoothly following the terrain elevations...
But I can't figure out how to actually calculate a point thats inside a triangle with 3 (x, y, z) vertices...
Say, I want to find the height in the middle of the triangle, how would I do this?
Thanks in advance.
Posts: 3,288
Threads: 167
Joined: Nov 2001
My advise don't. Try to make a code one, use anywhere collision detection system an use that instead. (I have a sample demo at AAP's site.)
But if you really want to do it that way, you could do interpolation( fast but is not as elegant) or you could use this:
ax + by + cz = d
Posts: 193
Threads: 20
Joined: Jun 2005
Hmm... :-?
ax + by + cz = d
What does that mean?
Thanks for your help
.
Posts: 3,288
Threads: 167
Joined: Nov 2001
Ooops! ax + by + cz + d = 0.
It's the plane equation. A, B and C are constants(Usually your plane normal) And assuming you know X and Z, Y should be easy to figure out.
Posts: 193
Threads: 20
Joined: Jun 2005
Ok, hmm...Im confused though.
I really dont understand it.
Could you make a quick example with this? plz
.
Thanks for your help. 8)
Posts: 3,288
Threads: 167
Joined: Nov 2001
I wouldn't it's cumbersome. What would be better is a general collision detection system you could adapt to all of your 3d projects like the one I used in that collision demo. Just plug the code and add gravity. Your object would "walk" the terrain.
Posts: 193
Threads: 20
Joined: Jun 2005
Yes but wouldnt the collision detection have to calculate the height of the plane to be able to tell if its colliding or not? :-?
Posts: 140
Threads: 13
Joined: Apr 2005
Posts: 193
Threads: 20
Joined: Jun 2005
Thanks, d.j.peters and relsoft for your help.
But doesnt a collision detection system have to calculate the height of a triangle to be able to tell if it collides? :-?
Posts: 3,288
Threads: 167
Joined: Nov 2001
Quote:I hope this can help.
http://nehe.gamedev.net/data/articles/ar...article=10
Joshy
Dj that would work (Geometry "sum of exterior angles of any poly = 360) but that is arse slow. What I and doc_dav use does not use any trig funk, but uses the only the dot product, very fast and effecient. It's in blackpawn's page.
Blue, nope, what we do is calculate intersections of planes and spheres. :*)