Browse Source

Added an option to display the generated maps on screen in the TestPBRLighting

Nehon 8 years ago
parent
commit
3205b8be35

+ 18 - 2
jme3-examples/src/main/java/jme3test/light/pbr/TestPBRLighting.java

@@ -33,11 +33,11 @@ package jme3test.light.pbr;
 
 
 import com.jme3.app.SimpleApplication;
 import com.jme3.app.SimpleApplication;
 import com.jme3.bounding.BoundingSphere;
 import com.jme3.bounding.BoundingSphere;
+import com.jme3.environment.util.*;
 import com.jme3.light.LightProbe;
 import com.jme3.light.LightProbe;
 import com.jme3.environment.LightProbeFactory;
 import com.jme3.environment.LightProbeFactory;
 import com.jme3.environment.EnvironmentCamera;
 import com.jme3.environment.EnvironmentCamera;
 import com.jme3.environment.generation.JobProgressAdapter;
 import com.jme3.environment.generation.JobProgressAdapter;
-import com.jme3.environment.util.LightsDebugState;
 import com.jme3.input.ChaseCamera;
 import com.jme3.input.ChaseCamera;
 import com.jme3.input.KeyInput;
 import com.jme3.input.KeyInput;
 import com.jme3.input.controls.ActionListener;
 import com.jme3.input.controls.ActionListener;
@@ -71,6 +71,10 @@ public class TestPBRLighting extends SimpleApplication {
         TestPBRLighting app = new TestPBRLighting();
         TestPBRLighting app = new TestPBRLighting();
         app.start();
         app.start();
     }
     }
+
+    private Node tex;
+    private Node tex2;
+
     private Geometry model;
     private Geometry model;
     private DirectionalLight dl;
     private DirectionalLight dl;
     private Node modelNode;
     private Node modelNode;
@@ -135,7 +139,17 @@ public class TestPBRLighting extends SimpleApplication {
             @Override
             @Override
             public void onAction(String name, boolean isPressed, float tpf) {
             public void onAction(String name, boolean isPressed, float tpf) {
                 if (name.equals("debug") && isPressed) {
                 if (name.equals("debug") && isPressed) {
-                    //envCam.toggleDebug();
+                    if (tex == null) {
+                        return;
+                    }
+                    if (tex.getParent() == null && tex2.getParent() == null) {
+                        guiNode.attachChild(tex);
+                    } else if (tex2.getParent() == null){
+                        tex.removeFromParent();
+                        guiNode.attachChild(tex2);
+                    } else {
+                        tex2.removeFromParent();
+                    }
                 }
                 }
 
 
                 if (name.equals("up") && isPressed) {
                 if (name.equals("up") && isPressed) {
@@ -183,6 +197,8 @@ public class TestPBRLighting extends SimpleApplication {
                 @Override
                 @Override
                 public void done(LightProbe result) {
                 public void done(LightProbe result) {
                     System.err.println("Done rendering env maps");
                     System.err.println("Done rendering env maps");
+                    tex = EnvMapUtils.getCubeMapCrossDebugViewWithMipMaps(result.getPrefilteredEnvMap(), assetManager);
+                    tex2 = EnvMapUtils.getCubeMapCrossDebugView(result.getIrradianceMap(), assetManager);
                 }
                 }
             });
             });
             ((BoundingSphere)probe.getBounds()).setRadius(100);
             ((BoundingSphere)probe.getBounds()).setRadius(100);