PDA

View Full Version : Quad with multiple vertices



Xero_Tolerance
04-25-2002, 02:02 PM
Ok, so when you make a quad it has four vertices right, top left, top right, bottom left, bottom right, to make the polygon. Well, I'm making a terrain editing program, like what's used in Empire Earth, so it's all flat and u can raise it and stuff. What I did was just have a file that reads in these vertices and makes the map right, so i have four vertices for each square, which also causes a lot of redundancy, because i have the points like...
. .
. .
for one square, then the next one has to be right next to it, so it has to share the vertex point value, but i just want it to share the entire vertex to save points, ya know, so instead of....
. .. .
. .. .
(the ones side by side would be the same value) I want...
. . .
. . .
basically just one quad with many vertices, so if I raise one i don't have to raise the matching one of the other block. If that's not possible, what would be the most efficient way of doing this? Cuase I did it alright, but I know it's not very effective the way I did it. Thanks all.

Osku
04-25-2002, 07:16 PM
Hello

Take a look at QUAD_STRIP, it might be what you are looking for.

Osku

Zeno
04-25-2002, 07:39 PM
And if you can use QUAD_STRIP, you can use TRIANGLE_STRIP and it might be slightly faster.

-- Zeno

Zuraffo
04-25-2002, 09:40 PM
I think you are confusing database management with actual rendering. It is perfectly alright to have only one copy of the vertex and render it twice. Although the rendering might be less efficient, but you won't need to duplicate any change to the database.

exp:

float a[][] = {
{0.0, 5.0, -5.0 },
{1.0, 3.0, 2.0 },
{4.0, -2.0, 1.0 },
{3.0, 1.0, 1.0 }
}

// As you can see, there is only 4 vertices. but you can render it as such:

glBegin( GL_TRIANGLES )
glVertex3fv( a[0]);
glVertex3fv( a[1]);
glVertex3fv( a[2]);

glVertex3fv( a[1]);
glVertex3fv( a[2]);
glVertex3fv( a[3]);
glEnd();

So if you update let's say a[2], both triangles will be updated.

Zu
p.s. in the above case it's better to use TRIANGLE_STRIP, but if you have a large db with discontinous surfaces, you might want to fall back on GL_TRIANGLES,

Deiussum
04-26-2002, 06:14 AM
One problem you may run into by using quads will the possibility of having your vertices non-planar, which could have unknown results.

Example... you lift 1 vertex of a square, the other vertices stay in place... in effect, you've "bent" the quad so that it is no longer planar.

If you use triangles instead, you will always know your vertices are planar.

tarantula
04-27-2002, 09:53 PM
Yeah I'd also suggest you work with triangles.If you use Quads like Deissum said you have to restrict the quads to being planar which wont give you a good looking terrain.

so you could use the same arrangement and let your quads be non planar and render them as triangles.

billy
04-30-2002, 06:52 AM
Create a list of vertices and then create a list of triangles that contain these vertices. Like this:

Points:
1 - 0,0,0
2 - 50,0,0
3 - 0,50,0
4 - 50,50,0
5 - 50,50,50
6 - etc.

Triangles:
1 - 1,2,3
2 - 2,3,6
3 - 3,6,5
4 - etc.

Notice that the triangles share the same vertices, so when you change the coordinates of a specific point, all triangles connected will adjust.