Class Material
java.lang.Object
com.marginallyclever.ro3.node.Node
com.marginallyclever.ro3.node.nodes.Material
Material
contains properties for rendering a surface. The first use case is to apply a texture to a
Mesh
.
This class provides several functionalities:
- It can set and get the texture.
- It can set and get the diffuse color.
- It can set and get the specular color.
- It can set and get the emission color.
- It can set and get the shininess.
- It can set and get the lit status.
- It can serialize and deserialize itself to and from JSON format.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
fromJSON
(org.json.JSONObject from) Deserialize this node and its children from a JSON object and its children.void
getComponents
(List<JPanel> list) Build a Swing Component that represents this Node.double
Calculate the emitted light from a material based on its emission color and strength.getIcon()
Set a custom icon for this node.double
getIOR()
double
Cosine-weighted hemisphere PDF for diffuse reflection.double
int
double
boolean
boolean
isLit()
lightSamplingBRDF
(Hit hit, javax.vecmath.Vector3d wi, javax.vecmath.Vector3d wo) Diffuse-only BRDF (f) for next-event (light) sampling.void
setDiffuseColor
(Color color) void
setDiffuseTexture
(TextureWithMetadata texture) void
setEmissionColor
(Color color) void
setEmissionStrength
(double emissionStrength) void
setIOR
(double ior) Set the index of refraction.void
setLit
(boolean isLit) void
setNormalTexture
(TextureWithMetadata texture) void
setReflectivity
(double arg0) Set the reflectivity of the material.void
setShininess
(int arg0) void
setSpecularColor
(Color color) void
setSpecularStrength
(double specularStrength) void
setSpecularTexture
(TextureWithMetadata texture) org.json.JSONObject
toJSON()
Serialize this node and its children to a JSON object and its children.Methods inherited from class com.marginallyclever.ro3.node.Node
addAttachListener, addChild, addChild, addDetachListener, addReadyListener, addRenameListener, findByPath, findChild, findChild, findFirstChild, findFirstSibling, findNodeByID, findParent, findParent, getAbsolutePath, getChildren, getName, getParent, getRootNode, getUniqueID, hasParent, isNameUsedBySibling, removeAttachListener, removeChild, removeDetachListener, removeReadyListener, removeRenameListener, setName, update, witnessProtection
-
Constructor Details
-
Material
public Material() -
Material
-
-
Method Details
-
getComponents
Description copied from class:Node
Build a Swing Component that represents this Node.- Overrides:
getComponents
in classNode
- Parameters:
list
- the list to add components to.
-
setDiffuseTexture
-
getDiffuseTexture
-
setNormalTexture
-
getNormalTexture
-
setSpecularTexture
-
getSpecularTexture
-
toJSON
public org.json.JSONObject toJSON()Description copied from class:Node
Serialize this node and its children to a JSON object and its children. Classes that override this method should call super.toJSON() first, then add to the object returned. -
fromJSON
public void fromJSON(org.json.JSONObject from) Description copied from class:Node
Deserialize this node and its children from a JSON object and its children. Classes that override this method should call super.fromJSON(). When they do it will trigger the creation of child nodes. The child nodes will then call their own fromJSON() methods. -
getDiffuseColor
-
setDiffuseColor
-
getSpecularColor
-
setSpecularColor
-
getEmissionColor
-
setEmissionColor
-
getEmissionStrength
public double getEmissionStrength()- Returns:
- the emission strength of the material. >=0
-
setEmissionStrength
public void setEmissionStrength(double emissionStrength) - Parameters:
emissionStrength
- the emission strength of the material. >=0
-
isEmissive
public boolean isEmissive() -
setShininess
public void setShininess(int arg0) -
getShininess
public int getShininess()- Returns:
- the shininess of the material 0...128
-
isLit
public boolean isLit() -
setLit
public void setLit(boolean isLit) -
getIcon
-
setSpecularStrength
public void setSpecularStrength(double specularStrength) -
getSpecularStrength
public double getSpecularStrength() -
setIOR
public void setIOR(double ior) Set the index of refraction.- Parameters:
ior
- the index of refraction
-
getIOR
public double getIOR()- Returns:
- the index of refraction.
-
setReflectivity
public void setReflectivity(double arg0) Set the reflectivity of the material.- Parameters:
arg0
- 0...1.0
-
getReflectivity
public double getReflectivity()- Returns:
- the reflectivity of the material.
-
getPDF
Cosine-weighted hemisphere PDF for diffuse reflection.- Parameters:
hit
- the hit recordin
- incoming direction (unit, towards surface)out
- outgoing direction (unit, towards viewer)- Returns:
- the PDF value
-
getEmittedLight
Calculate the emitted light from a material based on its emission color and strength.- Returns:
- the emitted light as a ColorDouble
-
scatter
-
lightSamplingBRDF
Diffuse-only BRDF (f) for next-event (light) sampling. Excludes specular (never light sampled) and transmission (delta). Does NOT include the cosine term or any pdf factors.
-