1 2 package com.badlogic.gdx.graphics.g3d.attributes; 3 4 import com.badlogic.gdx.graphics.g3d.Attribute; 5 import com.badlogic.gdx.graphics.g3d.Shader; 6 import com.badlogic.gdx.graphics.g3d.environment.SpotLight; 7 import com.badlogic.gdx.utils.Array; 8 9 /** An {@link Attribute} which can be used to send an {@link Array} of {@link SpotLight} instances to the {@link Shader}. The 10 * lights are stored by reference, the {@link #copy()} or {@link #SpotLightsAttribute(SpotLightsAttribute)} method 11 * will not create new lights. 12 * @author Xoppa */ 13 public class SpotLightsAttribute extends Attribute { 14 public final static String Alias = "spotLights"; 15 public final static long Type = register(Alias); 16 17 public final static boolean is (final long mask) { 18 return (mask & Type) == mask; 19 } 20 21 public final Array<SpotLight> lights; 22 23 public SpotLightsAttribute () { 24 super(Type); 25 lights = new Array<SpotLight>(1); 26 } 27 28 public SpotLightsAttribute (final SpotLightsAttribute copyFrom) { 29 this(); 30 lights.addAll(copyFrom.lights); 31 } 32 33 @Override 34 public SpotLightsAttribute copy () { 35 return new SpotLightsAttribute(this); 36 } 37 38 @Override 39 public int hashCode () { 40 int result = super.hashCode(); 41 for (SpotLight light : lights) 42 result = 1237 * result + (light == null ? 0 : light.hashCode()); 43 return result; 44 } 45 46 @Override 47 public int compareTo (Attribute o) { 48 if (type != o.type) return type < o.type ? -1 : 1; 49 return 0; // FIXME implement comparing 50 } 51 } 52