100 lines
2.3 KiB
Java
100 lines
2.3 KiB
Java
package electrosphere.renderer.light;
|
|
|
|
import org.joml.Vector3f;
|
|
|
|
/**
|
|
* Data about a point light
|
|
*/
|
|
public class PointLight {
|
|
Vector3f position;
|
|
float constant;
|
|
float linear;
|
|
float quadratic;
|
|
Vector3f ambient;
|
|
Vector3f diffuse;
|
|
Vector3f specular;
|
|
|
|
public void setPosition(Vector3f position) {
|
|
this.position = position;
|
|
}
|
|
|
|
public void setConstant(float constant) {
|
|
this.constant = constant;
|
|
}
|
|
|
|
public void setLinear(float linear) {
|
|
this.linear = linear;
|
|
}
|
|
|
|
public void setQuadratic(float quadratic) {
|
|
this.quadratic = quadratic;
|
|
}
|
|
|
|
public void setAmbient(Vector3f ambient) {
|
|
this.ambient = ambient;
|
|
}
|
|
|
|
public void setDiffuse(Vector3f diffuse) {
|
|
this.diffuse = diffuse;
|
|
}
|
|
|
|
public void setSpecular(Vector3f specular) {
|
|
this.specular = specular;
|
|
}
|
|
|
|
public Vector3f getPosition() {
|
|
return position;
|
|
}
|
|
|
|
public float getConstant() {
|
|
return constant;
|
|
}
|
|
|
|
public float getLinear() {
|
|
return linear;
|
|
}
|
|
|
|
public float getQuadratic() {
|
|
return quadratic;
|
|
}
|
|
|
|
public Vector3f getAmbient() {
|
|
return ambient;
|
|
}
|
|
|
|
public Vector3f getDiffuse() {
|
|
return diffuse;
|
|
}
|
|
|
|
public Vector3f getSpecular() {
|
|
return specular;
|
|
}
|
|
|
|
public PointLight(Vector3f position){
|
|
this.position = position;
|
|
constant = 1.0f;
|
|
linear = 0.01f;
|
|
quadratic = 0.01f;
|
|
ambient = new Vector3f(0.05f, 0.05f, 0.05f);
|
|
diffuse = new Vector3f(0.8f, 0.8f, 0.8f);
|
|
specular = new Vector3f(1.0f, 1.0f, 1.0f);
|
|
this.position.normalize();
|
|
ambient.normalize();
|
|
diffuse.normalize();
|
|
specular.normalize();
|
|
}
|
|
|
|
public PointLight(Vector3f position, Vector3f color){
|
|
this.position = position;
|
|
constant = 1.0f;
|
|
linear = 0.01f;
|
|
quadratic = 0.01f;
|
|
ambient = new Vector3f(color.x * 0.05f, color.y * 0.05f, color.z * 0.05f);
|
|
diffuse = new Vector3f(color.x * 0.8f, color.y * 0.8f, color.z * 0.8f);
|
|
specular = new Vector3f(color.x, color.y, color.z);
|
|
this.position.normalize();
|
|
ambient.normalize();
|
|
diffuse.normalize();
|
|
specular.normalize();
|
|
}
|
|
} |