RE: [Plib-devel] Vertex array code
Brought to you by:
sjbaker
From: Vallevand, M. K <Mar...@UN...> - 2000-05-17 16:57:01
|
Eric: Are you going to make any of these changes and submit them for including in plib? Or, should I begin fixing up ssgVtxArray, etc? I don't want to collide with anything you might be doing. I'm not moving real fast on any updates, because everything is 'good enough' right now. But, I think your optional array stuff is worth doing. Regards. Mark K Vallevand ma...@rs... Outside of a dog, a book is man's best friend. Inside of a dog, its too dark to read. - Groucho > -----Original Message----- > From: Vallevand, Mark K > Sent: Monday, May 15, 2000 2:56 PM > To: 'pli...@li...' > Subject: RE: [Plib-devel] Vertex array code > > > I like the part about optional arrays. This is > very similar to what I thought about for future > improvements. But, the tunable part is just for > performance, correct? > > In the fullness of time, I'd create a base class > (say, ssgVtx) that has almost all the algorithms > in it, with derived classes (say, ssgVtxTable, > ssgVtxArray, ssgVtxInterleavedArray, etc) that > have specific methods for getting at the vertex > data. I'd declare pure virtual methods in the > base class for all the methods required to be > supported by the derived classes. Right now, its > just opportunistic coding that allows ssgVtxArray > to be derived from ssgVtxTable. There is far too > much duplication between the classes. > > Regards. > Mark K Vallevand ma...@rs... > Outside of a dog, a book is man's best friend. > Inside of a dog, its too dark to read. - Groucho > > > > -----Original Message----- > > From: Eric Espie [mailto:Eri...@fr...] > > Sent: Monday, May 15, 2000 2:37 PM > > To: pli...@li... > > Subject: Re: [Plib-devel] Vertex array code > > > > > > "Vallevand, Mark K" wrote: > > > > > > Here is the vertex array code for ssg. > > > <<plib.tar.gz>> > > > I've included a diff file of changes to existing files, > the original > > > files, the changed files, and the new files. There isn't any > > > documentation except this email message. I based the changes > > > on plib 1.1.9.- > > > > > [...] > > > > Well done, I was planning to do it myself for Torcs. > > In order to allow optionnal arrays, I merged the codes > > from VtxTable and VtxArray (see the result below)... > > > > I have also a proposal for VtxTable, I don't know if it is > > interesting to do it that way (the number of vertices used to > > switch between the array and the other method should be tuned). > > > > Just an idea for the compiled vertex arrays: it would be > > interesting to > > manage the client states and arrays pointers externally (as > textures) > > in order to share bigger arrays between leaves and to use > index arrays > > to select small parts in each leaf. > > But this will be more complex to do and need a changes in the > > structure, > > like loading the arrays in a specific parent ssgEntity for example, > > and have the client states managed also by the parent ssgEntity. > > > > Eric. > > > > > > Here is my proposal for the draw_geometry functions (not > yet tested). > > > > > > void ssgVtxArray::draw_geometry () > > { > > int num_colours = getNumColours () ; > > int num_normals = getNumNormals () ; > > int num_texcoords = getNumTexCoords () ; > > > > glPushClientAttrib ( GL_CLIENT_VERTEX_ARRAY_BIT ) ; > > > > if ( num_colours == 0 ) > > glColor4f ( 1.0f, 1.0f, 1.0f, 1.0f ) ; > > else if ( num_colours == 1 ) > > glColor4fv ( ( (sgVec4 *) colours->get(0) ) [ 0 ] ) ; > > else if ( num_colours > 1 ) > > { > > glEnableClientState ( GL_COLOR_ARRAY ) ; > > glColorPointer ( 4, GL_FLOAT, 0, colours->get(0) ) ; > > } > > > > if ( num_normals == 1 ) > > glNormal3fv ( ( (sgVec3 *) normals->get(0) ) [ 0 ] ) ; > > else if ( num_normals > 1 ) > > { > > glEnableClientState ( GL_NORMAL_ARRAY ) ; > > glNormalPointer ( GL_FLOAT, 0, normals->get(0) ) ; > > } > > > > if ( num_texcoords > 1 ) > > { > > glEnableClientState ( GL_TEXTURE_COORD_ARRAY ) ; > > glTexCoordPointer ( 2, GL_FLOAT, 0, texcoords->get(0) ) ; > > } > > > > glEnableClientState ( GL_VERTEX_ARRAY ) ; > > glVertexPointer ( 3, GL_FLOAT, 0, vertices->get(0) ) ; > > > > int i = getNumIndices (); > > int *ii = indices->get(0); > > glDrawElements ( gltype, i, GL_UNSIGNED_INT, ii ) ; > > > > glPopClientAttrib ( ) ; > > } > > > > > > > > > > > > void ssgVtxTable::draw_geometry () > > { > > int num_colours = getNumColours () ; > > int num_normals = getNumNormals () ; > > int num_vertices = getNumVertices () ; > > int num_texcoords = getNumTexCoords () ; > > > > sgVec3 *vx = (sgVec3 *) vertices -> get(0) ; > > sgVec3 *nm = (sgVec3 *) normals -> get(0) ; > > sgVec2 *tx = (sgVec2 *) texcoords -> get(0) ; > > sgVec4 *cl = (sgVec4 *) colours -> get(0) ; > > > > if ( num_vertices < 9 /* To Be Tuned */ ) > > { > > glBegin ( gltype ) ; > > > > if ( num_colours == 0 ) glColor4f ( 1.0f, 1.0f, 1.0f, 1.0f ) ; > > if ( num_colours == 1 ) glColor4fv ( cl [ 0 ] ) ; > > if ( num_normals == 1 ) glNormal3fv ( nm [ 0 ] ) ; > > > > for ( int i = 0 ; i < num_vertices ; i++ ) > > { > > if ( num_colours > 1 ) glColor4fv ( cl [ i ] ) ; > > if ( num_normals > 1 ) glNormal3fv ( nm [ i ] ) ; > > if ( num_texcoords > 1 ) glTexCoord2fv ( tx [ i ] ) ; > > > > glVertex3fv ( vx [ i ] ) ; > > } > > > > glEnd () ; > > } > > else > > { > > glPushClientAttrib ( GL_CLIENT_VERTEX_ARRAY_BIT ) ; > > > > if ( num_colours == 0 ) > > glColor4f ( 1.0f, 1.0f, 1.0f, 1.0f ) ; > > else if ( num_colours == 1 ) > > glColor4fv ( cl [ 0 ] ) ; > > else if ( num_colours > 1 ) > > { > > glEnableClientState ( GL_COLOR_ARRAY ) ; > > glColorPointer ( 4, GL_FLOAT, 0, cl ) ; > > } > > > > if ( num_normals == 1 ) > > glNormal3fv ( nm [ 0 ] ) ; > > else if ( num_normals > 1 ) > > { > > glEnableClientState ( GL_NORMAL_ARRAY ) ; > > glNormalPointer ( GL_FLOAT, 0, nm ) ; > > } > > > > if ( num_texcoords > 1 ) > > { > > glEnableClientState ( GL_TEXTURE_COORD_ARRAY ) ; > > glTexCoordPointer ( 2, GL_FLOAT, 0, tx ) ; > > } > > > > glEnableClientState ( GL_VERTEX_ARRAY ) ; > > glVertexPointer ( 3, GL_FLOAT, 0, vx ) ; > > > > glDrawArrays ( gltype, 0, num_vertices ) ; > > > > glPopClientAttrib ( ) ; > > } > > > > } > > > > _______________________________________________ > > plib-devel mailing list > > pli...@li... > > http://lists.sourceforge.net/mailman/listinfo/plib-devel > > > |