Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 11, 2005, 5:17:21 PM (19 years ago)
Author:
patrick
Message:

orxonox/branches/md2_loader: started cleaning up: put model and md2model together

File:
1 edited

Legend:

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

    r4163 r4168  
    3636{
    3737  this->setClassName ("MD2Model");
     38
     39  MD2Loader* md2loader = new MD2Loader();
     40  this->model = new t3DModel;
     41  md2loader->importMD2(this->model, "../data/models/tris.md2");
    3842}
    3943
     
    4953
    5054
    51 void MD2Model::animate(t3DModel *pModel)
    52 {
    53   if( unlikely(pModel->objectList.size() <= 0)) return;
     55void MD2Model::animate()
     56{
     57  if( unlikely(this->model->objectList.size() <= 0)) return;
    5458  /* get current animation from the list */
    55   tAnimationInfo *pAnim = &(pModel->animationList[pModel->currentAnim]);
    56 
    57   int nextFrame = (pModel->currentFrame + 1) % pAnim->endFrame;
     59  tAnimationInfo *pAnim = &(this->model->animationList[this->model->currentAnim]);
     60
     61  int nextFrame = (this->model->currentFrame + 1) % pAnim->endFrame;
    5862  if( unlikely(nextFrame == 0))
    5963    nextFrame =  pAnim->startFrame;
    6064
    61   t3DObject *pFrame = &pModel->objectList[pModel->currentFrame];
    62   t3DObject *pNextFrame = &pModel->objectList[nextFrame];
     65  t3DObject *pFrame = &this->model->objectList[this->model->currentFrame];
     66  t3DObject *pNextFrame = &this->model->objectList[nextFrame];
    6367
    6468  /* we have stored the texture and face information only in the first frame */
    65   t3DObject *pFirstFrame = &pModel->objectList[0];
     69  t3DObject *pFirstFrame = &this->model->objectList[0];
    6670
    6771  /* get the current time as a value in the domain [0..1] :)) */
    68   float t = this->getCurrentTime(pModel, nextFrame);
     72  float t = this->getCurrentTime(this->model, nextFrame);
    6973
    7074  glBegin(GL_TRIANGLES);
     
    7882          if( likely(pFirstFrame->pTexVerts != NULL))
    7983            {
    80               glTexCoord2f(pFirstFrame->pTexVerts[ texIndex ].x,
    81                            pFirstFrame->pTexVerts[ texIndex ].y);
     84              glTexCoord2f(pFirstFrame->pTexVerts[texIndex].x,
     85                           pFirstFrame->pTexVerts[texIndex].y);
    8286            }
    8387                       
     
    106110    }
    107111  printf("t = %f\n", this->localTime);
    108   return (this->localTime/kAnimationSpeed);
     112  return (this->localTime / kAnimationSpeed);
    109113}
    110114
     
    112116void MD2Model::tick(float dtS)
    113117{
    114   /* TEMP TEMP TEMP: save the current step length */
    115   this->dtS = dtS;
    116118  this->localTime += dtS;
    117119}
     
    122124   these function will take NO argument in the final version, just for testing
    123125*/
    124 void MD2Model::draw(t3DModel *pModel)
    125 {
    126   if( pModel->objectList.size() <= 0) return;
    127 
    128   t3DObject *pObject = &pModel->objectList[0];
     126void MD2Model::draw()
     127{
     128  if( this->model->objectList.size() <= 0) return;
     129
     130  t3DObject *pObject = &this->model->objectList[0];
    129131  glBegin(GL_TRIANGLES);
    130132  for(int j = 0; j < pObject->numOfFaces; j++)
Note: See TracChangeset for help on using the changeset viewer.