Skip to content
Snippets Groups Projects
Commit ab95f9df authored by Matej Lukes's avatar Matej Lukes
Browse files

Material added

parent e5c3653d
No related branches found
No related tags found
No related merge requests found
package cz.fidentis.analyst.mesh.material;
import javax.media.j3d.Texture;
import javax.vecmath.Vector3d;
/**
* @author Matej Lukes
*/
public class Material {
private String name;
// colour info
private Vector3d ambient, diffuse, specularColors;
private double shininess, alpha, illumination;
// texture info
private String textureFileName;
private Texture texture;
/**
* @param arguments encapsulated arguments of constructor
*/
public Material(MaterialConstructorArguments arguments) {
this.name = arguments.getName();
this.ambient = arguments.getAmbient();
this.diffuse = arguments.getDiffuse();
this.specularColors = arguments.getSpecularColors();
this.shininess = arguments.getShininess();
this.alpha = arguments.getAlpha();
this.illumination = arguments.getIllumination();
this.textureFileName = arguments.getTextureFileName();
this.texture = arguments.getTexture();
}
@Override
public String toString() {
StringBuilder material = new StringBuilder();
material.append("shininess ").append(shininess).append(System.lineSeparator());
material.append("alpha ").append(alpha).append(System.lineSeparator());
material.append("illumination ").append(illumination).append(System.lineSeparator());
if (ambient != null) {
material.append("ambient ").append(ambient.x).append(" ")
.append(ambient.y).append(" ")
.append(ambient.z).append(System.lineSeparator());
}
if (diffuse != null) {
material.append("diffuse ").append(diffuse.x).append(" ")
.append(diffuse.y).append(" ")
.append(diffuse.z).append(System.lineSeparator());
}
if (specularColors != null) {
material.append("specular Colors ").append(specularColors.x)
.append(" ").append(specularColors.y).append(" ")
.append(specularColors.z).append(System.lineSeparator());
}
return material.toString();
}
/**
* @param name compared string
* @return true if material name is same as provided string.
*/
public boolean hasName(String name) {
return this.name.equals(name);
}
/**
* @return name of the material.
*/
public String getName() {
return name;
}
/**
* @return illumination
*/
public double getIllumination() {
return illumination;
}
/**
* @return alpha
*/
public double getAlpha() {
return alpha;
}
/**
* @return shininess
*/
public double getShininess() {
return shininess;
}
/**
* @return ambient
*/
public Vector3d getAmbient() {
return ambient;
}
/**
* @return diffuse
*/
public Vector3d getDiffuse() {
return diffuse;
}
/**
* @return specular colors
*/
public Vector3d getSpecularColors() {
return specularColors;
}
/**
* @return
*/
public Texture getTexture() {
return texture;
}
/**
* @return
*/
public String getTextureFile() {
return textureFileName;
}
}
package cz.fidentis.analyst.mesh.material;
import javax.media.j3d.Texture;
import javax.vecmath.Vector3d;
/**
* Argument for Material constructor
*
* @author Matej Lukes
*/
public class MaterialConstructorArguments {
private String name;
// colour info
private Vector3d ambient, diffuse, specularColors;
private double shininess, alpha, illumination;
// texture info
private String textureFileName;
private Texture texture;
/**
* @param illumination illumination of material
*/
public void setIllumination(double illumination) {
this.illumination = illumination;
}
/**
*
* @return illumination
*/
public double getIllumination() {
return illumination;
}
/**
*
* @param alpha alpha of material
*/
public void setAlpha(double alpha) {
this.alpha = alpha;
}
/**
*
* @return alpha
*/
public double getAlpha() {
return alpha;
}
/**
*
* @param shininess shininess of material
*/
public void setShininess(float shininess) {
this.shininess = shininess;
}
/**
*
* @return shininess
*/
public double getShininess() {
return shininess;
}
/**
*
* @param ambient ambient of material
*/
public void setAmbient(Vector3d ambient) {
this.ambient = ambient;
}
/**
*
* @return ambient
*/
public Vector3d getAmbient() {
return ambient;
}
/**
*
* @param diffuse diffuse of material
*/
public void setDiffuse(Vector3d diffuse) {
this.diffuse = diffuse;
}
/**
*
* @return diffuse
*/
public Vector3d getDiffuse() {
return diffuse;
}
/**
*
* @param specularColors specular colors of material
*/
public void setSpecularColors(Vector3d specularColors) {
this.specularColors = specularColors;
}
/**
*
* @return specular colors
*/
public Vector3d getSpecularColors() {
return specularColors;
}
public void setTexture(Texture texture) {
this.texture = texture;
}
/**
*
* @return texture
*/
public Texture getTexture() {
return texture;
}
/**
* @return name
*/
public String getName() {
return name;
}
/**
* @param name of material
*/
public void setName(String name) {
this.name = name;
}
/**
* @return name of texture file
*/
public String getTextureFileName() {
return textureFileName;
}
/**
* @param textureFileName name of file of material texture
*/
public void setTextureFileName(String textureFileName) {
this.textureFileName = textureFileName;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment