Advertisement

ok, got another good question.....

Started by February 11, 2003 05:28 PM
28 comments, last by jverkoey 22 years ago
Now, hopefully someone here''s an expert at how OpenGL works.... I am drawing these squares again, and what I want to be able to do is this: have a triangle strip that draws out a square, like below:
  
________
|\    /|
| \  / |
|  \/  |
|  /\  |
| /  \ |
|/    \|
--------
  
that''s not source, lol as you can see, it would compose of 4 triangles, ok? now, I have the height of each POINT of the square, but how do I find the middle point''s height based off of those four? for example, say the top left was 10, top right was 10, bottom right was 2, bottom left was 1, now, what I need to know is how, by knowing the 4 points, how to find the point in the exact CENTER... I was thinking of taking the resulting y value (y=mx+b) from the left line plus the y value from the right line, and then dividing the two together to get the average, but that doesn''t work......any other way I can do this?
have you tried to divide the width by 2 and the height by 2 to get the middle point?
Advertisement
He is correct if you have a height of 10 on one point and 2 of the other has 3 you find the center and the mid height the same way. midHeight = (Height1+Height2+height3)/3 obvious because this would

return 10+2+3/3 = 5 and that would be the mid points height.

You divide by 3 because that is how many points are in equation. This is also very simular to that of a grade point avg.

Note that if you would need to determine adjacent triangles to adjust for the floating point errors. if you get heights that are not very very close to each other you will get artifacts from it. where you will be able to see through the terrain.

[edited by - afterburn on February 11, 2003 9:47:34 PM]
--What are you nutz?I have nothing to say to your unevolved little brain. The more I say gives you more weapons to ask stupid questions.
ok, well, I guess now that I think of it, there''s probably a way to work with this.......sooo now the big question

how do I find the height of the tile no matter WHERE I''m standing? (on the tile)

bloodright.150m.com //For the latest on all of the IVGDA projects!
depends if you want an interpolation between the 4 corners of the exact height on the perticular triangle...

| - Project-X - my mega project.. yup, still cracking along - | - adDeath - an ad blocker I made - | - email me - |
so, how could i use interpolation if i have this data:

            Y          X Z[0] [0]= 15.5   also 0,0 on the tile[0] [1]= 2.0    also 88,0 on the tile[1] [1]= 0.0    also 88,88 on the tile[1] [0]= 1.0    also 0,88 on the tile               Y          X  Zmiddlepoint= 3.875   also 44,44 on the tile                        X  Zand the character is at 20,15  

how can I find the resulting y value for the character's position?

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

[edited by - jverkoey on February 11, 2003 11:40:20 PM]
Advertisement
The really brute force way is to take the 4 points,
get your point in the middle, then form a plane equation with each set of 3, then use that to find your character position point.

-V''lion

Bugle4d
~V'lionBugle4d
so, how would i make a plane equation?
Plane Equation:

Ax + By + Cz = D <- straight from algebra and geometry

the vector A,B,C is the plane''s normal and to find D just sub in your middle point to x,y,z and solve for D.
soo, do you think you could substitute what I typed in below for that equation? just so I know how it works (i'm kinda a visual sorta guy)


                Y          X Z[0] [0]= 15.5   also 0,0 on the tile[0] [1]= 2.0    also 88,0 on the tile[1] [1]= 0.0    also 88,88 on the tile[1] [0]= 1.0    also 0,88 on the tile               Y          X  Zmiddlepoint= 3.875   also 44,44 on the tile                        X  Zand the character is at 20,15      


[edited by - jverkoey on February 11, 2003 12:28:53 AM]

This topic is closed to new replies.

Advertisement