Advertisement

ok, got another good question.....

Started by February 11, 2003 05:28 PM
28 comments, last by jverkoey 22 years ago
Forget the plane, the easiest way to do this is to average the coordinates of the points. So say we had a square with coordinages:

pt1: a,b,c
pt2: e,f,g
pt3: h,i,j
pt4: k,l,m

then the center would be:

x = (a+e+h+k)/4
y = (b+f+i+l)/4
z = (c+g+j+m)/4

Its that simple
ARG, but the thing is, I WANT to find the current position of the character on the tile....lmao....cuz I need to create the illusion that you are walking on the tiles, and not through them.

imagine a big, huge flat plain, then imagine a hill in the middle, what happens when you walk up to that hill? you go UP the hill, you don''t go through it....lol

that''s what''s happening in my game, except I''m going through the hills, and I need to find out how much to add to the y value of the character to make him ON the hill....

PLEASE DON''T SAY ANYTHING ELSE ABOUT FINDING THE MIDPOINT, LMAO, I KNOW WHAT IT IS!
Advertisement
You could find the angle of the tile... and then maybe use the angle and the distance from the vertice of the tile to find the height of that particular position... and then you could just add that amount... or set it equal to that amount...
oooooooooook......lol, explain what you mean, with some numbers, What I need is someone who actually KNOWS how to do this, and isn''t just throwing out hypothesis...lol, I''m looking for numbers, an equation, I''ve given you the numbers to put in, now I need an equation to find the answer........

bloodright.150m.com //For the latest on all of the IVGDA projects!
Sorry, had to go to dinner, I''ll try to form it into equations now.
Hmm... that would work if the tile was just a line or if the two adjacent points where at the same height and the two other ones were at another height... but i don''t think it would work in this case where each point is at a different height...

I''ll keep trying to figure this out...
Advertisement
Ok i've researched planes a little more... Here's a good site...
http://astronomy.swin.edu.au/~pbourke/geometry/planeeq/

Ax + By + Cz + D = 0

A = y1 (z2 - z3) + y2 (z3 - z1) + y3 (z1 - z2)
B = z1 (x2 - x3) + z2 (x3 - x1) + z3 (x1 - x2)
C = x1 (y2 - y3) + x2 (y3 - y1) + x3 (y1 - y2)
- D = x1 (y2 z3 - y3 z2) + x2 (y3 z1 - y1 z3) + x3 (y1 z2 - y2 z1)

/* (this is wrong, see edit) So I think you could just choose 3 of the points (it doesn't matter which 3, you only need 3 points to define a plane) and */ then that would make your equation for the plane, and then you would solve for y i believe....

y = (-D - Ax - Cz)/B

:: Plugs in numbers, fourth point doesn't equate properly... ::
... grr... more thinking needs to be done... Your tile isn't a plane, it's just a bunch of numbers ;.;

...

I think it might work if you find the plane equation for each triangle on your square and then depending upon which triangle your character lays in that will be the equation used to find the height.
(for speedyness I'd recommend finding which triangle the character is in first, and then just do that one...)

Which is essentially what Vlion said...


I hope this helps...

EDIT: It does matter which 3 you choose since not all four points lie in the same plane. You need to use the middle point and two of the square's vertices (depending upon where the character is), Just to clarify.

[edited by - Sky on February 12, 2003 8:11:25 PM]

[edited by - Sky on February 12, 2003 8:18:36 PM]
lol, thanks for trying at least, hehe, I'll try and see if I can use that

bloodright.150m.com //For the latest on all of the IVGDA projects!

-POST SKY'S EDIT-

ahhh, that makes a lot more sense

[edited by - jverkoey on February 12, 2003 8:12:20 PM]
Gah, stupid gamedev forums... deleting my posts....


Sorry for being unclear, I was figuring it out as I went, so ya...


To find which triangle you''re in you just see if the character''s x and z coordinates are less than or greater then the midpoints x and z.

If they are BOTH equal then the height is equal to the midpoint''s height, which is the average of the corner''s of the square''s height.
THANK YOU VERY VERY VERY VERY VERY VERY VERY VERY VERY VERYVERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY MUCH!!!!

YOU CAN''T UNDERSTAND HOW GREATFUL I AM!!!!

IT WORKS!!!! YAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

lmao, if you can''t tell, I''m REALLLY happy!!!

I am definitely including you in the credits sky, just tell me what you want me to include as your name and all that, and I''ll put it in!!!

THANK YOU SOOOO MUCH!!!

(i tested it on my calculator first, by making a program that takes 3 points, (x,y,z), then outputs the values of A, B, C, and -D, then it prompts for an x and z value, and puts out the resultin y value, EXACTLY perfect!!!!)

THANK YOU!!!!!!!!!

bloodright.150m.com //For the latest on all of the IVGDA projects!

This topic is closed to new replies.

Advertisement