aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/ui/InteractUIExample.java8
-rw-r--r--ardor3d-extras/src/main/java/com/ardor3d/extension/interact/InteractManager.java70
-rw-r--r--ardor3d-extras/src/main/java/com/ardor3d/extension/interact/widget/MovePlanarWidget.java5
-rw-r--r--ardor3d-extras/src/main/java/com/ardor3d/extension/interact/widget/MoveWidget.java7
4 files changed, 87 insertions, 3 deletions
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 e93cf93..2e5dc1d 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
@@ -18,6 +18,7 @@ import com.ardor3d.bounding.BoundingBox;
import com.ardor3d.example.ExampleBase;
import com.ardor3d.example.Purpose;
import com.ardor3d.extension.interact.InteractManager;
+import com.ardor3d.extension.interact.InteractManager.UpdateLogic;
import com.ardor3d.extension.interact.data.SpatialState;
import com.ardor3d.extension.interact.filter.PlaneBoundaryFilter;
import com.ardor3d.extension.interact.widget.AbstractInteractWidget;
@@ -133,6 +134,13 @@ public class InteractUIExample extends ExampleBase {
// create a few way-markers to start things off
initPath();
+ manager.addUpdateLogic(new UpdateLogic() {
+
+ @Override
+ public void update(final double time, final InteractManager manager) {
+ manager.fireTargetDataUpdated();
+ }
+ });
}
private void addFloor() {
diff --git a/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/InteractManager.java b/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/InteractManager.java
index e924ede..d323736 100644
--- a/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/InteractManager.java
+++ b/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/InteractManager.java
@@ -68,6 +68,9 @@ public class InteractManager {
*/
protected List<UpdateFilter> _filters = new ArrayList<>();
+ /** ArrayList of update logic for this manager. */
+ protected List<UpdateLogic> _updateLogic;
+
public InteractManager() {
_state = new SpatialState();
setupLogicalLayer();
@@ -79,6 +82,7 @@ public class InteractManager {
}
public void update(final ReadOnlyTimer timer) {
+ runUpdateLogic(timer.getTimePerFrame());
for (final AbstractInteractWidget widget : _widgets) {
if (!widget.isActiveUpdateOnly() || widget == _activeWidget) {
widget.update(timer, this);
@@ -253,4 +257,70 @@ public class InteractManager {
return _state;
}
+ public interface UpdateLogic {
+ public void update(double time, InteractManager manager);
+ }
+
+ public void addUpdateLogic(final UpdateLogic logic) {
+ if (_updateLogic == null) {
+ _updateLogic = new ArrayList<UpdateLogic>(1);
+ }
+ _updateLogic.add(logic);
+ }
+
+ public boolean removeUpdateLogic(final UpdateLogic logic) {
+ if (_updateLogic == null) {
+ return false;
+ }
+ return _updateLogic.remove(logic);
+ }
+
+ public UpdateLogic removeUpdateLogic(final int index) {
+ if (_updateLogic == null) {
+ return null;
+ }
+ return _updateLogic.remove(index);
+ }
+
+ public void clearUpdateLogic() {
+ if (_updateLogic != null) {
+ _updateLogic.clear();
+ }
+ }
+
+ public UpdateLogic getUpdateLogic(final int i) {
+ if (_updateLogic == null) {
+ _updateLogic = new ArrayList<UpdateLogic>(1);
+ }
+ return _updateLogic.get(i);
+ }
+
+ public List<UpdateLogic> getUpdateLogic() {
+ if (_updateLogic == null) {
+ _updateLogic = new ArrayList<UpdateLogic>(1);
+ }
+ return _updateLogic;
+ }
+
+ public int getUpdateLogicCount() {
+ if (_updateLogic == null) {
+ return 0;
+ }
+ return _updateLogic.size();
+ }
+
+ public void runUpdateLogic(final double time) {
+ if (_updateLogic != null) {
+ for (int i = 0, gSize = _updateLogic.size(); i < gSize; i++) {
+ try {
+ final UpdateLogic logic = _updateLogic.get(i);
+ if (logic != null) {
+ logic.update(time, this);
+ }
+ } catch (final IndexOutOfBoundsException e) {
+ break;
+ }
+ }
+ }
+ }
}
diff --git a/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/widget/MovePlanarWidget.java b/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/widget/MovePlanarWidget.java
index 16b650f..6706f5d 100644
--- a/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/widget/MovePlanarWidget.java
+++ b/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/widget/MovePlanarWidget.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>.
*/
@@ -108,6 +108,9 @@ public class MovePlanarWidget extends AbstractInteractWidget {
_handle.setScale(1.0);
_handle.setRotation(Matrix3.IDENTITY);
} else {
+ _handle.setScale(Math.max(MoveWidget.MIN_SCALE, target.getWorldBound().getRadius()
+ + target.getWorldTranslation().subtract(target.getWorldBound().getCenter(), _calcVec3A).length()));
+
// update scale of widget using bounding radius
target.updateGeometricState(0);
diff --git a/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/widget/MoveWidget.java b/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/widget/MoveWidget.java
index c06569d..dff1987 100644
--- a/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/widget/MoveWidget.java
+++ b/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/widget/MoveWidget.java
@@ -151,6 +151,9 @@ public class MoveWidget extends AbstractInteractWidget {
_handle.setScale(1.0);
_handle.setRotation(Matrix3.IDENTITY);
} else {
+ _handle.setScale(Math.max(MoveWidget.MIN_SCALE, target.getWorldBound().getRadius()
+ + target.getWorldTranslation().subtract(target.getWorldBound().getCenter(), _calcVec3A).length()));
+
// update scale of widget using bounding radius
target.updateGeometricState(0);
@@ -242,8 +245,8 @@ public class MoveWidget extends AbstractInteractWidget {
_calcVec3B.set(_calcVec3A).addLocal(camera.getLeft());
_calcVec3C.set( //
arrow == _xArrow ? Vector3.UNIT_X : //
- arrow == _yArrow ? Vector3.UNIT_Y : //
- Vector3.UNIT_Z);
+ arrow == _yArrow ? Vector3.UNIT_Y : //
+ Vector3.UNIT_Z);
// rotate to arrow plane
_handle.getRotation().applyPost(_calcVec3C, _calcVec3C);