aboutsummaryrefslogtreecommitdiffstats
path: root/ardor3d-examples
diff options
context:
space:
mode:
Diffstat (limited to 'ardor3d-examples')
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/ExampleBase.java6
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/benchmark/ball/BubbleMarkUIExample.java58
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtDesktopExample.java3
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtExample.java3
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtAwtExample.java1
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtSwtExample.java3
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglSwingExample.java3
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglSwtExample.java3
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/effect/NewDynamicSmokerExample.java11
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/interact/InteractExample.java74
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/interact/TerrainInteractExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationCopyExample.java31
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationStateExample.java17
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ColladaExample.java13
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/GeneratedTexturesExample.java23
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/utils/atlas/TestAtlasPacker.java4
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/terrain/MountainShadowTerrainExample.java41
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/ui/InteractUIExample.java95
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/ui/PopOverUIExample.java337
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/ui/RotatingUIExample.java13
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/ui/SimpleUIExample.java18
-rw-r--r--ardor3d-examples/src/main/resources/com/ardor3d/example/i18n/example_descriptions.properties1
22 files changed, 570 insertions, 190 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 1ac5650..edbe562 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleBase.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleBase.java
@@ -384,8 +384,10 @@ public abstract class ExampleBase implements Runnable, Updater, Scene {
example._canvas = new JoglNewtWindow(canvasRenderer, settings);
final JoglNewtWindow canvas = (JoglNewtWindow) example._canvas;
example._mouseManager = new JoglNewtMouseManager(canvas);
- example._physicalLayer = new PhysicalLayer(new JoglNewtKeyboardWrapper(canvas), new JoglNewtMouseWrapper(
- canvas, example._mouseManager), DummyControllerWrapper.INSTANCE, new JoglNewtFocusWrapper(canvas));
+ example._canvas.setMouseManager(example._mouseManager);
+ example._physicalLayer = new PhysicalLayer(new JoglNewtKeyboardWrapper(canvas),
+ new JoglNewtMouseWrapper(canvas, example._mouseManager), DummyControllerWrapper.INSTANCE,
+ new JoglNewtFocusWrapper(canvas));
TextureRendererFactory.INSTANCE.setProvider(new JoglTextureRendererProvider());
example._logicalLayer.registerInput(example._canvas, example._physicalLayer);
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/benchmark/ball/BubbleMarkUIExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/benchmark/ball/BubbleMarkUIExample.java
index 16797b9..bfad955 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/benchmark/ball/BubbleMarkUIExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/benchmark/ball/BubbleMarkUIExample.java
@@ -3,13 +3,15 @@
*
* 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>.
*/
package com.ardor3d.example.benchmark.ball;
+import java.util.concurrent.Callable;
+
import com.ardor3d.example.ExampleBase;
import com.ardor3d.example.Purpose;
import com.ardor3d.extension.ui.UICheckBox;
@@ -17,6 +19,7 @@ import com.ardor3d.extension.ui.UIContainer;
import com.ardor3d.extension.ui.UIFrame;
import com.ardor3d.extension.ui.UIHud;
import com.ardor3d.extension.ui.UILabel;
+import com.ardor3d.extension.ui.UIPanel;
import com.ardor3d.extension.ui.UIRadioButton;
import com.ardor3d.extension.ui.backdrop.SolidBackdrop;
import com.ardor3d.extension.ui.event.ActionEvent;
@@ -30,6 +33,7 @@ import com.ardor3d.image.Texture;
import com.ardor3d.image.TextureStoreFormat;
import com.ardor3d.math.ColorRGBA;
import com.ardor3d.ui.text.BasicText;
+import com.ardor3d.util.GameTaskQueueManager;
import com.ardor3d.util.ReadOnlyTimer;
import com.ardor3d.util.TextureManager;
@@ -69,16 +73,15 @@ public class BubbleMarkUIExample extends ExampleBase {
final int width = _canvas.getCanvasRenderer().getCamera().getWidth();
final int height = _canvas.getCanvasRenderer().getCamera().getHeight();
- hud = new UIHud();
+ hud = new UIHud(_canvas);
// Add Frame for balls
_ballFrame = new UIFrame("Bubbles");
- _ballFrame.updateMinimumSizeFromContents();
- _ballFrame.pack(500, 300);
- _ballFrame.layout();
+ _ballFrame.getContentPanel().setMinimumContentSize(600, 300);
_ballFrame.setResizeable(false);
_ballFrame.setHudXY(5, 5);
_ballFrame.setUseStandin(false);
+ _ballFrame.pack();
hud.add(_ballFrame);
// Add background
@@ -93,36 +96,41 @@ public class BubbleMarkUIExample extends ExampleBase {
// Add fps display
frameRateLabel = BasicText.createDefaultTextLabel("fpsLabel", "");
- frameRateLabel.setTranslation(5, _canvas.getCanvasRenderer().getCamera().getHeight() - 5
- - frameRateLabel.getHeight(), 0);
+ frameRateLabel.setTranslation(5, hud.getHeight() - 5 - frameRateLabel.getHeight(), 0);
frameRateLabel.setTextColor(ColorRGBA.WHITE);
frameRateLabel.getSceneHints().setOrthoOrder(-1);
_root.attachChild(frameRateLabel);
- hud.setupInput(_canvas, _physicalLayer, _logicalLayer);
+ hud.setupInput(_physicalLayer, _logicalLayer);
}
private void buildConfigFrame(final int width, final int height) {
_configFrame = new UIFrame("Config");
- _configFrame.updateMinimumSizeFromContents();
- _configFrame.pack(320, 240);
+ final UIPanel panel = _configFrame.getContentPanel();
+ panel.setLayout(new AnchorLayout());
+ panel.setMinimumContentSize(320, 240);
_configFrame.setUseStandin(true);
- _configFrame.setHudXY(width - _configFrame.getLocalComponentWidth() - 5, height
- - _configFrame.getLocalComponentHeight() - 5);
-
- _configFrame.getContentPanel().setLayout(new AnchorLayout());
+ _configFrame.setHudXY(width - _configFrame.getLocalComponentWidth() - 5,
+ height - _configFrame.getLocalComponentHeight() - 5);
final UICheckBox vsync = new UICheckBox("Enable vsync");
- vsync.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, _configFrame.getContentPanel(),
- Alignment.TOP_LEFT, 5, -5));
+ vsync.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel, Alignment.TOP_LEFT, 5, -5));
vsync.setSelectable(true);
vsync.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent event) {
- _canvas.setVSyncEnabled(vsync.isSelected());
+ GameTaskQueueManager.getManager(_canvas.getCanvasRenderer().getRenderContext()).render(
+ new Callable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ _canvas.setVSyncEnabled(vsync.isSelected());
+ return null;
+ }
+ });
+
}
});
- _configFrame.getContentPanel().add(vsync);
+ panel.add(vsync);
final UICheckBox collide = new UICheckBox("Enable ball-ball collision");
collide.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, vsync, Alignment.BOTTOM_LEFT, 0, -5));
@@ -134,11 +142,11 @@ public class BubbleMarkUIExample extends ExampleBase {
skipBallCollide = !collide.isSelected();
}
});
- _configFrame.getContentPanel().add(collide);
+ panel.add(collide);
final UILabel ballsLabel = new UILabel("# of balls:");
ballsLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, collide, Alignment.BOTTOM_LEFT, 0, -15));
- _configFrame.getContentPanel().add(ballsLabel);
+ panel.add(ballsLabel);
final ButtonGroup ballsGroup = new ButtonGroup();
@@ -153,7 +161,7 @@ public class BubbleMarkUIExample extends ExampleBase {
}
});
balls16.setGroup(ballsGroup);
- _configFrame.getContentPanel().add(balls16);
+ panel.add(balls16);
final UIRadioButton balls32 = new UIRadioButton("32");
balls32.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, balls16, Alignment.BOTTOM_LEFT, 0, -5));
@@ -166,7 +174,7 @@ public class BubbleMarkUIExample extends ExampleBase {
}
});
balls32.setGroup(ballsGroup);
- _configFrame.getContentPanel().add(balls32);
+ panel.add(balls32);
final UIRadioButton balls64 = new UIRadioButton("64");
balls64.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, balls32, Alignment.BOTTOM_LEFT, 0, -5));
@@ -179,7 +187,7 @@ public class BubbleMarkUIExample extends ExampleBase {
}
});
balls64.setGroup(ballsGroup);
- _configFrame.getContentPanel().add(balls64);
+ panel.add(balls64);
final UIRadioButton balls128 = new UIRadioButton("128");
balls128.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, balls64, Alignment.BOTTOM_LEFT, 0, -5));
@@ -192,9 +200,9 @@ public class BubbleMarkUIExample extends ExampleBase {
}
});
balls128.setGroup(ballsGroup);
- _configFrame.getContentPanel().add(balls128);
+ panel.add(balls128);
- _configFrame.layout();
+ _configFrame.pack();
}
@Override
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 7af08d5..42f64cf 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
@@ -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>.
*/
@@ -152,6 +152,7 @@ public class JoglAwtDesktopExample {
final AwtFocusWrapper focusWrapper = new AwtFocusWrapper(theCanvas);
final AwtMouseManager mouseManager = new AwtMouseManager(theCanvas);
final AwtMouseWrapper mouseWrapper = new AwtMouseWrapper(theCanvas, mouseManager);
+ theCanvas.setMouseManager(mouseManager);
final ControllerWrapper controllerWrapper = new DummyControllerWrapper();
final PhysicalLayer pl = new PhysicalLayer(keyboardWrapper, mouseWrapper, controllerWrapper, focusWrapper);
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 aae1162..05f9c2e 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
@@ -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>.
*/
@@ -163,6 +163,7 @@ public class JoglAwtExample {
final AwtFocusWrapper focusWrapper = new AwtFocusWrapper(theCanvas);
final AwtMouseManager mouseManager = new AwtMouseManager(theCanvas);
final AwtMouseWrapper mouseWrapper = new AwtMouseWrapper(theCanvas, mouseManager);
+ theCanvas.setMouseManager(mouseManager);
final ControllerWrapper controllerWrapper = new DummyControllerWrapper();
final PhysicalLayer pl = new PhysicalLayer(keyboardWrapper, mouseWrapper, controllerWrapper, focusWrapper);
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 9770e36..01ce1cf 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
@@ -167,6 +167,7 @@ public class JoglNewtAwtExample {
final JoglNewtFocusWrapper focusWrapper = new JoglNewtFocusWrapper(theCanvas);
final JoglNewtMouseManager mouseManager = new JoglNewtMouseManager(theCanvas);
final JoglNewtMouseWrapper mouseWrapper = new JoglNewtMouseWrapper(theCanvas, mouseManager);
+ theCanvas.setMouseManager(mouseManager);
final ControllerWrapper controllerWrapper = new DummyControllerWrapper();
final PhysicalLayer pl = new PhysicalLayer(keyboardWrapper, mouseWrapper, controllerWrapper, focusWrapper);
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 8626d11..d83ddce 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
@@ -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>.
*/
@@ -206,6 +206,7 @@ public class JoglNewtSwtExample {
final JoglNewtFocusWrapper focusWrapper = new JoglNewtFocusWrapper(canvas1);
final JoglNewtMouseManager mouseManager = new JoglNewtMouseManager(canvas1);
final JoglNewtMouseWrapper mouseWrapper = new JoglNewtMouseWrapper(canvas1, mouseManager);
+ canvas1.setMouseManager(mouseManager);
final ControllerWrapper controllerWrapper = new DummyControllerWrapper();
final PhysicalLayer pl = new PhysicalLayer(keyboardWrapper, mouseWrapper, controllerWrapper, focusWrapper);
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 06b1034..53bb972 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
@@ -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>.
*/
@@ -164,6 +164,7 @@ public class JoglSwingExample {
final AwtFocusWrapper focusWrapper = new AwtFocusWrapper(theCanvas);
final AwtMouseManager mouseManager = new AwtMouseManager(theCanvas);
final AwtMouseWrapper mouseWrapper = new AwtMouseWrapper(theCanvas, mouseManager);
+ theCanvas.setMouseManager(mouseManager);
final ControllerWrapper controllerWrapper = new DummyControllerWrapper();
final PhysicalLayer pl = new PhysicalLayer(keyboardWrapper, mouseWrapper, controllerWrapper, focusWrapper);
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 29a4929..e2f6d33 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
@@ -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>.
*/
@@ -210,6 +210,7 @@ public class JoglSwtExample {
final SwtMouseWrapper mouseWrapper = new SwtMouseWrapper(canvas1);
final SwtFocusWrapper focusWrapper = new SwtFocusWrapper(canvas1);
final SwtMouseManager mouseManager = new SwtMouseManager(canvas1);
+ canvas1.setMouseManager(mouseManager);
final ControllerWrapper controllerWrapper = new DummyControllerWrapper();
final PhysicalLayer pl = new PhysicalLayer(keyboardWrapper, mouseWrapper, controllerWrapper, focusWrapper);
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/effect/NewDynamicSmokerExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/effect/NewDynamicSmokerExample.java
index 4eee5ca..c741a42 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/effect/NewDynamicSmokerExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/effect/NewDynamicSmokerExample.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>.
*/
@@ -237,8 +237,8 @@ public class NewDynamicSmokerExample extends ExampleBase {
private void addUI() {
// setup hud
- hud = new UIHud();
- hud.setupInput(_canvas, _physicalLayer, _logicalLayer);
+ hud = new UIHud(_canvas);
+ hud.setupInput(_physicalLayer, _logicalLayer);
hud.setMouseManager(_mouseManager);
final UIFrame frame = new UIFrame("Controls", EnumSet.noneOf(FrameButtons.class));
@@ -308,9 +308,8 @@ public class NewDynamicSmokerExample extends ExampleBase {
frame.setContentPanel(panel);
frame.pack();
- final Camera cam = _canvas.getCanvasRenderer().getCamera();
- frame.setLocalXY(cam.getWidth() - frame.getLocalComponentWidth(),
- cam.getHeight() - frame.getLocalComponentHeight());
+ frame.setLocalXY(hud.getWidth() - frame.getLocalComponentWidth(),
+ hud.getHeight() - frame.getLocalComponentHeight());
hud.add(frame);
}
}
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/interact/InteractExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/interact/InteractExample.java
index da38966..7cd7452 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/interact/InteractExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/interact/InteractExample.java
@@ -1,15 +1,17 @@
/**
- * Copyright (c) 2008-2014 Ardor Labs, Inc.
+ * Copyright (c) 2008-2018 Ardor Labs, Inc.
*
* 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>.
*/
package com.ardor3d.example.interact;
+import java.net.URISyntaxException;
+
import com.ardor3d.bounding.BoundingBox;
import com.ardor3d.bounding.BoundingSphere;
import com.ardor3d.example.ExampleBase;
@@ -18,15 +20,20 @@ import com.ardor3d.extension.interact.InteractManager;
import com.ardor3d.extension.interact.filter.AllowScaleFilter;
import com.ardor3d.extension.interact.filter.MinMaxScaleFilter;
import com.ardor3d.extension.interact.filter.PlaneBoundaryFilter;
+import com.ardor3d.extension.interact.widget.AbstractInteractWidget;
import com.ardor3d.extension.interact.widget.BasicFilterList;
import com.ardor3d.extension.interact.widget.InteractMatrix;
+import com.ardor3d.extension.interact.widget.MoveMultiPlanarWidget;
+import com.ardor3d.extension.interact.widget.MovePlanarWidget;
import com.ardor3d.extension.interact.widget.MoveWidget;
import com.ardor3d.extension.interact.widget.RotateWidget;
import com.ardor3d.extension.interact.widget.SimpleScaleWidget;
import com.ardor3d.framework.Canvas;
+import com.ardor3d.image.Image;
import com.ardor3d.image.Texture;
import com.ardor3d.image.Texture2D;
import com.ardor3d.input.Key;
+import com.ardor3d.input.MouseCursor;
import com.ardor3d.input.logical.InputTrigger;
import com.ardor3d.input.logical.KeyHeldCondition;
import com.ardor3d.input.logical.KeyPressedCondition;
@@ -49,13 +56,15 @@ import com.ardor3d.scenegraph.shape.Box;
import com.ardor3d.scenegraph.shape.Sphere;
import com.ardor3d.util.ReadOnlyTimer;
import com.ardor3d.util.TextureManager;
+import com.ardor3d.util.resource.ResourceLocatorTool;
+import com.ardor3d.util.resource.SimpleResourceLocator;
/**
* An example illustrating the use of the interact framework.
*/
@Purpose(htmlDescriptionKey = "com.ardor3d.example.interact.InteractExample", //
-thumbnailPath = "com/ardor3d/example/media/thumbnails/interact_InteractExample.jpg", //
-maxHeapMemory = 64)
+ thumbnailPath = "com/ardor3d/example/media/thumbnails/interact_InteractExample.jpg", //
+ maxHeapMemory = 64)
public class InteractExample extends ExampleBase {
private InteractManager manager;
@@ -157,6 +166,8 @@ public class InteractExample extends ExampleBase {
}
private void addControls() {
+ setupCursors();
+
// create our manager
manager = new InteractManager();
manager.setupInput(_canvas, _physicalLayer, _logicalLayer);
@@ -165,8 +176,8 @@ public class InteractExample extends ExampleBase {
// add some widgets.
rotateWidget = new RotateWidget(filterList).withXAxis().withYAxis().withZAxis();
- rotateWidget.setTexture((Texture2D) TextureManager.load("images/tick.png",
- Texture.MinificationFilter.Trilinear, true));
+ rotateWidget.setTexture(
+ (Texture2D) TextureManager.load("images/tick.png", Texture.MinificationFilter.Trilinear, true));
manager.addWidget(rotateWidget);
scaleWidget = new SimpleScaleWidget(filterList).withArrow(Vector3.UNIT_Y);
@@ -179,29 +190,29 @@ public class InteractExample extends ExampleBase {
manager.setActiveWidget(rotateWidget);
// add triggers to change which widget is active
- manager.getLogicalLayer().registerTrigger(
- new InputTrigger(new KeyHeldCondition(Key.LSHIFT), new TriggerAction() {
+ manager.getLogicalLayer()
+ .registerTrigger(new InputTrigger(new KeyHeldCondition(Key.LSHIFT), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
manager.setActiveWidget(scaleWidget);
}
}));
- manager.getLogicalLayer().registerTrigger(
- new InputTrigger(new KeyReleasedCondition(Key.LSHIFT), new TriggerAction() {
+ manager.getLogicalLayer()
+ .registerTrigger(new InputTrigger(new KeyReleasedCondition(Key.LSHIFT), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
manager.setActiveWidget(rotateWidget);
}
}));
- manager.getLogicalLayer().registerTrigger(
- new InputTrigger(new KeyHeldCondition(Key.LCONTROL), new TriggerAction() {
+ manager.getLogicalLayer()
+ .registerTrigger(new InputTrigger(new KeyHeldCondition(Key.LCONTROL), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
manager.setActiveWidget(moveWidget);
}
}));
- manager.getLogicalLayer().registerTrigger(
- new InputTrigger(new KeyReleasedCondition(Key.LCONTROL), new TriggerAction() {
+ manager.getLogicalLayer()
+ .registerTrigger(new InputTrigger(new KeyReleasedCondition(Key.LCONTROL), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
manager.setActiveWidget(rotateWidget);
@@ -212,8 +223,9 @@ public class InteractExample extends ExampleBase {
manager.getLogicalLayer().registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
- rotateWidget.setInteractMatrix(rotateWidget.getInteractMatrix() == InteractMatrix.World ? InteractMatrix.Local
- : InteractMatrix.World);
+ rotateWidget.setInteractMatrix(
+ rotateWidget.getInteractMatrix() == InteractMatrix.World ? InteractMatrix.Local
+ : InteractMatrix.World);
rotateWidget.targetDataUpdated(manager);
moveWidget.setInteractMatrix(rotateWidget.getInteractMatrix());
moveWidget.targetDataUpdated(manager);
@@ -221,8 +233,8 @@ public class InteractExample extends ExampleBase {
}));
// add triggers to change which widget is active
- manager.getLogicalLayer().registerTrigger(
- new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
+ manager.getLogicalLayer()
+ .registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
manager.getSpatialTarget().setRotation(Matrix3.IDENTITY);
@@ -236,6 +248,32 @@ public class InteractExample extends ExampleBase {
manager.addFilter(new PlaneBoundaryFilter(new Plane(Vector3.UNIT_Y, 0)));
}
+ public static void setupCursors() {
+ try {
+ final SimpleResourceLocator srl = new SimpleResourceLocator(ResourceLocatorTool
+ .getClassPathResource(AbstractInteractWidget.class, "com/ardor3d/extension/interact/widget/"));
+ ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, srl);
+
+ // ROTATE
+ Image img = TextureManager.load("rotate.png", Texture.MinificationFilter.BilinearNoMipMaps, true)
+ .getImage();
+ RotateWidget.DEFAULT_CURSOR = new MouseCursor("rotate", img, img.getWidth() / 2, img.getHeight() / 2);
+
+ // SCALE
+ img = TextureManager.load("scale.png", Texture.MinificationFilter.BilinearNoMipMaps, true).getImage();
+ SimpleScaleWidget.DEFAULT_CURSOR = new MouseCursor("scale", img, 3, img.getHeight() - 3);
+
+ // MOVE
+ img = TextureManager.load("move.png", Texture.MinificationFilter.BilinearNoMipMaps, true).getImage();
+ MoveWidget.DEFAULT_CURSOR = new MouseCursor("move", img, img.getWidth() / 2, img.getHeight() / 2);
+ MoveMultiPlanarWidget.DEFAULT_CURSOR = new MouseCursor("move", img, img.getWidth() / 2,
+ img.getHeight() / 2);
+ MovePlanarWidget.DEFAULT_CURSOR = new MouseCursor("move", img, img.getWidth() / 2, img.getHeight() / 2);
+ } catch (final URISyntaxException ex) {
+ ex.printStackTrace();
+ }
+ }
+
@Override
protected void processPicks(final PrimitivePickResults pickResults) {
final PickData pick = pickResults.findFirstIntersectingPickData();
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/interact/TerrainInteractExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/interact/TerrainInteractExample.java
index 601d890..d9c466e 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/interact/TerrainInteractExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/interact/TerrainInteractExample.java
@@ -1 +1 @@
-/** * Copyright (c) 2008-2014 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.interact; import java.util.concurrent.Callable; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.interact.InteractManager; import com.ardor3d.extension.interact.widget.CompoundInteractWidget; import com.ardor3d.extension.interact.widget.InteractMatrix; import com.ardor3d.extension.interact.widget.MovePlanarWidget.MovePlane; 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.heightmap.MidPointHeightMapGenerator; import com.ardor3d.extension.terrain.providers.array.ArrayTerrainDataProvider; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.CanvasRenderer; import com.ardor3d.image.Texture.MinificationFilter; import com.ardor3d.image.Texture2D; 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.light.DirectionalLight; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.Vector3; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.FogState; import com.ardor3d.renderer.state.FogState.DensityFunction; import com.ardor3d.scenegraph.shape.PQTorus; import com.ardor3d.util.GameTaskQueue; import com.ardor3d.util.GameTaskQueueManager; import com.ardor3d.util.ReadOnlyTimer; import com.ardor3d.util.TextureManager; /** * Example showing interact widgets with the Geometry Clipmap Terrain system. Requires GLSL support. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.interact.TerrainInteractExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/interact_TerrainInteractExample.jpg", // maxHeapMemory = 128) public class TerrainInteractExample extends ExampleBase { private final float farPlane = 3000.0f; private Terrain terrain; private InteractManager manager; public static void main(final String[] args) { ExampleBase.start(TerrainInteractExample.class); } @Override protected void updateExample(final ReadOnlyTimer timer) { manager.update(timer); } @Override protected void updateLogicalLayer(final ReadOnlyTimer timer) { manager.getLogicalLayer().checkTriggers(timer.getTimePerFrame()); } @Override protected void renderExample(final Renderer renderer) { super.renderExample(renderer); manager.render(renderer); } /** * Initialize pssm pass and scene. */ @Override protected void initExample() { // Setup main camera. _canvas.setTitle("Terrain Example"); _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(400, 220, 715)); _canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(430, 200, 730), Vector3.UNIT_Y); _canvas.getCanvasRenderer() .getCamera() .setFrustumPerspective( 70.0, (float) _canvas.getCanvasRenderer().getCamera().getWidth() / _canvas.getCanvasRenderer().getCamera().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(500); setupDefaultStates(); try { 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, 500, 1)); terrain = new TerrainBuilder(terrainDataProvider, _canvas.getCanvasRenderer().getCamera()) .setShowDebugPanels(false).build(); _root.attachChild(terrain); } catch (final Exception ex1) { System.out.println("Problem setting up terrain..."); ex1.printStackTrace(); } addControls(); // Add something to move around final PQTorus obj = new PQTorus("obj", 4, 3, 1.5, .5, 128, 8); obj.setScale(10); obj.updateModelBound(); _root.attachChild(obj); _root.updateGeometricState(0); try { Thread.sleep(500); } catch (final InterruptedException e) { } obj.setTranslation(630, terrain.getHeightAt(630, 830) + 20, 830); manager.setSpatialTarget(obj); } private void setupDefaultStates() { _lightState.detachAll(); final DirectionalLight dLight = new DirectionalLight(); dLight.setEnabled(true); dLight.setAmbient(new ColorRGBA(0.4f, 0.4f, 0.5f, 1)); dLight.setDiffuse(new ColorRGBA(0.6f, 0.6f, 0.5f, 1)); dLight.setSpecular(new ColorRGBA(0.3f, 0.3f, 0.2f, 1)); dLight.setDirection(new Vector3(-1, -1, -1).normalizeLocal()); _lightState.attach(dLight); _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(ColorRGBA.GRAY); fs.setDensityFunction(DensityFunction.Linear); _root.setRenderState(fs); } private void addControls() { // create our manager manager = new InteractManager(); manager.setupInput(_canvas, _physicalLayer, _logicalLayer); // final add our widget final CompoundInteractWidget widget = new CompoundInteractWidget() .withMoveXAxis(new ColorRGBA(1, 0, 0, .65f), 1.2, .15, .5, .2) .withMoveZAxis(new ColorRGBA(0, 0, 1, .65f), 1.2, .15, .5, .2) // .withRotateYAxis() // .withPlanarHandle(MovePlane.XZ, new ColorRGBA(1, 0, 1, .65f)) // .withRingTexture((Texture2D) TextureManager.load("images/tick.png", MinificationFilter.Trilinear, true)); // widget.getHandle().setRenderState(_lightState); manager.addWidget(widget); manager.setActiveWidget(widget); // add toggle for matrix mode on widget manager.getLogicalLayer().registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { widget.setInteractMatrix(widget.getInteractMatrix() == InteractMatrix.World ? InteractMatrix.Local : InteractMatrix.World); widget.targetDataUpdated(manager); } })); // add a filter manager.addFilter(new TerrainHeightFilter(terrain, 20)); } } \ No newline at end of file
+/** * Copyright (c) 2008-2014 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.interact; import java.util.concurrent.Callable; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.interact.InteractManager; import com.ardor3d.extension.interact.widget.CompoundInteractWidget; import com.ardor3d.extension.interact.widget.InteractMatrix; import com.ardor3d.extension.interact.widget.MovePlanarWidget.MovePlane; 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.heightmap.MidPointHeightMapGenerator; import com.ardor3d.extension.terrain.providers.array.ArrayTerrainDataProvider; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.CanvasRenderer; import com.ardor3d.image.Texture.MinificationFilter; import com.ardor3d.image.Texture2D; 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.light.DirectionalLight; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.Vector3; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.FogState; import com.ardor3d.renderer.state.FogState.DensityFunction; import com.ardor3d.scenegraph.shape.PQTorus; import com.ardor3d.util.GameTaskQueue; import com.ardor3d.util.GameTaskQueueManager; import com.ardor3d.util.ReadOnlyTimer; import com.ardor3d.util.TextureManager; /** * Example showing interact widgets with the Geometry Clipmap Terrain system. Requires GLSL support. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.interact.TerrainInteractExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/interact_TerrainInteractExample.jpg", // maxHeapMemory = 128) public class TerrainInteractExample extends ExampleBase { private final float farPlane = 3000.0f; private Terrain terrain; private InteractManager manager; public static void main(final String[] args) { ExampleBase.start(TerrainInteractExample.class); } @Override protected void updateExample(final ReadOnlyTimer timer) { manager.update(timer); } @Override protected void updateLogicalLayer(final ReadOnlyTimer timer) { manager.getLogicalLayer().checkTriggers(timer.getTimePerFrame()); } @Override protected void renderExample(final Renderer renderer) { super.renderExample(renderer); manager.render(renderer); } /** * Initialize pssm pass and scene. */ @Override protected void initExample() { // Setup main camera. _canvas.setTitle("Terrain Example"); _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(400, 220, 715)); _canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(430, 200, 730), Vector3.UNIT_Y); _canvas.getCanvasRenderer() .getCamera() .setFrustumPerspective( 70.0, (float) _canvas.getCanvasRenderer().getCamera().getWidth() / _canvas.getCanvasRenderer().getCamera().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(500); setupDefaultStates(); try { 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, 500, 1)); terrain = new TerrainBuilder(terrainDataProvider, _canvas.getCanvasRenderer().getCamera()) .setShowDebugPanels(false).build(); _root.attachChild(terrain); } catch (final Exception ex1) { System.out.println("Problem setting up terrain..."); ex1.printStackTrace(); } addControls(); // Add something to move around final PQTorus obj = new PQTorus("obj", 4, 3, 1.5, .5, 128, 8); obj.setScale(10); obj.updateModelBound(); _root.attachChild(obj); _root.updateGeometricState(0); try { Thread.sleep(500); } catch (final InterruptedException e) { } obj.setTranslation(630, terrain.getHeightAt(630, 830) + 20, 830); manager.setSpatialTarget(obj); } private void setupDefaultStates() { _lightState.detachAll(); final DirectionalLight dLight = new DirectionalLight(); dLight.setEnabled(true); dLight.setAmbient(new ColorRGBA(0.4f, 0.4f, 0.5f, 1)); dLight.setDiffuse(new ColorRGBA(0.6f, 0.6f, 0.5f, 1)); dLight.setSpecular(new ColorRGBA(0.3f, 0.3f, 0.2f, 1)); dLight.setDirection(new Vector3(-1, -1, -1).normalizeLocal()); _lightState.attach(dLight); _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(ColorRGBA.GRAY); fs.setDensityFunction(DensityFunction.Linear); _root.setRenderState(fs); } private void addControls() { InteractExample.setupCursors(); // create our manager manager = new InteractManager(); manager.setupInput(_canvas, _physicalLayer, _logicalLayer); // final add our widget final CompoundInteractWidget widget = new CompoundInteractWidget() .withMoveXAxis(new ColorRGBA(1, 0, 0, .65f), 1.2, .15, .5, .2) .withMoveZAxis(new ColorRGBA(0, 0, 1, .65f), 1.2, .15, .5, .2) // .withRotateYAxis() // .withPlanarHandle(MovePlane.XZ, new ColorRGBA(1, 0, 1, .65f)) // .withRingTexture((Texture2D) TextureManager.load("images/tick.png", MinificationFilter.Trilinear, true)); // widget.getHandle().setRenderState(_lightState); manager.addWidget(widget); manager.setActiveWidget(widget); // add toggle for matrix mode on widget manager.getLogicalLayer().registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { widget.setInteractMatrix(widget.getInteractMatrix() == InteractMatrix.World ? InteractMatrix.Local : InteractMatrix.World); widget.targetDataUpdated(manager); } })); // add a filter manager.addFilter(new TerrainHeightFilter(terrain, 20)); } } \ No newline at end of file
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationCopyExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationCopyExample.java
index 055c242..4ba6898 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationCopyExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationCopyExample.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>.
*/
@@ -145,24 +145,23 @@ public class AnimationCopyExample extends ExampleBase {
}
private void createHUD() {
- hud = new UIHud();
- hud.setupInput(_canvas, _physicalLayer, _logicalLayer);
+ hud = new UIHud(_canvas);
+ hud.setupInput(_physicalLayer, _logicalLayer);
hud.setMouseManager(_mouseManager);
// Add fps display
frameRateLabel = new UILabel("X");
- frameRateLabel.setHudXY(5,
- _canvas.getCanvasRenderer().getCamera().getHeight() - 5 - frameRateLabel.getContentHeight());
+ frameRateLabel.setHudXY(5, hud.getHeight() - 5 - frameRateLabel.getContentHeight());
frameRateLabel.setForegroundColor(ColorRGBA.WHITE);
hud.add(frameRateLabel);
final UIFrame optionsFrame = new UIFrame("Controls", EnumSet.noneOf(FrameButtons.class));
- final UIPanel basePanel = optionsFrame.getContentPanel();
- basePanel.setLayout(new AnchorLayout());
+ final UIPanel panel = optionsFrame.getContentPanel();
+ panel.setLayout(new AnchorLayout());
runWalkButton = new UIButton("Start running...");
- runWalkButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, basePanel, Alignment.TOP_LEFT, 5, -5));
+ runWalkButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel, Alignment.TOP_LEFT, 5, -5));
runWalkButton.addActionListener(new ActionListener() {
boolean walk = true;
@@ -181,7 +180,7 @@ public class AnimationCopyExample extends ExampleBase {
}
}
});
- basePanel.add(runWalkButton);
+ panel.add(runWalkButton);
punchButton = new UIButton("PUNCH!");
punchButton
@@ -193,7 +192,7 @@ public class AnimationCopyExample extends ExampleBase {
punchButton.setEnabled(false);
}
});
- basePanel.add(punchButton);
+ panel.add(punchButton);
headCheck = new UICheckBox("Procedurally turn head");
headCheck.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, punchButton, Alignment.BOTTOM_LEFT, 0, -5));
@@ -205,7 +204,7 @@ public class AnimationCopyExample extends ExampleBase {
manager.getValuesStore().put("head_blend", headCheck.isSelected() ? 1.0 : 0.0);
}
});
- basePanel.add(headCheck);
+ panel.add(headCheck);
final UICheckBox gpuSkinningCheck = new UICheckBox("Use GPU skinning");
gpuSkinningCheck
@@ -232,7 +231,7 @@ public class AnimationCopyExample extends ExampleBase {
}, true);
}
});
- basePanel.add(gpuSkinningCheck);
+ panel.add(gpuSkinningCheck);
final UICheckBox vboCheck = new UICheckBox("Use VBO");
vboCheck.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, gpuSkinningCheck, Alignment.BOTTOM_LEFT, 0, -5));
@@ -244,7 +243,7 @@ public class AnimationCopyExample extends ExampleBase {
gpuShader.setUseAttributeVBO(vboCheck.isSelected());
}
});
- basePanel.add(vboCheck);
+ panel.add(vboCheck);
final UICheckBox skeletonCheck = new UICheckBox("Show skeleton");
final UICheckBox boneLabelCheck = new UICheckBox("Show joint labels");
@@ -258,7 +257,7 @@ public class AnimationCopyExample extends ExampleBase {
boneLabelCheck.setEnabled(showSkeleton);
}
});
- basePanel.add(skeletonCheck);
+ panel.add(skeletonCheck);
boneLabelCheck.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, skeletonCheck, Alignment.BOTTOM_LEFT, 0,
-5));
@@ -271,10 +270,8 @@ public class AnimationCopyExample extends ExampleBase {
showJointLabels = boneLabelCheck.isSelected();
}
});
- basePanel.add(boneLabelCheck);
+ panel.add(boneLabelCheck);
- optionsFrame.updateMinimumSizeFromContents();
- optionsFrame.layout();
optionsFrame.pack();
optionsFrame.setUseStandin(true);
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationStateExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationStateExample.java
index b9120a4..ccd0e48 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationStateExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationStateExample.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>.
*/
@@ -140,14 +140,13 @@ public class AnimationStateExample extends ExampleBase {
}
private void createHUD() {
- hud = new UIHud();
- hud.setupInput(_canvas, _physicalLayer, _logicalLayer);
+ hud = new UIHud(_canvas);
+ hud.setupInput(_physicalLayer, _logicalLayer);
hud.setMouseManager(_mouseManager);
// Add fps display
frameRateLabel = new UILabel("X");
- frameRateLabel.setHudXY(5,
- _canvas.getCanvasRenderer().getCamera().getHeight() - 5 - frameRateLabel.getContentHeight());
+ frameRateLabel.setHudXY(5, hud.getHeight() - 5 - frameRateLabel.getContentHeight());
frameRateLabel.setForegroundColor(ColorRGBA.WHITE);
hud.add(frameRateLabel);
@@ -180,7 +179,7 @@ public class AnimationStateExample extends ExampleBase {
punchButton = new UIButton("PUNCH!");
punchButton
- .setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, runWalkButton, Alignment.BOTTOM_LEFT, 0, -5));
+ .setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, runWalkButton, Alignment.BOTTOM_LEFT, 0, -5));
punchButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent event) {
@@ -209,7 +208,7 @@ public class AnimationStateExample extends ExampleBase {
stopButton = new UIButton("Stop");
stopButton
- .setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, playPauseButton, Alignment.BOTTOM_LEFT, 0, -5));
+ .setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, playPauseButton, Alignment.BOTTOM_LEFT, 0, -5));
stopButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent event) {
@@ -221,7 +220,7 @@ public class AnimationStateExample extends ExampleBase {
final UICheckBox resetAnimCheck = new UICheckBox("Reset Animation On Stop");
resetAnimCheck
- .setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, stopButton, Alignment.BOTTOM_LEFT, 0, -5));
+ .setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, stopButton, Alignment.BOTTOM_LEFT, 0, -5));
resetAnimCheck.setSelected(false);
resetAnimCheck.addActionListener(new ActionListener() {
@Override
@@ -298,8 +297,6 @@ public class AnimationStateExample extends ExampleBase {
});
basePanel.add(boneLabelCheck);
- optionsFrame.updateMinimumSizeFromContents();
- optionsFrame.layout();
optionsFrame.pack();
optionsFrame.setUseStandin(true);
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 f769883..277e555 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
@@ -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>.
*/
@@ -132,14 +132,13 @@ public class ColladaExample extends ExampleBase {
_root.attachChild(t1);
_root.getSceneHints().setCullHint(CullHint.Never);
- hud = new UIHud();
- hud.setupInput(_canvas, _physicalLayer, _logicalLayer);
+ hud = new UIHud(_canvas);
+ hud.setupInput(_physicalLayer, _logicalLayer);
hud.setMouseManager(_mouseManager);
// Add fps display
frameRateLabel = new UILabel("X");
- frameRateLabel.setHudXY(5,
- _canvas.getCanvasRenderer().getCamera().getHeight() - 5 - frameRateLabel.getContentHeight());
+ frameRateLabel.setHudXY(5, hud.getHeight() - 5 - frameRateLabel.getContentHeight());
frameRateLabel.setForegroundColor(ColorRGBA.WHITE);
hud.add(frameRateLabel);
@@ -167,7 +166,7 @@ public class ColladaExample extends ExampleBase {
final UICheckBox skinCheck = new UICheckBox("Show skin mesh");
skinCheck
- .setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, loadSceneButton, Alignment.BOTTOM_LEFT, 0, -5));
+ .setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, loadSceneButton, Alignment.BOTTOM_LEFT, 0, -5));
skinCheck.setSelected(true);
skinCheck.addActionListener(new ActionListener() {
@Override
@@ -202,8 +201,6 @@ public class ColladaExample extends ExampleBase {
});
basePanel.add(boneLabelCheck);
- optionsFrame.updateMinimumSizeFromContents();
- optionsFrame.layout();
optionsFrame.pack();
optionsFrame.setUseStandin(true);
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/GeneratedTexturesExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/GeneratedTexturesExample.java
index 0cb1dce..f92d64c 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/GeneratedTexturesExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/GeneratedTexturesExample.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>.
*/
@@ -144,8 +144,8 @@ public class GeneratedTexturesExample extends ExampleBase {
padding = wside / 10;
// Set up hud
- hud = new UIHud();
- hud.setupInput(_canvas, _physicalLayer, _logicalLayer);
+ hud = new UIHud(_canvas);
+ hud.setupInput(_physicalLayer, _logicalLayer);
// Set up the frames
for (int i = 0; i < views.length; i++) {
@@ -246,8 +246,7 @@ public class GeneratedTexturesExample extends ExampleBase {
zoomed = null;
}
- final int endY = 0, endX = (_canvas.getCanvasRenderer().getCamera().getWidth() - _canvas.getCanvasRenderer()
- .getCamera().getHeight()) / 2;
+ final int endY = 0, endX = (hud.getWidth() - hud.getHeight()) / 2;
// add an animator to do the zoom
uiPanel.addController(new SpatialController<UIPanel>() {
@@ -271,12 +270,12 @@ public class GeneratedTexturesExample extends ExampleBase {
// use an scurve to smoothly zoom
final float sCurve = MathUtils.scurve5(ratio);
- final float size = sCurve * (_canvas.getCanvasRenderer().getCamera().getHeight() - hside) + hside;
+ final float size = sCurve * (hud.getHeight() - hside) + hside;
parent.setLocalComponentSize((int) (size * hside / wside), (int) size);
// use an scurve to smoothly shift origin
- parent.setHudXY(Math.round(MathUtils.lerp(sCurve, originX, endX)), Math.round(MathUtils.lerp(sCurve,
- originY, endY)));
+ parent.setHudXY(Math.round(MathUtils.lerp(sCurve, originX, endX)),
+ Math.round(MathUtils.lerp(sCurve, originY, endY)));
parent.layout();
}
@@ -416,8 +415,8 @@ public class GeneratedTexturesExample extends ExampleBase {
final Function3D combinedWood = Functions.add(baseWood, woodGrain);
final Function3D perturbedWood = new TurbulenceFunction3D(combinedWood, 1 / 256.0, 4, 4.0);
final Function3D translatedWood = Functions.translateInput(perturbedWood, 0, 0, 1.5);
- final Function3D rotatedWood = Functions.rotateInput(translatedWood, new Matrix3().fromAngles(
- MathUtils.DEG_TO_RAD * 6, 0, 0));
+ final Function3D rotatedWood = Functions.rotateInput(translatedWood,
+ new Matrix3().fromAngles(MathUtils.DEG_TO_RAD * 6, 0, 0));
final Function3D finalWood = new TurbulenceFunction3D(rotatedWood, 1 / 512.0, 2, 2.0);
final ReadOnlyColorRGBA[] woodColors = new ReadOnlyColorRGBA[256];
@@ -444,8 +443,8 @@ public class GeneratedTexturesExample extends ExampleBase {
// Build up our function
final Function3D primaryJade = new RidgeFunction3D(Functions.simplexNoise(), 6, 2.0, 2.207);
final Function3D baseSecondaryJade = new CylinderFunction3D(2);
- final Function3D rotatedBaseSecondaryJade = Functions.rotateInput(baseSecondaryJade, new Matrix3().fromAngles(
- 0, MathUtils.DEG_TO_RAD * 65, MathUtils.DEG_TO_RAD * 85));
+ final Function3D rotatedBaseSecondaryJade = Functions.rotateInput(baseSecondaryJade,
+ new Matrix3().fromAngles(0, MathUtils.DEG_TO_RAD * 65, MathUtils.DEG_TO_RAD * 85));
final Function3D perturbedBaseSecondaryJade = new TurbulenceFunction3D(rotatedBaseSecondaryJade, 1.0 / 4.0, 4,
4.0);
final Function3D secondaryJade = Functions.scaleBias(perturbedBaseSecondaryJade, .25, 0);
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/utils/atlas/TestAtlasPacker.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/utils/atlas/TestAtlasPacker.java
index 2df7c4e..7f83f13 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/utils/atlas/TestAtlasPacker.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/utils/atlas/TestAtlasPacker.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>.
*/
@@ -29,7 +29,7 @@ public class TestAtlasPacker {
final Random rand = new Random();
for (int i = 0; i < 2000; i++) {
- /* final AtlasNode node = */packer.insert(rand.nextInt(100) + 10, rand.nextInt(100) + 10);
+ packer.insert(rand.nextInt(100) + 10, rand.nextInt(100) + 10);
}
final JFrame frame = new JFrame("Pack");
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 3f1efd2..a04b34c 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
@@ -1,5 +1,6 @@
+
/**
- * Copyright (c) 2008-2018 Ardor Labs, Inc.
+ * Copyright (c) 2008-2012 Ardor Labs, Inc.
*
* This file is part of Ardor3D.
*
@@ -82,7 +83,9 @@ import com.ardor3d.util.resource.ResourceLocatorTool;
* Example showing the Geometry Clipmap Terrain system with 'MegaTextures' where the terrain data is provided from a
* float array populated from a heightmap generated from an Image. Requires GLSL support.
*/
-@Purpose(htmlDescriptionKey = "com.ardor3d.example.terrain.MountainShadowTerrainExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/terrain_MountainShadowTerrainExample.jpg", // maxHeapMemory = 128)
+@Purpose(htmlDescriptionKey = "com.ardor3d.example.terrain.ImageMapTerrainExample", //
+ thumbnailPath = "com/ardor3d/example/media/thumbnails/terrain_ImageMapTerrainExample.jpg", //
+ maxHeapMemory = 128)
public class MountainShadowTerrainExample extends ExampleBase {
private final float farPlane = 8000.0f;
@@ -102,7 +105,8 @@ public class MountainShadowTerrainExample extends ExampleBase {
/** Pssm shadow map pass. */
private ParallelSplitShadowMapPass _pssmPass;
- private DirectionalLight directionalLight;
+ private DirectionalLight light;
+
private double lightTime;
private boolean moveLight = false;
@@ -127,7 +131,8 @@ public class MountainShadowTerrainExample extends ExampleBase {
}
}
- terrain.getGeometryClipmapShader().setUniform("lightDir", directionalLight.getDirection());
+ terrain.getGeometryClipmapShader().setUniform("lightDir", light.getDirection());
+
for (int i = 0; i < _pssmPass.getNumOfSplits(); i++) {
TextureState screen = (TextureState) _orthoQuad[i].getLocalRenderState(StateType.Texture);
Texture copy;
@@ -196,7 +201,8 @@ public class MountainShadowTerrainExample extends ExampleBase {
if (moveLight) {
lightTime += timer.getTimePerFrame();
- directionalLight.setDirection(new Vector3(Math.sin(lightTime), -.8, Math.cos(lightTime)).normalizeLocal()); }
+ light.setDirection(new Vector3(Math.sin(lightTime), -.8, Math.cos(lightTime)).normalizeLocal());
+ }
}
/**
@@ -229,7 +235,8 @@ public class MountainShadowTerrainExample extends ExampleBase {
addUI();
// Initialize PSSM shadows
- _pssmPass = new ParallelSplitShadowMapPass(directionalLight, 2048, 4); _pssmPass.setFiltering(Filter.None);
+ _pssmPass = new ParallelSplitShadowMapPass(light, 2048, 4);
+ _pssmPass.setFiltering(Filter.None);
_pssmPass.setRenderShadowedScene(false);
_pssmPass.setKeepMainShader(true);
// _pssmPass.setMinimumLightDistance(500); // XXX: Tune this
@@ -290,7 +297,9 @@ 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(
+ new UrlInputSupplier(ResourceLocatorTool.getClassPathResource(ShadowedTerrainExample.class,
+ "com/ardor3d/extension/terrain/shadowedGeometryClipmapShader_normalMap.frag")));
terrain.reloadShader();
terrain.getGeometryClipmapShader().setUniform("normalMap", 5);
terrainNode.attachChild(terrain);
@@ -371,7 +380,14 @@ public class MountainShadowTerrainExample extends ExampleBase {
terrainNode.setRenderState(new ZBufferState());
_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(new Vector3(-1, -1, -1).normalizeLocal()); _lightState.attach(directionalLight); _lightState.setEnabled(true);
+ 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(new Vector3(-1, -1, -1).normalizeLocal());
+ _lightState.attach(light);
+ _lightState.setEnabled(true);
final FogState fs = new FogState();
fs.setStart(farPlane / 2.0f);
@@ -404,8 +420,8 @@ public class MountainShadowTerrainExample extends ExampleBase {
private void addUI() {
// setup hud
- hud = new UIHud();
- hud.setupInput(_canvas, _physicalLayer, _logicalLayer);
+ hud = new UIHud(_canvas);
+ hud.setupInput(_physicalLayer, _logicalLayer);
hud.setMouseManager(_mouseManager);
final UIFrame frame = new UIFrame("Controls", EnumSet.noneOf(FrameButtons.class));
@@ -452,9 +468,8 @@ public class MountainShadowTerrainExample extends ExampleBase {
frame.setContentPanel(panel);
frame.pack();
- final Camera cam = _canvas.getCanvasRenderer().getCamera();
- frame.setLocalXY(cam.getWidth() - frame.getLocalComponentWidth(),
- cam.getHeight() - frame.getLocalComponentHeight());
+ frame.setLocalXY(hud.getWidth() - frame.getLocalComponentWidth(),
+ hud.getHeight() - frame.getLocalComponentHeight());
hud.add(frame);
}
}
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/ui/InteractUIExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/ui/InteractUIExample.java
index 2bc3de0..e364180 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/ui/InteractUIExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/ui/InteractUIExample.java
@@ -26,19 +26,16 @@ import com.ardor3d.extension.interact.widget.BasicFilterList;
import com.ardor3d.extension.interact.widget.IFilterList;
import com.ardor3d.extension.interact.widget.MovePlanarWidget;
import com.ardor3d.extension.interact.widget.MovePlanarWidget.MovePlane;
-import com.ardor3d.extension.ui.FloatingUIContainer;
import com.ardor3d.extension.ui.Orientation;
import com.ardor3d.extension.ui.UIButton;
import com.ardor3d.extension.ui.UIComboBox;
import com.ardor3d.extension.ui.UIContainer;
-import com.ardor3d.extension.ui.UIFrame;
import com.ardor3d.extension.ui.UIHud;
import com.ardor3d.extension.ui.UIPanel;
import com.ardor3d.extension.ui.UIPieMenu;
import com.ardor3d.extension.ui.UIPieMenuItem;
import com.ardor3d.extension.ui.UISlider;
import com.ardor3d.extension.ui.backdrop.EmptyBackdrop;
-import com.ardor3d.extension.ui.border.EmptyBorder;
import com.ardor3d.extension.ui.event.ActionEvent;
import com.ardor3d.extension.ui.event.ActionListener;
import com.ardor3d.extension.ui.event.SelectionListener;
@@ -86,7 +83,7 @@ import com.ardor3d.util.TextureManager;
maxHeapMemory = 64)
public class InteractUIExample extends ExampleBase {
- final UIHud hud = new UIHud();
+ private UIHud hud;
private InteractManager manager;
private MovePlanarWidget moveWidget;
private InsertMarkerUIWidget insertWidget;
@@ -120,6 +117,7 @@ public class InteractUIExample extends ExampleBase {
@Override
protected void initExample() {
_canvas.setTitle("Interact Example");
+ hud = new UIHud(_canvas);
final Camera camera = _canvas.getCanvasRenderer().getCamera();
camera.setLocation(15, 11, -9);
@@ -273,7 +271,7 @@ public class InteractUIExample extends ExampleBase {
manager = new InteractManager(new MarkerState());
manager.setupInput(_canvas, _physicalLayer, _logicalLayer);
- hud.setupInput(_canvas, _physicalLayer, manager.getLogicalLayer());
+ hud.setupInput(_physicalLayer, manager.getLogicalLayer());
hud.setMouseManager(_mouseManager);
final BasicFilterList filterList = new BasicFilterList();
@@ -421,8 +419,10 @@ public class InteractUIExample extends ExampleBase {
tempVec.set(Camera.getCurrentCamera().getScreenCoordinates(spat.getWorldTransform().applyForward(tempVec)));
tempVec.setZ(0);
menu.showAt((int) tempVec.getX(), (int) tempVec.getY());
- _mouseManager.setPosition((int) tempVec.getX(), (int) tempVec.getY() + 1);
_mouseManager.setPosition((int) tempVec.getX(), (int) tempVec.getY());
+ if (menu.getCenterItem() != null) {
+ menu.getCenterItem().mouseEntered((int) tempVec.getX(), (int) tempVec.getY(), null);
+ }
}
protected void hideMenu() {
@@ -445,7 +445,7 @@ public class InteractUIExample extends ExampleBase {
class InsertMarkerUIWidget extends AbstractInteractWidget {
- UIFrame popupFrame;
+ UIPanel uiPanel;
public InsertMarkerUIWidget(final IFilterList filterList) {
super(filterList);
@@ -493,16 +493,11 @@ public class InteractUIExample extends ExampleBase {
}
});
- popupFrame = new FloatingUIContainer();
- popupFrame.getContentPanel().add(centerPanel);
- popupFrame.getBasePanel().setBackdrop(new EmptyBackdrop());
- popupFrame.getBasePanel().setBorder(new EmptyBorder());
-
- popupFrame.updateMinimumSizeFromContents();
- popupFrame.layout();
- popupFrame.pack();
+ uiPanel = new UIPanel();
+ uiPanel.add(centerPanel);
+ uiPanel.pack();
- _handle = popupFrame;
+ _handle = uiPanel;
}
private void AddButton(final UIContainer parent, final String label, final ActionListener actionListener) {
@@ -525,7 +520,7 @@ public class InteractUIExample extends ExampleBase {
tempVec.zero();
tempVec.set(Camera.getCurrentCamera().getScreenCoordinates(spat.getWorldTransform().applyForward(tempVec)));
tempVec.setZ(0);
- tempVec.subtractLocal(popupFrame.getContentWidth() / 2, -10, 0);
+ tempVec.subtractLocal(uiPanel.getContentWidth() / 2, -10, 0);
_handle.setTranslation(tempVec);
_handle.updateWorldTransform(true);
}
@@ -535,14 +530,14 @@ public class InteractUIExample extends ExampleBase {
super.receivedControl(manager);
final Spatial spat = manager.getSpatialTarget();
if (spat != null) {
- hud.add(popupFrame);
+ hud.add(uiPanel);
}
}
@Override
public void lostControl(final InteractManager manager) {
super.lostControl(manager);
- hud.remove(popupFrame);
+ hud.remove(uiPanel);
}
@Override
@@ -551,9 +546,9 @@ public class InteractUIExample extends ExampleBase {
if (manager.getActiveWidget() == this) {
final Spatial spat = manager.getSpatialTarget();
if (spat == null) {
- hud.remove(popupFrame);
+ hud.remove(uiPanel);
} else {
- hud.add(popupFrame);
+ hud.add(uiPanel);
}
}
}
@@ -561,7 +556,7 @@ public class InteractUIExample extends ExampleBase {
class ColorSelectUIWidget extends AbstractInteractWidget {
- UIFrame popupFrame;
+ UIPanel uiPanel;
ColorRGBA unconsumedColor;
public ColorSelectUIWidget(final IFilterList filterList) {
@@ -572,13 +567,13 @@ public class InteractUIExample extends ExampleBase {
private void createFrame() {
- final UIPanel centerPanel = new UIPanel(null);
+ final UIPanel centerPanel = new UIPanel();
centerPanel.setBackdrop(new EmptyBackdrop());
centerPanel.setLayoutData(BorderLayoutData.CENTER);
final UIComboBox combo = new UIComboBox(
new DefaultComboBoxModel("White", "Black", "Red", "Green", "Blue", "Yellow", "Magenta", "Cyan"));
- combo.setLocalComponentWidth(100);
+ combo.setMinimumContentWidth(100);
combo.addSelectionListener(new SelectionListener<UIComboBox>() {
@Override
public void selectionChanged(final UIComboBox component, final Object newValue) {
@@ -596,16 +591,11 @@ public class InteractUIExample extends ExampleBase {
});
centerPanel.add(combo);
- popupFrame = new FloatingUIContainer();
- popupFrame.getContentPanel().add(centerPanel);
- popupFrame.getBasePanel().setBackdrop(new EmptyBackdrop());
- popupFrame.getBasePanel().setBorder(null);
+ uiPanel = new UIPanel();
+ uiPanel.add(centerPanel);
+ uiPanel.pack();
- popupFrame.updateMinimumSizeFromContents();
- popupFrame.layout();
- popupFrame.pack();
-
- _handle = popupFrame;
+ _handle = uiPanel;
}
@Override
@@ -618,7 +608,7 @@ public class InteractUIExample extends ExampleBase {
tempVec.zero();
tempVec.set(Camera.getCurrentCamera().getScreenCoordinates(spat.getWorldTransform().applyForward(tempVec)));
tempVec.setZ(0);
- tempVec.subtractLocal(popupFrame.getContentWidth() / 2, -20, 0);
+ tempVec.subtractLocal(uiPanel.getContentWidth() / 2, -20, 0);
_handle.setTranslation(tempVec);
_handle.updateWorldTransform(true);
}
@@ -628,14 +618,14 @@ public class InteractUIExample extends ExampleBase {
super.receivedControl(manager);
final Spatial spat = manager.getSpatialTarget();
if (spat != null) {
- hud.add(popupFrame);
+ hud.add(uiPanel);
}
}
@Override
public void lostControl(final InteractManager manager) {
super.lostControl(manager);
- hud.remove(popupFrame);
+ hud.remove(uiPanel);
}
@Override
@@ -655,9 +645,9 @@ public class InteractUIExample extends ExampleBase {
if (manager.getActiveWidget() == this) {
final Spatial spat = manager.getSpatialTarget();
if (spat == null) {
- hud.remove(popupFrame);
+ hud.remove(uiPanel);
} else {
- hud.add(popupFrame);
+ hud.add(uiPanel);
}
}
}
@@ -665,7 +655,7 @@ public class InteractUIExample extends ExampleBase {
class PulseControlUIWidget extends AbstractInteractWidget {
- UIFrame popupFrame;
+ UIPanel uiPanel;
Double unconsumedPulse;
public PulseControlUIWidget(final IFilterList filterList) {
@@ -676,7 +666,7 @@ public class InteractUIExample extends ExampleBase {
private void createFrame() {
- final UIPanel centerPanel = new UIPanel(null);
+ final UIPanel centerPanel = new UIPanel();
centerPanel.setBackdrop(new EmptyBackdrop());
centerPanel.setLayoutData(BorderLayoutData.CENTER);
@@ -692,19 +682,14 @@ public class InteractUIExample extends ExampleBase {
}
}
});
- slider.setLocalComponentWidth(100);
+ slider.setMinimumContentWidth(100);
centerPanel.add(slider);
- popupFrame = new FloatingUIContainer();
- popupFrame.getContentPanel().add(centerPanel);
- popupFrame.getBasePanel().setBackdrop(new EmptyBackdrop());
- popupFrame.getBasePanel().setBorder(null);
-
- popupFrame.updateMinimumSizeFromContents();
- popupFrame.layout();
- popupFrame.pack();
+ uiPanel = new UIPanel();
+ uiPanel.add(centerPanel);
+ uiPanel.pack();
- _handle = popupFrame;
+ _handle = uiPanel;
}
@Override
@@ -717,7 +702,7 @@ public class InteractUIExample extends ExampleBase {
tempVec.zero();
tempVec.set(Camera.getCurrentCamera().getScreenCoordinates(spat.getWorldTransform().applyForward(tempVec)));
tempVec.setZ(0);
- tempVec.subtractLocal(popupFrame.getContentWidth() / 2, -20, 0);
+ tempVec.subtractLocal(uiPanel.getContentWidth() / 2, -20, 0);
_handle.setTranslation(tempVec);
_handle.updateWorldTransform(true);
}
@@ -727,14 +712,14 @@ public class InteractUIExample extends ExampleBase {
super.receivedControl(manager);
final Spatial spat = manager.getSpatialTarget();
if (spat != null) {
- hud.add(popupFrame);
+ hud.add(uiPanel);
}
}
@Override
public void lostControl(final InteractManager manager) {
super.lostControl(manager);
- hud.remove(popupFrame);
+ hud.remove(uiPanel);
}
@Override
@@ -754,9 +739,9 @@ public class InteractUIExample extends ExampleBase {
if (manager.getActiveWidget() == this) {
final Spatial spat = manager.getSpatialTarget();
if (spat == null) {
- hud.remove(popupFrame);
+ hud.remove(uiPanel);
} else {
- hud.add(popupFrame);
+ hud.add(uiPanel);
}
}
}
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/ui/PopOverUIExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/ui/PopOverUIExample.java
new file mode 100644
index 0000000..6387bce
--- /dev/null
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/ui/PopOverUIExample.java
@@ -0,0 +1,337 @@
+/**
+ * Copyright (c) 2008-2017 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.ui;
+
+import java.util.EnumSet;
+
+import com.ardor3d.bounding.BoundingBox;
+import com.ardor3d.example.ExampleBase;
+import com.ardor3d.example.Purpose;
+import com.ardor3d.extension.ui.Orientation;
+import com.ardor3d.extension.ui.UIButton;
+import com.ardor3d.extension.ui.UIComponent;
+import com.ardor3d.extension.ui.UIFrame;
+import com.ardor3d.extension.ui.UIFrame.FrameButtons;
+import com.ardor3d.extension.ui.UIHud;
+import com.ardor3d.extension.ui.UIMenuItem;
+import com.ardor3d.extension.ui.UIPanel;
+import com.ardor3d.extension.ui.UIPieMenu;
+import com.ardor3d.extension.ui.UIPieMenuItem;
+import com.ardor3d.extension.ui.UIPopupMenu;
+import com.ardor3d.extension.ui.UISlider;
+import com.ardor3d.extension.ui.UITextField;
+import com.ardor3d.extension.ui.event.ActionEvent;
+import com.ardor3d.extension.ui.event.ActionListener;
+import com.ardor3d.extension.ui.layout.RowLayout;
+import com.ardor3d.extension.ui.util.Insets;
+import com.ardor3d.image.Texture;
+import com.ardor3d.math.ColorRGBA;
+import com.ardor3d.math.MathUtils;
+import com.ardor3d.math.Matrix3;
+import com.ardor3d.math.Vector3;
+import com.ardor3d.math.type.ReadOnlyVector3;
+import com.ardor3d.renderer.Renderer;
+import com.ardor3d.renderer.state.MaterialState;
+import com.ardor3d.renderer.state.MaterialState.ColorMaterial;
+import com.ardor3d.renderer.state.RenderState.StateType;
+import com.ardor3d.renderer.state.TextureState;
+import com.ardor3d.scenegraph.controller.SpatialController;
+import com.ardor3d.scenegraph.shape.Box;
+import com.ardor3d.util.ReadOnlyTimer;
+import com.ardor3d.util.TextureManager;
+
+/**
+ * Illustrates the use of Popup and Pie menus.
+ */
+@Purpose(htmlDescriptionKey = "com.ardor3d.example.ui.PopOverUIExample", //
+thumbnailPath = "com/ardor3d/example/media/thumbnails/ui_PopOverUIExample.jpg", //
+maxHeapMemory = 64)
+public class PopOverUIExample extends ExampleBase implements ActionListener {
+ private static final String[] COLORS = new String[] { "Red", "White", "Blue", "Black" };
+ private static final String[] SPINS = new String[] { "None", "Around X", "Around Y", "Around Z" };
+ private static final String[] TEXS = new String[] { "None", "Logo", "Ball", "Clock" };
+ private static final String[] SCALE = new String[] { "Scale..." };
+
+ UIHud hud;
+ private Box box;
+
+ public static void main(final String[] args) {
+ start(PopOverUIExample.class);
+ }
+
+ @Override
+ protected void initExample() {
+ _canvas.setTitle("PopOver UI Example");
+
+ UIComponent.setUseTransparency(true);
+
+ // Add a spinning 3D box to show behind UI.
+ box = new Box("Box", new Vector3(0, 0, 0), 5, 5, 5);
+ box.setModelBound(new BoundingBox());
+ box.setTranslation(new Vector3(0, 0, -15));
+ _root.attachChild(box);
+
+ final MaterialState ms = new MaterialState();
+ ms.setColorMaterial(ColorMaterial.Diffuse);
+ box.setRenderState(ms);
+
+ setTexture("Logo");
+ setSpin("Around Y");
+
+ hud = new UIHud(_canvas);
+ hud.setupInput(_physicalLayer, _logicalLayer);
+ hud.setMouseManager(_mouseManager);
+
+ final UIButton dropButton = new UIButton("Drop Menu");
+ dropButton.setPadding(new Insets(6, 15, 6, 15));
+ dropButton.setHudXY(hud.getWidth() / 10 - dropButton.getLocalComponentWidth() / 2,
+ hud.getHeight() - dropButton.getLocalComponentHeight() - 5);
+ dropButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(final ActionEvent event) {
+ showPopupMenu(dropButton.getHudX(), dropButton.getHudY());
+ }
+ });
+ hud.add(dropButton);
+
+ final UIButton pieButton = new UIButton("Pie Menu");
+ pieButton.setPadding(new Insets(6, 15, 6, 15));
+ pieButton.setHudXY(9 * hud.getWidth() / 10 - pieButton.getLocalComponentWidth() / 2, hud.getHeight()
+ - pieButton.getLocalComponentHeight() - 5);
+ pieButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(final ActionEvent event) {
+ showPieMenu(hud.getWidth() / 2, hud.getHeight() / 2);
+ }
+ });
+ hud.add(pieButton);
+ }
+
+ @Override
+ public void actionPerformed(final ActionEvent event) {
+ final UIButton src = (UIButton) event.getSource();
+ final String command = src.getActionCommand();
+ switch (command) {
+ case "Color":
+ setColor(src.getText());
+ return;
+ case "Spin":
+ setSpin(src.getText());
+ return;
+ case "Texture":
+ setTexture(src.getText());
+ return;
+ case "Scale":
+ showScaleDialog();
+ return;
+ }
+ }
+
+ protected void showPopupMenu(final int hudX, final int hudY) {
+ final UIPopupMenu menu = new UIPopupMenu();
+ final int minWidth = 120;
+
+ final UIPopupMenu colorMenu = new UIPopupMenu();
+ colorMenu.setMinimumContentSize(minWidth, 5);
+ menu.addItem(new UIMenuItem("Set Color...", null, colorMenu));
+ AddMenuItems(colorMenu, "Color", false, COLORS);
+
+ final UIPopupMenu spinMenu = new UIPopupMenu();
+ spinMenu.setMinimumContentSize(minWidth, 5);
+ menu.addItem(new UIMenuItem("Set Spin...", null, spinMenu));
+ AddMenuItems(spinMenu, "Spin", false, SPINS);
+
+ final UIPopupMenu texMenu = new UIPopupMenu();
+ texMenu.setMinimumContentSize(minWidth, 5);
+ menu.addItem(new UIMenuItem("Set Texture...", null, texMenu));
+ AddMenuItems(texMenu, "Texture", false, TEXS);
+
+ AddMenuItems(menu, "Scale", false, SCALE);
+
+ menu.updateMinimumSizeFromContents();
+ menu.layout();
+
+ hud.closePopupMenus();
+
+ hud.showSubPopupMenu(menu);
+ menu.showAt(hudX, hudY);
+ }
+
+ protected void showPieMenu(final int hudX, final int hudY) {
+ final UIPieMenu menu = new UIPieMenu(hud, 70, 200);
+
+ final UIPieMenu colorMenu = new UIPieMenu(hud);
+ menu.addItem(new UIPieMenuItem("Set Color...", null, colorMenu, 100));
+ AddMenuItems(colorMenu, "Color", true, COLORS);
+
+ final UIPieMenu spinMenu = new UIPieMenu(hud);
+ menu.addItem(new UIPieMenuItem("Set Spin...", null, spinMenu, 100));
+ AddMenuItems(spinMenu, "Spin", true, SPINS);
+
+ final UIPieMenu texMenu = new UIPieMenu(hud);
+ menu.addItem(new UIPieMenuItem("Set Texture...", null, texMenu, 100));
+ AddMenuItems(texMenu, "Texture", true, TEXS);
+
+ AddMenuItems(menu, "Scale", true, SCALE);
+
+ menu.setCenterItem(new UIPieMenuItem("Cancel", null, true, null));
+
+ menu.updateMinimumSizeFromContents();
+ menu.layout();
+
+ hud.closePopupMenus();
+
+ hud.showSubPopupMenu(menu);
+ menu.showAt(hudX, hudY);
+ _mouseManager.setPosition(hudX, hudY);
+ if (menu.getCenterItem() != null) {
+ menu.getCenterItem().mouseEntered(hudX, hudY, null);
+ }
+
+ }
+
+ private void AddMenuItems(final UIPopupMenu parent, final String actionCommand, final boolean pie,
+ final String[] colors) {
+ for (final String color : colors) {
+ final UIMenuItem item = pie ? new UIPieMenuItem(color, null, true, this) : new UIMenuItem(color, null,
+ true, this);
+ item.setActionCommand(actionCommand);
+ parent.addItem(item);
+ }
+ }
+
+ private void setColor(final String text) {
+ switch (text) {
+ case "Red":
+ box.setDefaultColor(ColorRGBA.RED);
+ break;
+ case "Blue":
+ box.setDefaultColor(ColorRGBA.BLUE);
+ break;
+ case "Black":
+ box.setDefaultColor(ColorRGBA.BLACK);
+ break;
+ default:
+ case "White":
+ box.setDefaultColor(ColorRGBA.WHITE);
+ break;
+ }
+ }
+
+ private void setSpin(final String text) {
+ box.clearControllers();
+ final ReadOnlyVector3 axis;
+ switch (text) {
+ case "None":
+ return;
+ case "Around X":
+ axis = Vector3.UNIT_X;
+ break;
+ case "Around Y":
+ axis = Vector3.UNIT_Y;
+ break;
+ default:
+ case "Around Z":
+ axis = Vector3.UNIT_Z;
+ break;
+ }
+ box.addController(new SpatialController<Box>() {
+ private final Matrix3 rotate = new Matrix3();
+ private double angle = 0;
+
+ @Override
+ public void update(final double time, final Box caller) {
+ angle += time * 50;
+ angle %= 360;
+ rotate.fromAngleNormalAxis(angle * MathUtils.DEG_TO_RAD, axis);
+ caller.setRotation(rotate);
+ }
+ });
+ }
+
+ private void setTexture(final String text) {
+ // Add a texture to the box.
+ final TextureState ts = new TextureState();
+
+ String imageFile;
+ switch (text) {
+ case "None":
+ box.clearRenderState(StateType.Texture);
+ box.updateWorldRenderStates(true);
+ return;
+ case "Ball":
+ imageFile = "images/ball.png";
+ break;
+ case "Clock":
+ imageFile = "images/clock.png";
+ break;
+ case "Logo":
+ default:
+ imageFile = "images/ardor3d_white_256.jpg";
+ break;
+ }
+
+ final Texture tex = TextureManager.load(imageFile, Texture.MinificationFilter.Trilinear, true);
+ ts.setTexture(tex);
+ box.setRenderState(ts);
+ box.updateWorldRenderStates(true);
+ }
+
+ private void showScaleDialog() {
+ final UIFrame scaleDialog = new UIFrame("Set Scale...", EnumSet.of(FrameButtons.CLOSE));
+ scaleDialog.setResizeable(false);
+ final UIPanel contentPanel = scaleDialog.getContentPanel();
+ final RowLayout layout = new RowLayout(true, false, false);
+ layout.setSpacing(4);
+ contentPanel.setLayout(layout);
+ contentPanel.setMargin(new Insets(0, 5, 0, 5));
+
+ final UISlider scaleSlider = new UISlider(Orientation.Horizontal, 1, 20, (int) (box.getScale().getX() * 10));
+ scaleSlider.setMinimumContentWidth(200);
+ contentPanel.add(scaleSlider);
+
+ final UITextField scaleTextField = new UITextField();
+ scaleTextField.setEditable(false);
+ scaleTextField.setText("1.0");
+ scaleTextField.setMinimumContentWidth(30);
+ contentPanel.add(scaleTextField);
+
+ scaleSlider.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(final ActionEvent event) {
+ box.setScale(scaleSlider.getValue() / 10.0);
+ scaleTextField.setText(String.format("%.1f", box.getScale().getX()));
+ }
+ });
+
+ hud.add(scaleDialog);
+ scaleDialog.pack();
+ scaleDialog.centerOn(hud);
+ }
+
+ @Override
+ protected void updateLogicalLayer(final ReadOnlyTimer timer) {
+ hud.getLogicalLayer().checkTriggers(timer.getTimePerFrame());
+ }
+
+ @Override
+ protected void renderExample(final Renderer renderer) {
+ super.renderExample(renderer);
+ renderer.renderBuckets();
+ renderer.draw(hud);
+ }
+
+ @Override
+ protected void updateExample(final ReadOnlyTimer timer) {
+ hud.updateGeometricState(timer.getTimePerFrame());
+ }
+
+}
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/ui/RotatingUIExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/ui/RotatingUIExample.java
index d7e10d9..c35ef5c 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/ui/RotatingUIExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/ui/RotatingUIExample.java
@@ -52,13 +52,10 @@ public class RotatingUIExample extends ExampleBase {
final UIFrame frame = new UIFrame("Sample");
frame.setContentPanel(panel);
- frame.updateMinimumSizeFromContents();
- frame.layout();
- frame.pack(300, 200);
+ frame.pack();
frame.setUseStandin(false);
frame.setOpacity(1f);
- frame.setLocationRelativeTo(_canvas.getCanvasRenderer().getCamera());
frame.setName("sample");
final Matrix3 rotate = new Matrix3();
@@ -66,11 +63,11 @@ public class RotatingUIExample extends ExampleBase {
rotate.fromAngleNormalAxis(45 * MathUtils.DEG_TO_RAD, axis);
frame.setRotation(rotate);
- hud = new UIHud();
+ hud = new UIHud(_canvas);
hud.add(frame);
- hud.setupInput(_canvas, _physicalLayer, _logicalLayer);
+ hud.setupInput(_physicalLayer, _logicalLayer);
- frame.setLocationRelativeTo(_canvas.getCanvasRenderer().getCamera());
+ frame.centerOn(hud);
}
private UIPanel makePanel() {
@@ -106,6 +103,8 @@ public class RotatingUIExample extends ExampleBase {
});
rotatingLabel.setLayoutData(BorderLayoutData.NORTH);
+ panel.setMinimumContentSize(300, 200);
+
return panel;
}
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/ui/SimpleUIExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/ui/SimpleUIExample.java
index 8cf69fc..d998180 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/ui/SimpleUIExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/ui/SimpleUIExample.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>.
*/
@@ -28,9 +28,9 @@ import com.ardor3d.extension.ui.UIRadioButton;
import com.ardor3d.extension.ui.UIScrollPanel;
import com.ardor3d.extension.ui.UISlider;
import com.ardor3d.extension.ui.UITabbedPane;
+import com.ardor3d.extension.ui.UITabbedPane.TabPlacement;
import com.ardor3d.extension.ui.UITextArea;
import com.ardor3d.extension.ui.UITextField;
-import com.ardor3d.extension.ui.UITabbedPane.TabPlacement;
import com.ardor3d.extension.ui.backdrop.MultiImageBackdrop;
import com.ardor3d.extension.ui.event.ActionEvent;
import com.ardor3d.extension.ui.event.ActionListener;
@@ -126,13 +126,10 @@ public class SimpleUIExample extends ExampleBase {
frame = new UIFrame("UI Sample");
frame.setContentPanel(pane);
- frame.updateMinimumSizeFromContents();
- frame.layout();
frame.pack();
frame.setUseStandin(true);
frame.setOpacity(1f);
- frame.setLocationRelativeTo(_canvas.getCanvasRenderer().getCamera());
frame.setName("sample");
// Uncomment #1...
@@ -153,10 +150,12 @@ public class SimpleUIExample extends ExampleBase {
// }
// });
- hud = new UIHud();
+ hud = new UIHud(_canvas);
hud.add(frame);
- hud.setupInput(_canvas, _physicalLayer, _logicalLayer);
+ hud.setupInput(_physicalLayer, _logicalLayer);
hud.setMouseManager(_mouseManager);
+
+ frame.centerOn(hud);
}
private UIPanel makeLoginPanel() {
@@ -206,7 +205,7 @@ public class SimpleUIExample extends ExampleBase {
final ActionListener actionListener = new ActionListener() {
@Override
public void actionPerformed(final ActionEvent event) {
- applyChat(historyArea, chatField);
+ applyChat(historyArea, chatField, scrollArea);
}
};
chatButton.addActionListener(actionListener);
@@ -221,11 +220,12 @@ public class SimpleUIExample extends ExampleBase {
return chatPanel;
}
- private void applyChat(final UITextArea historyArea, final UITextField chatField) {
+ private void applyChat(final UITextArea historyArea, final UITextField chatField, final UIScrollPanel scrollArea) {
final String text = chatField.getText();
if (text.length() > 0) {
historyArea.setText(historyArea.getText() + "\n" + text);
chatField.setText("");
+ scrollArea.layout();
}
}
diff --git a/ardor3d-examples/src/main/resources/com/ardor3d/example/i18n/example_descriptions.properties b/ardor3d-examples/src/main/resources/com/ardor3d/example/i18n/example_descriptions.properties
index 9b681f3..646a251 100644
--- a/ardor3d-examples/src/main/resources/com/ardor3d/example/i18n/example_descriptions.properties
+++ b/ardor3d-examples/src/main/resources/com/ardor3d/example/i18n/example_descriptions.properties
@@ -93,5 +93,6 @@ com.ardor3d.example.terrain.ShapesPlusProceduralTerrainExample=Example showing t
com.ardor3d.example.terrain.TerrainWaterExample=Example showing how to combine the terrain and water systems. Requires GLSL support.
com.ardor3d.example.terrain.ZupTerrainExample=Example showing the Geometry Clipmap Terrain system with 'MegaTextures' using Z-Up. This is done by flipping the terrain system from y-up to z-up and inverting interactions with it back to the y-up terrain coordinate space. Requires GLSL support.
com.ardor3d.example.ui.BMTextExample=Illustrates how to modify text properties (e.g. font, color, alignment) and display on a canvas.
+com.ardor3d.example.ui.PopOverUIExample=Illustrates the use of Popup and Pie menus.
com.ardor3d.example.ui.RotatingUIExample=Illustrates how to display and move GUI primitatives (e.g. RadioButton, Lable, TabbedPane) on a canvas.
com.ardor3d.example.ui.SimpleUIExample=Illustrates how to display GUI primitatives (e.g. RadioButton, Lable, TabbedPane) on a canvas.