From 33060d6cafbb84f19efa99e2ad3cea73cc1fd8ed Mon Sep 17 00:00:00 2001 From: Joshua Slack Date: Thu, 27 Apr 2017 13:50:25 -0500 Subject: Made GeometryTool effectively into a static class --- .../extension/model/obj/ObjGeometryStore.java | 15 ++++-------- .../ardor3d/extension/model/obj/ObjImporter.java | 28 ++++++---------------- 2 files changed, 11 insertions(+), 32 deletions(-) (limited to 'ardor3d-extras/src/main/java/com') diff --git a/ardor3d-extras/src/main/java/com/ardor3d/extension/model/obj/ObjGeometryStore.java b/ardor3d-extras/src/main/java/com/ardor3d/extension/model/obj/ObjGeometryStore.java index cac72f6..bd96824 100644 --- a/ardor3d-extras/src/main/java/com/ardor3d/extension/model/obj/ObjGeometryStore.java +++ b/ardor3d-extras/src/main/java/com/ardor3d/extension/model/obj/ObjGeometryStore.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 . */ @@ -58,15 +58,8 @@ public class ObjGeometryStore { private final Map materialLibrary = Maps.newHashMap(); private final Map _materialMap = Maps.newHashMap(); - private final GeometryTool _geometryTool; - public ObjGeometryStore() { - this(new GeometryTool()); - } - - public ObjGeometryStore(final GeometryTool geometryTool) { super(); - _geometryTool = geometryTool; } public Map getMaterialLibrary() { @@ -199,7 +192,7 @@ public class ObjGeometryStore { } points.getMeshData().setIndices(indexBuffer); - _geometryTool.minimizeVerts(points, EnumSet.noneOf(MatchCondition.class)); + GeometryTool.minimizeVerts(points, EnumSet.noneOf(MatchCondition.class)); applyCurrentMaterial(points); mapToGroups(points); @@ -247,7 +240,7 @@ public class ObjGeometryStore { } line.getMeshData().setIndexLengths(lengths); } - _geometryTool.minimizeVerts(line, EnumSet.of(MatchCondition.UVs)); + GeometryTool.minimizeVerts(line, EnumSet.of(MatchCondition.UVs)); applyCurrentMaterial(line); mapToGroups(line); @@ -326,7 +319,7 @@ public class ObjGeometryStore { groupData.setVertGroups(vertGroups); groupData.setGroupConditions(VertGroupData.DEFAULT_GROUP, EnumSet.of(MatchCondition.Normal, MatchCondition.UVs)); - _geometryTool.minimizeVerts(mesh, groupData); + GeometryTool.minimizeVerts(mesh, groupData); applyCurrentMaterial(mesh); mapToGroups(mesh); diff --git a/ardor3d-extras/src/main/java/com/ardor3d/extension/model/obj/ObjImporter.java b/ardor3d-extras/src/main/java/com/ardor3d/extension/model/obj/ObjImporter.java index f7b7c28..4328e19 100644 --- a/ardor3d-extras/src/main/java/com/ardor3d/extension/model/obj/ObjImporter.java +++ b/ardor3d-extras/src/main/java/com/ardor3d/extension/model/obj/ObjImporter.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 . */ @@ -21,7 +21,6 @@ import com.ardor3d.image.TextureStoreFormat; import com.ardor3d.math.MathUtils; import com.ardor3d.math.Vector3; import com.ardor3d.util.TextureManager; -import com.ardor3d.util.geom.GeometryTool; import com.ardor3d.util.resource.ResourceLocator; import com.ardor3d.util.resource.ResourceLocatorTool; import com.ardor3d.util.resource.ResourceSource; @@ -103,7 +102,7 @@ public class ObjImporter { /** * Reads a Wavefront OBJ file from the given resource - * + * * @param resource * the name of the resource to find. * @return an ObjGeometryStore data object containing the scene and other useful elements. @@ -125,27 +124,14 @@ public class ObjImporter { /** * Reads a Wavefront OBJ file from the given resource - * + * * @param resource * the name of the resource to find. * @return an ObjGeometryStore data object containing the scene and other useful elements. */ public ObjGeometryStore load(final ResourceSource resource) { - return load(resource, new GeometryTool()); - } - - /** - * Reads a Wavefront OBJ file from the given resource - * - * @param resource - * the name of the resource to find. - * @param geometryTool - * the geometry tool used to minimize the vertex count. - * @return an ObjGeometryStore data object containing the scene and other useful elements. - */ - public ObjGeometryStore load(final ResourceSource resource, final GeometryTool geometryTool) { try { - final ObjGeometryStore store = new ObjGeometryStore(geometryTool); + final ObjGeometryStore store = new ObjGeometryStore(); long currentSmoothGroup = -1; final BufferedReader reader = new BufferedReader(new InputStreamReader(resource.openStream())); @@ -218,7 +204,7 @@ public class ObjImporter { else if ("cstype".equals(keyword)) { // TODO: Add support for cstype ObjImporter.logger - .warning("ObjModelImporter: cstype not supported. (line " + lineNo + ") " + line); + .warning("ObjModelImporter: cstype not supported. (line " + lineNo + ") " + line); } // if degree @@ -385,7 +371,7 @@ public class ObjImporter { /** * Load a .mtl resource - * + * * @param fileName * the name of the mtl resource to load. * @param modelSource @@ -411,7 +397,7 @@ public class ObjImporter { /** * Load a .mtl resource - * + * * @param resource * the mtl file to load, as a ResourceSource * @param store -- cgit v1.2.3 From 240660efaeb9117a50f2e9cca0a7153e500490b3 Mon Sep 17 00:00:00 2001 From: Joshua Slack Date: Tue, 30 May 2017 15:10:52 -0500 Subject: fixed missing calls to received/lost control on interact widgets. added tracking of userdata to SpatialState to allow setting/applying other elements via interact widgets --- .../com/ardor3d/extension/interact/InteractManager.java | 10 ++++++++-- .../com/ardor3d/extension/interact/data/SpatialState.java | 13 ++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'ardor3d-extras/src/main/java/com') 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 e49ad25..e55c63a 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 @@ -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 . */ @@ -141,7 +141,7 @@ public class InteractManager { /** * Convenience method for setting up the manager's connection to the Ardor3D input system, along with a forwarding * address for input events that the manager does not care about. - * + * * @param canvas * the canvas to register with * @param physicalLayer @@ -205,7 +205,13 @@ public class InteractManager { } public void setActiveWidget(final AbstractInteractWidget widget) { + if (_activeWidget != null) { + _activeWidget.lostControl(this); + } _activeWidget = widget; + if (_activeWidget != null) { + _activeWidget.receivedControl(this); + } } public AbstractInteractWidget getActiveWidget() { diff --git a/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/data/SpatialState.java b/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/data/SpatialState.java index b68bf30..b9aaae4 100644 --- a/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/data/SpatialState.java +++ b/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/data/SpatialState.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 . */ @@ -16,20 +16,31 @@ import com.ardor3d.scenegraph.Spatial; public class SpatialState { protected Transform _transform = new Transform(); + protected Object _userData = null; public SpatialState() {} /** copy constructor */ public SpatialState(final SpatialState toCopy) { _transform.set(toCopy._transform); + _userData = toCopy._userData; } public Transform getTransform() { return _transform; } + public Object getUserData() { + return _userData; + } + + public void setUserData(final Object userData) { + _userData = userData; + } + public void applyState(final Spatial target) { target.setTransform(_transform); + target.setUserData(_userData); } } -- cgit v1.2.3