|
28 | 28 | import com.jme3.math.Quaternion; |
29 | 29 | import com.jme3.math.Vector2f; |
30 | 30 | import com.jme3.math.Vector3f; |
| 31 | +import com.jme3.post.FilterPostProcessor; |
31 | 32 | import com.jme3.renderer.Camera; |
| 33 | +import com.jme3.renderer.queue.RenderQueue.ShadowMode; |
32 | 34 | import com.jme3.scene.Node; |
33 | 35 | import com.jme3.scene.Spatial; |
34 | 36 | import com.jme3.scene.Spatial.CullHint; |
| 37 | +import com.jme3.shadow.SpotLightShadowFilter; |
| 38 | +import com.jme3.shadow.SpotLightShadowRenderer; |
35 | 39 | import com.jme3.texture.Texture; |
36 | 40 | import com.jme3.texture.Texture2D; |
37 | 41 | import com.jme3.ui.Picture; |
@@ -148,6 +152,28 @@ public void initialize(final AppStateManager stateManager, final Application app |
148 | 152 | keeperLight.setName("Keeper Hand"); |
149 | 153 | this.app.getRootNode().addLight(keeperLight); |
150 | 154 |
|
| 155 | + var viewPort = this.app.getViewPort(); |
| 156 | + |
| 157 | + final int SHADOWMAP_SIZE = 512; |
| 158 | + |
| 159 | + if (false) { |
| 160 | + } else if (true) { |
| 161 | + var sr = new SpotLightShadowRenderer(assetManager, SHADOWMAP_SIZE); |
| 162 | + sr.setLight(keeperLight); |
| 163 | + viewPort.addProcessor(sr); |
| 164 | + } else { |
| 165 | + var fpp = new FilterPostProcessor(assetManager); |
| 166 | + var plsf = new SpotLightShadowFilter(assetManager, SHADOWMAP_SIZE) /*{ |
| 167 | + { |
| 168 | + shadowRenderer.displayDebug(); |
| 169 | + } |
| 170 | + }*/; |
| 171 | + plsf.setLight(keeperLight); |
| 172 | + plsf.setEnabled(true); |
| 173 | + fpp.addFilter(plsf); |
| 174 | + viewPort.addProcessor(fpp); |
| 175 | + } |
| 176 | + this.app.getRootNode().setShadowMode(ShadowMode.CastAndReceive); |
151 | 177 | // Start loading stuff (maybe we should do this earlier...) |
152 | 178 | inHandLoader.start(); |
153 | 179 | } |
|
0 commit comments