Changeset 1051


Ignore:
Timestamp:
06/23/06 13:42:41 (18 years ago)
Author:
gumbau
Message:

Vertex arrays

Location:
GTP/trunk/Lib/Geom/shared
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshView.cpp

    r1050 r1051  
    686686        { 
    687687                //      Paint the current strip. 
    688                 glBegin(GL_TRIANGLE_STRIP); 
    689688 
    690689                //      First index of the strip. 
     
    697696                //} 
    698697 
     698                int size= 0; 
    699699                //      If is the final strip 
    700700                if (strip       == (geosubmesh->mStripCount - 1)) 
     
    702702                        //      The end of the index array. 
    703703                        indexEnd        = &geosubmesh->mIndex[geosubmesh->mIndexCount]; 
     704            size= indexEnd - indexBegin; 
    704705                } 
    705706                else 
     
    708709                        indexEnd        = geosubmesh->mStrip[strip + 1]; 
    709710 
     711                for (index = indexBegin; index < indexEnd; index++) 
     712                { 
     713                        size++; 
     714                } 
    710715                        //      Remove degenerated 
    711716                        //indexEnd--; 
     
    729734                } 
    730735 
    731                 //      For each index of the strip. 
    732                 for (index = indexBegin; index < indexEnd; index++) 
    733                 { 
    734                         position        =       indexBegin[i]; 
    735  
    736                         //      Gets the vertex normal. 
    737                         vector3 =       geosubmesh->mVertexBuffer->mNormal[position]; 
    738  
    739                         x                               =       vector3[0]; 
    740                         y                               =       vector3[1]; 
    741                         z                               =       vector3[2]; 
    742  
    743                         //      Sets the vertex normal. 
    744                         glNormal3f(x,y,z); 
    745  
    746                         // set the texture coordinates if needed 
    747                         if (usetex) 
    748                         { 
    749                                 vector2 = geosubmesh->mVertexBuffer->mTexCoords[position]; 
    750                                 x                               =       vector2[0]; 
    751                                 y                               =       vector2[1]; 
    752                                 glTexCoord2f(x,y); 
    753                         } 
    754  
    755                         //      Gets the vertex coordinates. 
    756                         vector3 =       geosubmesh->mVertexBuffer->mPosition[position]; 
    757  
    758                         x                               =       vector3[0]; 
    759                         y                               =       vector3[1]; 
    760                         z                               =       vector3[2]; 
    761  
    762  
    763                         //      Sets the vertex position. 
    764                         glVertex3f(x,y,z); 
    765  
    766                         //      Increments i. 
    767                         i++; 
    768                 } 
    769  
    770                 glEnd(); 
     736 
     737        //VERTEX ARRAYS 
     738        glEnableClientState(GL_VERTEX_ARRAY); 
     739        glEnableClientState(GL_NORMAL_ARRAY); 
     740        if (usetex) 
     741                glEnableClientState(GL_TEXTURE_COORD_ARRAY); 
     742        else 
     743                glDisableClientState(GL_TEXTURE_COORD_ARRAY); 
     744 
     745                glVertexPointer(3, GL_FLOAT, 0, geosubmesh->mVertexBuffer->mPosition); 
     746                glNormalPointer(GL_FLOAT, 0, geosubmesh->mVertexBuffer->mNormal); 
     747                if (usetex) 
     748                        glTexCoordPointer(2, GL_FLOAT, 0, geosubmesh->mVertexBuffer->mTexCoords); 
     749 
     750                glDrawElements( GL_TRIANGLE_STRIP, 
     751                        size 
     752                        , 
     753                        GL_UNSIGNED_INT, 
     754                        indexBegin 
     755                        ); 
     756 
     757        if (submesh==leavesSubMesh) 
     758        { 
     759                glDisable(GL_ALPHA_TEST); 
     760                glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,0); 
     761        } 
    771762 
    772763        } 
Note: See TracChangeset for help on using the changeset viewer.