|
|
|
@ -74,20 +74,19 @@ import java.util.logging.Logger; |
|
|
|
|
public class RenderManager { |
|
|
|
|
|
|
|
|
|
private static final Logger logger = Logger.getLogger(RenderManager.class.getName()); |
|
|
|
|
private Renderer renderer; |
|
|
|
|
private UniformBindingManager uniformBindingManager = new UniformBindingManager(); |
|
|
|
|
private ArrayList<ViewPort> preViewPorts = new ArrayList<ViewPort>(); |
|
|
|
|
private ArrayList<ViewPort> viewPorts = new ArrayList<ViewPort>(); |
|
|
|
|
private ArrayList<ViewPort> postViewPorts = new ArrayList<ViewPort>(); |
|
|
|
|
private final Renderer renderer; |
|
|
|
|
private final UniformBindingManager uniformBindingManager = new UniformBindingManager(); |
|
|
|
|
private final ArrayList<ViewPort> preViewPorts = new ArrayList<>(); |
|
|
|
|
private final ArrayList<ViewPort> viewPorts = new ArrayList<>(); |
|
|
|
|
private final ArrayList<ViewPort> postViewPorts = new ArrayList<>(); |
|
|
|
|
private Camera prevCam = null; |
|
|
|
|
private Material forcedMaterial = null; |
|
|
|
|
private String forcedTechnique = null; |
|
|
|
|
private RenderState forcedRenderState = null; |
|
|
|
|
private final List<MatParamOverride> forcedOverrides = new ArrayList<>(); |
|
|
|
|
private int viewX, viewY, viewWidth, viewHeight; |
|
|
|
|
private Matrix4f orthoMatrix = new Matrix4f(); |
|
|
|
|
private LightList filteredLightList = new LightList(null); |
|
|
|
|
private String tmpTech; |
|
|
|
|
private final Matrix4f orthoMatrix = new Matrix4f(); |
|
|
|
|
private final LightList filteredLightList = new LightList(null); |
|
|
|
|
private boolean handleTranlucentBucket = true; |
|
|
|
|
private AppProfiler prof; |
|
|
|
|
private LightFilter lightFilter = new DefaultLightFilter(); |
|
|
|
@ -552,49 +551,54 @@ public class RenderManager { |
|
|
|
|
* for rendering the material, and the material's own render state is ignored. |
|
|
|
|
* Otherwise, the material's render state is used as intended. |
|
|
|
|
* |
|
|
|
|
* @param g The geometry to render |
|
|
|
|
* |
|
|
|
|
* @param geom The geometry to render |
|
|
|
|
* |
|
|
|
|
* @see Technique |
|
|
|
|
* @see RenderState |
|
|
|
|
* @see Material#selectTechnique(java.lang.String, com.jme3.renderer.RenderManager) |
|
|
|
|
* @see Material#render(com.jme3.scene.Geometry, com.jme3.renderer.RenderManager) |
|
|
|
|
*/ |
|
|
|
|
public void renderGeometry(Geometry g) { |
|
|
|
|
if (g.isIgnoreTransform()) { |
|
|
|
|
public void renderGeometry(Geometry geom) { |
|
|
|
|
if (geom.isIgnoreTransform()) { |
|
|
|
|
setWorldMatrix(Matrix4f.IDENTITY); |
|
|
|
|
} else { |
|
|
|
|
setWorldMatrix(g.getWorldMatrix()); |
|
|
|
|
setWorldMatrix(geom.getWorldMatrix()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Perform light filtering if we have a light filter.
|
|
|
|
|
LightList lightList = g.getWorldLightList(); |
|
|
|
|
LightList lightList = geom.getWorldLightList(); |
|
|
|
|
|
|
|
|
|
if (lightFilter != null) { |
|
|
|
|
filteredLightList.clear(); |
|
|
|
|
lightFilter.filterLights(g, filteredLightList); |
|
|
|
|
lightFilter.filterLights(geom, filteredLightList); |
|
|
|
|
lightList = filteredLightList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Material material = geom.getMaterial(); |
|
|
|
|
|
|
|
|
|
//if forcedTechnique we try to force it for render,
|
|
|
|
|
//if it does not exists in the mat def, we check for forcedMaterial and render the geom if not null
|
|
|
|
|
//else the geom is not rendered
|
|
|
|
|
if (forcedTechnique != null) { |
|
|
|
|
MaterialDef matDef = g.getMaterial().getMaterialDef(); |
|
|
|
|
MaterialDef matDef = material.getMaterialDef(); |
|
|
|
|
if (matDef.getTechniqueDefs(forcedTechnique) != null) { |
|
|
|
|
tmpTech = g.getMaterial().getActiveTechnique() != null |
|
|
|
|
? g.getMaterial().getActiveTechnique().getDef().getName() |
|
|
|
|
|
|
|
|
|
Technique activeTechnique = material.getActiveTechnique(); |
|
|
|
|
|
|
|
|
|
String previousTechniqueName = activeTechnique != null |
|
|
|
|
? activeTechnique.getDef().getName() |
|
|
|
|
: TechniqueDef.DEFAULT_TECHNIQUE_NAME; |
|
|
|
|
g.getMaterial().selectTechnique(forcedTechnique, this); |
|
|
|
|
|
|
|
|
|
geom.getMaterial().selectTechnique(forcedTechnique, this); |
|
|
|
|
//saving forcedRenderState for future calls
|
|
|
|
|
RenderState tmpRs = forcedRenderState; |
|
|
|
|
if (g.getMaterial().getActiveTechnique().getDef().getForcedRenderState() != null) { |
|
|
|
|
if (geom.getMaterial().getActiveTechnique().getDef().getForcedRenderState() != null) { |
|
|
|
|
//forcing forced technique renderState
|
|
|
|
|
forcedRenderState = g.getMaterial().getActiveTechnique().getDef().getForcedRenderState(); |
|
|
|
|
forcedRenderState = geom.getMaterial().getActiveTechnique().getDef().getForcedRenderState(); |
|
|
|
|
} |
|
|
|
|
// use geometry's material
|
|
|
|
|
g.getMaterial().render(g, lightList, this); |
|
|
|
|
g.getMaterial().selectTechnique(tmpTech, this); |
|
|
|
|
material.render(geom, lightList, this); |
|
|
|
|
material.selectTechnique(previousTechniqueName, this); |
|
|
|
|
|
|
|
|
|
//restoring forcedRenderState
|
|
|
|
|
forcedRenderState = tmpRs; |
|
|
|
@ -603,13 +607,13 @@ public class RenderManager { |
|
|
|
|
//If forcedTechnique does not exists, and forcedMaterial is not set, the geom MUST NOT be rendered
|
|
|
|
|
} else if (forcedMaterial != null) { |
|
|
|
|
// use forced material
|
|
|
|
|
forcedMaterial.render(g, lightList, this); |
|
|
|
|
forcedMaterial.render(geom, lightList, this); |
|
|
|
|
} |
|
|
|
|
} else if (forcedMaterial != null) { |
|
|
|
|
// use forced material
|
|
|
|
|
forcedMaterial.render(g, lightList, this); |
|
|
|
|
forcedMaterial.render(geom, lightList, this); |
|
|
|
|
} else { |
|
|
|
|
g.getMaterial().render(g, lightList, this); |
|
|
|
|
material.render(geom, lightList, this); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|