|
@@ -4,8 +4,9 @@ import org.lwjgl.util.vector.Vector2f;
|
|
|
import org.lwjgl.util.vector.Vector3f;
|
|
|
|
|
|
import eu.tankernn.gameEngine.entities.Camera;
|
|
|
+import eu.tankernn.gameEngine.entities.ILight;
|
|
|
|
|
|
-public class Sun implements IParticle {
|
|
|
+public class Sun implements IParticle, ILight {
|
|
|
|
|
|
private static final float SUN_DIS = 50;// fairly arbitrary - but make sure
|
|
|
// it doesn't go behind skybox
|
|
@@ -13,12 +14,13 @@ public class Sun implements IParticle {
|
|
|
private final ParticleTexture texture;
|
|
|
|
|
|
private Vector3f lightDirection = new Vector3f(0, -1, 0);
|
|
|
- private Vector3f position;
|
|
|
+ private Vector3f position, color;
|
|
|
private float scale;
|
|
|
|
|
|
- public Sun(ParticleTexture texture, float scale) {
|
|
|
+ public Sun(ParticleTexture texture, float scale, Vector3f color) {
|
|
|
this.texture = texture;
|
|
|
this.scale = scale;
|
|
|
+ this.color = color;
|
|
|
}
|
|
|
|
|
|
public void setScale(float scale) {
|
|
@@ -41,7 +43,7 @@ public class Sun implements IParticle {
|
|
|
public float getScale() {
|
|
|
return scale;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public Vector3f getPosition() {
|
|
|
return position;
|
|
|
}
|
|
@@ -51,10 +53,11 @@ public class Sun implements IParticle {
|
|
|
* distance of the sun from the camera is fairly arbitrary, although care
|
|
|
* should be taken to ensure it doesn't get rendered outside the skybox.
|
|
|
*
|
|
|
- * @param camPos - The camera's position.
|
|
|
+ * @param camPos
|
|
|
+ * - The camera's position.
|
|
|
* @return The 3D world position of the sun.
|
|
|
*/
|
|
|
- public Vector3f calculateWorldPosition(Vector3f camPos) {
|
|
|
+ private Vector3f calculateWorldPosition(Vector3f camPos) {
|
|
|
Vector3f sunPos = new Vector3f(lightDirection);
|
|
|
sunPos.negate();
|
|
|
sunPos.scale(SUN_DIS);
|
|
@@ -87,4 +90,14 @@ public class Sun implements IParticle {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Vector3f getColor() {
|
|
|
+ return color;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Vector3f getAttenuation() {
|
|
|
+ return new Vector3f(1, 0, 0);
|
|
|
+ }
|
|
|
+
|
|
|
}
|