home *** CD-ROM | disk | FTP | other *** search
/ Quark 3 / Quark3.iso / KATALOG / ARCHIV / TOOL / T001.ZIP / SOURCE.ZIP / md3view.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-23  |  5.2 KB  |  184 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. /*! 
  20. md3view.h - the header file holding the platform independent viewer interface.
  21. the structure MD3ViewState holds all of the runtime global data needed by the viewer
  22. holds most viewer interaction constants and mode enumerations. 
  23. this should be the only file included by system dependent code, but that rule is flexible.
  24. */
  25.  
  26. #ifndef _MD3_VIEW_H_
  27. #define _MD3_VIEW_H_
  28.  
  29. //this is the caption name & the name in the about box
  30. #define FILENAME "MD3View v1.51"
  31.  
  32. /*! 
  33. enumeration of various display modes that the ogl rendering engine supports. line refers
  34. to wire frame, fill to flat shaded polygons, and textured is self explanatory. 
  35. */
  36. enum DrawMode {
  37.     DRAW_LINE,
  38.     DRAW_FILL,
  39.     DRAW_TEXTURE
  40. };
  41.  
  42. /*! 
  43. texture modes supported by the engine, translates loosely to TEX_FAST being GL_NEAREST texture
  44. fileter with fastest perspective correction. used mostly but he software driver. unfiltered is GL_NEAREST
  45. with full perspective correction and filtered uses bilinear filetering.
  46. */
  47. enum TextureMode {
  48.     TEX_FAST,
  49.     TEX_UNFILTERED,
  50.     TEX_FILTERED
  51. };
  52.  
  53. /*!
  54. MD3ViewState - main global structure that holds all the global variables need by the viewer at runtime.
  55. is used for everythign and everwhere. 
  56. */
  57.  
  58. typedef struct
  59. {    
  60.     float            zPos;
  61.     float            rotAngleX, rotAngleY;    
  62.     double            animSpeed;
  63.     double            timeStamp1;
  64.     float           frameFrac;
  65.     bool            hasAnimation;
  66.     bool            interpolate;
  67.     bool            done;
  68.     bool            animate;
  69.     
  70. /*    MD3GL        *    glmdl;
  71.     MD3            *    model;
  72.     unsigned int*    frames;
  73. */
  74.     NodeDictionary  textureRes;                 // map of texture names to TextureGL data, stores texture resources
  75.     unsigned int    topTextureBind;             // simple index to keep track of texture bindings
  76.  
  77.     NodeSequence    modelList;                   // list of gl_meshes loaded
  78.     gl_model       *baseModel;                  // base model of a tag hierarchy
  79.  
  80.     DrawMode        drawMode;
  81.     TextureMode     texMode;
  82.  
  83.     GLenum          faceSide;
  84.  
  85.     char            basepath[64];
  86.  
  87. #ifdef WIN32
  88.     HWND            hwnd;
  89.     HDC                hdc;
  90.     HGLRC            glrc;
  91. #endif
  92.  
  93. } MDViewState;
  94.  
  95. const double ANIM_SLOWER = 1.3;
  96. const double ANIM_FASTER = 0.9;
  97. const float MOUSE_ROT_SCALE  = 0.5f;
  98. const float MOUSE_ZPOS_SCALE = 0.1f;
  99.  
  100. extern MDViewState mdview;
  101.  
  102.  
  103. #ifdef WIN32
  104. #include <windows.h>
  105. /*!
  106. platform independent key enumeration to drag functions
  107. */
  108. enum mkey_enum {
  109.     KEY_LBUTTON = MK_LBUTTON,
  110.     KEY_RBUTTON = MK_RBUTTON,
  111.     KEY_MBUTTON = MK_MBUTTON    
  112. };
  113. #endif
  114.  
  115. /*! initializes the mdview structures, should be called at startup before the gui is created */
  116. void init_mdview();
  117.  
  118. /*! initializes the gl structures should be called immiedietly after opengl context has been created */
  119. bool init_mdview_gl();
  120.  
  121. /*! called when window is resized to update gl matrices, actually defined in md3gl.cpp */
  122. void set_windowSize( int x, int y );
  123.  
  124. /*! called to render the main viewer screen */
  125. void render_mdview();
  126.  
  127. /*! commands to handle mouse dragging, uses key_flags defines above */
  128. void start_drag( mkey_enum keyFlags, int x, int y );
  129. void drag(  mkey_enum keyFlags, int x, int y );
  130. void end_drag(  mkey_enum keyFlags, int x, int y );
  131.  
  132. /*! 
  133. loads a model into the file, called by a file open dialog box 
  134. */
  135. bool loadmdl( char *filename );
  136.  
  137. /*
  138. writes the current mesh frame to a raw file
  139. */
  140. void write_baseModelToRaw( char *fname );
  141.  
  142. /*
  143. frees data for shutdown, call this only as the last thing before exiting or bad thigns will happen
  144. */
  145. void shutdown_mdviewdata();
  146.  
  147. /*
  148. frees all mdviewdata, and effectively resets the data state back to init
  149. */
  150. void free_mdviewdata();
  151.  
  152.  
  153. /*! rewinds the animation, called by menu or key callbacks */
  154. void rewindAnim();
  155.  
  156. void animation_loop();
  157.  
  158. /*
  159. frees a model that has been loaded before by loadmdl_totag into the modelptr slot
  160. */
  161. void freemdl_fromtag( GLMODEL_DBLPTR modelptr );
  162.  
  163. /*
  164. loads a model into the slot pointed to by dblptr
  165. */
  166. void loadmdl_totag( char *fullName, GLMODEL_DBLPTR dblptr );
  167.  
  168. /*
  169. loads a new costum skin and sets all the models to it
  170. */
  171. void importNewSkin( char *fullName );
  172.  
  173. #define ABOUT_TEXT          "\n\n " FILENAME "\t\n\n" \
  174.                             "A q3test model viewer\t\n\n" \
  175.                             "started by Sander 'FireStorm' van Rossen\t\n" \
  176.                             "& Matthew 'pagan' Baranowski\t\n\n" \
  177.                             "a Mental Vortex production\t\n\n" \
  178.                             "For more information go to: \t\n" \
  179.                             "mvwebsite.hypermart.net\t\n\n" \
  180.                             "SOURCE CODE IS FREELY AVAILABLE!!!\n\n"
  181.                             
  182.  
  183. #endif
  184.