light constructors
This commit is contained in:
parent
89fe2e57be
commit
25ca07d3d2
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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) {
|
||||
|
@ -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.
|
||||
* <p>
|
||||
* 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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user