One can now have a block ForcedRenderState in a technique defnition. this renderstate if filled will be forced into the renderer when the technique is forced

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9749 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 12 years ago
parent eab37f7fce
commit 2915316e45
  1. 11
      engine/src/core-plugins/com/jme3/material/plugins/J3MLoader.java
  2. 10
      engine/src/core/com/jme3/material/TechniqueDef.java
  3. 13
      engine/src/core/com/jme3/renderer/RenderManager.java

@ -353,6 +353,15 @@ public class J3MLoader implements AssetLoader {
renderState = null; renderState = null;
} }
private void readForcedRenderState(List<Statement> renderStates) throws IOException{
renderState = new RenderState();
for (Statement statement : renderStates){
readRenderStateStatement(statement.getLine());
}
technique.setForcedRenderState(renderState);
renderState = null;
}
// <DEFINENAME> [ ":" <PARAMNAME> ] // <DEFINENAME> [ ":" <PARAMNAME> ]
private void readDefine(String statement) throws IOException{ private void readDefine(String statement) throws IOException{
String[] split = statement.split(":"); String[] split = statement.split(":");
@ -386,6 +395,8 @@ public class J3MLoader implements AssetLoader {
readWorldParams(statement.getContents()); readWorldParams(statement.getContents());
}else if (split[0].equals("RenderState")){ }else if (split[0].equals("RenderState")){
readRenderState(statement.getContents()); readRenderState(statement.getContents());
}else if (split[0].equals("ForcedRenderState")){
readForcedRenderState(statement.getContents());
}else if (split[0].equals("Defines")){ }else if (split[0].equals("Defines")){
readDefines(statement.getContents()); readDefines(statement.getContents());
}else{ }else{

@ -113,6 +113,8 @@ public class TechniqueDef implements Savable {
private boolean usesShaders; private boolean usesShaders;
private RenderState renderState; private RenderState renderState;
private RenderState forcedRenderState;
private LightMode lightMode = LightMode.Disable; private LightMode lightMode = LightMode.Disable;
private ShadowMode shadowMode = ShadowMode.Disable; private ShadowMode shadowMode = ShadowMode.Disable;
@ -376,6 +378,14 @@ public class TechniqueDef implements Savable {
} }
} }
public RenderState getForcedRenderState() {
return forcedRenderState;
}
public void setForcedRenderState(RenderState forcedRenderState) {
this.forcedRenderState = forcedRenderState;
}
/** /**
* Returns a list of world parameters that are used by this * Returns a list of world parameters that are used by this
* technique definition. * technique definition.

@ -67,10 +67,8 @@ import java.util.logging.Logger;
public class RenderManager { public class RenderManager {
private static final Logger logger = Logger.getLogger(RenderManager.class.getName()); private static final Logger logger = Logger.getLogger(RenderManager.class.getName());
private Renderer renderer; private Renderer renderer;
private UniformBindingManager uniformBindingManager = new UniformBindingManager(); private UniformBindingManager uniformBindingManager = new UniformBindingManager();
private ArrayList<ViewPort> preViewPorts = new ArrayList<ViewPort>(); private ArrayList<ViewPort> preViewPorts = new ArrayList<ViewPort>();
private ArrayList<ViewPort> viewPorts = new ArrayList<ViewPort>(); private ArrayList<ViewPort> viewPorts = new ArrayList<ViewPort>();
private ArrayList<ViewPort> postViewPorts = new ArrayList<ViewPort>(); private ArrayList<ViewPort> postViewPorts = new ArrayList<ViewPort>();
@ -81,7 +79,6 @@ public class RenderManager {
private boolean shader; private boolean shader;
private int viewX, viewY, viewWidth, viewHeight; private int viewX, viewY, viewWidth, viewHeight;
private Matrix4f orthoMatrix = new Matrix4f(); private Matrix4f orthoMatrix = new Matrix4f();
private String tmpTech; private String tmpTech;
private boolean handleTranlucentBucket = true; private boolean handleTranlucentBucket = true;
@ -502,9 +499,19 @@ public class RenderManager {
if (g.getMaterial().getMaterialDef().getTechniqueDef(forcedTechnique) != null) { if (g.getMaterial().getMaterialDef().getTechniqueDef(forcedTechnique) != null) {
tmpTech = g.getMaterial().getActiveTechnique() != null ? g.getMaterial().getActiveTechnique().getDef().getName() : "Default"; tmpTech = g.getMaterial().getActiveTechnique() != null ? g.getMaterial().getActiveTechnique().getDef().getName() : "Default";
g.getMaterial().selectTechnique(forcedTechnique, this); g.getMaterial().selectTechnique(forcedTechnique, this);
//saving forcedRenderState for future calls
RenderState tmpRs = forcedRenderState;
if (g.getMaterial().getActiveTechnique().getDef().getForcedRenderState() != null) {
//forcing forced technique renderState
forcedRenderState = g.getMaterial().getActiveTechnique().getDef().getForcedRenderState();
}
// use geometry's material // use geometry's material
g.getMaterial().render(g, this); g.getMaterial().render(g, this);
g.getMaterial().selectTechnique(tmpTech, this); g.getMaterial().selectTechnique(tmpTech, this);
//restoring forcedRenderState
forcedRenderState = tmpRs;
//Reverted this part from revision 6197 //Reverted this part from revision 6197
//If forcedTechnique does not exists, and frocedMaterial is not set, the geom MUST NOT be rendered //If forcedTechnique does not exists, and frocedMaterial is not set, the geom MUST NOT be rendered
} else if (forcedMaterial != null) { } else if (forcedMaterial != null) {

Loading…
Cancel
Save