aboutsummaryrefslogtreecommitdiffstats
path: root/ardor3d-examples/src/main
diff options
context:
space:
mode:
authorJulien Gouesse <[email protected]>2016-06-30 22:36:24 +0200
committerJulien Gouesse <[email protected]>2016-06-30 22:36:24 +0200
commitced8e5e5a3439630b51a5aef53ef5dfbde69eb95 (patch)
treed09e41e49f4ad4a172a2cb4760d373aead49d4eb /ardor3d-examples/src/main
parent1257dbbf93986d1c2f21c0b1758efd8ffd110cf5 (diff)
Switches from Java 1.6 to Java 1.7 and fixes numerous warnings
Diffstat (limited to 'ardor3d-examples/src/main')
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/ExampleBase.java4
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/ExampleRunner.java14
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/PropertiesDialog.java28
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/PropertiesGameSettings.java96
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/basic/LineExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/basic/MatrixLookAtExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtDesktopExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtAwtExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtSwtExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglSwingExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglSwtExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/effect/ExtrusionExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationDemoExample.java17
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ColladaExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/Texture3DExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/utils/atlas/AtlasExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/utils/atlas/AtlasExampleMultiTextured.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ShadowedTerrainExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/ui/BMFontLoader.java2
20 files changed, 89 insertions, 100 deletions
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleBase.java b/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleBase.java
index 83618d9..3f3076a 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleBase.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleBase.java
@@ -417,8 +417,8 @@ public abstract class ExampleBase implements Runnable, Updater, Scene {
}
final URL dialogImageRef = dialogImage;
- final AtomicReference<PropertiesDialog> dialogRef = new AtomicReference<PropertiesDialog>();
- final Stack<Runnable> mainThreadTasks = new Stack<Runnable>();
+ final AtomicReference<PropertiesDialog> dialogRef = new AtomicReference<>();
+ final Stack<Runnable> mainThreadTasks = new Stack<>();
try {
if (EventQueue.isDispatchThread()) {
dialogRef.set(new PropertiesDialog(settings, dialogImageRef, mainThreadTasks));
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleRunner.java b/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleRunner.java
index ad65b8b..e55846a 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleRunner.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleRunner.java
@@ -449,7 +449,7 @@ public class ExampleRunner extends JFrame {
final Class<?> clazz = (Class<?>) selected;
final boolean isWindows = System.getProperty("os.name").contains("Windows");
- final List<String> args = new ArrayList<String>();
+ final List<String> args = new ArrayList<>();
args.add(isWindows ? "javaw" : "java");
args.add("-Xmx" + maxHeapMemory + "M");
args.add("-cp");
@@ -509,10 +509,10 @@ public class ExampleRunner extends JFrame {
class ClassTreeModel implements TreeModel, SearchFilter {
private final EventListenerList listeners = new EventListenerList();
- private final LinkedHashMap<Package, Vector<Class<?>>> classes = new LinkedHashMap<Package, Vector<Class<?>>>();
+ private final LinkedHashMap<Package, Vector<Class<?>>> classes = new LinkedHashMap<>();
// the next two maps are for caching the status for the search filter
- private final HashMap<Class<?>, Boolean> classMatches = new HashMap<Class<?>, Boolean>();
- private final HashMap<Package, Boolean> packageMatches = new HashMap<Package, Boolean>();
+ private final HashMap<Class<?>, Boolean> classMatches = new HashMap<>();
+ private final HashMap<Package, Boolean> packageMatches = new HashMap<>();
private String root = "all examples";
private FileFilter classFileFilter;
private int size;
@@ -526,7 +526,7 @@ public class ExampleRunner extends JFrame {
@Override
public Object getChild(final Object parent, final int index) {
if (root.equals(parent)) {
- final Vector<Package> vec = new Vector<Package>(classes.keySet());
+ final Vector<Package> vec = new Vector<>(classes.keySet());
return vec.get(index);
}
final Vector<Class<?>> cl = classes.get(parent);
@@ -545,7 +545,7 @@ public class ExampleRunner extends JFrame {
@Override
public int getIndexOfChild(final Object parent, final Object child) {
if (root.equals(parent)) {
- final Vector<Package> vec = new Vector<Package>(classes.keySet());
+ final Vector<Package> vec = new Vector<>(classes.keySet());
return vec.indexOf(child);
}
final Vector<Class<?>> cl = classes.get(parent);
@@ -566,7 +566,7 @@ public class ExampleRunner extends JFrame {
classMatches.put(clazz, false);
Vector<Class<?>> cl = classes.get(clazz.getPackage());
if (cl == null) {
- cl = new Vector<Class<?>>();
+ cl = new Vector<>();
classes.put(clazz.getPackage(), cl);
}
size++;
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/PropertiesDialog.java b/ardor3d-examples/src/main/java/com/ardor3d/example/PropertiesDialog.java
index 5124b44..a12274a 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/PropertiesDialog.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/PropertiesDialog.java
@@ -266,9 +266,9 @@ public final class PropertiesDialog extends JDialog {
displayResCombo.addKeyListener(aListener);
samplesCombo = setUpSamplesChooser();
samplesCombo.addKeyListener(aListener);
- colorDepthCombo = new JComboBox<String>();
+ colorDepthCombo = new JComboBox<>();
colorDepthCombo.addKeyListener(aListener);
- displayFreqCombo = new JComboBox<String>();
+ displayFreqCombo = new JComboBox<>();
displayFreqCombo.addKeyListener(aListener);
fullscreenBox = new JCheckBox("Fullscreen?");
fullscreenBox.setSelected(source.isFullscreen());
@@ -413,7 +413,7 @@ public final class PropertiesDialog extends JDialog {
*/
private JComboBox<String> setUpResolutionChooser() {
final String[] res = getResolutions(modes);
- final JComboBox<String> resolutionBox = new JComboBox<String>(res);
+ final JComboBox<String> resolutionBox = new JComboBox<>(res);
resolutionBox.setSelectedItem(source.getWidth() + " x " + source.getHeight());
resolutionBox.addActionListener(new ActionListener() {
@@ -433,7 +433,7 @@ public final class PropertiesDialog extends JDialog {
* @return the list of renderers.
*/
private JComboBox<String> setUpRendererChooser() {
- final JComboBox<String> nameBox = new JComboBox<String>(new String[] { "JOGL 2" });
+ final JComboBox<String> nameBox = new JComboBox<>(new String[] { "JOGL 2" });
// final String old = source.getRenderer();
/*
* if (old != null) { if (old.startsWith("JOGL")) {
@@ -446,7 +446,7 @@ public final class PropertiesDialog extends JDialog {
}
private JComboBox<String> setUpSamplesChooser() {
- final JComboBox<String> nameBox = new JComboBox<String>(samples);
+ final JComboBox<String> nameBox = new JComboBox<>(samples);
nameBox.setSelectedItem(source.getRenderer());
return nameBox;
}
@@ -472,11 +472,11 @@ public final class PropertiesDialog extends JDialog {
// grab available depths
final String[] depths = getDepths(resolution, modes);
- colorDepthCombo.setModel(new DefaultComboBoxModel<String>(depths));
+ colorDepthCombo.setModel(new DefaultComboBoxModel<>(depths));
colorDepthCombo.setSelectedItem(colorDepth);
// grab available frequencies
final String[] freqs = getFrequencies(resolution, modes);
- displayFreqCombo.setModel(new DefaultComboBoxModel<String>(freqs));
+ displayFreqCombo.setModel(new DefaultComboBoxModel<>(freqs));
// Try to reset freq
displayFreqCombo.setSelectedItem(displayFreq);
}
@@ -488,12 +488,12 @@ public final class PropertiesDialog extends JDialog {
*/
private void updateResolutionChoices() {
if (!fullscreenBox.isSelected()) {
- displayResCombo.setModel(new DefaultComboBoxModel<String>(windowedResolutions));
- colorDepthCombo.setModel(new DefaultComboBoxModel<String>(new String[] { "24 bpp", "16 bpp" }));
- displayFreqCombo.setModel(new DefaultComboBoxModel<String>(new String[] { "n/a" }));
+ displayResCombo.setModel(new DefaultComboBoxModel<>(windowedResolutions));
+ colorDepthCombo.setModel(new DefaultComboBoxModel<>(new String[] { "24 bpp", "16 bpp" }));
+ displayFreqCombo.setModel(new DefaultComboBoxModel<>(new String[] { "n/a" }));
displayFreqCombo.setEnabled(false);
} else {
- displayResCombo.setModel(new DefaultComboBoxModel<String>(getResolutions(modes)));
+ displayResCombo.setModel(new DefaultComboBoxModel<>(getResolutions(modes)));
displayFreqCombo.setEnabled(true);
updateDisplayChoices();
}
@@ -526,7 +526,7 @@ public final class PropertiesDialog extends JDialog {
* Returns every unique resolution from an array of <code>DisplayMode</code>s.
*/
private static String[] getResolutions(final DisplayMode[] modes) {
- final List<String> resolutions = new ArrayList<String>(modes.length);
+ final List<String> resolutions = new ArrayList<>(modes.length);
for (int i = 0; i < modes.length; i++) {
final String res = modes[i].getWidth() + " x " + modes[i].getHeight();
if (!resolutions.contains(res)) {
@@ -543,7 +543,7 @@ public final class PropertiesDialog extends JDialog {
* Returns every possible bit depth for the given resolution.
*/
private static String[] getDepths(final String resolution, final DisplayMode[] modes) {
- final Set<String> depths = new TreeSet<String>(new Comparator<String>() {
+ final Set<String> depths = new TreeSet<>(new Comparator<String>() {
@Override
public int compare(final String o1, final String o2) {
// reverse order
@@ -573,7 +573,7 @@ public final class PropertiesDialog extends JDialog {
* Returns every possible refresh rate for the given resolution.
*/
private static String[] getFrequencies(final String resolution, final DisplayMode[] modes) {
- final List<String> freqs = new ArrayList<String>(4);
+ final List<String> freqs = new ArrayList<>(4);
for (int i = 0; i < modes.length; i++) {
final String res = modes[i].getWidth() + " x " + modes[i].getHeight();
final String freq = modes[i].getRefreshRate() + " Hz";
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/PropertiesGameSettings.java b/ardor3d-examples/src/main/java/com/ardor3d/example/PropertiesGameSettings.java
index dbac6e3..b93c085 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/PropertiesGameSettings.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/PropertiesGameSettings.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>.
*/
@@ -12,7 +12,6 @@ package com.ardor3d.example;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -26,7 +25,7 @@ import com.ardor3d.util.resource.ResourceLocatorTool;
/**
* <code>PropertiesGameSettings</code> handles loading and saving a properties file that defines the display settings. A
* property file is identified during creation of the object. The properties file should have the following format:
- *
+ *
* <PRE>
* &lt;CODE&gt;
* FREQ=60
@@ -106,7 +105,7 @@ public class PropertiesGameSettings {
/**
* Constructor creates the <code>PropertiesGameSettings</code> object for use.
- *
+ *
* @param personalFilename
* the properties file to use, read from filesystem. Must not be null.
* @param dfltsFilename
@@ -138,7 +137,7 @@ public class PropertiesGameSettings {
/**
* <code>get</code> takes an arbitrary string as a key and returns any value associated with it, null if none.
- *
+ *
* @param key
* the key to use for data retrieval.
* @return the string associated with the key, null if none.
@@ -154,7 +153,7 @@ public class PropertiesGameSettings {
/**
* If the properties file does not contain the setting or was not read properly, the default value is returned.
- *
+ *
* @throws InternalError
* in all cases
*/
@@ -183,7 +182,7 @@ public class PropertiesGameSettings {
/**
* <code>getDepth</code> returns the depth as read from the properties file. If the properties file does not contain
* depth or was not read properly, the default depth is returned.
- *
+ *
* @return the depth determined by the properties file, or the default.
*/
public int getDepth() {
@@ -197,7 +196,7 @@ public class PropertiesGameSettings {
/**
* If the properties file does not contain the setting or was not read properly, the default value is returned.
- *
+ *
* @throws InternalError
* in all cases
*/
@@ -218,7 +217,7 @@ public class PropertiesGameSettings {
/**
* If the properties file does not contain the setting or was not read properly, the default value is returned.
- *
+ *
* @throws InternalError
* in all cases
*/
@@ -230,7 +229,7 @@ public class PropertiesGameSettings {
/**
* <code>getFrequency</code> returns the frequency of the monitor as read from the properties file. If the
* properties file does not contain frequency or was not read properly the default frequency is returned.
- *
+ *
* @return the frequency determined by the properties file, or the default.
*/
public int getFrequency() {
@@ -244,7 +243,7 @@ public class PropertiesGameSettings {
/**
* Legacy method.
- *
+ *
* @deprecated Use method isFullscreen instead.
* @see #isFullscreen()
*/
@@ -256,7 +255,7 @@ public class PropertiesGameSettings {
/**
* <code>getHeight</code> returns the height as read from the properties file. If the properties file does not
* contain height or was not read properly, the default height is returned.
- *
+ *
* @return the height determined by the properties file, or the default.
*/
public int getHeight() {
@@ -284,9 +283,9 @@ public class PropertiesGameSettings {
}
/**
- *
+ *
* <code>getRenderer</code> returns the requested rendering API, or the default.
- *
+ *
* @return the rendering API or the default.
*/
public String getRenderer() {
@@ -300,7 +299,7 @@ public class PropertiesGameSettings {
/**
* If the properties file does not contain the setting or was not read properly, the default value is returned.
- *
+ *
* @throws InternalError
* in all cases
*/
@@ -311,7 +310,7 @@ public class PropertiesGameSettings {
/**
* If the properties file does not contain the setting or was not read properly, the default value is returned.
- *
+ *
* @throws InternalError
* in all cases
*/
@@ -323,7 +322,7 @@ public class PropertiesGameSettings {
/**
* <code>getWidth</code> returns the width as read from the properties file. If the properties file does not contain
* width or was not read properly, the default width is returned.
- *
+ *
* @return the width determined by the properties file, or the default.
*/
public int getWidth() {
@@ -338,7 +337,7 @@ public class PropertiesGameSettings {
/**
* <code>isFullscreen</code> returns the fullscreen flag as read from the properties file. If the properties file
* does not contain the fullscreen flag or was not read properly, the default value is returned.
- *
+ *
* @return the fullscreen flag determined by the properties file, or the default.
*/
public boolean isFullscreen() {
@@ -352,7 +351,7 @@ public class PropertiesGameSettings {
/**
* If the properties file does not contain the setting or was not read properly, the default value is returned.
- *
+ *
* @throws InternalError
* in all cases
*/
@@ -367,7 +366,7 @@ public class PropertiesGameSettings {
/**
* If the properties file does not contain the setting or was not read properly, the default value is returned.
- *
+ *
* @throws InternalError
* in all cases
*/
@@ -378,7 +377,7 @@ public class PropertiesGameSettings {
/**
* If the properties file does not contain the setting or was not read properly, the default value is returned.
- *
+ *
* @throws InternalError
* in all cases
*/
@@ -390,35 +389,26 @@ public class PropertiesGameSettings {
/**
* <code>load</code> attempts to load the properties file defined during instantiation and put all properties in the
* table. If there is a problem loading or reading the file, false is returned. If all goes well, true is returned.
- *
+ *
* @return the success of the load, true indicated success and false indicates failure.
*/
public boolean load() {
- FileInputStream fin = null;
- try {
- fin = new FileInputStream(filename);
- } catch (final FileNotFoundException e) {
- logger.warning("Could not load properties. Creating a new one.");
- return false;
- }
-
- try {
+ try (final FileInputStream fin = new FileInputStream(filename)) {
prop.load(fin);
- fin.close();
+
+ // confirm that the properties file has all the data we need.
+ if (null == prop.getProperty("WIDTH") || null == prop.getProperty("HEIGHT")
+ || null == prop.getProperty("DEPTH") || null == prop.getProperty("FULLSCREEN")) {
+ logger.warning("Properties file not complete.");
+ return false;
+ }
+
+ logger.finer("Read properties");
+ return true;
} catch (final IOException e) {
logger.warning("Could not load properties. Creating a new one.");
return false;
}
-
- // confirm that the properties file has all the data we need.
- if (null == prop.getProperty("WIDTH") || null == prop.getProperty("HEIGHT")
- || null == prop.getProperty("DEPTH") || null == prop.getProperty("FULLSCREEN")) {
- logger.warning("Properties file not complete.");
- return false;
- }
-
- logger.finer("Read properties");
- return true;
}
/**
@@ -430,21 +420,20 @@ public class PropertiesGameSettings {
/**
* Persists current property mappings to designated file, overwriting if file already present.
- *
+ *
* @throws IOException
* for I/O failures
*/
public void save() throws IOException {
- final FileOutputStream fout = new FileOutputStream(filename);
- prop.store(fout, "Game Settings written by " + getClass().getName() + " at " + new java.util.Date());
-
- fout.close();
+ try (final FileOutputStream fout = new FileOutputStream(filename)) {
+ prop.store(fout, "Game Settings written by " + getClass().getName() + " at " + new java.util.Date());
+ }
logger.finer("Saved properties");
}
/**
* <code>save(int, int, int, int, boolean, String)</code> overwrites the properties file with the given parameters.
- *
+ *
* @param width
* the width of the resolution.
* @param height
@@ -595,7 +584,7 @@ public class PropertiesGameSettings {
/**
* Not implemented. Properties can not store an arbitrary Object in human-readable format. Use set(String, String)
* instead.
- *
+ *
* @see #set(String, String)
* @throws InternalError
* in all cases
@@ -648,7 +637,7 @@ public class PropertiesGameSettings {
/**
* save() method which throws only a RuntimeExceptin.
- *
+ *
* @throws RuntimeSetting
* for IO failure
* @see #save()
@@ -675,7 +664,7 @@ public class PropertiesGameSettings {
* AbstractGameSettings.assignDefaults(propfilename).
* <P/>
* Property file paths are relative to CLASSPATH element roots.
- *
+ *
* @param propFileName
* Properties file read as CLASSPATH resource. If you give null, no properties file will be loaded.
*/
@@ -745,8 +734,9 @@ public class PropertiesGameSettings {
try {
p.load(istream);
} catch (final IOException ioe) {
- logger.log(Level.WARNING, "Failed to load customizations from '" + propFileName
- + "'. Continuing without customizations.", ioe);
+ logger.log(Level.WARNING,
+ "Failed to load customizations from '" + propFileName + "'. Continuing without customizations.",
+ ioe);
return;
}
Integer i;
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/basic/LineExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/basic/LineExample.java
index a4fcfa8..e45cddb 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/basic/LineExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/basic/LineExample.java
@@ -107,7 +107,7 @@ public class LineExample extends ExampleBase {
private Line makeLine(final Grapher grapher, final double min, final double max, final double step) {
// This is just one way to make a line... You can also generate the FloatBuffer directly.
// Make an array to hold the Vector3 points that will make up our Line.
- final ArrayList<Vector3> vertexList = new ArrayList<Vector3>();
+ final ArrayList<Vector3> vertexList = new ArrayList<>();
// Step through our range [min, max] by our step amount.
for (double x = min; x <= max; x += step) {
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/basic/MatrixLookAtExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/basic/MatrixLookAtExample.java
index 5bf947d..6934943 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/basic/MatrixLookAtExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/basic/MatrixLookAtExample.java
@@ -39,7 +39,7 @@ maxHeapMemory = 64)
public class MatrixLookAtExample extends ExampleBase {
private Mesh targetMesh;
- private final List<Mesh> boxes = new ArrayList<Mesh>();
+ private final List<Mesh> boxes = new ArrayList<>();
private double time = 0.0;
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtDesktopExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtDesktopExample.java
index 5cad0b3..d14d43b 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtDesktopExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtDesktopExample.java
@@ -61,7 +61,7 @@ public class JoglAwtDesktopExample {
static MouseCursor _cursor1;
static MouseCursor _cursor2;
- static Map<Canvas, Boolean> _showCursor1 = new HashMap<Canvas, Boolean>();
+ static Map<Canvas, Boolean> _showCursor1 = new HashMap<>();
public static void main(final String[] args) throws Exception {
System.setProperty("ardor3d.useMultipleContexts", "true");
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtExample.java
index 287e0f9..ca3d78c 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtExample.java
@@ -58,7 +58,7 @@ public class JoglAwtExample {
static MouseCursor _cursor1;
static MouseCursor _cursor2;
- static Map<Canvas, Boolean> _showCursor1 = new HashMap<Canvas, Boolean>();
+ static Map<Canvas, Boolean> _showCursor1 = new HashMap<>();
public static void main(final String[] args) throws Exception {
System.setProperty("ardor3d.useMultipleContexts", "true");
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtAwtExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtAwtExample.java
index dbd6ab4..c44fde3 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtAwtExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtAwtExample.java
@@ -61,7 +61,7 @@ public class JoglNewtAwtExample {
static MouseCursor _cursor1;
static MouseCursor _cursor2;
- static Map<Canvas, Boolean> _showCursor1 = new HashMap<Canvas, Boolean>();
+ static Map<Canvas, Boolean> _showCursor1 = new HashMap<>();
public static void main(final String[] args) throws Exception {
System.setProperty("ardor3d.useMultipleContexts", "true");
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtSwtExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtSwtExample.java
index 0aea9e5..ad3d9f6 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtSwtExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtSwtExample.java
@@ -73,7 +73,7 @@ public class JoglNewtSwtExample {
static MouseCursor _cursor1;
static MouseCursor _cursor2;
- static Map<Canvas, Boolean> _showCursor1 = new HashMap<Canvas, Boolean>();
+ static Map<Canvas, Boolean> _showCursor1 = new HashMap<>();
private static final Logger logger = Logger.getLogger(JoglNewtSwtExample.class.toString());
private static int i = 0;
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglSwingExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglSwingExample.java
index b19d581..daab345 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglSwingExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglSwingExample.java
@@ -59,7 +59,7 @@ public class JoglSwingExample {
static MouseCursor _cursor1;
static MouseCursor _cursor2;
- static Map<Canvas, Boolean> _showCursor1 = new HashMap<Canvas, Boolean>();
+ static Map<Canvas, Boolean> _showCursor1 = new HashMap<>();
public static void main(final String[] args) throws Exception {
System.setProperty("ardor3d.useMultipleContexts", "true");
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglSwtExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglSwtExample.java
index ec7d852..7fb0519 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglSwtExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglSwtExample.java
@@ -73,7 +73,7 @@ public class JoglSwtExample {
static MouseCursor _cursor1;
static MouseCursor _cursor2;
- static Map<Canvas, Boolean> _showCursor1 = new HashMap<Canvas, Boolean>();
+ static Map<Canvas, Boolean> _showCursor1 = new HashMap<>();
private static final Logger logger = Logger.getLogger(JoglSwtExample.class.toString());
private static int i = 0;
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/effect/ExtrusionExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/effect/ExtrusionExample.java
index 05ab024..a7fa7ad 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/effect/ExtrusionExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/effect/ExtrusionExample.java
@@ -42,7 +42,7 @@ public class ExtrusionExample extends ExampleBase {
_canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(0, 0, 80));
_canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(), Vector3.UNIT_Y);
- final List<ReadOnlyVector3> path = new ArrayList<ReadOnlyVector3>();
+ final List<ReadOnlyVector3> path = new ArrayList<>();
path.add(new Vector3(0, 0, 0));
path.add(new Vector3(0, 0, 4));
path.add(new Vector3(1, 0, 8));
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationDemoExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationDemoExample.java
index 0912b12..24c8eba 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationDemoExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationDemoExample.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>.
*/
@@ -59,17 +59,17 @@ import com.ardor3d.util.resource.URLResourceSource;
* Illustrates loading several animations from Collada and arranging them in an animation state machine.
*/
@Purpose(htmlDescriptionKey = "com.ardor3d.example.pipeline.AnimationDemoExample", //
-thumbnailPath = "com/ardor3d/example/media/thumbnails/pipeline_AnimationDemoExample.jpg", //
-maxHeapMemory = 64)
+ thumbnailPath = "com/ardor3d/example/media/thumbnails/pipeline_AnimationDemoExample.jpg", //
+ maxHeapMemory = 64)
public class AnimationDemoExample extends ExampleBase {
private static final long MIN_STATE_TIME = 5000;
static AnimationDemoExample instance;
- private final List<AnimationManager> managers = new ArrayList<AnimationManager>();
- private final List<AnimationInfo> animInfo = new ArrayList<AnimationInfo>();
- private final Map<SkeletonPose, SkinnedMesh> poseToMesh = new IdentityHashMap<SkeletonPose, SkinnedMesh>();
+ private final List<AnimationManager> managers = new ArrayList<>();
+ private final List<AnimationInfo> animInfo = new ArrayList<>();
+ private final Map<SkeletonPose, SkinnedMesh> poseToMesh = new IdentityHashMap<>();
public static void main(final String[] args) {
ExampleBase.start(AnimationDemoExample.class);
@@ -148,8 +148,7 @@ public class AnimationDemoExample extends ExampleBase {
try {
gpuShader.setVertexShader(ResourceLocatorTool.getClassPathResourceAsStream(AnimationDemoExample.class,
"com/ardor3d/extension/animation/skeletal/skinning_gpu_texture.vert"));
- gpuShader.setFragmentShader(ResourceLocatorTool.getClassPathResourceAsStream(
- AnimationDemoExample.class,
+ gpuShader.setFragmentShader(ResourceLocatorTool.getClassPathResourceAsStream(AnimationDemoExample.class,
"com/ardor3d/extension/animation/skeletal/skinning_gpu_texture.frag"));
gpuShader.setUniform("texture", 0);
@@ -197,7 +196,7 @@ public class AnimationDemoExample extends ExampleBase {
return skeleton;
}
- private final Map<String, AnimationClip> animationStore = new HashMap<String, AnimationClip>();
+ private final Map<String, AnimationClip> animationStore = new HashMap<>();
private AnimationManager createAnimationManager(final SkeletonPose pose) {
// Make our manager
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ColladaExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ColladaExample.java
index 960e9a3..7658797 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ColladaExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ColladaExample.java
@@ -359,7 +359,7 @@ public class ColladaExample extends ExampleBase {
private List<File> findFiles(final File rootDir, final String name, List<File> fileList) {
if (fileList == null) {
- fileList = new ArrayList<File>();
+ fileList = new ArrayList<>();
}
final File[] files = rootDir.listFiles();
for (int i = 0; i < files.length; i++) {
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/Texture3DExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/Texture3DExample.java
index 8a7ce03..0c82d57 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/Texture3DExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/Texture3DExample.java
@@ -78,7 +78,7 @@ public class Texture3DExample extends ExampleBase {
img.setHeight(32);
img.setDepth(32);
- final List<ByteBuffer> data = new ArrayList<ByteBuffer>();
+ final List<ByteBuffer> data = new ArrayList<>();
for (int i = 0; i < 32; i++) {
final Image colorImage = GeneratedImageFactory
.createSolidColorImage(ColorRGBA.randomColor(null), false, 32);
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/utils/atlas/AtlasExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/utils/atlas/AtlasExample.java
index cc3353c..962771a 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/utils/atlas/AtlasExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/utils/atlas/AtlasExample.java
@@ -158,7 +158,7 @@ public class AtlasExample extends ExampleBase {
private void packIntoAtlas(final Spatial spatial) {
// Gather up all meshes to do the atlas operation on
- final List<Mesh> meshes = new ArrayList<Mesh>();
+ final List<Mesh> meshes = new ArrayList<>();
final Visitor visitor = new Visitor() {
@Override
public void visit(final Spatial spatial) {
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/utils/atlas/AtlasExampleMultiTextured.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/utils/atlas/AtlasExampleMultiTextured.java
index 8e3ee11..831fc05 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/utils/atlas/AtlasExampleMultiTextured.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/utils/atlas/AtlasExampleMultiTextured.java
@@ -159,7 +159,7 @@ public class AtlasExampleMultiTextured extends ExampleBase {
private void packIntoAtlas(final Spatial spatial) {
// Gather up all meshes to do the atlas operation on
- final List<Mesh> meshes = new ArrayList<Mesh>();
+ final List<Mesh> meshes = new ArrayList<>();
final Visitor visitor = new Visitor() {
@Override
public void visit(final Spatial spatial) {
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 3f339fc..89ba8fd 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
@@ -1 +1 @@
-/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * 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>. */ package com.ardor3d.example.terrain; import java.util.Random; import java.util.concurrent.Callable; import java.util.logging.Level; import java.util.logging.Logger; import com.ardor3d.bounding.BoundingBox; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.shadow.map.ParallelSplitShadowMapPass; import com.ardor3d.extension.shadow.map.ParallelSplitShadowMapPass.Filter; 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; import com.ardor3d.framework.CanvasRenderer; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.intersection.PickingUtil; import com.ardor3d.intersection.PrimitivePickResults; import com.ardor3d.light.DirectionalLight; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.Ray3; import com.ardor3d.math.Vector3; import com.ardor3d.renderer.Camera; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.FogState; import com.ardor3d.renderer.state.FogState.DensityFunction; import com.ardor3d.scenegraph.Mesh; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.shape.Box; import com.ardor3d.scenegraph.shape.Sphere; import com.ardor3d.ui.text.BasicText; import com.ardor3d.util.GameTaskQueue; import com.ardor3d.util.GameTaskQueueManager; import com.ardor3d.util.ReadOnlyTimer; import com.ardor3d.util.resource.ResourceLocatorTool; /** * Example showing the Geometry Clipmap Terrain system combined with PSSM. (a bit experimental) Requires GLSL support. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.terrain.ShadowedTerrainExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/terrain_ShadowedTerrainExample.jpg", // maxHeapMemory = 128) public class ShadowedTerrainExample extends ExampleBase { /** The Constant logger. */ private static final Logger logger = Logger.getLogger(ShadowedTerrainExample.class.getName()); private boolean updateTerrain = true; private final float farPlane = 2500.0f; private Terrain terrain; private final Sphere sphere = new Sphere("sp", 16, 16, 1); private final Ray3 pickRay = new Ray3(); private boolean groundCamera = false; private Camera terrainCamera; /** Pssm shadow map pass. */ private ParallelSplitShadowMapPass _pssmPass; private DirectionalLight light; /** Temp vec for updating light pos. */ private final Vector3 lightPosition = new Vector3(10000, 10000, 10000); /** Text fields used to present info about the example. */ private final BasicText _exampleInfo[] = new BasicText[5]; public static void main(final String[] args) { ExampleBase.start(ShadowedTerrainExample.class); } @Override protected void updateExample(final ReadOnlyTimer timer) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); // Make sure camera is above terrain final double height = terrain.getHeightAt(camera.getLocation().getX(), camera.getLocation().getZ()); if (height > -Float.MAX_VALUE && (groundCamera || camera.getLocation().getY() < height + 3)) { camera.setLocation(new Vector3(camera.getLocation().getX(), height + 3, camera.getLocation().getZ())); } if (updateTerrain) { terrainCamera.set(camera); } // if we're picking... if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { // Set up our pick ray pickRay.setOrigin(camera.getLocation()); pickRay.setDirection(camera.getDirection()); // do pick and move the sphere final PrimitivePickResults pickResults = new PrimitivePickResults(); pickResults.setCheckDistance(true); PickingUtil.findPick(_root, pickRay, pickResults); if (pickResults.getNumber() != 0) { final Vector3 intersectionPoint = pickResults.getPickData(0).getIntersectionRecord() .getIntersectionPoint(0); sphere.setTranslation(intersectionPoint); // XXX: maybe change the color of the ball for valid vs. invalid? } } } @Override protected void renderExample(final Renderer renderer) { // Lazy init since it needs the renderer... if (!_pssmPass.isInitialised()) { _pssmPass.init(renderer); _pssmPass.setPssmShader(terrain.getGeometryClipmapShader()); for (int i = 0; i < _pssmPass.getNumOfSplits(); i++) { terrain.getClipTextureState().setTexture(_pssmPass.getShadowMapTexture(i), i + 1); } for (int i = 0; i < ParallelSplitShadowMapPass._MAX_SPLITS; i++) { terrain.getGeometryClipmapShader().setUniform("shadowMap" + i, i + 1); } } // Update shadowmaps _pssmPass.updateShadowMaps(renderer); // Render scene and terrain with shadows super.renderExample(renderer); renderer.renderBuckets(); // Render overlay shadows for all objects except the terrain _pssmPass.renderShadowedScene(renderer); // TODO: this results in text etc also being shadowed, since they are drawn in the main render... } /** * Initialize pssm pass and scene. */ @Override protected void initExample() { _canvas.setTitle("Terrain Example"); final Camera cam = _canvas.getCanvasRenderer().getCamera(); cam.setLocation(new Vector3(440, 215, 275)); cam.lookAt(new Vector3(450, 140, 360), Vector3.UNIT_Y); cam.setFrustumPerspective(70.0, (float) cam.getWidth() / cam.getHeight(), 1.0f, farPlane); final CanvasRenderer canvasRenderer = _canvas.getCanvasRenderer(); final RenderContext renderContext = canvasRenderer.getRenderContext(); final Renderer renderer = canvasRenderer.getRenderer(); GameTaskQueueManager.getManager(renderContext).getQueue(GameTaskQueue.RENDER).enqueue(new Callable<Void>() { @Override public Void call() throws Exception { renderer.setBackgroundColor(ColorRGBA.GRAY); return null; } }); _controlHandle.setMoveSpeed(200); setupDefaultStates(); sphere.getSceneHints().setAllPickingHints(false); sphere.getSceneHints().setCullHint(CullHint.Always); _root.attachChild(sphere); try { // Keep a separate camera to be able to freeze terrain update terrainCamera = new Camera(cam); final int SIZE = 2048; final MidPointHeightMapGenerator raw = new MidPointHeightMapGenerator(SIZE, 0.6f); raw.setHeightRange(0.2f); final float[] heightMap = raw.getHeightData(); 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.reloadShader(); _root.attachChild(terrain); } catch (final Exception e) { logger.log(Level.SEVERE, "Problem setting up terrain...", e); System.exit(1); } // Initialize PSSM shadows _pssmPass = new ParallelSplitShadowMapPass(light, 1024, 4); _pssmPass.setFiltering(Filter.Pcf); _pssmPass.setRenderShadowedScene(false); _pssmPass.setKeepMainShader(true); _pssmPass.setMaxShadowDistance(750); // XXX: Tune this // _pssmPass.setMinimumLightDistance(500); // XXX: Tune this _pssmPass.setUseSceneTexturing(false); _pssmPass.setUseObjectCullFace(false); // _pssmPass.setDrawDebug(true); final Node occluders = setupOccluders(); _root.attachChild(occluders); // TODO: could we use the shadow variable in scenehints here?? // Add objects that will get shadowed through overlay render _pssmPass.add(occluders); // Add terrain in as bounds receiver as well, since it's not in the overlay list _pssmPass.addBoundsReceiver(terrain); // Add our occluders that will produce shadows _pssmPass.addOccluder(occluders); // Setup labels for presenting example info. final Node textNodes = new Node("Text"); _root.attachChild(textNodes); textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off); final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2; for (int i = 0; i < _exampleInfo.length; i++) { _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16); _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0)); textNodes.attachChild(_exampleInfo[i]); } textNodes.updateGeometricState(0.0); updateText(); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() { @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) { _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) { _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) { _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) { _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) { 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) { if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { sphere.getSceneHints().setCullHint(CullHint.Always); } else if (sphere.getSceneHints().getCullHint() == CullHint.Always) { sphere.getSceneHints().setCullHint(CullHint.Dynamic); } updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() { @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) { 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) { 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) { 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) { _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) { final Camera cam = _canvas.getCanvasRenderer().getCamera(); System.out.println("camera location: " + cam.getLocation()); System.out.println("camera direction: " + cam.getDirection()); } })); } private Node setupOccluders() { final Node occluders = new Node("Occluders"); final Box box = new Box("Box", new Vector3(), 1, 40, 1); box.setModelBound(new BoundingBox()); box.setRandomColors(); final Random rand = new Random(1337); for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { final Mesh sm = box.makeCopy(true); sm.setTranslation(500 + rand.nextDouble() * 300 - 150, 20 + rand.nextDouble() * 5.0, 500 + rand.nextDouble() * 300 - 150); occluders.attachChild(sm); } } return occluders; } private void setupDefaultStates() { _lightState.detachAll(); light = new DirectionalLight(); light.setEnabled(true); light.setAmbient(new ColorRGBA(0.4f, 0.4f, 0.5f, 1)); light.setDiffuse(new ColorRGBA(0.6f, 0.6f, 0.5f, 1)); light.setSpecular(new ColorRGBA(0.3f, 0.3f, 0.2f, 1)); light.setDirection(lightPosition.normalize(null).negateLocal()); _lightState.attach(light); _lightState.setEnabled(true); final CullState cs = new CullState(); cs.setEnabled(true); cs.setCullFace(CullState.Face.Back); _root.setRenderState(cs); final FogState fs = new FogState(); fs.setStart(farPlane / 2.0f); fs.setEnd(farPlane); fs.setColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); fs.setDensityFunction(DensityFunction.Linear); _root.setRenderState(fs); } /** * Update text information. */ private void updateText() { _exampleInfo[0].setText("[1/2/3] Moving speed: " + _controlHandle.getMoveSpeed() * 3.6 + " km/h"); _exampleInfo[1].setText("[P] Do picking: " + (sphere.getSceneHints().getCullHint() == CullHint.Dynamic)); _exampleInfo[2].setText("[SPACE] Toggle fly/walk: " + (groundCamera ? "walk" : "fly")); _exampleInfo[3].setText("[J] Regenerate heightmap/texture"); _exampleInfo[4].setText("[U] Freeze terrain(debug): " + !updateTerrain); } } \ No newline at end of file
+/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * 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>. */ package com.ardor3d.example.terrain; import java.util.Random; import java.util.concurrent.Callable; import java.util.logging.Level; import java.util.logging.Logger; import com.ardor3d.bounding.BoundingBox; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.shadow.map.ParallelSplitShadowMapPass; import com.ardor3d.extension.shadow.map.ParallelSplitShadowMapPass.Filter; 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; import com.ardor3d.framework.CanvasRenderer; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.intersection.PickingUtil; import com.ardor3d.intersection.PrimitivePickResults; import com.ardor3d.light.DirectionalLight; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.Ray3; import com.ardor3d.math.Vector3; import com.ardor3d.renderer.Camera; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.FogState; import com.ardor3d.renderer.state.FogState.DensityFunction; import com.ardor3d.scenegraph.Mesh; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.shape.Box; import com.ardor3d.scenegraph.shape.Sphere; import com.ardor3d.ui.text.BasicText; import com.ardor3d.util.GameTaskQueue; import com.ardor3d.util.GameTaskQueueManager; import com.ardor3d.util.ReadOnlyTimer; import com.ardor3d.util.resource.ResourceLocatorTool; /** * Example showing the Geometry Clipmap Terrain system combined with PSSM. (a bit experimental) Requires GLSL support. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.terrain.ShadowedTerrainExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/terrain_ShadowedTerrainExample.jpg", // maxHeapMemory = 128) public class ShadowedTerrainExample extends ExampleBase { /** The Constant logger. */ private static final Logger logger = Logger.getLogger(ShadowedTerrainExample.class.getName()); private boolean updateTerrain = true; private final float farPlane = 2500.0f; private Terrain terrain; private final Sphere sphere = new Sphere("sp", 16, 16, 1); private final Ray3 pickRay = new Ray3(); private boolean groundCamera = false; private Camera terrainCamera; /** Pssm shadow map pass. */ private ParallelSplitShadowMapPass _pssmPass; private DirectionalLight directionalLight; /** Temp vec for updating light pos. */ private final Vector3 lightPosition = new Vector3(10000, 10000, 10000); /** Text fields used to present info about the example. */ private final BasicText _exampleInfo[] = new BasicText[5]; public static void main(final String[] args) { ExampleBase.start(ShadowedTerrainExample.class); } @Override protected void updateExample(final ReadOnlyTimer timer) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); // Make sure camera is above terrain final double height = terrain.getHeightAt(camera.getLocation().getX(), camera.getLocation().getZ()); if (height > -Float.MAX_VALUE && (groundCamera || camera.getLocation().getY() < height + 3)) { camera.setLocation(new Vector3(camera.getLocation().getX(), height + 3, camera.getLocation().getZ())); } if (updateTerrain) { terrainCamera.set(camera); } // if we're picking... if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { // Set up our pick ray pickRay.setOrigin(camera.getLocation()); pickRay.setDirection(camera.getDirection()); // do pick and move the sphere final PrimitivePickResults pickResults = new PrimitivePickResults(); pickResults.setCheckDistance(true); PickingUtil.findPick(_root, pickRay, pickResults); if (pickResults.getNumber() != 0) { final Vector3 intersectionPoint = pickResults.getPickData(0).getIntersectionRecord() .getIntersectionPoint(0); sphere.setTranslation(intersectionPoint); // XXX: maybe change the color of the ball for valid vs. invalid? } } } @Override protected void renderExample(final Renderer renderer) { // Lazy init since it needs the renderer... if (!_pssmPass.isInitialised()) { _pssmPass.init(renderer); _pssmPass.setPssmShader(terrain.getGeometryClipmapShader()); for (int i = 0; i < _pssmPass.getNumOfSplits(); i++) { terrain.getClipTextureState().setTexture(_pssmPass.getShadowMapTexture(i), i + 1); } for (int i = 0; i < ParallelSplitShadowMapPass._MAX_SPLITS; i++) { terrain.getGeometryClipmapShader().setUniform("shadowMap" + i, i + 1); } } // Update shadowmaps _pssmPass.updateShadowMaps(renderer); // Render scene and terrain with shadows super.renderExample(renderer); renderer.renderBuckets(); // Render overlay shadows for all objects except the terrain _pssmPass.renderShadowedScene(renderer); // TODO: this results in text etc also being shadowed, since they are drawn in the main render... } /** * Initialize pssm pass and scene. */ @Override protected void initExample() { _canvas.setTitle("Terrain Example"); final Camera cam = _canvas.getCanvasRenderer().getCamera(); cam.setLocation(new Vector3(440, 215, 275)); cam.lookAt(new Vector3(450, 140, 360), Vector3.UNIT_Y); cam.setFrustumPerspective(70.0, (float) cam.getWidth() / cam.getHeight(), 1.0f, farPlane); final CanvasRenderer canvasRenderer = _canvas.getCanvasRenderer(); final RenderContext renderContext = canvasRenderer.getRenderContext(); final Renderer renderer = canvasRenderer.getRenderer(); GameTaskQueueManager.getManager(renderContext).getQueue(GameTaskQueue.RENDER).enqueue(new Callable<Void>() { @Override public Void call() throws Exception { renderer.setBackgroundColor(ColorRGBA.GRAY); return null; } }); _controlHandle.setMoveSpeed(200); setupDefaultStates(); sphere.getSceneHints().setAllPickingHints(false); sphere.getSceneHints().setCullHint(CullHint.Always); _root.attachChild(sphere); try { // Keep a separate camera to be able to freeze terrain update terrainCamera = new Camera(cam); final int SIZE = 2048; final MidPointHeightMapGenerator raw = new MidPointHeightMapGenerator(SIZE, 0.6f); raw.setHeightRange(0.2f); final float[] heightMap = raw.getHeightData(); 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.reloadShader(); _root.attachChild(terrain); } catch (final Exception e) { logger.log(Level.SEVERE, "Problem setting up terrain...", e); System.exit(1); } // Initialize PSSM shadows _pssmPass = new ParallelSplitShadowMapPass(directionalLight, 1024, 4); _pssmPass.setFiltering(Filter.Pcf); _pssmPass.setRenderShadowedScene(false); _pssmPass.setKeepMainShader(true); _pssmPass.setMaxShadowDistance(750); // XXX: Tune this // _pssmPass.setMinimumLightDistance(500); // XXX: Tune this _pssmPass.setUseSceneTexturing(false); _pssmPass.setUseObjectCullFace(false); // _pssmPass.setDrawDebug(true); final Node occluders = setupOccluders(); _root.attachChild(occluders); // TODO: could we use the shadow variable in scenehints here?? // Add objects that will get shadowed through overlay render _pssmPass.add(occluders); // Add terrain in as bounds receiver as well, since it's not in the overlay list _pssmPass.addBoundsReceiver(terrain); // Add our occluders that will produce shadows _pssmPass.addOccluder(occluders); // Setup labels for presenting example info. final Node textNodes = new Node("Text"); _root.attachChild(textNodes); textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off); final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2; for (int i = 0; i < _exampleInfo.length; i++) { _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16); _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0)); textNodes.attachChild(_exampleInfo[i]); } textNodes.updateGeometricState(0.0); updateText(); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() { @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) { _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) { _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) { _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) { _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) { 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) { if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { sphere.getSceneHints().setCullHint(CullHint.Always); } else if (sphere.getSceneHints().getCullHint() == CullHint.Always) { sphere.getSceneHints().setCullHint(CullHint.Dynamic); } updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() { @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) { 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) { 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) { 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) { _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) { final Camera cam = _canvas.getCanvasRenderer().getCamera(); System.out.println("camera location: " + cam.getLocation()); System.out.println("camera direction: " + cam.getDirection()); } })); } private Node setupOccluders() { final Node occluders = new Node("Occluders"); final Box box = new Box("Box", new Vector3(), 1, 40, 1); box.setModelBound(new BoundingBox()); box.setRandomColors(); final Random rand = new Random(1337); for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { final Mesh sm = box.makeCopy(true); sm.setTranslation(500 + rand.nextDouble() * 300 - 150, 20 + rand.nextDouble() * 5.0, 500 + rand.nextDouble() * 300 - 150); occluders.attachChild(sm); } } return occluders; } 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); final CullState cs = new CullState(); cs.setEnabled(true); cs.setCullFace(CullState.Face.Back); _root.setRenderState(cs); final FogState fs = new FogState(); fs.setStart(farPlane / 2.0f); fs.setEnd(farPlane); fs.setColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); fs.setDensityFunction(DensityFunction.Linear); _root.setRenderState(fs); } /** * Update text information. */ private void updateText() { _exampleInfo[0].setText("[1/2/3] Moving speed: " + _controlHandle.getMoveSpeed() * 3.6 + " km/h"); _exampleInfo[1].setText("[P] Do picking: " + (sphere.getSceneHints().getCullHint() == CullHint.Dynamic)); _exampleInfo[2].setText("[SPACE] Toggle fly/walk: " + (groundCamera ? "walk" : "fly")); _exampleInfo[3].setText("[J] Regenerate heightmap/texture"); _exampleInfo[4].setText("[U] Freeze terrain(debug): " + !updateTerrain); } } \ No newline at end of file
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/ui/BMFontLoader.java b/ardor3d-examples/src/main/java/com/ardor3d/example/ui/BMFontLoader.java
index 73be066..3947b1e 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/ui/BMFontLoader.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/ui/BMFontLoader.java
@@ -25,7 +25,7 @@ public class BMFontLoader {
static Logger logger = Logger.getLogger(BMFontLoader.class.getName());
static BMFontLoader s_instance = null;
- final ArrayList<BMFont> _fontList = new ArrayList<BMFont>();
+ final ArrayList<BMFont> _fontList = new ArrayList<>();
public static List<BMFont> allFonts() {
return instance()._fontList;