aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/terrain/MountainShadowTerrainExample.java6
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ShadowedTerrainExample.java60
-rw-r--r--ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/Terrain.java26
-rw-r--r--ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/UrlInputSupplier.java21
4 files changed, 56 insertions, 57 deletions
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/MountainShadowTerrainExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/MountainShadowTerrainExample.java
index a04b34c..f5ad049 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/MountainShadowTerrainExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/MountainShadowTerrainExample.java
@@ -27,7 +27,6 @@ import com.ardor3d.extension.shadow.map.ParallelSplitShadowMapPass.Filter;
import com.ardor3d.extension.shadow.map.ShadowCasterManager;
import com.ardor3d.extension.terrain.client.Terrain;
import com.ardor3d.extension.terrain.client.TerrainBuilder;
-import com.ardor3d.extension.terrain.client.UrlInputSupplier;
import com.ardor3d.extension.terrain.heightmap.ImageHeightMap;
import com.ardor3d.extension.terrain.providers.array.ArrayTerrainDataProvider;
import com.ardor3d.extension.ui.Orientation;
@@ -297,9 +296,8 @@ public class MountainShadowTerrainExample extends ExampleBase {
.setShowDebugPanels(true);
terrain = builder.build();
- terrain.setPixelShader(
- new UrlInputSupplier(ResourceLocatorTool.getClassPathResource(ShadowedTerrainExample.class,
- "com/ardor3d/extension/terrain/shadowedGeometryClipmapShader_normalMap.frag")));
+ terrain.setPixelShader(ResourceLocatorTool.getClassPathResource(ShadowedTerrainExample.class,
+ "com/ardor3d/extension/terrain/shadowedGeometryClipmapShader_normalMap.frag"));
terrain.reloadShader();
terrain.getGeometryClipmapShader().setUniform("normalMap", 5);
terrainNode.attachChild(terrain);
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ShadowedTerrainExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ShadowedTerrainExample.java
index 1c7766e..ac8c129 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ShadowedTerrainExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ShadowedTerrainExample.java
@@ -24,7 +24,6 @@ import com.ardor3d.extension.shadow.map.ShadowCasterManager;
import com.ardor3d.extension.terrain.client.Terrain;
import com.ardor3d.extension.terrain.client.TerrainBuilder;
import com.ardor3d.extension.terrain.client.TerrainDataProvider;
-import com.ardor3d.extension.terrain.client.UrlInputSupplier;
import com.ardor3d.extension.terrain.heightmap.MidPointHeightMapGenerator;
import com.ardor3d.extension.terrain.providers.array.ArrayTerrainDataProvider;
import com.ardor3d.framework.Canvas;
@@ -83,7 +82,7 @@ public class ShadowedTerrainExample extends ExampleBase {
/** Pssm shadow map pass. */
private ParallelSplitShadowMapPass _pssmPass;
- private DirectionalLight directionalLight;
+ private DirectionalLight directionalLight;
/** Temp vec for updating light pos. */
private final Vector3 lightPosition = new Vector3(10000, 10000, 10000);
@@ -192,10 +191,12 @@ public class ShadowedTerrainExample extends ExampleBase {
raw.setHeightRange(0.2f);
final float[] heightMap = raw.getHeightData();
- final TerrainDataProvider terrainDataProvider = new ArrayTerrainDataProvider(heightMap, SIZE, new Vector3( 1, 300, 1));
+ final TerrainDataProvider terrainDataProvider = new ArrayTerrainDataProvider(heightMap, SIZE,
+ new Vector3(1, 300, 1));
terrain = new TerrainBuilder(terrainDataProvider, terrainCamera).setShowDebugPanels(true).build();
- terrain.setPixelShader(new UrlInputSupplier(ResourceLocatorTool .getClassPathResource(ShadowedTerrainExample.class, "com/ardor3d/extension/terrain/shadowedGeometryClipmapShaderPCF.frag")));
+ terrain.setPixelShader(ResourceLocatorTool.getClassPathResource(ShadowedTerrainExample.class,
+ "com/ardor3d/extension/terrain/shadowedGeometryClipmapShaderPCF.frag"));
terrain.reloadShader();
_root.attachChild(terrain);
@@ -205,7 +206,8 @@ public class ShadowedTerrainExample extends ExampleBase {
}
// Initialize PSSM shadows
- _pssmPass = new ParallelSplitShadowMapPass(directionalLight, 1024, 4); _pssmPass.setFiltering(Filter.Pcf);
+ _pssmPass = new ParallelSplitShadowMapPass(directionalLight, 1024, 4);
+ _pssmPass.setFiltering(Filter.Pcf);
_pssmPass.setRenderShadowedScene(false);
_pssmPass.setKeepMainShader(true);
_pssmPass.setMaxShadowDistance(750); // XXX: Tune this
@@ -244,45 +246,52 @@ public class ShadowedTerrainExample extends ExampleBase {
updateText();
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() {
- @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
+ @Override
+ public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
updateTerrain = !updateTerrain;
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() {
- @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
+ @Override
+ public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
_controlHandle.setMoveSpeed(5);
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() {
- @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
+ @Override
+ public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
_controlHandle.setMoveSpeed(50);
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() {
- @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
+ @Override
+ public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
_controlHandle.setMoveSpeed(400);
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() {
- @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
+ @Override
+ public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
_controlHandle.setMoveSpeed(1000);
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
- @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
+ @Override
+ public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
groundCamera = !groundCamera;
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.P), new TriggerAction() {
- @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
+ @Override
+ public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) {
sphere.getSceneHints().setCullHint(CullHint.Always);
} else if (sphere.getSceneHints().getCullHint() == CullHint.Always) {
@@ -292,39 +301,45 @@ public class ShadowedTerrainExample extends ExampleBase {
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() {
- @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
+ @Override
+ public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
terrain.getTextureClipmap().setShowDebug(!terrain.getTextureClipmap().isShowDebug());
terrain.reloadShader();
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.G), new TriggerAction() {
- @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
+ @Override
+ public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
terrain.reloadShader();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FIVE), new TriggerAction() {
- @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
+ @Override
+ public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() / 2);
terrain.reloadShader();
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SIX), new TriggerAction() {
- @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
+ @Override
+ public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() * 2);
terrain.reloadShader();
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.C), new TriggerAction() {
- @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
+ @Override
+ public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
_pssmPass.setUpdateMainCamera(!_pssmPass.isUpdateMainCamera());
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ZERO), new TriggerAction() {
- @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
+ @Override
+ public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
final Camera cam = _canvas.getCanvasRenderer().getCamera();
System.out.println("camera location: " + cam.getLocation());
System.out.println("camera direction: " + cam.getDirection());
@@ -356,7 +371,14 @@ public class ShadowedTerrainExample extends ExampleBase {
private void setupDefaultStates() {
_lightState.detachAll();
- directionalLight = new DirectionalLight(); directionalLight.setEnabled(true); directionalLight.setAmbient(new ColorRGBA(0.4f, 0.4f, 0.5f, 1)); directionalLight.setDiffuse(new ColorRGBA(0.6f, 0.6f, 0.5f, 1)); directionalLight.setSpecular(new ColorRGBA(0.3f, 0.3f, 0.2f, 1)); directionalLight.setDirection(lightPosition.normalize(null).negateLocal()); _lightState.attach(directionalLight); _lightState.setEnabled(true);
+ directionalLight = new DirectionalLight();
+ directionalLight.setEnabled(true);
+ directionalLight.setAmbient(new ColorRGBA(0.4f, 0.4f, 0.5f, 1));
+ directionalLight.setDiffuse(new ColorRGBA(0.6f, 0.6f, 0.5f, 1));
+ directionalLight.setSpecular(new ColorRGBA(0.3f, 0.3f, 0.2f, 1));
+ directionalLight.setDirection(lightPosition.normalize(null).negateLocal());
+ _lightState.attach(directionalLight);
+ _lightState.setEnabled(true);
final CullState cs = new CullState();
cs.setEnabled(true);
diff --git a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/Terrain.java b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/Terrain.java
index 6087ddf..25a2064 100644
--- a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/Terrain.java
+++ b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/Terrain.java
@@ -3,7 +3,7 @@
*
* This file is part of Ardor3D.
*
- * Ardor3D is free software: you can redistribute it and/or modify it
+ * Ardor3D is free software: you can redistribute it and/or modify it
* under the terms of its license which may be found in the accompanying
* LICENSE file or at <http://www.ardor3d.com/LICENSE>.
*/
@@ -11,6 +11,7 @@
package com.ardor3d.extension.terrain.client;
import java.io.IOException;
+import java.net.URL;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.Collections;
@@ -47,7 +48,6 @@ import com.ardor3d.scenegraph.Node;
import com.ardor3d.scenegraph.event.DirtyType;
import com.ardor3d.scenegraph.hint.DataMode;
import com.ardor3d.util.resource.ResourceLocatorTool;
-import com.google.common.io.ByteSource;
/**
* An implementation of geometry clipmapping
@@ -83,8 +83,8 @@ public class Terrain extends Node implements Pickable {
private final DoubleBufferedList<Region> mailBox = new DoubleBufferedList<>();
- private ByteSource vertexShader;
- private ByteSource pixelShader;
+ private URL vertexShader;
+ private URL pixelShader;
/** Timers for mailbox updates */
private long oldTime = 0;
@@ -156,10 +156,10 @@ public class Terrain extends Node implements Pickable {
ex.printStackTrace();
}
- vertexShader = new UrlInputSupplier(ResourceLocatorTool.getClassPathResource(Terrain.class,
- "com/ardor3d/extension/terrain/texturedGeometryClipmapShader.vert"));
- pixelShader = new UrlInputSupplier(ResourceLocatorTool.getClassPathResource(Terrain.class,
- "com/ardor3d/extension/terrain/texturedGeometryClipmapShader.frag"));
+ vertexShader = ResourceLocatorTool.getClassPathResource(Terrain.class,
+ "com/ardor3d/extension/terrain/texturedGeometryClipmapShader.vert");
+ pixelShader = ResourceLocatorTool.getClassPathResource(Terrain.class,
+ "com/ardor3d/extension/terrain/texturedGeometryClipmapShader.frag");
// setScale(terrainConfiguration.getScale());
// TODO: hack. unify scale handling over cache etc
@@ -422,8 +422,8 @@ public class Terrain extends Node implements Pickable {
_geometryClipmapShader.setVertexShader(vertexShader.openStream());
_geometryClipmapShader.setFragmentShader(pixelShader.openStream());
} catch (final IOException ex) {
- Terrain.logger
- .logp(Level.SEVERE, getClass().getName(), "init(Renderer)", "Could not load shaders.", ex);
+ Terrain.logger.logp(Level.SEVERE, getClass().getName(), "init(Renderer)", "Could not load shaders.",
+ ex);
}
_geometryClipmapShader.setUniform("texture", 0);
@@ -619,11 +619,11 @@ public class Terrain extends Node implements Pickable {
return _clips;
}
- public void setVertexShader(final ByteSource vertexShader) {
+ public void setVertexShader(final URL vertexShader) {
this.vertexShader = vertexShader;
}
- public void setPixelShader(final ByteSource pixelShader) {
+ public void setPixelShader(final URL pixelShader) {
this.pixelShader = pixelShader;
}
@@ -633,7 +633,7 @@ public class Terrain extends Node implements Pickable {
/**
* set the minimum (highest resolution) clipmap level visible
- *
+ *
* @param level
* clamped to valid range
*/
diff --git a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/UrlInputSupplier.java b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/UrlInputSupplier.java
deleted file mode 100644
index 5dee8af..0000000
--- a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/UrlInputSupplier.java
+++ /dev/null
@@ -1,21 +0,0 @@
-
-package com.ardor3d.extension.terrain.client;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-import com.google.common.io.ByteSource;
-
-public class UrlInputSupplier extends ByteSource {
- private final URL url;
-
- public UrlInputSupplier(final URL url) {
- this.url = url;
- }
-
- @Override
- public InputStream openStream() throws IOException {
- return url.openStream();
- }
-}