Archived

This topic is now archived and is closed to further replies.

Heightdefining

This topic is 5933 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I''m constructing a RPG in sort of a Tomb Raider type 3d engine. My question is if i have a square with 4 corners that differ in height and the X-Z coordinates (in a 0-1scale) where the player currently is the square. How do I in the fastest possible way calculate the Y coordinate based on where the player is in relation to the objects edges. EX: y0 y1 ______________ | | | | | | | | | x | |______________| y2 y3 x=playerpos Regards Fredrik

Share this post


Link to post
Share on other sites
Well, sorry I didn´t really read your post well. I don't know if this is the fastest way to do it:

(y0 * px * pz + y1 * (1-px) * pz + y2 * px * (1-pz) + y3 * (1-px) * (1-pz)) / 4

Where px and pz are the player coordinates.

Nick


Edited by - nickm on October 18, 2001 3:04:48 PM

Edited by - nickm on October 18, 2001 3:05:18 PM

Share this post


Link to post
Share on other sites
You shouldn''t divide by 4. If n=y0=y1=y2=y3 then y(x,z) = nxz + nx(1-z) + n(1-x)z + n(1-x)(1-z) = nxz + nx - nxz + nz - nxz + n -nz - nx + nxz = n not n/4. The center would be (y0+y1+y2+y3)/4.

Share this post


Link to post
Share on other sites
Yeah you''re absolutely right... You know, I was really tired (almost sleeping) when I posted that message

Share this post


Link to post
Share on other sites