Home | History | Annotate | Download | only in attributes
      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.PointLight;
      7 import com.badlogic.gdx.utils.Array;
      8 
      9 /** An {@link Attribute} which can be used to send an {@link Array} of {@link PointLight} instances to the {@link Shader}. The
     10  * lights are stored by reference, the {@link #copy()} or {@link #PointLightsAttribute(PointLightsAttribute)} method
     11  * will not create new lights.
     12  * @author Xoppa */
     13 public class PointLightsAttribute extends Attribute {
     14 	public final static String Alias = "pointLights";
     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<PointLight> lights;
     22 
     23 	public PointLightsAttribute () {
     24 		super(Type);
     25 		lights = new Array<PointLight>(1);
     26 	}
     27 
     28 	public PointLightsAttribute (final PointLightsAttribute copyFrom) {
     29 		this();
     30 		lights.addAll(copyFrom.lights);
     31 	}
     32 
     33 	@Override
     34 	public PointLightsAttribute copy () {
     35 		return new PointLightsAttribute(this);
     36 	}
     37 
     38 	@Override
     39 	public int hashCode () {
     40 		int result = super.hashCode();
     41 		for (PointLight light : lights)
     42 			result = 1231 * 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