/*******************************************************************************
 * Copyright 2011 See AUTHORS file.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/

package com.badlogic.gdx.graphics.g3d.environment;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector3;

/** Note that the default shader doesn't support point lights, you'll have to supply your own shader to use this class.
 * @author realitix */
public class SpotLight extends BaseLight {
	public final Vector3 position = new Vector3();
	public final Vector3 direction = new Vector3();
	public float intensity;
	public float cutoffAngle;

	public SpotLight set (final SpotLight copyFrom) {
		return set(copyFrom.color, copyFrom.position, copyFrom.direction, copyFrom.intensity, copyFrom.cutoffAngle);
	}

	public SpotLight set (final Color color, final Vector3 position, final Vector3 direction, final float intensity,
		final float cutoffAngle) {
		if (color != null) this.color.set(color);
		if (position != null) this.position.set(position);
		if (direction != null) this.direction.set(direction).nor();
		this.intensity = intensity;
		this.cutoffAngle = cutoffAngle;
		return this;
	}

	public SpotLight set (final float r, final float g, final float b, final Vector3 position, final Vector3 direction,
		final float intensity, final float cutoffAngle) {
		this.color.set(r, g, b, 1f);
		if (position != null) this.position.set(position);
		if (direction != null) this.direction.set(direction).nor();
		this.intensity = intensity;
		this.cutoffAngle = cutoffAngle;
		return this;
	}

	public SpotLight set (final Color color, final float posX, final float posY, final float posZ, final float dirX,
		final float dirY, final float dirZ, final float intensity, final float cutoffAngle) {
		if (color != null) this.color.set(color);
		this.position.set(posX, posY, posZ);
		this.direction.set(dirX, dirY, dirZ).nor();
		this.intensity = intensity;
		this.cutoffAngle = cutoffAngle;
		return this;
	}

	public SpotLight set (final float r, final float g, final float b, final float posX, final float posY, final float posZ,
		final float dirX, final float dirY, final float dirZ, final float intensity, final float cutoffAngle) {
		this.color.set(r, g, b, 1f);
		this.position.set(posX, posY, posZ);
		this.direction.set(dirX, dirY, dirZ).nor();
		this.intensity = intensity;
		this.cutoffAngle = cutoffAngle;
		return this;
	}

	public SpotLight setTarget (final Vector3 target) {
		direction.set(target).sub(position).nor();
		return this;
	}

	@Override
	public boolean equals (Object obj) {
		return (obj instanceof SpotLight) ? equals((SpotLight)obj) : false;
	}

	public boolean equals (SpotLight other) {
		return (other != null && (other == this || (color.equals(other.color) && position.equals(other.position)
			&& direction.equals(other.direction) && MathUtils.isEqual(intensity, other.intensity) && MathUtils.isEqual(cutoffAngle,
			other.cutoffAngle))));
	}
}

@@ -112,18 +112,17 @@
 file.%0A *
- 
 %0A
+
  * Licen
@@ -293,17 +293,16 @@
 se at%0A *
- 
 %0A *   ht
@@ -344,17 +344,16 @@
 E-2.0%0A *
- 
 %0A * Unle
@@ -972,12 +972,11 @@
 ort 
+s
 po
-in
 t li
@@ -1252,16 +1252,40 @@
 ffAngle;
+%0A%09public float exponent;
 %0A%0A%09publi
@@ -1437,16 +1437,35 @@
 offAngle
+, copyFrom.exponent
 );%0A%09%7D%0A%0A%09
@@ -1594,32 +1594,54 @@
 loat cutoffAngle
+, final float exponent
 ) %7B%0A%09%09if (color 
@@ -1843,32 +1843,60 @@
  = cutoffAngle;%0A
+%09%09this.exponent = exponent;%0A
 %09%09return this;%0A%09
@@ -2055,32 +2055,54 @@
 loat cutoffAngle
+, final float exponent
 ) %7B%0A%09%09this.color
@@ -2291,32 +2291,60 @@
  = cutoffAngle;%0A
+%09%09this.exponent = exponent;%0A
 %09%09return this;%0A%09
@@ -2540,24 +2540,46 @@
  cutoffAngle
+, final float exponent
 ) %7B%0A%09%09if (co
@@ -2755,32 +2755,60 @@
  = cutoffAngle;%0A
+%09%09this.exponent = exponent;%0A
 %09%09return this;%0A%09
@@ -3034,16 +3034,38 @@
 offAngle
+, final float exponent
 ) %7B%0A%09%09th
@@ -3240,16 +3240,44 @@
 fAngle;%0A
+%09%09this.exponent = exponent;%0A
 %09%09return
@@ -3803,16 +3803,17 @@
 gle,%0A%09%09%09
+%09
 other.cu
@@ -3822,16 +3822,64 @@
 ffAngle)
+ && MathUtils.isEqual(exponent, other.exponent) 
 )));%0A%09%7D%0A

Add exponent to SpotLight.