Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6259 in orxonox.OLD


Ignore:
Timestamp:
Dec 22, 2005, 2:36:03 PM (18 years ago)
Author:
bensch
Message:

heightMap: vertex-array draws as it should

Location:
branches/height_map/src/lib/graphics/importer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/height_map/src/lib/graphics/importer/vertex_array_model.cc

    r6249 r6259  
    6868  PRINTF(4)("drawing the 3D-VertexArrayModels\n");
    6969
    70   glEnableClientState(GL_VERTEX_ARRAY |
    71                       GL_TEXTURE_COORD_ARRAY |
    72                       GL_NORMAL_ARRAY);
    73   glEnableClientState(GL_INDEX_ARRAY);
     70  glEnableClientState(GL_VERTEX_ARRAY );
     71  glEnableClientState(GL_TEXTURE_COORD_ARRAY );
     72  glEnableClientState(GL_NORMAL_ARRAY );
     73  glEnableClientState(GL_COLOR_ARRAY );
     74
    7475
    7576  glVertexPointer(3, GL_FLOAT, 0, this->vertices.getArray());
    7677  glNormalPointer(GL_FLOAT, 0, this->normals.getArray());
    77   glTexCoordPointer(2, GL_FLOAT, 0, this->texCoords.getArray()); 
    78 
    79       glDrawElements(GL_TRIANGLE_STRIP, this->indices.getCount(), GL_UNSIGNED_BYTE, this->indices.getArray());
    80 /*  for (GLuint i = 1; i < this->stripes.size(); ++i)
     78  glTexCoordPointer(2, GL_FLOAT, 0, this->texCoords.getArray());
     79  glColorPointer(3, GL_FLOAT, 0, this->colors.getArray());
     80
     81//      glDrawElements(GL_TRIANGLE_STRIP, this->indices.getCount(), GL_UNSIGNED_BYTE, this->indices.getArray());
     82  for (GLuint i = 1; i < this->stripes.size(); ++i)
    8183    {
    8284      glDrawRangeElements(GL_TRIANGLE_STRIP,
     
    8688                          GL_UNSIGNED_BYTE,
    8789                          this->indices.getArray());
    88     }*/
     90    }
    8991}
    9092
     
    131133
    132134/**
    133  * adds a Texture Coordinate
     135 * @brief adds a Texture Coordinate
    134136 * @param u The u coordinate of the TextureCoordinate.
    135137 * @param v The y coordinate of the TextureCoordinate.
     
    142144  this->texCoords.addEntry(v);
    143145  this->pModelInfo.numTexCoor++;
     146}
     147
     148/**
     149 * @brief adds a new Color
     150 * @param r the Red Component of the VertexColor to add.
     151 * @param g the Green Component of the VertexColor to add.
     152 * @param b the Blue of the VertexColor to add.
     153 */
     154void VertexArrayModel::addColor(float r, float g, float b)
     155{
     156  this->colors.addEntry(r, g, b);
     157  // FIXME
    144158}
    145159
     
    165179  this->texCoords.finalizeArray();
    166180  this->normals.finalizeArray();
     181  this->colors.finalizeArray();
    167182  this->indices.finalizeArray();
    168183
     
    184199/////////////
    185200/**
    186  * @brief Includes a default model
    187  *
    188  * This will inject a Cube, because this is the most basic model.
    189  */
     201* @brief Includes a default model
     202*
     203* This will inject a Cube, because this is the most basic model.
     204*/
    190205void VertexArrayModel::planeModel()
    191206{
     207  unsigned int sizeX = 20, sizeY = 10;
     208
    192209  unsigned int i, j;
    193   for (i = 0; i < 20; i++)
     210  for (i = 0; i < sizeY; i++)
    194211    {
    195       for (j = 0; j < 20; j++)
    196         {
    197           this->addVertex((float)i, .5, (float)(j));
    198           this->addNormal(0, 1, 0);
    199           this->addTexCoor((float)i/20.0, (float)j/20.0);
    200 
    201         }
     212      for (j = 0; j < sizeX; j++)
     213        {
     214          this->addVertex((float)i - sizeY/2.0, -(float)i * (float)j/(float)sizeY/(float)sizeX * 10.0 , (float)(j) - sizeX/2.0);
     215          this->addNormal((float)i/(float)sizeY, 1, (float)j/(float)sizeX);
     216          this->addTexCoor((float)i/(float)sizeY, (float)j/(float)sizeY);
     217          this->addColor((float)i/20.0, 0.0, (float)j/20.0);
     218        }
    202219    }
    203   for (i = 0; i < 20; i++)
     220
     221  for (i = 0; i < sizeY-1; i++)
     222  {
     223    for (j = 0; j < sizeX; j++)
    204224    {
    205       this->addIndice(i);
    206       this->addIndice(i+20);
     225      this->addIndice(sizeX*i + j);
     226      this->addIndice(sizeX*(i+1) + j);
    207227    }
    208 }
     228    if (i < sizeY -1 )
     229      this->newStripe();
     230  }
     231}
  • branches/height_map/src/lib/graphics/importer/vertex_array_model.h

    r6037 r6259  
    3939  void addNormal(float x, float y, float z);
    4040  void addTexCoor(float u, float v);
     41  void addColor(float r, float g, float b);
     42
    4143  void addIndice(GLubyte indice);
    4244
    4345  void finalize();
    4446
    45   // 
     47  //
    4648  void planeModel();
    4749
     
    5557  tArray<GLfloat>            normals;         //!< The Array that handles the Normals.
    5658  tArray<GLfloat>            texCoords;       //!< The Array that handles the VertexTextureCoordinates.
     59  tArray<GLfloat>            colors;          //!< The Array that handles Colors.
    5760
    5861  tArray<GLubyte>            indices;         //!< The Array that tells us what Vertex is connected to which other one.
Note: See TracChangeset for help on using the changeset viewer.