Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6199 in orxonox.OLD


Ignore:
Timestamp:
Dec 20, 2005, 10:21:30 PM (18 years ago)
Author:
patrick
Message:

christmas: jumping now also works

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

Legend:

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

    r6198 r6199  
    5050sAnim MD2Model::animationList[21] =
    5151  {
    52  // begin, end, fps
    53     {   0,  39,  9 },   //!< STAND
    54     {  40,  45, 10 },   //!< RUN
    55     {  46,  53, 10 },   //!< ATTACK
    56     {  54,  57,  7 },   //!< PAIN_A
    57     {  58,  61,  7 },   //!< PAIN_B
    58     {  62,  65,  7 },   //!< PAIN_C
    59     {  66,  71,  7 },   //!< JUMP
    60     {  72,  83,  7 },   //!< FLIP
    61     {  84,  94,  7 },   //!< SALUTE
    62     {  95, 111, 10 },   //!< FALLBACK
    63     { 112, 122,  7 },   //!< WAVE
    64     { 123, 134,  6 },   //!< POINTT
    65     { 135, 153, 10 },   //!< CROUCH_STAND
    66     { 154, 159,  7 },   //!< CROUCH_WALK
    67     { 160, 168, 10 },   //!< CROUCH_ATTACK
    68     { 196, 172,  7 },   //!< CROUCH_PAIN
    69     { 173, 177,  5 },   //!< CROUCH_DEATH
    70     { 178, 183,  7 },   //!< DEATH_FALLBACK
    71     { 184, 189,  7 },   //!< DEATH_FALLFORWARD
    72     { 190, 197,  7 },   //!< DEATH_FALLBACKSLOW
    73     { 198, 198,  5 },   //!< BOOM
     52 // begin, end, fps, stoppable
     53    {   0,  39,  9, 1 },   //!< STAND
     54    {  40,  45, 10, 1 },   //!< RUN
     55    {  46,  53, 10, 1 },   //!< ATTACK
     56    {  54,  57,  7, 1 },   //!< PAIN_A
     57    {  58,  61,  7, 1 },   //!< PAIN_B
     58    {  62,  65,  7, 1 },   //!< PAIN_C
     59    {  66,  71,  7, 0 },   //!< JUMP
     60    {  72,  83,  7, 1 },   //!< FLIP
     61    {  84,  94,  7, 1 },   //!< SALUTE
     62    {  95, 111, 10, 1 },   //!< FALLBACK
     63    { 112, 122,  7, 1 },   //!< WAVE
     64    { 123, 134,  6, 1 },   //!< POINTT
     65    { 135, 153, 10, 1 },   //!< CROUCH_STAND
     66    { 154, 159,  7, 1 },   //!< CROUCH_WALK
     67    { 160, 168, 10, 1 },   //!< CROUCH_ATTACK
     68    { 196, 172,  7, 1 },   //!< CROUCH_PAIN
     69    { 173, 177,  5, 0 },   //!< CROUCH_DEATH
     70    { 178, 183,  7, 0 },   //!< DEATH_FALLBACK
     71    { 184, 189,  7, 0 },   //!< DEATH_FALLFORWARD
     72    { 190, 197,  7, 0 },   //!< DEATH_FALLBACKSLOW
     73    { 198, 198,  5, 1 },   //!< BOOM
    7474  };
    7575
     
    9191
    9292  this->scaleFactor = this->data->scaleFactor;
     93
     94  /* set the animation stat mannualy */
     95  this->animationState.type = STAND;
    9396  this->setAnim(STAND);
    9497
     
    141144  if( (type < 0) || (type > MAX_ANIMATIONS) )
    142145    type = STAND;
     146
     147  if( MD2Model::animationList[this->animationState.type].bStoppable == 0)
     148  {
     149    if( this->animationState.numPlays == 0 )
     150      return;
     151  }
    143152
    144153  this->animationState.startFrame = animationList[type].firstFrame;
     
    147156  this->animationState.fps = animationList[type].fps;
    148157  this->animationState.type = type;
     158  this->animationState.numPlays = 0;
    149159
    150160  this->animationState.interpolationState = 0.0f;
     
    161171void MD2Model::tick(float time)
    162172{
    163   this->animationState.localTime += time;
    164 
    165   this->animate();
     173  this->animate(time);
    166174  this->processLighting();
    167175  this->interpolate(/*verticesList*/);
     
    223231  glPopAttrib();
    224232}
    225 
    226 
    227 
    228233
    229234
     
    271276
    272277
    273 
    274 
    275278/**
    276279  \brief animates the current model
     
    278281  depending on the time passed (tick function), the player will select another model
    279282*/
    280 void MD2Model::animate()
    281 {
     283void MD2Model::animate(float time)
     284{
     285  this->animationState.localTime += time;
     286
    282287  if( this->animationState.localTime - this->animationState.lastTime > (1.0f / this->animationState.fps))
    283288    {
     
    286291
    287292      if( this->animationState.nextFrame > this->animationState.endFrame)
     293      {
    288294        this->animationState.nextFrame = this->animationState.startFrame;
     295        this->animationState.numPlays++;
     296      }
    289297      this->animationState.lastTime = this->animationState.localTime;
    290298    }
  • branches/christmas_branche/src/lib/graphics/importer/md2Model.h

    r6198 r6199  
    116116  int              lastFrame;            //!< last frame of the animation
    117117  int              fps;                  //!< speed: number of frames per second
     118  int              bStoppable;           //!< 1 if the animation is stoppable 0 else
    118119} sAnim;
    119120
     
    134135  int              currentFrame;         //!< the current frame
    135136  int              nextFrame;            //!< the next frame in the list
     137  int              numPlays;             //!< the number of times, this has been played in series
    136138} sAnimState;
    137139
     
    228230
    229231private:
    230   void animate();
     232  void animate(float time);
    231233  void processLighting();
    232234  void interpolate(/*sVec3D* verticesList*/);
Note: See TracChangeset for help on using the changeset viewer.