vertices.....
people tell me one thing!
i am new to opengl and i noticed something strange, suppose i have a 3d shape where 4 triangles meet at one corner(vertice), when i rotate this i must do triangle by triangle wchich obviously means i rotate this vertex 4 times (a waste).
really there is no method for rotating vertexlist and normal list
and then do projections?
eeh of course i can write own routines for matrixes and stuff and keep & process list myself then just make declare all again with begin/end seuences, but this looks like insane as well..
can anyone tell me how should it be done?
thanx in advance
pgm
p.greg marczyk
p.greg marczyk
if you only rotate/move/scale model (NO morphing) you can just use somethink like that:
glPushMatrix()
glTranslate()
glRotate()
glScale()
DrawModel()
glPopMatrix()
the other way is something like this.
have a list of vertices&normals and rotate them every frame and then have a static indices array.
eg:
float vertic[5][3];
int indice[9] = { 0, 1, 2, 1, 2, 3, 2, 3, 4 }
so you have 3 triangles :
0, 1, 2
1, 2, 3
2, 3, 4
.. you only have to transform vertices once per frame...
There are more worlds than the one that you hold in your hand...
glPushMatrix()
glTranslate()
glRotate()
glScale()
DrawModel()
glPopMatrix()
the other way is something like this.
have a list of vertices&normals and rotate them every frame and then have a static indices array.
eg:
float vertic[5][3];
int indice[9] = { 0, 1, 2, 1, 2, 3, 2, 3, 4 }
so you have 3 triangles :
0, 1, 2
1, 2, 3
2, 3, 4
.. you only have to transform vertices once per frame...
There are more worlds than the one that you hold in your hand...
You should never let your fears become the boundaries of your dreams.
if you''re using vertex arrays or drawing the triangles 1 by 1, there is no other way than to draw that vertex 4 times. if you''re using lists ogl does this for you. the only difference is that you''ll get a static shape whose vertexes you can''t manipulate, but the prebuilt shape (a number of polys really) are copied from memory which is alot faster than building them anew each cycle. bottom line - if you figure out how to draw a 3d shape (a pyramid in this case) using only 1 poly (which normally means that none of its vertexes converge), please let me know 
as to rotating a vertex list - i don''t see your point. what difference does it make if you''re rotating each vertex 1 by 1 or mathematically rotating an entire array and then drawing them? you''d have to rotate a triangle''s vertexes 4 times no matter how you''re doing it and even if you do have a prebuilt list of vertex coordinates, building them would have taken the same amount of time that is spent on rotating the triangle vertexes. or, then again, maybe i''m missing your point... in any case you''d get a static set of vertexes, right?
crispy

as to rotating a vertex list - i don''t see your point. what difference does it make if you''re rotating each vertex 1 by 1 or mathematically rotating an entire array and then drawing them? you''d have to rotate a triangle''s vertexes 4 times no matter how you''re doing it and even if you do have a prebuilt list of vertex coordinates, building them would have taken the same amount of time that is spent on rotating the triangle vertexes. or, then again, maybe i''m missing your point... in any case you''d get a static set of vertexes, right?
crispy
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
pgm:
Indexed vertex arrays do exactly what you are looking for. You have a shared vertex list and an index list for each triangle. Now depending on your 3D card, a single vertex is only transformed *once*, even if it is referenced by multiple triangles. Eg. GeForces will do that automatically for you on a limited range of vertices (they use a so called ''vertex-cache'' where they store a list of the most recently used vertices). Another option is to ''lock'' your vertex array manually (compiled vertex array, or CVA). You tell the graphics board to only transform each vertex in the list once, and it will be reused by all triangles referencing it.
Vertex arrays are the way to go.
/ Yann
Indexed vertex arrays do exactly what you are looking for. You have a shared vertex list and an index list for each triangle. Now depending on your 3D card, a single vertex is only transformed *once*, even if it is referenced by multiple triangles. Eg. GeForces will do that automatically for you on a limited range of vertices (they use a so called ''vertex-cache'' where they store a list of the most recently used vertices). Another option is to ''lock'' your vertex array manually (compiled vertex array, or CVA). You tell the graphics board to only transform each vertex in the list once, and it will be reused by all triangles referencing it.
Vertex arrays are the way to go.
/ Yann
reply for crispy:
i dont aggre with you
in dos times when i was doing all stuff myself without any libraries i used two lists , vertice list , and triangle list
i moved/rotated shape vertices, then was going thru list of triangles holding 3 vertices for each triangle (by the way ordered clockwise so i knew wchich triangles face backwards
and projeted/textured/whatevered them, this way i processed each vertex ONCE only no matter how much triangles meet in this vertex
right?
p.greg marczyk
i dont aggre with you
in dos times when i was doing all stuff myself without any libraries i used two lists , vertice list , and triangle list
i moved/rotated shape vertices, then was going thru list of triangles holding 3 vertices for each triangle (by the way ordered clockwise so i knew wchich triangles face backwards

right?
p.greg marczyk
p.greg marczyk
reply for crispy:
i dont aggre with you
in dos times when i was doing all stuff myself without any libraries i used two lists , vertice list , and triangle list
i moved/rotated shape vertices, then was going thru list of triangles holding 3 vertices for each triangle (by the way ordered clockwise so i knew wchich triangles face backwards
and projeted/textured/whatevered them, this way i processed each vertex ONCE only no matter how much triangles meet in this vertex
right?
p.greg marczyk
i dont aggre with you
in dos times when i was doing all stuff myself without any libraries i used two lists , vertice list , and triangle list
i moved/rotated shape vertices, then was going thru list of triangles holding 3 vertices for each triangle (by the way ordered clockwise so i knew wchich triangles face backwards

right?
p.greg marczyk
p.greg marczyk
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement