main.io.github.seba244c.icespire.graphics.Material Maven / Gradle / Ivy
package io.github.seba244c.icespire.graphics;
import org.joml.Vector4f;
/**
* Materials wich can be appleid to meshes.
* Materials on meshes changes the color and texture of a mesh
* @author Sebsa
* @since 1.0.2
*
*/
public class Material {
private static final Vector4f DEFAULT_COLOUR = new Vector4f(1.0f, 1.0f, 1.0f, 1.0f);
private Vector4f ambientColour;
private Vector4f diffuseColour;
private Vector4f specularColour;
private float reflectance;
private Texture texture;
public Material() {
this.ambientColour = DEFAULT_COLOUR;
this.diffuseColour = DEFAULT_COLOUR;
this.specularColour = DEFAULT_COLOUR;
this.texture = null;
this.reflectance = 0;
}
public Material(Vector4f colour, float reflectance) {
this(colour, colour, colour, null, reflectance);
}
public Material(Texture texture) {
this(DEFAULT_COLOUR, DEFAULT_COLOUR, DEFAULT_COLOUR, texture, 0);
}
public Material(Texture texture, float reflectance) {
this(DEFAULT_COLOUR, DEFAULT_COLOUR, DEFAULT_COLOUR, texture, reflectance);
}
public Material(Vector4f ambientColour, Vector4f diffuseColour, Vector4f specularColour, Texture texture, float reflectance) {
this.ambientColour = ambientColour;
this.diffuseColour = diffuseColour;
this.specularColour = specularColour;
this.texture = texture;
this.reflectance = reflectance;
}
public Vector4f getAmbientColour() {
return ambientColour;
}
public void setAmbientColour(Vector4f ambientColour) {
this.ambientColour = ambientColour;
}
public Vector4f getDiffuseColour() {
return diffuseColour;
}
public void setDiffuseColour(Vector4f diffuseColour) {
this.diffuseColour = diffuseColour;
}
public Vector4f getSpecularColour() {
return specularColour;
}
public void setSpecularColour(Vector4f specularColour) {
this.specularColour = specularColour;
}
public float getReflectance() {
return reflectance;
}
public void setReflectance(float reflectance) {
this.reflectance = reflectance;
}
public boolean isTextured() {
return this.texture != null;
}
public Texture getTexture() {
return texture;
}
public void setTexture(Texture texture) {
this.texture = texture;
}
}