Advertisement
Guest User

rr.LightsAndColors.java

a guest
Sep 26th, 2012
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.54 KB | None | 0 0
  1. package rr;
  2.  
  3. import i.BppMode;
  4. import i.Main;
  5.  
  6. /**
  7.  *   Combined colormap and light LUTs.
  8.  *   Used for z-depth cuing per column/row,
  9.  *   and other lighting effects (sector ambient, flash).
  10.  *  
  11.  * @author velktron
  12.  *
  13.  * @param <V> The data type of the SCREEN
  14.  */
  15.  
  16. public class LightsAndColors<V> {
  17.    
  18.     /** For HiColor, these are, effectively, a bunch of 555 RGB palettes,
  19.      *  for TrueColor they are a bunch of 32-bit ARGB palettes etc.
  20.      *  Only for indexed they represent index remappings.  
  21.      */
  22.  
  23.     /** "peg" this to the one from RendererData */
  24.     public V[] colormaps;
  25.  
  26.     /** lighttable_t** */
  27.     public V[] walllights;
  28.  
  29.     /** Use in conjunction with pfixedcolormap */
  30.     public V fixedcolormap;
  31.     /** Use in conjunction with fixedcolormap[] */
  32.     public int pfixedcolormap;
  33.    
  34.     /**
  35.      * Color tables for different players, translate a limited part to another
  36.      * (color ramps used for suit colors).
  37.      */
  38.  
  39.     public byte[][] translationtables;
  40.    
  41.    
  42.     /** Bits representing color levels. 5 for 32. */
  43.     public static final int LBITS;
  44.    
  45.     /**
  46.      * These two are tied by an inverse relationship. E.g. 256 levels, 0 shift
  47.      * 128 levels, 1 shift ...etc... 16 levels, 4 shift (default). Or even less,
  48.      * if you want.
  49.      *
  50.      * By setting it to the max however you get smoother light and get rid of
  51.      * lightsegshift globally, too. Of course, by increasing the number of light
  52.      * levels, you also put more memory pressure, and due to their being only
  53.      * 256 colors to begin with, visually, there won't be many differences.
  54.      */
  55.    
  56.      
  57.     public static final int LIGHTLEVELS;
  58.     public static final int LIGHTSEGSHIFT;
  59.    
  60.    
  61.   /** Number of diminishing brightness levels.
  62.      There a 0-31, i.e. 32 LUT in the COLORMAP lump.
  63.      TODO: how can those be distinct from the light levels???
  64.      */    
  65.    
  66.   public static final int  NUMCOLORMAPS;
  67.  
  68.    
  69.     // These are a bit more tricky to figure out though.
  70.  
  71.     /** Maximum index used for light levels of sprites. In practice,
  72.      *  it's capped by the number of light levels???
  73.      *  
  74.      *  Normally set to 48 (32 +16???)
  75.      */
  76.    
  77.     public static final int MAXLIGHTSCALE;
  78.    
  79.     /** Used to scale brightness of walls and sprites. Their "scale" is shifted by
  80.      *  this amount, and this results in an index, which is capped by MAXLIGHTSCALE.
  81.      *  Normally it's 12 for 32 levels, so 11 for 64, 10 for 128, ans 9 for 256.
  82.      *  
  83.      */
  84.     public static final int LIGHTSCALESHIFT;
  85.    
  86.     /** This one seems arbitrary. Will auto-fit to 128 possible levels? */
  87.     public static final int MAXLIGHTZ = 256;
  88.    
  89.     /** Normally 20 for 32 colormaps, applied to distance.
  90.      * Formula: 25-LBITS
  91.      *  
  92.      */
  93.     public static final int LIGHTZSHIFT;
  94.  
  95.     public V[][] scalelight;
  96.     public V[] scalelightfixed;
  97.     public V[][] zlight;
  98.     public V[] spritelights;
  99.  
  100.     // bumped light from gun blasts
  101.     public int extralight;
  102.    
  103.     static {
  104.  
  105.         // Horrible hack.
  106.        
  107.         switch (Main.bpp){
  108.         case Indexed:
  109.         case HiColor:
  110.             LBITS=5;
  111.             break;
  112.         case TrueColor:
  113.             LBITS=8;
  114.             break;
  115.         default:
  116.             LBITS=5;
  117.             break;
  118.         }
  119.        
  120.         LIGHTLEVELS = 1<<LBITS;
  121.         LIGHTSEGSHIFT = 8-LBITS;
  122.         NUMCOLORMAPS=     LIGHTLEVELS;
  123.         MAXLIGHTSCALE = LIGHTLEVELS+LIGHTLEVELS/2;
  124.         LIGHTSCALESHIFT = 17-LBITS;
  125.         LIGHTZSHIFT=25-LBITS;
  126.     }
  127.    
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement