Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calculating height INSIDE 3d triangles
#1
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
It's the difference between asking someone how much flour goes into pancakes, and handing them a sorry mix of oozing green goo and asking them to fix it." - Deleter

-Founder & President of the No More Religion Threads movement-
Reply
#2
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
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#3
Hmm... :-?

ax + by + cz = d

What does that mean?

Thanks for your help Smile.
It's the difference between asking someone how much flour goes into pancakes, and handing them a sorry mix of oozing green goo and asking them to fix it." - Deleter

-Founder & President of the No More Religion Threads movement-
Reply
#4
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.
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#5
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)
It's the difference between asking someone how much flour goes into pancakes, and handing them a sorry mix of oozing green goo and asking them to fix it." - Deleter

-Founder & President of the No More Religion Threads movement-
Reply
#6
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.
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#7
Yes but wouldnt the collision detection have to calculate the height of the plane to be able to tell if its colliding or not? :-?
It's the difference between asking someone how much flour goes into pancakes, and handing them a sorry mix of oozing green goo and asking them to fix it." - Deleter

-Founder & President of the No More Religion Threads movement-
Reply
#8
I hope this can help.
http://nehe.gamedev.net/data/articles/ar...article=10

Joshy
sorry about my english
Reply
#9
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? :-?
It's the difference between asking someone how much flour goes into pancakes, and handing them a sorry mix of oozing green goo and asking them to fix it." - Deleter

-Founder & President of the No More Religion Threads movement-
Reply
#10
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. :*)
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)