home *** CD-ROM | disk | FTP | other *** search
/ Quark 3 / Quark3.iso / KATALOG / ARCHIV / TOOL / T001.ZIP / SOURCE.ZIP / animation.cpp next >
Encoding:
C/C++ Source or Header  |  1999-05-03  |  2.0 KB  |  75 lines

  1. /*
  2. Copyright (C) Matthew 'pagan' Baranowski & Sander 'FireStorm' van Rossen
  3.  
  4. This program is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License
  6. as published by the Free Software Foundation; either version 2
  7. of the License, or (at your option) any later version.
  8.  
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. GNU General Public License for more details.
  13.  
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  17. */
  18.  
  19. #include "system.h"
  20. #include "ndictionary.h"
  21. #include "md3gl.h"
  22. #include "md3view.h"
  23.  
  24. double getDoubleTime (void);
  25.  
  26. /*
  27. sets all model frames to 0
  28. */
  29. void rewindAnim()
  30. {
  31.     NodePosition pos;    
  32.     gl_model *model;
  33.  
  34.     for (pos=mdview.modelList->first() ; pos!=NULL ; pos=mdview.modelList->after(pos)) {
  35.         model = (gl_model *)pos->element();
  36.         model->currentFrame = 0;
  37.     }            
  38. //    for (unsigned int i=0; i<mdview.model->Header.Mesh_num ; i++) {
  39. //        mdview.frames[i]=0;        
  40. //    }
  41. }
  42.  
  43. /*
  44. exectues every frame
  45. */
  46. void animation_loop() 
  47.     if (!mdview.animate) return;
  48.     if (mdview.modelList->isEmpty()) return;
  49.  
  50.     NodePosition pos;    
  51.     gl_model *model;
  52.  
  53.     double timeStamp2 = getDoubleTime();
  54.     mdview.frameFrac = (float)((timeStamp2 - mdview.timeStamp1) / mdview.animSpeed);
  55.     
  56.     if (mdview.frameFrac > 1.f) {
  57.         mdview.frameFrac = 0;
  58.         mdview.timeStamp1 = timeStamp2;        
  59.  
  60.             for (pos=mdview.modelList->first() ; pos!=NULL ; pos=mdview.modelList->after(pos)) {
  61.                 model = (gl_model *)pos->element();
  62.                 model->currentFrame++;
  63.                 if (model->currentFrame == model->frameNum) model->currentFrame = 0;                
  64.             }            
  65.             render_mdview();
  66.             swap_buffers();
  67.         
  68.     }
  69.     else if (mdview.interpolate) {
  70.         render_mdview();
  71.         swap_buffers();
  72.     }    
  73. }
  74.