- java.lang.Object
-
- be.yildizgames.common.util.BaseRegisterable
-
- be.yildizgames.common.util.Resource
-
- be.yildizgames.module.graphic.material.Material
-
- All Implemented Interfaces:
be.yildizgames.common.util.Registerable
public abstract class Material extends be.yildizgames.common.util.ResourceA Material is an element used to display 2D image on a 2D or 3D object. It has a unique name, and a List of MaterialTechnique.- Author:
- Grégory Van den Borre
-
-
Field Summary
Fields Modifier and Type Field Description static StringBLACK_NAMESimple black material name, to get the matching material use Material.black().static StringBLUE_NAMESimple blue material name, to get the matching material use Material.blue().static StringEMPTY_NAMEEmpty Texture name, to get the matching material use Material.empty().static StringGRAY_NAMESimple gray material name, to get the matching material use Material.gray().static StringGREEN_NAMESimple green material name, to get the matching material use Material.green().static StringRED_NAMESimple red material name, to get the matching material use Material.red().static StringYELLOW_NAMESimple yellow material name, to get the matching material use Material.yellow().
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract MaterialEffectaddEffect(MaterialEffect.EffectType type, long time)Add an effect to this material.MaterialaddGlowTechnique(String maskFile)Add a technique with a glow texture.static Materialblack()static Materialblue()Materialcopy(String name)Create a copy of this material.protected abstract MaterialcopyImpl(String name)Implementation specific to copy the material.MaterialTechniquecreateTechnique()Create a new MaterialTechnique and insert it in the list.protected abstract MaterialTechniquecreateTechniqueImpl(int techniqueIndex)Add a technique in implementation.MaterialdisableLight()The material will no longer be affected by light and will always be visible(useful for GUI elements...).static Materialempty()static Materialget(String name)Retrieve a Material from its unique name.MaterialTechniquegetTechnique(int index)Get a technique used with this material, throw InvalidParameterException If no technique is found for the given parameter.static Materialgray()static Materialgreen()voidreceiveShadow(boolean receive)Set the material receive shadows or not.protected abstract voidreceiveShadowImpl(boolean receive)Implementation specific to receive shadows on material.static Materialred()MaterialsetBlendMode(MaterialPass.BlendMode mode)Set the blend mode for the first technique, first pass.MaterialsetEmissive(be.yildizgames.module.color.Color c)Shortcut for set emissive in technique 0, pass 0.MaterialsetFragmentShader(FragmentShader s)Shortcut for set fragment shader in technique 0, pass 0.MaterialsetFragmentShaderParameter(ShaderParamColor param)Shortcut for set fragment shader parameter in technique 0, pass 0.MaterialsetFragmentShaderParameter(ShaderParamFloat param)Shortcut for set fragment shader parameter in technique 0, pass 0.MaterialsetFragmentShaderParameter(ShaderParamFloat2 param)Shortcut for set fragment shader parameter in technique 0, pass 0.MaterialsetFragmentShaderParameter(ShaderParamFloat3 param)Shortcut for set fragment shader parameter in technique 0, pass 0.MaterialsetFragmentShaderParameter(ShaderParamFloat4 param)Shortcut for set fragment shader parameter in technique 0, pass 0.MaterialsetFragmentShaderParameterAuto(String name, ShaderConstantType auto)Shortcut for set fragment shader parameter auto in technique 0, pass 0.MaterialsetFragmentShaderParameterAuto(String name, ShaderConstantType auto, int param)Shortcut for set fragment shader parameter auto in technique 0, pass 0.MaterialsetSceneBlend(MaterialPass.SceneBlend sb1, MaterialPass.SceneBlend sb2)Set the scene blend for the first pass of the first technique.MaterialsetTransparency(MaterialPass.Transparency t)Set transparency for every pass of every techniques.MaterialsetVertexShader(VertexShader s)Shortcut for set vertex shader in technique 0, pass 0.MaterialsetVertexShaderParameter(ShaderParamColor param)Shortcut for set vertex shader parameter in technique 0, pass 0.MaterialsetVertexShaderParameter(ShaderParamFloat param)Shortcut for set vertex shader parameter in technique 0, pass 0.MaterialsetVertexShaderParameter(ShaderParamFloat2 param)Shortcut for set vertex shader parameter in technique 0, pass 0.MaterialsetVertexShaderParameter(ShaderParamFloat3 param)Shortcut for set vertex shader parameter in technique 0, pass 0.MaterialsetVertexShaderParameter(ShaderParamFloat4 param)Shortcut for set vertex shader parameter in technique 0, pass 0.MaterialsetVertexShaderParameterAuto(String name, ShaderConstantType auto)Shortcut for set vertex shader parameter auto in technique 0, pass 0.MaterialsetVertexShaderParameterAuto(String name, ShaderConstantType auto, int param)Shortcut for set vertex shader parameter auto in technique 0, pass 0.static Materialyellow()
-
-
-
Field Detail
-
GRAY_NAME
public static final String GRAY_NAME
Simple gray material name, to get the matching material use Material.gray().- See Also:
- Constant Field Values
-
EMPTY_NAME
public static final String EMPTY_NAME
Empty Texture name, to get the matching material use Material.empty().- See Also:
- Constant Field Values
-
GREEN_NAME
public static final String GREEN_NAME
Simple green material name, to get the matching material use Material.green().- See Also:
- Constant Field Values
-
RED_NAME
public static final String RED_NAME
Simple red material name, to get the matching material use Material.red().- See Also:
- Constant Field Values
-
BLUE_NAME
public static final String BLUE_NAME
Simple blue material name, to get the matching material use Material.blue().- See Also:
- Constant Field Values
-
YELLOW_NAME
public static final String YELLOW_NAME
Simple yellow material name, to get the matching material use Material.yellow().- See Also:
- Constant Field Values
-
BLACK_NAME
public static final String BLACK_NAME
Simple black material name, to get the matching material use Material.black().- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Material
protected Material(String name)
Protected constructor, only called from children.- Parameters:
name- Material name, must be unique
-
Material
protected Material(String name, List<MaterialTechnique> list)
Copy constructor.- Parameters:
name- Name for the new material.list- List of copied techniques.
-
-
Method Detail
-
get
public static Material get(String name)
Retrieve a Material from its unique name.- Parameters:
name- Unique material name.- Returns:
- Found material.
-
empty
public static Material empty()
- Returns:
- An empty material.
-
green
public static Material green()
- Returns:
- A simple green material.
-
blue
public static Material blue()
- Returns:
- A simple blue material.
-
red
public static Material red()
- Returns:
- A simple red material.
-
gray
public static Material gray()
- Returns:
- A simple gray material.
-
yellow
public static Material yellow()
- Returns:
- A simple yellow material.
-
black
public static Material black()
- Returns:
- A simple black material.
-
createTechnique
public final MaterialTechnique createTechnique()
Create a new MaterialTechnique and insert it in the list.- Returns:
- The newly created MaterialTechnique.
-
addGlowTechnique
public final Material addGlowTechnique(String maskFile)
Add a technique with a glow texture.- Parameters:
maskFile- Texture mask to glow.- Returns:
- This material for chaining.
-
setBlendMode
public final Material setBlendMode(MaterialPass.BlendMode mode)
Set the blend mode for the first technique, first pass.- Parameters:
mode- BlendMode to set.- Returns:
- This material for chaining.
-
setSceneBlend
public final Material setSceneBlend(MaterialPass.SceneBlend sb1, MaterialPass.SceneBlend sb2)
Set the scene blend for the first pass of the first technique.- Parameters:
sb1- Blending first parameter.sb2- Blending second parameter.- Returns:
- This material for chaining.
-
disableLight
public final Material disableLight()
The material will no longer be affected by light and will always be visible(useful for GUI elements...).- Returns:
- This material for chaining.
-
copy
public final Material copy(String name)
Create a copy of this material.- Parameters:
name- The name must be unique so the copy must have a new name.- Returns:
- A perfect copy of this material except for the name.
-
addEffect
public abstract MaterialEffect addEffect(MaterialEffect.EffectType type, long time)
Add an effect to this material.- Parameters:
type- Effect type to apply.time- Time for the effect to be completed, in millisec.- Returns:
- The applied material effect.
-
copyImpl
protected abstract Material copyImpl(String name)
Implementation specific to copy the material.- Parameters:
name- Copy unique name.- Returns:
- The copied material.
-
createTechniqueImpl
protected abstract MaterialTechnique createTechniqueImpl(int techniqueIndex)
Add a technique in implementation.- Parameters:
techniqueIndex- Index of the added technique.- Returns:
- The created technique.
-
getTechnique
public final MaterialTechnique getTechnique(int index)
Get a technique used with this material, throw InvalidParameterException If no technique is found for the given parameter.- Parameters:
index- Index of the technique used, first is 0.- Returns:
- The associated technique.
-
setEmissive
public final Material setEmissive(be.yildizgames.module.color.Color c)
Shortcut for set emissive in technique 0, pass 0. If technique 0 pass 0 does not exist, nothing is done.- Parameters:
c- Emissive color to set.- Returns:
- This material for chaining.
-
setVertexShader
public final Material setVertexShader(VertexShader s)
Shortcut for set vertex shader in technique 0, pass 0. If technique 0 pass 0 does not exist, nothing is done.- Parameters:
s- Shader to set.- Returns:
- This material for chaining.
-
setFragmentShader
public final Material setFragmentShader(FragmentShader s)
Shortcut for set fragment shader in technique 0, pass 0. If technique 0 pass 0 does not exist, nothing is done.- Parameters:
s- Shader to set.- Returns:
- This material for chaining.
-
setFragmentShaderParameter
public final Material setFragmentShaderParameter(ShaderParamFloat4 param)
Shortcut for set fragment shader parameter in technique 0, pass 0. If technique 0 pass 0 does not exist, nothing is done.- Parameters:
param- Parameter param.- Returns:
- This material for chaining.
-
setFragmentShaderParameter
public final Material setFragmentShaderParameter(ShaderParamFloat3 param)
Shortcut for set fragment shader parameter in technique 0, pass 0. If technique 0 pass 0 does not exist, nothing is done.- Parameters:
param- Parameter param.- Returns:
- This material for chaining.
-
setFragmentShaderParameter
public final Material setFragmentShaderParameter(ShaderParamFloat2 param)
Shortcut for set fragment shader parameter in technique 0, pass 0. If technique 0 pass 0 does not exist, nothing is done.- Parameters:
param- Parameter param.- Returns:
- This material for chaining.
-
setFragmentShaderParameter
public final Material setFragmentShaderParameter(ShaderParamFloat param)
Shortcut for set fragment shader parameter in technique 0, pass 0. If technique 0 pass 0 does not exist, nothing is done.- Parameters:
param- Parameter param.- Returns:
- This material for chaining.
-
setFragmentShaderParameter
public final Material setFragmentShaderParameter(ShaderParamColor param)
Shortcut for set fragment shader parameter in technique 0, pass 0. If technique 0 pass 0 does not exist, nothing is done.- Parameters:
param- Parameter param.- Returns:
- This material for chaining.
-
setFragmentShaderParameterAuto
public final Material setFragmentShaderParameterAuto(String name, ShaderConstantType auto)
Shortcut for set fragment shader parameter auto in technique 0, pass 0. If technique 0 pass 0 does not exist, nothing is done.- Parameters:
name- Parameter name.auto- Parameter automatically updated from graphic engine.- Returns:
- This material for chaining.
-
setFragmentShaderParameterAuto
public final Material setFragmentShaderParameterAuto(String name, ShaderConstantType auto, int param)
Shortcut for set fragment shader parameter auto in technique 0, pass 0. If technique 0 pass 0 does not exist, nothing is done.- Parameters:
name- Parameter name.auto- Parameter automatically updated from graphic engine.param- Additional parameter.- Returns:
- This material for chaining.
-
setVertexShaderParameter
public final Material setVertexShaderParameter(ShaderParamFloat4 param)
Shortcut for set vertex shader parameter in technique 0, pass 0. If technique 0 pass 0 does not exist, nothing is done.- Parameters:
param- Parameter param.- Returns:
- This material for chaining.
-
setVertexShaderParameter
public final Material setVertexShaderParameter(ShaderParamFloat3 param)
Shortcut for set vertex shader parameter in technique 0, pass 0. If technique 0 pass 0 does not exist, nothing is done.- Parameters:
param- Parameter param.- Returns:
- This material for chaining.
-
setVertexShaderParameter
public final Material setVertexShaderParameter(ShaderParamFloat2 param)
Shortcut for set vertex shader parameter in technique 0, pass 0. If technique 0 pass 0 does not exist, nothing is done.- Parameters:
param- Parameter param.- Returns:
- This material for chaining.
-
setVertexShaderParameter
public final Material setVertexShaderParameter(ShaderParamFloat param)
Shortcut for set vertex shader parameter in technique 0, pass 0. If technique 0 pass 0 does not exist, nothing is done.- Parameters:
param- Parameter param.- Returns:
- This material for chaining.
-
setVertexShaderParameter
public final Material setVertexShaderParameter(ShaderParamColor param)
Shortcut for set vertex shader parameter in technique 0, pass 0. If technique 0 pass 0 does not exist, nothing is done.- Parameters:
param- Parameter param.- Returns:
- This material for chaining.
-
setVertexShaderParameterAuto
public final Material setVertexShaderParameterAuto(String name, ShaderConstantType auto, int param)
Shortcut for set vertex shader parameter auto in technique 0, pass 0. If technique 0 pass 0 does not exist, nothing is done.- Parameters:
name- Parameter name.auto- Parameter automatically updated from graphic engine.param- Additional parameter.- Returns:
- This material for chaining.
-
setVertexShaderParameterAuto
public final Material setVertexShaderParameterAuto(String name, ShaderConstantType auto)
Shortcut for set vertex shader parameter auto in technique 0, pass 0. If technique 0 pass 0 does not exist, nothing is done.- Parameters:
name- Parameter name.auto- Parameter automatically updated from graphic engine.- Returns:
- This material for chaining.
-
receiveShadow
public final void receiveShadow(boolean receive)
Set the material receive shadows or not.- Parameters:
receive-trueto receive.
-
receiveShadowImpl
protected abstract void receiveShadowImpl(boolean receive)
Implementation specific to receive shadows on material.- Parameters:
receive-trueto receive.
-
setTransparency
public final Material setTransparency(MaterialPass.Transparency t)
Set transparency for every pass of every techniques.- Parameters:
t- Transparency type.- Returns:
- This object.
-
-