@ -81,9 +81,9 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
private AssetKey key ;
private AssetKey key ;
private String name ;
private String name ;
private MaterialDef def ;
private MaterialDef def ;
private ListMap < String , MatParam > paramValues = new ListMap < String , MatParam > ( ) ;
private ListMap < String , MatParam > paramValues = new ListMap < > ( ) ;
private Technique technique ;
private Technique technique ;
private HashMap < String , Technique > techniques = new HashMap < String , Technique > ( ) ;
private HashMap < String , Technique > techniques = new HashMap < > ( ) ;
private RenderState additionalState = null ;
private RenderState additionalState = null ;
private RenderState mergedRenderState = new RenderState ( ) ;
private RenderState mergedRenderState = new RenderState ( ) ;
private boolean transparent = false ;
private boolean transparent = false ;
@ -143,10 +143,12 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
this . name = name ;
this . name = name ;
}
}
@Override
public void setKey ( AssetKey key ) {
public void setKey ( AssetKey key ) {
this . key = key ;
this . key = key ;
}
}
@Override
public AssetKey getKey ( ) {
public AssetKey getKey ( ) {
return key ;
return key ;
}
}
@ -200,9 +202,9 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
mat . additionalState = additionalState . clone ( ) ;
mat . additionalState = additionalState . clone ( ) ;
}
}
mat . technique = null ;
mat . technique = null ;
mat . techniques = new HashMap < String , Technique > ( ) ;
mat . techniques = new HashMap < > ( ) ;
mat . paramValues = new ListMap < String , MatParam > ( ) ;
mat . paramValues = new ListMap < > ( ) ;
for ( int i = 0 ; i < paramValues . size ( ) ; i + + ) {
for ( int i = 0 ; i < paramValues . size ( ) ; i + + ) {
Map . Entry < String , MatParam > entry = paramValues . getEntry ( i ) ;
Map . Entry < String , MatParam > entry = paramValues . getEntry ( i ) ;
mat . paramValues . put ( entry . getKey ( ) , entry . getValue ( ) . clone ( ) ) ;
mat . paramValues . put ( entry . getKey ( ) , entry . getValue ( ) . clone ( ) ) ;
@ -933,10 +935,9 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
* < / ul >
* < / ul >
*
*
* @param geometry The geometry to render
* @param geometry The geometry to render
* @param lights Presorted and filtered light list to use for rendering
* @param renderManager The render manager requesting the rendering
* @param renderManager The render manager requesting the rendering
* /
* /
public void render ( Geometry geometry , LightList lights , RenderManager renderManager ) {
public void render ( Geometry geometry , RenderManager renderManager ) {
if ( technique = = null ) {
if ( technique = = null ) {
selectTechnique ( TechniqueDef . DEFAULT_TECHNIQUE_NAME , renderManager ) ;
selectTechnique ( TechniqueDef . DEFAULT_TECHNIQUE_NAME , renderManager ) ;
}
}
@ -956,7 +957,7 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
SafeArrayList < MatParamOverride > overrides = geometry . getWorldMatParamOverrides ( ) ;
SafeArrayList < MatParamOverride > overrides = geometry . getWorldMatParamOverrides ( ) ;
// Select shader to use
// Select shader to use
Shader shader = technique . makeCurrent ( renderManager , overrides , renderManager . getForcedMatParams ( ) , lights , rendererCaps ) ;
Shader shader = technique . makeCurrent ( renderManager , geometry , overrides , renderManager . getForcedMatParams ( ) , rendererCaps ) ;
// Begin tracking which uniforms were changed by material.
// Begin tracking which uniforms were changed by material.
clearUniformsSetByCurrent ( shader ) ;
clearUniformsSetByCurrent ( shader ) ;
@ -965,29 +966,24 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
renderManager . updateUniformBindings ( shader ) ;
renderManager . updateUniformBindings ( shader ) ;
// Set material parameters
// Set material parameters
int unit = updateShaderMaterialParameters ( renderer , shader , overrides , renderManager . getForcedMatParams ( ) ) ;
int nextText ureU nit = updateShaderMaterialParameters ( renderer , shader , overrides , renderManager . getForcedMatParams ( ) ) ;
// Clear any uniforms not changed by material.
// Clear any uniforms not changed by material.
resetUniformsNotSetByCurrent ( shader ) ;
resetUniformsNotSetByCurrent ( shader ) ;
// Delegate rendering to the technique
// Delegate rendering to the technique
technique . render ( renderManager , shader , geometry , lights , u nit) ;
technique . render ( renderManager , shader , geometry , nextTextureU nit) ;
}
}
/ * *
@Override
* Called by { @link RenderManager } to render the geometry by
public String toString ( ) {
* using this material .
return "Material[name=" + name +
*
", def=" + ( def ! = null ? def . getName ( ) : null ) +
* Note that this version of the render method
", tech=" + ( technique ! = null & & technique . getDef ( ) ! = null ? technique . getDef ( ) . getName ( ) : null ) +
* does not perform light filtering .
"]" ;
*
* @param geom The geometry to render
* @param rm The render manager requesting the rendering
* /
public void render ( Geometry geom , RenderManager rm ) {
render ( geom , geom . getWorldLightList ( ) , rm ) ;
}
}
@Override
public void write ( JmeExporter ex ) throws IOException {
public void write ( JmeExporter ex ) throws IOException {
OutputCapsule oc = ex . getCapsule ( this ) ;
OutputCapsule oc = ex . getCapsule ( this ) ;
oc . write ( def . getAssetName ( ) , "material_def" , null ) ;
oc . write ( def . getAssetName ( ) , "material_def" , null ) ;
@ -998,13 +994,6 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
}
}
@Override
@Override
public String toString ( ) {
return "Material[name=" + name +
", def=" + ( def ! = null ? def . getName ( ) : null ) +
", tech=" + ( technique ! = null & & technique . getDef ( ) ! = null ? technique . getDef ( ) . getName ( ) : null ) +
"]" ;
}
public void read ( JmeImporter im ) throws IOException {
public void read ( JmeImporter im ) throws IOException {
InputCapsule ic = im . getCapsule ( this ) ;
InputCapsule ic = im . getCapsule ( this ) ;
@ -1054,7 +1043,7 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
}
}
def = ( MaterialDef ) im . getAssetManager ( ) . loadAsset ( new AssetKey ( defName ) ) ;
def = ( MaterialDef ) im . getAssetManager ( ) . loadAsset ( new AssetKey ( defName ) ) ;
paramValues = new ListMap < String , MatParam > ( ) ;
paramValues = new ListMap < > ( ) ;
// load the textures and update nextTexUnit
// load the textures and update nextTexUnit
for ( Map . Entry < String , MatParam > entry : params . entrySet ( ) ) {
for ( Map . Entry < String , MatParam > entry : params . entrySet ( ) ) {