From 25ca07d3d2330813a56e05d37fdc30742cd94ec5 Mon Sep 17 00:00:00 2001 From: Matt Benson Date: Sun, 26 Jul 2015 18:26:22 -0500 Subject: [PATCH 1/3] light constructors --- .../java/com/jme3/light/AmbientLight.java | 10 +++++- .../java/com/jme3/light/DirectionalLight.java | 15 ++++++++- .../src/main/java/com/jme3/light/Light.java | 11 +++++-- .../main/java/com/jme3/light/PointLight.java | 15 ++++++++- .../main/java/com/jme3/light/SpotLight.java | 32 +++++++++++++------ 5 files changed, 69 insertions(+), 14 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/light/AmbientLight.java b/jme3-core/src/main/java/com/jme3/light/AmbientLight.java index e147c6590..8dd5f9266 100644 --- a/jme3-core/src/main/java/com/jme3/light/AmbientLight.java +++ b/jme3-core/src/main/java/com/jme3/light/AmbientLight.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2012, 2015 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,6 +32,7 @@ package com.jme3.light; import com.jme3.bounding.BoundingBox; +import com.jme3.math.ColorRGBA; import com.jme3.math.Vector3f; import com.jme3.renderer.Camera; import com.jme3.scene.Spatial; @@ -49,6 +50,13 @@ import com.jme3.util.TempVars; */ public class AmbientLight extends Light { + public AmbientLight() { + } + + public AmbientLight(ColorRGBA color) { + super(color); + } + @Override public boolean intersectsBox(BoundingBox box, TempVars vars) { return true; diff --git a/jme3-core/src/main/java/com/jme3/light/DirectionalLight.java b/jme3-core/src/main/java/com/jme3/light/DirectionalLight.java index c4258a67f..31e6e34a9 100644 --- a/jme3-core/src/main/java/com/jme3/light/DirectionalLight.java +++ b/jme3-core/src/main/java/com/jme3/light/DirectionalLight.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2012, 2015 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -36,6 +36,7 @@ import com.jme3.export.InputCapsule; import com.jme3.export.JmeExporter; import com.jme3.export.JmeImporter; import com.jme3.export.OutputCapsule; +import com.jme3.math.ColorRGBA; import com.jme3.math.Vector3f; import com.jme3.renderer.Camera; import com.jme3.scene.Spatial; @@ -53,6 +54,18 @@ public class DirectionalLight extends Light { protected Vector3f direction = new Vector3f(0f, -1f, 0f); + public DirectionalLight() { + } + + public DirectionalLight(Vector3f direction) { + setDirection(direction); + } + + public DirectionalLight(Vector3f direction, ColorRGBA color) { + super(color); + setDirection(direction); + } + @Override public void computeLastDistance(Spatial owner) { lastDistance = 0; // directional lights are always closest to their owner diff --git a/jme3-core/src/main/java/com/jme3/light/Light.java b/jme3-core/src/main/java/com/jme3/light/Light.java index 4217e1b62..b1c48be7a 100644 --- a/jme3-core/src/main/java/com/jme3/light/Light.java +++ b/jme3-core/src/main/java/com/jme3/light/Light.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2012, 2015 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -94,7 +94,7 @@ public abstract class Light implements Savable, Cloneable { } } - protected ColorRGBA color = new ColorRGBA(1f,1f,1f,1f); + protected ColorRGBA color = new ColorRGBA(ColorRGBA.White); /** * Used in LightList for caching the distance @@ -115,6 +115,13 @@ public abstract class Light implements Savable, Cloneable { boolean frustumCheckNeeded = true; boolean intersectsFrustum = false; + protected Light() { + } + + protected Light(ColorRGBA color) { + setColor(color); + } + /** * Returns the color of the light. * diff --git a/jme3-core/src/main/java/com/jme3/light/PointLight.java b/jme3-core/src/main/java/com/jme3/light/PointLight.java index 55a129275..50a89698c 100644 --- a/jme3-core/src/main/java/com/jme3/light/PointLight.java +++ b/jme3-core/src/main/java/com/jme3/light/PointLight.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2012, 2015 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -38,6 +38,7 @@ import com.jme3.export.InputCapsule; import com.jme3.export.JmeExporter; import com.jme3.export.JmeImporter; import com.jme3.export.OutputCapsule; +import com.jme3.math.ColorRGBA; import com.jme3.math.FastMath; import com.jme3.math.Plane; import com.jme3.math.Vector3f; @@ -62,6 +63,18 @@ public class PointLight extends Light { protected float radius = 0; protected float invRadius = 0; + public PointLight() { + } + + public PointLight(Vector3f position) { + setPosition(position); + } + + public PointLight(Vector3f position, ColorRGBA color) { + super(color); + setPosition(position); + } + @Override public void computeLastDistance(Spatial owner) { if (owner.getWorldBound() != null) { diff --git a/jme3-core/src/main/java/com/jme3/light/SpotLight.java b/jme3-core/src/main/java/com/jme3/light/SpotLight.java index e6443df7c..2eb69a473 100644 --- a/jme3-core/src/main/java/com/jme3/light/SpotLight.java +++ b/jme3-core/src/main/java/com/jme3/light/SpotLight.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2012, 2015 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -34,6 +34,7 @@ package com.jme3.light; import com.jme3.bounding.BoundingBox; import com.jme3.bounding.BoundingVolume; import com.jme3.export.*; +import com.jme3.math.ColorRGBA; import com.jme3.math.FastMath; import com.jme3.math.Plane; import com.jme3.math.Vector3f; @@ -44,27 +45,27 @@ import java.io.IOException; /** * Represents a spot light. - * A spot light emmit a cone of light from a position and in a direction. - * It can be used to fake torch lights or car's lights. + * A spot light emits a cone of light from a position and in a direction. + * It can be used to fake torch lights or cars' lights. *

* In addition to a position and a direction, spot lights also have a range which * can be used to attenuate the influence of the light depending on the - * distance between the light and the effected object. + * distance between the light and the affected object. * Also the angle of the cone can be tweaked by changing the spot inner angle and the spot outer angle. - * the spot inner angle determin the cone of light where light has full influence. - * the spot outer angle determin the cone global cone of light of the spot light. - * the light intensity slowly decrease between the inner cone and the outer cone. + * the spot inner angle determines the cone of light where light has full influence. + * the spot outer angle determines the cone global cone of light of the spot light. + * the light intensity slowly decreases between the inner cone and the outer cone. * @author Nehon */ public class SpotLight extends Light { protected Vector3f position = new Vector3f(); - protected Vector3f direction = new Vector3f(0,-1,0); + protected Vector3f direction = new Vector3f(0, -1, 0); protected float spotInnerAngle = FastMath.QUARTER_PI / 8; protected float spotOuterAngle = FastMath.QUARTER_PI / 6; protected float spotRange = 100; protected float invSpotRange = 1f / 100; - protected float packedAngleCos=0; + protected float packedAngleCos = 0; protected float outerAngleCosSqr, outerAngleSinSqr; protected float outerAngleSinRcp, outerAngleSin, outerAngleCos; @@ -74,6 +75,19 @@ public class SpotLight extends Light { computeAngleParameters(); } + public SpotLight(Vector3f position, Vector3f direction) { + this(); + setPosition(position); + setDirection(direction); + } + + public SpotLight(Vector3f position, Vector3f direction, ColorRGBA color) { + super(color); + computeAngleParameters(); + setPosition(position); + setDirection(direction); + } + private void computeAngleParameters() { float innerCos = FastMath.cos(spotInnerAngle); outerAngleCos = FastMath.cos(spotOuterAngle); From 168e1755ffb442291b122d83815709bae4043d3b Mon Sep 17 00:00:00 2001 From: Nehon Date: Sat, 29 Aug 2015 12:56:26 +0200 Subject: [PATCH 2/3] Added some more constructors to SpotLight and PointLight, also added javadoc to all lights constructors. --- .../java/com/jme3/light/DirectionalLight.java | 14 +++- .../main/java/com/jme3/light/PointLight.java | 40 +++++++++- .../main/java/com/jme3/light/SpotLight.java | 76 ++++++++++++++++++- 3 files changed, 123 insertions(+), 7 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/light/DirectionalLight.java b/jme3-core/src/main/java/com/jme3/light/DirectionalLight.java index 31e6e34a9..87fbf695a 100644 --- a/jme3-core/src/main/java/com/jme3/light/DirectionalLight.java +++ b/jme3-core/src/main/java/com/jme3/light/DirectionalLight.java @@ -54,13 +54,25 @@ public class DirectionalLight extends Light { protected Vector3f direction = new Vector3f(0f, -1f, 0f); + /** + * Creates a DirectionalLight + */ public DirectionalLight() { } + /** + * Creates a DirectionalLight with the given direction + * @param direction the light's direction + */ public DirectionalLight(Vector3f direction) { setDirection(direction); } + /** + * Creates a DirectionalLight with the given direction and the given color + * @param direction the light's direction + * @param color the light's color + */ public DirectionalLight(Vector3f direction, ColorRGBA color) { super(color); setDirection(direction); @@ -90,7 +102,7 @@ public class DirectionalLight extends Light { * * @param dir the direction of the light. */ - public void setDirection(Vector3f dir){ + public final void setDirection(Vector3f dir){ direction.set(dir); if (!direction.isUnitVector()) { direction.normalizeLocal(); diff --git a/jme3-core/src/main/java/com/jme3/light/PointLight.java b/jme3-core/src/main/java/com/jme3/light/PointLight.java index 676c35282..ff3b3295f 100644 --- a/jme3-core/src/main/java/com/jme3/light/PointLight.java +++ b/jme3-core/src/main/java/com/jme3/light/PointLight.java @@ -32,7 +32,6 @@ package com.jme3.light; import com.jme3.bounding.BoundingBox; -import com.jme3.bounding.BoundingSphere; import com.jme3.bounding.BoundingVolume; import com.jme3.export.InputCapsule; import com.jme3.export.JmeExporter; @@ -40,7 +39,6 @@ import com.jme3.export.JmeImporter; import com.jme3.export.OutputCapsule; import com.jme3.math.ColorRGBA; import com.jme3.math.FastMath; -import com.jme3.math.Plane; import com.jme3.math.Vector3f; import com.jme3.renderer.Camera; import com.jme3.scene.Spatial; @@ -63,17 +61,51 @@ public class PointLight extends Light { protected float radius = 0; protected float invRadius = 0; + /** + * Creates a PointLight + */ public PointLight() { } + /** + * Creates a PointLight at the given position + * @param position the position in world space + */ public PointLight(Vector3f position) { setPosition(position); } + /** + * Creates a PointLight at the given position and with the given color + * @param position the position in world space + * @param color the light color + */ public PointLight(Vector3f position, ColorRGBA color) { super(color); setPosition(position); } + + /** + * Creates a PointLight at the given position, with the given color and the + * given radius + * @param position the position in world space + * @param color the light color + * @param radius the light radius + */ + public PointLight(Vector3f position, ColorRGBA color, float radius) { + this(position, color); + setRadius(radius); + } + + /** + * Creates a PointLight at the given position, with the given radius + * @param position the position in world space + * @param radius the light radius + */ + public PointLight(Vector3f position, float radius) { + this(position); + setRadius(radius); + } @Override public void computeLastDistance(Spatial owner) { @@ -101,7 +133,7 @@ public class PointLight extends Light { * * @param position the world space position of the light. */ - public void setPosition(Vector3f position) { + public final void setPosition(Vector3f position) { this.position.set(position); } @@ -128,7 +160,7 @@ public class PointLight extends Light { * * @throws IllegalArgumentException If radius is negative */ - public void setRadius(float radius) { + public final void setRadius(float radius) { if (radius < 0) { throw new IllegalArgumentException("Light radius cannot be negative"); } diff --git a/jme3-core/src/main/java/com/jme3/light/SpotLight.java b/jme3-core/src/main/java/com/jme3/light/SpotLight.java index 2eb69a473..9b551d3d8 100644 --- a/jme3-core/src/main/java/com/jme3/light/SpotLight.java +++ b/jme3-core/src/main/java/com/jme3/light/SpotLight.java @@ -70,23 +70,95 @@ public class SpotLight extends Light { protected float outerAngleCosSqr, outerAngleSinSqr; protected float outerAngleSinRcp, outerAngleSin, outerAngleCos; + /** + * Creates a SpotLight. + */ public SpotLight() { super(); computeAngleParameters(); } + /** + * Creates a SpotLight at the given position and with the given direction. + * @param position the position in world space. + * @param direction the direction of the light. + */ public SpotLight(Vector3f position, Vector3f direction) { this(); setPosition(position); setDirection(direction); } + + /** + * Creates a SpotLight at the given position, with the given direction, and the + * given range. + * @param position the position in world space. + * @param direction the direction of the light. + * @param range the spot light range + */ + public SpotLight(Vector3f position, Vector3f direction, float range) { + this(); + setPosition(position); + setDirection(direction); + this.spotRange = range; + } + /** + * Creates a SpotLight at the given position, with the given direction and + * the given color. + * @param position the position in world space. + * @param direction the direction of the light. + * @param color the light's color. + */ public SpotLight(Vector3f position, Vector3f direction, ColorRGBA color) { super(color); computeAngleParameters(); setPosition(position); setDirection(direction); } + + + /** + * Creates a SpotLight at the given position, with the given direction, + * the given range and the given color. + * @param position the position in world space. + * @param direction the direction of the light. + * @param range the spot light range + * @param color the light's color. + */ + public SpotLight(Vector3f position, Vector3f direction, float range, ColorRGBA color) { + super(color); + computeAngleParameters(); + setPosition(position); + setDirection(direction); + this.spotRange = range; + } + + /** + * Creates a SpotLight at the given position, with the given direction, + * the given color and the given inner and outer angles + * (controls the falloff of the light) + * + * @param position the position in world space. + * @param direction the direction of the light. + * @param range the spot light range + * @param color the light's color. + * @param innerAngle the inner angle of the spot light. + * @param outerAngle the outer angle of the spot light. + * + * @see SpotLight#setSpotInnerAngle(float) + * @see SpotLight#setSpotOuterAngle(float) + */ + public SpotLight(Vector3f position, Vector3f direction, float range, ColorRGBA color, float innerAngle, float outerAngle) { + super(color); + this.spotInnerAngle = innerAngle; + this.spotOuterAngle = outerAngle; + computeAngleParameters(); + setPosition(position); + setDirection(direction); + this.spotRange = range; + } + private void computeAngleParameters() { float innerCos = FastMath.cos(spotInnerAngle); @@ -203,7 +275,7 @@ public class SpotLight extends Light { return direction; } - public void setDirection(Vector3f direction) { + public final void setDirection(Vector3f direction) { this.direction.set(direction); } @@ -211,7 +283,7 @@ public class SpotLight extends Light { return position; } - public void setPosition(Vector3f position) { + public final void setPosition(Vector3f position) { this.position.set(position); } From 2f6388c13b13e95baca3f330e1195074bac6c0a6 Mon Sep 17 00:00:00 2001 From: Kirill Vainer Date: Sat, 29 Aug 2015 12:32:54 -0400 Subject: [PATCH 3/3] travis-ci: fix build failures on PRs / branches --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bdc1336f7..fb7588262 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,7 @@ install: script: - ./gradlew check - ./gradlew createZipDistribution - - "[ $TRAVIS_BRANCH == 'master' ] && [ $TRAVIS_PULL_REQUEST == 'false' ] && ./gradlew uploadArchives;" + - [ $TRAVIS_BRANCH == 'master' ] && [ $TRAVIS_PULL_REQUEST == 'false' ] && ./gradlew uploadArchives || : before_deploy: - export RELEASE_DIST=$(ls build/distributions/*.zip)