Qbasicnews.com

Full Version: Calculating height INSIDE 3d triangles
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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. Big Grin
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
Hmm... :-?

ax + by + cz = d

What does that mean?

Thanks for your help Smile.
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.
Ok, hmm...Im confused though.
I really dont understand it.

Could you make a quick example with this? plz Smile .

Thanks for your help. 8)
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.
Yes but wouldnt the collision detection have to calculate the height of the plane to be able to tell if its colliding or not? :-?
Thanks, d.j.peters and relsoft for your help. Smile
But doesnt a collision detection system have to calculate the height of a triangle to be able to tell if it collides? :-?
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. :*)
Pages: 1 2