home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Amiga / Jeux / demos / crystalPPC.lha / polytext.h < prev    next >
C/C++ Source or Header  |  1998-01-15  |  2KB  |  88 lines

  1. #ifndef POLYTEXT_H
  2. #define POLYTEXT_H
  3.  
  4. #ifndef MATH3D_H
  5. #include "math3d.h"
  6. #endif
  7.  
  8. class Polygon3D;
  9. class TextureCache;
  10. class Texture;
  11. class Textures;
  12. class PolyPlane;
  13. class Light;
  14. class DynLight;
  15. class Vertex;
  16. class LightMap;
  17.  
  18. class PolyTexture
  19. {
  20.   friend class Polygon3D;
  21.   friend class TextureCache;
  22.  
  23. private:
  24.   PolyTexture* next, * prev; // Linked in texture cache.
  25.   int in_cache;             // TRUE if in cache.
  26.   Polygon3D* polygon;
  27.  
  28.   int texnr;
  29.   Texture* texture;
  30.  
  31.   // Bounding box of corresponding polygon in 2D texture space.
  32.   // Note that the u-axis of this bounding box is made a power of 2 for
  33.   // efficiency reasons.
  34.   int Imin_u, Imin_v, Imax_u, Imax_v;
  35.   int shf_u, and_u;
  36.  
  37.   // New texture data with lighting added. This is an untiled texture
  38.   // so it is more efficient to draw. This texture data is allocated
  39.   // and maintained by the texture cache. If a PolyTexture is in the
  40.   // cache it will be allocated, otherwise it won't.
  41.   int w, h, size;
  42.   unsigned char* tmap;
  43.   int du, dv;
  44.   float fdu, fdv;
  45.  
  46.   // Mipmap size and lightmap to use for lightmap boxes: 16, 8, 4, or 2.
  47.   LightMap* lm;
  48.   int mipmap_size;
  49.  
  50.   // Information for dynamic lights.
  51.   // @@@ Note! Dynamic lights are not functional yet!
  52.   int light_u, light_v;        // Center u,v point for dynamic light.
  53.   int sq_rad;            // Squared radius for dynamic light.
  54.  
  55. public:
  56.   PolyTexture ();
  57.   ~PolyTexture ();
  58.  
  59.   int get_width () { return w; }
  60.   int get_height () { return h; }
  61.   unsigned char* get_bitmap () { return tmap; }
  62.   int get_du () { return du; }
  63.   int get_dv () { return dv; }
  64.   float get_fdu () { return fdu; }
  65.   float get_fdv () { return fdv; }
  66.   int get_shf_u () { return shf_u; }
  67.   int get_and_u () { return and_u; }
  68.  
  69.   void set_polygon (Polygon3D* p) { polygon = p; }
  70.  
  71.   void set_texnr (Textures* textures, int texnr);
  72.   int get_texnr () { return texnr; }
  73.   Texture* get_texture () { return texture; }
  74.  
  75.   int get_light_u () { return light_u; }
  76.   int get_light_v () { return light_v; }
  77.   int get_sq_rad () { return sq_rad; }
  78.  
  79.   void create_lighted_texture (Textures* textures);
  80.   void create_bounding_texture_box ();
  81.  
  82.   void shine (Light* light);
  83.   void setup_dyn_light (DynLight* light, float sq_dist);
  84. };
  85.  
  86. #endif /*POLYTEXT_H*/
  87.  
  88.