[gameprogrammer] Re: triangle strips or fans
- From: Olof Bjarnason <olof.bjarnason@xxxxxxxxx>
- To: gameprogrammer@xxxxxxxxxxxxx
- Date: Tue, 7 Feb 2006 17:33:44 +0100
1. create a grid of vectors for all "height points" for your height
map model, that is compute the x- y- and z- coordinates, where z =
heightmap(x,y), lets say vec_grid[x][y]
2. now to access the "height vertice" for integer grid location (x,y)
you use vec_grid[x][y]
3. to access the neightbours of a grid location is trivial:
vec_grid[x-1][y-1], etc.
4. now to compute the fan for a certain 3x3 heightmap neighbourhood,
you simple upload vertex-by-vertvex in correct order.
5. say you want to create the fan around u,v, integers. then upload
could look like:
glVertex3fv(vec_grid[u][v].array);
glVertex3fv(vec_grid[u][v-1].array);
glVertex3fv(vec_grid[u+1][v-1].array);
glVertex3fv(vec_grid[u+1][v].array);
glVertex3fv(vec_grid[u+1][v+1].array);
glVertex3fv(vec_grid[u][v+1].array);
glVertex3fv(vec_grid[u-1][v+1].array);
glVertex3fv(vec_grid[u-1][v].array);
glVertex3fv(vec_grid[u-1][v-1].array);
glVertex3fv(vec_grid[u][v-1].array);
.. or counter-clockwise if you have opposite triangle front face.
.array is a c-array representing the vector in question, array[3].
6. if you are using vector arrays / indices, you simply store the
indices in the grid instead, and upload the appropriate indices
similarly but into an index array instead of using glVertex3f.
7. using method of (6) should be relatively simple after you got
method of (5) working
/Olof
On 2/7/06, Roger D Vargas <luo_hei@xxxxxxxx> wrote:
> Do you think I can generate the map geometry from a list of heights and
> use an one dimension array to store the vertices?
>
> Olof Bjarnason escribió:
> > try using fences if you are in opengl.. that way you could have a
> > piece of ground like this:
> >
> > -----
> > |\|/|
> > |/|\|
> > -----
> >
> > (try viewing my ACSII art in notepad if you are on
> > not-constant-width-font mail program)
> >
> > It is a 9 vertice geometric entity. 4 vertices are corners, 4 vertices
> > are on the midpoint of the edges. The last vertice is in the middle of
> > the figure. Each corner is connected to each middlepoint. The middle
> > vertice is connected to all other points.
> >
> > That way, each of the 9 vertices can have an individual height from
> > you heightmap, and the total number of glVertice calls / indices if
> > you are using vertice arrays is 10 IIRC, to render not less than 8
> > triangles. That is 10/8 ~= 1.25 vertice calls per triangle. (3 vertice
> > calls per triangle with ordinary calls of course..) It's quite nice..
> >
> > You have to be cautious on the order you are sending your vertices
> > though, read up on the fence order of opengl.
> >
> > /Olof
> >
> > On 2/7/06, Enrico Zschemisch <enrico.zschemisch@xxxxxx> wrote:
> >> Hi,
> >>
> >>> Indices? What is that?
> >> Do you mean indices in general?
> >>
> >> http://en.wikipedia.org/wiki/Array
> >>
> >> --
> >> Telefonieren Sie schon oder sparen Sie noch?
> >> NEU: GMX Phone_Flat http://www.gmx.net/de/go/telefonie
> >>
> >>
> >> ---------------------
> >> To unsubscribe go to http://gameprogrammer.com/mailinglist.html
> >>
> >>
> >>
> >
> >
> > ---------------------
> > To unsubscribe go to http://gameprogrammer.com/mailinglist.html
> >
> >
> >
>
> --
> Roger D. Vargas
> http://dsgp.blogspot.com | Linux, programación, juegos
>
>
> ______________________________________________
> LLama Gratis a cualquier PC del Mundo.
> Llamadas a fijos y móviles desde 1 céntimo por minuto.
> http://es.voice.yahoo.com
>
>
> ---------------------
> To unsubscribe go to http://gameprogrammer.com/mailinglist.html
>
>
>
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- References:
- [gameprogrammer] Re: triangle strips or fans
- From: Roger D Vargas
- [gameprogrammer] Re: triangle strips or fans
- From: Enrico Zschemisch
- [gameprogrammer] Re: triangle strips or fans
- From: Olof Bjarnason
- [gameprogrammer] Re: triangle strips or fans
- From: Roger D Vargas
Other related posts:
- » [gameprogrammer] triangle strips or fans
- » [gameprogrammer] Re: triangle strips or fans
- » [gameprogrammer] Re: triangle strips or fans
- » [gameprogrammer] Re: triangle strips or fans
- » [gameprogrammer] Re: triangle strips or fans
- » [gameprogrammer] Re: triangle strips or fans
- » [gameprogrammer] Re: triangle strips or fans
- [gameprogrammer] Re: triangle strips or fans
- From: Roger D Vargas
- [gameprogrammer] Re: triangle strips or fans
- From: Enrico Zschemisch
- [gameprogrammer] Re: triangle strips or fans
- From: Olof Bjarnason
- [gameprogrammer] Re: triangle strips or fans
- From: Roger D Vargas