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

  1. #ifndef LIGHTMAP_H
  2. #define LIGHTMAP_H
  3.  
  4. class PolyTexture;
  5. class Polygon3D;
  6.  
  7. // There are three possible levels of mipmapping accuracy.
  8. // This accuracy has nothing to do with the quality of the
  9. // mipmapped texture itself but it controls the quality
  10. // of the shadows.
  11. //
  12. // With MIPMAP_SHADOW_ACCURATE the shadows
  13. // are 'perfect' at all distances. Even polygons that are
  14. // far away (mipmap level 3) will have correct shadows.
  15. // The disadvantage of this is that this is slower for the
  16. // texture cache. It will not influence stationary frame rate,
  17. // but far away textures will take somewhat longer to load
  18. // in the cache. Once in the cache, there is no difference.
  19. //
  20. // MIPMAP_SHADOW_INACCURATE gives the fastest way for the
  21. // texture cache but shadows will be noticeably worse when
  22. // polygons gets farther away. This is rather ugly. This
  23. // mode is included only so that you can see the difference :-)
  24. //
  25. // MIPMAP_SHADOW_REASONABLE is somewhat in between. Polygons
  26. // far away will have reasonably accurate shadows (not as
  27. // accurate as with MIPMAP_SHADOW_ACCURATE) and they will
  28. // draw somewhat faster (not as fast as with MIPMAP_SHADOW_INACCURATE).
  29. //
  30. // Note that none of these options affect textures that are
  31. // really close by.
  32. //
  33. // Note that changing this option (by pressing 'alt-t') will only
  34. // be visible when a texture is removed from the texture cache and
  35. // reinserted again. The texture cache can be cleared by pressing 'r'.
  36.  
  37. #define MIPMAP_SHADOW_ACCURATE 0
  38. #define MIPMAP_SHADOW_INACCURATE 1
  39. #define MIPMAP_SHADOW_REASONABLE 2
  40.  
  41. class LightMap
  42. {
  43.   friend class PolyTexture;
  44.  
  45. private:
  46.   unsigned char* light_map;
  47.   unsigned char* red_light_map;
  48.   unsigned char* blue_light_map;
  49.   int size;
  50.  
  51. public:
  52.   static int setting;    // One of MIPMAP_SHADOW_...
  53.  
  54. public:
  55.   LightMap ();
  56.   ~LightMap ();
  57.  
  58.   unsigned char* get_light_map () { return light_map; }
  59.   unsigned char* get_red_light_map () { return red_light_map; }
  60.   unsigned char* get_blue_light_map () { return blue_light_map; }
  61.  
  62.   // Allocate the lightmap. 'w' and 'h' are the size of the
  63.   // bounding box in lightmap space.
  64.   void alloc (int w, int h, Polygon3D* poly);
  65.  
  66.   // Allocate this lightmap by mipmapping the given source
  67.   // lightmap.
  68.   void mipmap_lightmap (int w, int h, LightMap* source, int w2, int h2);
  69. };
  70.  
  71. #endif /*LIGHTMAP_H*/
  72.  
  73.