Qbasicnews.com
Calculating height INSIDE 3d triangles - Printable Version

+- Qbasicnews.com (http://qbasicnews.com/newforum)
+-- Forum: Qbasic "like" compilers/interpreters (http://qbasicnews.com/newforum/forum-5.html)
+--- Forum: FB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-15.html)
+--- Thread: Calculating height INSIDE 3d triangles (/thread-8104.html)

Pages: 1 2


Calculating height INSIDE 3d triangles - TheBlueKeyboard - 09-17-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. Big Grin


Calculating height INSIDE 3d triangles - relsoft - 09-19-2005

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


Calculating height INSIDE 3d triangles - TheBlueKeyboard - 09-19-2005

Hmm... :-?

ax + by + cz = d

What does that mean?

Thanks for your help Smile.


Calculating height INSIDE 3d triangles - relsoft - 09-21-2005

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.


Calculating height INSIDE 3d triangles - TheBlueKeyboard - 09-21-2005

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)


Calculating height INSIDE 3d triangles - relsoft - 09-22-2005

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.


Calculating height INSIDE 3d triangles - TheBlueKeyboard - 09-25-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? :-?


Calculating height INSIDE 3d triangles - d.j.peters - 09-25-2005

I hope this can help.
http://nehe.gamedev.net/data/articles/article.asp?article=10

Joshy


Calculating height INSIDE 3d triangles - TheBlueKeyboard - 09-25-2005

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? :-?


Calculating height INSIDE 3d triangles - relsoft - 09-27-2005

Quote:I hope this can help.
http://nehe.gamedev.net/data/articles/article.asp?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. :*)