diff --git a/jme3-core/src/main/java/com/jme3/material/Material.java b/jme3-core/src/main/java/com/jme3/material/Material.java index 73e103659..3de42e7fb 100644 --- a/jme3-core/src/main/java/com/jme3/material/Material.java +++ b/jme3-core/src/main/java/com/jme3/material/Material.java @@ -263,8 +263,14 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable { // E.g. if user chose custom technique for one material but // uses default technique for other material, the materials // are not equal. - String thisDefName = this.technique != null ? this.technique.getDef().getName() : "Default"; - String otherDefName = other.technique != null ? other.technique.getDef().getName() : "Default"; + String thisDefName = this.technique != null + ? this.technique.getDef().getName() + : TechniqueDef.DEFAULT_TECHNIQUE_NAME; + + String otherDefName = other.technique != null + ? other.technique.getDef().getName() + : TechniqueDef.DEFAULT_TECHNIQUE_NAME; + if (!thisDefName.equals(otherDefName)) { return false; } @@ -693,23 +699,18 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable { /** * Select the technique to use for rendering this material. *
- * If name
is "Default", then one of the
- * {@link MaterialDef#getDefaultTechniques() default techniques}
- * on the material will be selected. Otherwise, the named technique
- * will be found in the material definition.
- *
* Any candidate technique for selection (either default or named)
* must be verified to be compatible with the system, for that, the
* renderManager
is queried for capabilities.
*
- * @param name The name of the technique to select, pass "Default" to
- * select one of the default techniques.
+ * @param name The name of the technique to select, pass
+ * {@link TechniqueDef#DEFAULT_TECHNIQUE_NAME} to select one of the default
+ * techniques.
* @param renderManager The {@link RenderManager render manager}
* to query for capabilities.
*
- * @throws IllegalArgumentException If "Default" is passed and no default
- * techniques are available on the material definition, or if a name
- * is passed but there's no technique by that name.
+ * @throws IllegalArgumentException If no technique exists with the given
+ * name.
* @throws UnsupportedOperationException If no candidate technique supports
* the system capabilities.
*/
@@ -839,7 +840,7 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
*/
public void preload(RenderManager renderManager) {
if (technique == null) {
- selectTechnique("Default", renderManager);
+ selectTechnique(TechniqueDef.DEFAULT_TECHNIQUE_NAME, renderManager);
}
TechniqueDef techniqueDef = technique.getDef();
Renderer renderer = renderManager.getRenderer();
@@ -939,7 +940,7 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
*/
public void render(Geometry geometry, LightList lights, RenderManager renderManager) {
if (technique == null) {
- selectTechnique("Default", renderManager);
+ selectTechnique(TechniqueDef.DEFAULT_TECHNIQUE_NAME, renderManager);
}
TechniqueDef techniqueDef = technique.getDef();
diff --git a/jme3-core/src/main/java/com/jme3/material/TechniqueDef.java b/jme3-core/src/main/java/com/jme3/material/TechniqueDef.java
index c954a1469..d5a593878 100644
--- a/jme3-core/src/main/java/com/jme3/material/TechniqueDef.java
+++ b/jme3-core/src/main/java/com/jme3/material/TechniqueDef.java
@@ -53,6 +53,14 @@ public class TechniqueDef implements Savable {
*/
public static final int SAVABLE_VERSION = 1;
+ /**
+ * The default technique name.
+ *
+ * The technique with this name is selected if no specific technique is
+ * requested by the user. Currently set to "Default".
+ */
+ public static final String DEFAULT_TECHNIQUE_NAME = "Default";
+
/**
* Describes light rendering mode.
*/
@@ -132,7 +140,7 @@ public class TechniqueDef implements Savable {
public TechniqueDef(String name, int sortId){
this();
this.sortId = sortId;
- this.name = name == null ? "Default" : name;
+ this.name = name == null ? TechniqueDef.DEFAULT_TECHNIQUE_NAME : name;
}
/**
@@ -157,7 +165,8 @@ public class TechniqueDef implements Savable {
/**
* Returns the name of this technique as specified in the J3MD file.
- * Default techniques have the name "Default".
+ * Default
+ * techniques have the name {@link #DEFAULT_TECHNIQUE_NAME}.
*
* @return the name of this technique
*/
diff --git a/jme3-core/src/main/java/com/jme3/renderer/RenderManager.java b/jme3-core/src/main/java/com/jme3/renderer/RenderManager.java
index bdfe33fd6..f250b2f65 100644
--- a/jme3-core/src/main/java/com/jme3/renderer/RenderManager.java
+++ b/jme3-core/src/main/java/com/jme3/renderer/RenderManager.java
@@ -582,7 +582,9 @@ public class RenderManager {
if (forcedTechnique != null) {
MaterialDef matDef = g.getMaterial().getMaterialDef();
if (matDef.getTechniqueDefs(forcedTechnique) != null) {
- tmpTech = g.getMaterial().getActiveTechnique() != null ? g.getMaterial().getActiveTechnique().getDef().getName() : "Default";
+ tmpTech = g.getMaterial().getActiveTechnique() != null
+ ? g.getMaterial().getActiveTechnique().getDef().getName()
+ : TechniqueDef.DEFAULT_TECHNIQUE_NAME;
g.getMaterial().selectTechnique(forcedTechnique, this);
//saving forcedRenderState for future calls
RenderState tmpRs = forcedRenderState;
diff --git a/jme3-core/src/test/java/com/jme3/renderer/OpaqueComparatorTest.java b/jme3-core/src/test/java/com/jme3/renderer/OpaqueComparatorTest.java
index 84555c9f6..ee4d279fd 100644
--- a/jme3-core/src/test/java/com/jme3/renderer/OpaqueComparatorTest.java
+++ b/jme3-core/src/test/java/com/jme3/renderer/OpaqueComparatorTest.java
@@ -33,6 +33,7 @@ package com.jme3.renderer;
import com.jme3.asset.AssetManager;
import com.jme3.material.Material;
+import com.jme3.material.TechniqueDef;
import com.jme3.math.ColorRGBA;
import com.jme3.renderer.queue.GeometryList;
import com.jme3.renderer.queue.OpaqueComparator;
@@ -92,7 +93,7 @@ public class OpaqueComparatorTest {
String techniqueName = materials[i].getActiveTechnique().getDef().getName();
clonedMaterial.selectTechnique(techniqueName, renderManager);
} else {
- clonedMaterial.selectTechnique("Default", renderManager);
+ clonedMaterial.selectTechnique(TechniqueDef.DEFAULT_TECHNIQUE_NAME, renderManager);
}
geom.setMaterial(clonedMaterial);
@@ -156,7 +157,7 @@ public class OpaqueComparatorTest {
Material lightingMatGlow = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
lightingMatDefault.setName("TechDefault");
- lightingMatDefault.selectTechnique("Default", renderManager);
+ lightingMatDefault.selectTechnique(TechniqueDef.DEFAULT_TECHNIQUE_NAME, renderManager);
lightingPostShadow.setName("TechPostShad");
lightingPostShadow.selectTechnique("PostShadow", renderManager);
@@ -272,7 +273,7 @@ public class OpaqueComparatorTest {
tex2.getImage().setId(3);
matBase1.setName("BASE");
- matBase1.selectTechnique("Default", renderManager);
+ matBase1.selectTechnique(TechniqueDef.DEFAULT_TECHNIQUE_NAME, renderManager);
matBase1.setBoolean("UseVertexColor", true);
matBase1.setTexture("DiffuseMap", texBase);
diff --git a/jme3-core/src/tools/java/jme3tools/shadercheck/ShaderCheck.java b/jme3-core/src/tools/java/jme3tools/shadercheck/ShaderCheck.java
index e409caa53..98d379b38 100644
--- a/jme3-core/src/tools/java/jme3tools/shadercheck/ShaderCheck.java
+++ b/jme3-core/src/tools/java/jme3tools/shadercheck/ShaderCheck.java
@@ -38,7 +38,7 @@ public class ShaderCheck {
MaterialDef def = (MaterialDef) assetManager.loadAsset(matdefName);
EnumSet