Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4224 in orxonox.OLD


Ignore:
Timestamp:
May 19, 2005, 9:37:46 PM (19 years ago)
Author:
patrick
Message:

orxonox/branches/md2_model: debugging the md2 file

Location:
orxonox/branches/md2_loader/src
Files:
3 edited

Legend:

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

    r4215 r4224  
    4141sAnim MD2Model2::animationList[21] =
    4242  {
     43 // begin, end, fps
    4344    {   0,  39,  9 },   // STAND
    4445    {  40,  45, 10 },   // RUN
     
    511512 
    512513  this->textureID = 0;
    513   this->scaleFactor = 1.0f;
     514  this->scaleFactor = 0.001f;
    514515
    515516  this->setAnim(STAND);
     
    552553  this->numFrames = header.numFrames;
    553554  this->numVertices = header.numVertices;
     555  this->numTriangles = header.numTriangles;
    554556  this->numGLCommands = header.numGlCommands;
    555557  /* allocate memory for the data storage */
     
    583585          pVertex[i][0] = (frame->pVertices[i].v[0] * frame->scale[0]) + frame->translate[0];
    584586          pVertex[i][1] = (frame->pVertices[i].v[1] * frame->scale[1]) + frame->translate[1];
    585           pVertex[i][2] = (frame->pVertices[i].v[2] * frame->scale[2]) + frame->translate[2];     
     587          pVertex[i][2] = (frame->pVertices[i].v[2] * frame->scale[2]) + frame->translate[2];
    586588
    587589          pNormals[i] = frame->pVertices[i].lightNormalIndex;
     
    617619  nextVec = &this->pVertices[this->numVertices * this->animationState.nextFrame];
    618620
    619   //printf("currVec: %f, %f, %f\n", currVec[0][0], currVec[0][1], currVec[0][2]);
    620   //printf("nextVec: %f, %f, %f\n", nextVec[0], nextVec[1], nextVec[2]);
     621    printf("currVec: %f, %f, %f\n", currVec[0][0], currVec[0][1], currVec[0][2]);
     622    printf("nextVec: %f, %f, %f\n", nextVec[0][0], nextVec[1][1], nextVec[2][2]);
    621623 
    622   for(int i = 0; i < this->numFrames; ++i)
    623     {
    624       /*
    625       verticesList[i][0] = this->pVertices[i + (this->numFrames * this->animationState.currentFrame)][0] * this->scaleFactor;
    626       verticesList[i][1] = this->pVertices[i + (this->numFrames * this->animationState.currentFrame)][1] * this->scaleFactor;
    627       verticesList[i][2] = this->pVertices[i + (this->numFrames * this->animationState.currentFrame)][2] * this->scaleFactor;
    628       */
    629 
    630       verticesList[i][0] = (currVec[i][0] + this->animationState.interpolationState * (nextVec[i][0] - currVec[i][0])) * this->scaleFactor;
    631       verticesList[i][1] = (currVec[i][1] + this->animationState.interpolationState * (nextVec[i][1] - currVec[i][1])) * this->scaleFactor;
    632       verticesList[i][2] = (currVec[i][2] + this->animationState.interpolationState * (nextVec[i][2] - currVec[i][2])) * this->scaleFactor;
    633     }
     624    printf("numFrames: %i\n", this->numFrames);
     625    printf("currentFrame: %i\n", this->animationState.currentFrame);
     626
     627    //for(int i = 0; i < this->numFrames; ++i)
     628    for(int i = 0; i < this->numVertices; ++i)
     629      {
     630        /*
     631        verticesList[i][0] = this->pVertices[i + (this->numFrames * this->animationState.currentFrame)][0] * this->scaleFactor;
     632        verticesList[i][1] = this->pVertices[i + (this->numFrames * this->animationState.currentFrame)][1] * this->scaleFactor;
     633        verticesList[i][2] = this->pVertices[i + (this->numFrames * this->animationState.currentFrame)][2] * this->scaleFactor;
     634        */
     635
     636
     637        verticesList[i][0] = (currVec[i][0] + this->animationState.interpolationState * (nextVec[i][0] - currVec[i][0])) * this->scaleFactor;
     638        verticesList[i][1] = (currVec[i][1] + this->animationState.interpolationState * (nextVec[i][1] - currVec[i][1])) * this->scaleFactor;
     639        verticesList[i][2] = (currVec[i][2] + this->animationState.interpolationState * (nextVec[i][2] - currVec[i][2])) * this->scaleFactor;
     640
     641
     642        //printf("  pVertices %f, %f, %f\n", pVertices[i][0], pVertices[i][1], pVertices[i][2]);
     643        //printf("  list:     %f, %f, %f \n", verticesList[i][0], verticesList[i][1], verticesList[i][2]);     
     644      }
    634645}
    635646
     
    639650  if( (type < 0) || (type > MAX_ANIMATIONS) )
    640651    type = 0;
    641  
    642   this->animationState.startFrame = animationList[type].firstFrame;
    643   this->animationState.endFrame = animationList[type].lastFrame;
    644   this->animationState.nextFrame = animationList[type].firstFrame + 1;
    645   this->animationState.fps = animationList[type].fps;
    646   this->animationState.type = type;
     652
     653this->animationState.startFrame = animationList[type].firstFrame;
     654this->animationState.endFrame = animationList[type].lastFrame;
     655this->animationState.nextFrame = animationList[type].firstFrame + 1;
     656this->animationState.fps = animationList[type].fps;
     657this->animationState.type = type;
     658
     659this->animationState.interpolationState = 0.0;
     660this->animationState.localTime = 0.0;
     661this->animationState.lastTime = 0.0;
     662this->animationState.currentFrame = animationList[type].firstFrame;
    647663}
    648664
     
    670686
    671687
    672 /* hhmmm... id used a very different way to do lightning...*/
     688/* hhmmm... id used a very different way to do lightning... */
    673689void MD2Model2::processLighting()
    674690{
    675691  shadeDots = anormsDots[((int)(md2Angle*(SHADEDOT_QUANT / 360.0)))&(SHADEDOT_QUANT - 1)];
    676692}
     693
    677694
    678695void MD2Model2::tick(float time)
     
    696713
    697714  glPopMatrix();
     715}
     716
     717
     718void MD2Model2::draw2()
     719{
     720  glBegin(GL_TRIANGLES);
     721  for(int j = 0; j < this->numTriangles; j++)
     722    {
     723      for(int whichVertex = 0; whichVertex < 3; whichVertex++)
     724        {
     725          /*
     726          int index = pObject->pFaces[j].vertIndex[whichVertex];
     727          int index2 = pObject->pFaces[j].coordIndex[whichVertex];
     728          glNormal3f(-pObject->pNormals[index].x, -pObject->pNormals[index].y, -pObject->pNormals[index].z);
     729         
     730          if( likely(pObject->pTexVerts != NULL))
     731            {
     732              glTexCoord2f(pObject->pTexVerts[index2].x, pObject->pTexVerts[index2].y);
     733            }
     734          glVertex3f(pObject->pVerts[index].x, pObject->pVerts[index].y, pObject->pVerts[index].z);
     735          */
     736        }
     737    }
     738  glEnd();
    698739}
    699740
     
    716757  /* draw the triangles */
    717758  /* \todo: take int i out of while loop */
    718   while( int i = *(pCommands++)) /* strange looking while loop for maximum performance */
    719     {
     759  while( false /*int i = *(pCommands++)*/) /* strange looking while loop for maximum performance */
     760    {
     761      int i;
    720762      if( i < 0)
    721763        {
     
    737779          glTexCoord2f( ((float *)pCommands)[0], ((float *)pCommands)[1] );
    738780          glVertex3fv(verticesList[pCommands[2]]);
     781
     782          //printf("draw vert: %f, %f, %f\n", verticesList[pCommands[2]][0], verticesList[pCommands[2]][1], verticesList[pCommands[2]][2] );
    739783        }
    740784      glEnd();
  • orxonox/branches/md2_loader/src/lib/graphics/importer/md2Model.h

    r4213 r4224  
    22    \file md2Model.h
    33    \brief Definition of an MD2 Model, a model format invented by ID Software.
    4        
    5         We are deeply thankfull for all the wunderfull things id software made for us gamers!
    6 
    7         The md2 file format is structured in a very simple way: it contains animations which are made out of
    8         frames (so called keyframes). Each frame is a complete draweable model in a specific position.
    9         A frame is a collection of vertex and its compagnions (normals, texture coordinates).
    10        
    11         A typical model has about 200 frames, the maximum frame count is fixed by MD2_MAX_FRAMES to currently
    12         512 frames. The maximal vetices count is set to 2048 verteces, not enough?
    13         You just have to change the MD2_MAX_* values if it doesn't fit your purposes...
    14 
    15         Surface Culling is fully implemented in md2 models: quake2 uses front face culling.
     4   
     5    We are deeply thankfull for all the wunderfull things id software made for us gamers!
     6   
     7    The md2 file format is structured in a very simple way: it contains animations which are made out of
     8    frames (so called keyframes). Each frame is a complete draweable model in a specific position.
     9    A frame is a collection of vertex and its compagnions (normals, texture coordinates).
     10   
     11    A typical model has about 200 frames, the maximum frame count is fixed by MD2_MAX_FRAMES to currently
     12    512 frames. The maximal vetices count is set to 2048 verteces, not enough?
     13    You just have to change the MD2_MAX_* values if it doesn't fit your purposes...
     14   
     15    Surface Culling is fully implemented in md2 models: quake2 uses front face culling.
    1616*/
    1717
     
    187187  void drawFrame(int frame);
    188188  void draw();
     189  void draw2();
    189190 
    190191  void setAnim(int type);
     
    209210  int numFrames;
    210211  int numVertices;
     212  int numTriangles;
    211213  int numGLCommands;
    212214
     
    219221  sAnimState animationState;
    220222  float scaleFactor;
     223  //tMd2Header* header;
    221224};
    222225
  • orxonox/branches/md2_loader/src/world_entities/test_entity.cc

    r4213 r4224  
    4242void TestEntity::tick (float time)
    4343{
    44   this->md2Model2->tick(time);
     44  //this->md2Model2->tick(time);
    4545}
    4646
     
    7272
    7373  this->md2Model2->draw();
     74 
    7475
    7576  glPopMatrix();
Note: See TracChangeset for help on using the changeset viewer.