Heightdefining
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
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
(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
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.
Keys to success: Ability, ambition and opportunity.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement