Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6184 in orxonox.OLD for branches/christmas_branche/src/lib/graphics


Ignore:
Timestamp:
Dec 20, 2005, 1:44:21 PM (19 years ago)
Author:
patrick
Message:

christmas: importer now supports also md2 models

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/christmas_branche/src/lib/graphics/importer/md2Model.cc

    r6181 r6184  
    9292  this->scaleFactor = this->data->scaleFactor;
    9393  this->setAnim(STAND);
     94
     95  this->debug();
    9496}
    9597
     
    119121  currVec = &this->data->pVertices[this->data->numVertices * this->animationState.currentFrame];
    120122  nextVec = &this->data->pVertices[this->data->numVertices * this->animationState.nextFrame];
     123  PRINTF(0)("current frame nr %i, next frame nr %i\n", this->animationState.currentFrame, this->animationState.nextFrame);
     124
    121125
    122126  for( int i = 0; i < this->data->numVertices; ++i)
     
    177181{
    178182  glPushMatrix();
    179 //   this->renderFrame();
     183  //this->renderFrame();
    180184  renderFrameTriangles();
    181185  glPopMatrix();
     
    231235void MD2Model::renderFrameTriangles() const
    232236{
    233   static sVec3D verticesList[MD2_MAX_VERTICES]; /* performance: created only once in a lifetime */
     237  //static sVec3D verticesList[MD2_MAX_VERTICES]; /* performance: created only once in a lifetime */
    234238  int* pCommands = this->data->pGLCommands;
    235239  /* some face culling stuff */
     
    248252  for( int i = 0, k = 0; i < this->data->numTriangles; ++i, k += 3)
    249253  {
    250     //printf("%i: (%f, %f)\n", i, (float)this->data->pTexCoor[this->data->pTriangles[i].indexToTexCoor[2]].s, (float)this->data->pTexCoor[this->data->pTriangles[i].indexToTexCoor[2]].t);
    251 
    252     glTexCoord2f((float)this->data->pTexCoor[this->data->pTriangles[i].indexToTexCoor[0]].s,
    253                   (float)this->data->pTexCoor[this->data->pTriangles[i].indexToTexCoor[0]].t);
    254  //glNormal3f(Md2Model.normal[i].x, Md2Model.normal[i].y, Md2Model.normal[i].z);
     254    float* v = this->data->pVertices[this->data->pTriangles[i].indexToVertices[0]];
     255
     256    printf("triangle: %i\n", i);
     257    printf("     v0: (%f, %f, %f)\n", v[0], v[1], v[2]);
     258    v = this->data->pVertices[this->data->pTriangles[i].indexToVertices[1]];
     259    printf("     v1: (%f, %f, %f)\n", v[0], v[1], v[2]);
     260    v = this->data->pVertices[this->data->pTriangles[i].indexToVertices[2]];
     261    printf("     v2: (%f, %f, %f)\n", v[0], v[1], v[2]);
     262
     263
     264    glNormal3f(anorms[i][0], anorms[i][1], anorms[i][2]);
    255265    glVertex3fv(this->data->pVertices[this->data->pTriangles[i].indexToVertices[0]]);
    256266
    257     glTexCoord2f((float)this->data->pTexCoor[this->data->pTriangles[i].indexToTexCoor[1]].s,
    258                   (float)this->data->pTexCoor[this->data->pTriangles[i].indexToTexCoor[1]].t);
    259 
    260  //    glNormal3f(Md2Model.normal[i].x, Md2Model.normal[i].y, Md2Model.normal[i].z);
     267    glNormal3f(anorms[i][0], anorms[i][1], anorms[i][2]);
    261268    glVertex3fv(this->data->pVertices[this->data->pTriangles[i].indexToVertices[1]]);
    262269
    263     glTexCoord2f((float)this->data->pTexCoor[this->data->pTriangles[i].indexToTexCoor[2]].s,
    264                   (float)this->data->pTexCoor[this->data->pTriangles[i].indexToTexCoor[2]].t);
    265  //    glNormal3f(Md2Model.normal[i].x, Md2Model.normal[i].y, Md2Model.normal[i].z);
     270    glNormal3f(anorms[i][0], anorms[i][1], anorms[i][2]);
    266271    glVertex3fv(this->data->pVertices[this->data->pTriangles[i].indexToVertices[2]]);
    267272  }
     
    269274  glEnd();
    270275}
    271 
    272 
    273 
    274 
    275 
    276 
    277 
    278 
    279 
    280276
    281277
     
    451447  for(int i = 0; i < this->numFrames; ++i)
    452448    {
     449      printf("==============vertex loading for frame %i/%i========\n", i, this->numFrames);
    453450      frame = (sFrame*)(buffer + this->header->frameSize * i);
    454451      pVertex = this->pVertices + this->numVertices  * i;
     
    462459          pVertex[j][2] = (-1.0 * (frame->pVertices[j].v[1] * frame->scale[1] + frame->translate[1])) * this->scaleFactor;
    463460
     461          printf("vertex %i/%i: (%f, %f, %f)\n", j, this->numVertices, pVertex[j][0], pVertex[j][1], pVertex[j][2]);
     462
    464463          pNormals[j] = frame->pVertices[j].lightNormalIndex;
    465464        }
Note: See TracChangeset for help on using the changeset viewer.