Merge pull request #293 from davidB/david_materiel_no_render

add TechniqueDef.noRender
experimental
Kirill Vainer 10 years ago
commit 328966ba79
  1. 5
      jme3-core/src/main/java/com/jme3/material/Material.java
  2. 27
      jme3-core/src/main/java/com/jme3/material/TechniqueDef.java
  3. 2
      jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java

@ -1147,10 +1147,11 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
*/
public void render(Geometry geom, LightList lights, RenderManager rm) {
autoSelectTechnique(rm);
TechniqueDef techDef = technique.getDef();
Renderer r = rm.getRenderer();
if (techDef.isNoRender()) return;
TechniqueDef techDef = technique.getDef();
Renderer r = rm.getRenderer();
if (rm.getForcedRenderState() != null) {
r.applyRenderState(rm.getForcedRenderState());

@ -102,6 +102,7 @@ public class TechniqueDef implements Savable {
private List<ShaderNode> shaderNodes;
private ShaderGenerationInfo shaderGenerationInfo;
private boolean noRender = false;
private RenderState renderState;
private RenderState forcedRenderState;
@ -201,6 +202,28 @@ public class TechniqueDef implements Savable {
this.renderState = renderState;
}
/**
* Sets if this technique should not be used to render.
*
* @param noRender not render or render ?
*
* @see NoRender
*/
public void setNoRender(boolean noRender) {
this.noRender = noRender;
}
/**
* Returns true if this technique should not be used to render.
* (eg. to not render a material with default technique)
*
* @return true if this technique should not be rendered, false otherwise.
*
*/
public boolean isNoRender(){
return noRender;
}
/**
* @deprecated jME3 always requires shaders now
*/
@ -448,6 +471,7 @@ public class TechniqueDef implements Savable {
oc.write(lightMode, "lightMode", LightMode.Disable);
oc.write(shadowMode, "shadowMode", ShadowMode.Disable);
oc.write(renderState, "renderState", null);
oc.write(noRender, "noRender", false);
oc.write(usesNodes, "usesNodes", false);
oc.writeSavableArrayList((ArrayList)shaderNodes,"shaderNodes", null);
oc.write(shaderGenerationInfo, "shaderGenerationInfo", null);
@ -470,6 +494,7 @@ public class TechniqueDef implements Savable {
lightMode = ic.readEnum("lightMode", LightMode.class, LightMode.Disable);
shadowMode = ic.readEnum("shadowMode", ShadowMode.class, ShadowMode.Disable);
renderState = (RenderState) ic.readSavable("renderState", null);
noRender = ic.readBoolean("noRender", false);
if (ic.getSavableVersion(TechniqueDef.class) == 0) {
// Old version
@ -525,6 +550,6 @@ public class TechniqueDef implements Savable {
//todo: make toString return something usefull
@Override
public String toString() {
return "TechniqueDef{" + "requiredCaps=" + requiredCaps + ", name=" + name /*+ ", vertName=" + vertName + ", fragName=" + fragName + ", vertLanguage=" + vertLanguage + ", fragLanguage=" + fragLanguage */+ ", presetDefines=" + presetDefines + ", usesNodes=" + usesNodes + ", shaderNodes=" + shaderNodes + ", shaderGenerationInfo=" + shaderGenerationInfo + ", renderState=" + renderState + ", forcedRenderState=" + forcedRenderState + ", lightMode=" + lightMode + ", shadowMode=" + shadowMode + ", defineParams=" + defineParams + ", worldBinds=" + worldBinds + '}';
return "TechniqueDef{" + "requiredCaps=" + requiredCaps + ", name=" + name /*+ ", vertName=" + vertName + ", fragName=" + fragName + ", vertLanguage=" + vertLanguage + ", fragLanguage=" + fragLanguage */+ ", presetDefines=" + presetDefines + ", usesNodes=" + usesNodes + ", shaderNodes=" + shaderNodes + ", shaderGenerationInfo=" + shaderGenerationInfo + ", renderState=" + renderState + ", forcedRenderState=" + forcedRenderState + ", lightMode=" + lightMode + ", shadowMode=" + shadowMode + ", defineParams=" + defineParams + ", worldBinds=" + worldBinds + ", noRender=" + noRender + '}';
}
}

@ -441,6 +441,8 @@ public class J3MLoader implements AssetLoader {
if (isUseNodes) {
nodesLoaderDelegate.readFragmentShaderNodes(statement.getContents());
}
} else if (split[0].equals("NoRender")) {
technique.setNoRender(true);
} else {
throw new MatParseException(null, split[0], statement);
}

Loading…
Cancel
Save