home *** CD-ROM | disk | FTP | other *** search
/ Quake 'em / QUAKEEM.BIN / quake / programs / qeu03 / f_sprite.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-03  |  3.5 KB  |  99 lines

  1. /*
  2.  * Copyright (C) 1996 by Raphael Quinet.  All rights reserved.
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and
  5.  * its documentation for any purpose and without fee is hereby
  6.  * granted, provided that the above copyright notice appear in all
  7.  * copies and that both that copyright notice and this permission
  8.  * notice appear in supporting documentation.  If more than a few
  9.  * lines of this code are used in a program which displays a copyright
  10.  * notice or credit notice, the following acknowledgment must also be
  11.  * displayed on the same screen: "This product includes software
  12.  * developed by Raphael Quinet for use in the Quake Editing Utilities
  13.  * project."  THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR
  14.  * IMPLIED WARRANTY.
  15.  *
  16.  * More information about the QEU project can be found on the WWW:
  17.  * "http://www.montefiore.ulg.ac.be/~quinet/games/editing.html" or by
  18.  * mail: Raphael Quinet, 9 rue des Martyrs, B-4550 Nandrin, Belgium.
  19.  */
  20.  
  21. #ifndef _F_SPRITE_H_
  22. #define _F_SPRITE_H_
  23. /*
  24.  * F_SPRITE.H - Read and write Quake sprite files.
  25.  */
  26. #include "f_bitmap.h"
  27.  
  28. /*
  29.  * NOTE: There are still some parts of the sprite format which are a
  30.  *       bit strange for me.  I could be wrong for the multi-image
  31.  *       stuff, even if it works rather well.  The test version of
  32.  *       Quake doesn't contain enough "special" sprites like the
  33.  *       torches (s_torch*.spr) and the shots (shots.spr), so I'm
  34.  *       not sure if my guesses are correct.
  35.  */
  36.  
  37. /*
  38.  * The SpriteImage structure defines an individual image in a sprite.
  39.  * This is a flat bitmap with an optional offset.
  40.  */
  41. typedef struct
  42. {
  43.   Int16   xoffset;        /* horizontal offset of picture */
  44.   Int16   yoffset;        /* vertical offset of picture */
  45.   BitMap  bitmap;         /* bitmap data (incl. width and height) */
  46. } SpriteImage;
  47.  
  48. /*
  49.  * (...)
  50.  * If numimages = 0, the frame contains only one image and no data in
  51.  * "unknown".  If numimages > 0, the frame contains several images and
  52.  * each one has a corresponding value in "unknown".
  53.  */
  54. typedef struct
  55. {
  56.   UInt16       numimages; /* number of sub-frames (images) */
  57.   Float32     *unknown;   /*! array of ? (probably scale factors) */
  58.   SpriteImage *images;    /* array of images */
  59. } SpriteFrame;
  60.  
  61. /*
  62.  * The SpriteInfo structure defines a simple sprite.  It is is stored
  63.  * at the beginning of a Quake sprite file (extension *.spr, magic
  64.  * "IDSP") and defines the size of the sprite and its number of
  65.  * frames.
  66.  *
  67.  * Thanks to Olivier Montanuy for the information about the meaning of
  68.  * some of the fields in this structure.
  69.  */
  70. typedef struct SpriteInfo *SpritePtr;
  71. struct SpriteInfo
  72. {
  73.   UInt32       unknown1;   /*! version number?  always 1 */
  74.   UInt32       unknown2;   /*! ? 1 or 2 */
  75.   Float32      radius;     /* maximum radius of all frames */
  76.   UInt16       maxwidth;   /* maximum width of all frames. */
  77.   UInt16       maxheight;  /* maximum height of all frames. */
  78.   UInt16       numframes;  /* number of frames */
  79.   SpriteFrame *frames;     /* array of frames */
  80.   UInt32       unknown4;   /*! ? always 0*/
  81.   UInt32       unknown5;   /*! ? 1 or 0 */
  82. };
  83.  
  84. /*
  85.  * Prototypes.
  86.  */
  87. SpritePtr NewSprite();
  88. void      FreeSprite(SpritePtr sprite);
  89. UInt16    AddSpriteImage(SpritePtr sprite, Int16 framenum, Bool multi,
  90.              Float32 unknown, Int16 xoffset, Int16 yoffset,
  91.              BitMap *bmptr);
  92. SpritePtr ReadSprite(FILE *file, UInt32 offset);
  93. void      DumpSprite(FILE *outf, SpritePtr sprite);
  94.  
  95. UInt32    SaveSprite(FILE *file, SpritePtr sprite);
  96.  
  97. #endif /* _F_SPRITE_H_ */
  98. /* end of file */
  99.