Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4168 in orxonox.OLD for orxonox/branches/md2_loader/src


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

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

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

Legend:

Unmodified
Added
Removed
  • orxonox/branches/md2_loader/src/lib/graphics/importer/Makefile.in

    r4156 r4168  
    4242subdir = src/lib/graphics/importer
    4343DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
    44         $(srcdir)/Makefile.in TODO
     44        $(srcdir)/Makefile.in
    4545ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    4646am__aclocal_m4_deps = $(top_srcdir)/configure.ac
  • 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++)
  • orxonox/branches/md2_loader/src/lib/graphics/importer/md2Model.h

    r4163 r4168  
    119119  void drawModel(float time);
    120120  void drawFrame(int frame);
    121  
    122   void draw(t3DModel *pModel);
     121  void draw();
    123122 
    124123  void setAnim(int type);
     
    127126  void tick(float dtS);
    128127
    129   void animate(/*float time*/ t3DModel *pModel);
     128  void animate(/*float time*/);
    130129private:
    131130  void processLightning();
     
    134133  float getCurrentTime(t3DModel *pModel, int nextFrame);
    135134
    136   float dtS;
     135  t3DModel* model;
    137136  float localTime;
    138137};
     
    145144  virtual ~MD2Loader();
    146145 
    147   bool importMD2(t3DModel *pModel, char *fileName, char *texture);
     146  bool importMD2(t3DModel *pModel, char *fileName, char *texture = NULL);
    148147
    149148private:
  • orxonox/branches/md2_loader/src/world_entities/test_entity.cc

    r4163 r4168  
    2828TestEntity::TestEntity () : WorldEntity()
    2929
    30   MD2Loader* md2loader = new MD2Loader();
    31   this->model = new t3DModel;
    3230  this->md2Model = new MD2Model();
    3331
    34   md2loader->importMD2(this->model, "../data/models/tris.md2", "../data/models/tris.pcx");
    35 
    36   this->material = new Material("Sky");
     32  this->material = new Material("Clown");
    3733  this->material->setDiffuseMap("../data/models/tris.pcx");
    3834  this->material->setIllum(3);
     
    7066  glMultMatrixf((float*)matrix);
    7167 
    72   //this->model->draw();
     68
    7369  /* TESTGING TESTING TESTING */
    7470  this->material->select();
    7571  //this->md2Model->draw(this->model);
    76   this->md2Model->animate(this->model);
     72  this->md2Model->animate();
    7773
    7874  glPopMatrix();
Note: See TracChangeset for help on using the changeset viewer.