|
@@ -52,8 +52,11 @@ import org.openide.nodes.Sheet;
|
|
import org.openide.util.actions.SystemAction;
|
|
import org.openide.util.actions.SystemAction;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * This Class actually represents the MotionPaths Waypoints in the SceneComposer.<br>
|
|
|
|
- * It is added and managed by {@link JmeVector3fChildren } but it could also be used for any other Waypointish Thing
|
|
|
|
|
|
+ * This Class actually represents the MotionPaths Waypoints in the
|
|
|
|
+ * SceneComposer.<br>
|
|
|
|
+ * It is added and managed by {@link JmeVector3fChildren } but it could also be
|
|
|
|
+ * used for any other Waypointish Thing
|
|
|
|
+ *
|
|
* @author MeFisto94
|
|
* @author MeFisto94
|
|
*/
|
|
*/
|
|
@SuppressWarnings({"unchecked", "rawtypes", "OverridableMethodCallInConstructor", "LeakingThisInConstructor"})
|
|
@SuppressWarnings({"unchecked", "rawtypes", "OverridableMethodCallInConstructor", "LeakingThisInConstructor"})
|
|
@@ -64,63 +67,70 @@ public class JmeVector3f extends JmeSpatial {
|
|
private JmeMotionPath jmeMotionPath;
|
|
private JmeMotionPath jmeMotionPath;
|
|
private Vector3f v;
|
|
private Vector3f v;
|
|
private float extents;
|
|
private float extents;
|
|
-
|
|
|
|
|
|
+
|
|
public JmeVector3f() {
|
|
public JmeVector3f() {
|
|
super();
|
|
super();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public JmeVector3f(JmeVector3fChildren parent, JmeMotionPath jmeMotionPath, Vector3f vec) {
|
|
public JmeVector3f(JmeVector3fChildren parent, JmeMotionPath jmeMotionPath, Vector3f vec) {
|
|
super();
|
|
super();
|
|
-
|
|
|
|
|
|
+
|
|
v = vec;
|
|
v = vec;
|
|
this.parent = parent;
|
|
this.parent = parent;
|
|
this.jmeMotionPath = jmeMotionPath;
|
|
this.jmeMotionPath = jmeMotionPath;
|
|
spatial = generateBox();
|
|
spatial = generateBox();
|
|
-
|
|
|
|
|
|
+
|
|
getLookupContents().add(spatial);
|
|
getLookupContents().add(spatial);
|
|
getLookupContents().add(vec);
|
|
getLookupContents().add(vec);
|
|
getLookupContents().add(this);
|
|
getLookupContents().add(this);
|
|
-
|
|
|
|
|
|
+
|
|
super.setDisplayName("Waypoint");
|
|
super.setDisplayName("Waypoint");
|
|
super.setName(spatial.getName());
|
|
super.setName(spatial.getName());
|
|
-
|
|
|
|
|
|
+
|
|
attachBox(spatial, jmeMotionPath);
|
|
attachBox(spatial, jmeMotionPath);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* GenerateBox will simply generate our {@link DebugBoxGeometry }
|
|
* GenerateBox will simply generate our {@link DebugBoxGeometry }
|
|
- * @return
|
|
|
|
|
|
+ *
|
|
|
|
+ * @return the generated DebugBoxGeometry
|
|
*/
|
|
*/
|
|
private Geometry generateBox() {
|
|
private Geometry generateBox() {
|
|
extents = jmeMotionPath.getDebugBoxExtents();
|
|
extents = jmeMotionPath.getDebugBoxExtents();
|
|
DebugBoxGeometry geom = new DebugBoxGeometry("Waypoint", extents, this);
|
|
DebugBoxGeometry geom = new DebugBoxGeometry("Waypoint", extents, this);
|
|
-
|
|
|
|
|
|
+
|
|
Material mat = new Material(SceneApplication.getApplication().getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
|
Material mat = new Material(SceneApplication.getApplication().getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
|
mat.setColor("Color", ColorRGBA.Cyan);
|
|
mat.setColor("Color", ColorRGBA.Cyan);
|
|
geom.setMaterial(mat);
|
|
geom.setMaterial(mat);
|
|
geom.setInternalLocalTranslation(v);
|
|
geom.setInternalLocalTranslation(v);
|
|
-
|
|
|
|
|
|
+
|
|
return geom;
|
|
return geom;
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * AttachBox is the internal method simply used to attach the DebugBox to the Scene Graph.
|
|
|
|
|
|
+ * AttachBox is the internal method simply used to attach the DebugBox to
|
|
|
|
+ * the Scene Graph.
|
|
|
|
+ *
|
|
* @param s The Spatial to attach
|
|
* @param s The Spatial to attach
|
|
* @param jmeMotionPath The Parental Node to refresh.
|
|
* @param jmeMotionPath The Parental Node to refresh.
|
|
*/
|
|
*/
|
|
protected void attachBox(final Spatial s, final JmeMotionPath jmeMotionPath) {
|
|
protected void attachBox(final Spatial s, final JmeMotionPath jmeMotionPath) {
|
|
SceneApplication.getApplication().enqueue(new Callable<Void>() {
|
|
SceneApplication.getApplication().enqueue(new Callable<Void>() {
|
|
- @Override
|
|
|
|
- public Void call() throws Exception {
|
|
|
|
- SceneApplication.getApplication().getRootNode().attachChild(s);
|
|
|
|
- jmeMotionPath.refresh(true);
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public Void call() throws Exception {
|
|
|
|
+ SceneApplication.getApplication().getRootNode().attachChild(s);
|
|
|
|
+ jmeMotionPath.refresh(true);
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * This detaches the DebugBox from the SceneGraph but also waits for this to happen.
|
|
|
|
- * This is because we want to reattach a new box and it's just better this way :P
|
|
|
|
- * @param s
|
|
|
|
|
|
+ * This detaches the DebugBox from the SceneGraph but also waits for this to
|
|
|
|
+ * happen.<br>This is because we want to reattach a new box and it's just
|
|
|
|
+ * better this way :P
|
|
|
|
+ *
|
|
|
|
+ * @param s The Spatial to detach
|
|
*/
|
|
*/
|
|
protected void detachBox(final Spatial s) {
|
|
protected void detachBox(final Spatial s) {
|
|
SceneApplication.getApplication().enqueue(new Callable<Void>() {
|
|
SceneApplication.getApplication().enqueue(new Callable<Void>() {
|
|
@@ -131,10 +141,11 @@ public class JmeVector3f extends JmeSpatial {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * This will trigger a rebuild of the whole Box.
|
|
|
|
- * It is used internally if the box dimensions have changed ({@link JmeMotionPath#setDebugBoxExtents(float) })
|
|
|
|
- * Moving the Boxes around does NOT need a rebuild.
|
|
|
|
|
|
+ * This will trigger a rebuild of the whole Box.<br>It is used internally if
|
|
|
|
+ * the box dimensions have changed ({@link JmeMotionPath#setDebugBoxExtents(float)
|
|
|
|
+ * }).<br>Moving the Boxes around does NOT need a rebuild.
|
|
*/
|
|
*/
|
|
public void updateBox() {
|
|
public void updateBox() {
|
|
getLookupContents().remove(spatial);
|
|
getLookupContents().remove(spatial);
|
|
@@ -143,21 +154,23 @@ public class JmeVector3f extends JmeSpatial {
|
|
getLookupContents().add(spatial);
|
|
getLookupContents().add(spatial);
|
|
attachBox(spatial, jmeMotionPath);
|
|
attachBox(spatial, jmeMotionPath);
|
|
}
|
|
}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * This is called when the Vector v has been moved (without the setVector3f which is our callback).
|
|
|
|
- * This means it was moved by the Properties Dialog (see setXYZ())
|
|
|
|
|
|
+ * This is called when the Vector v has been moved (without the setVector3f
|
|
|
|
+ * which is our callback).<br>This means it was moved by the Properties
|
|
|
|
+ * Dialog (see setXYZ())
|
|
*/
|
|
*/
|
|
public void moveBox() {
|
|
public void moveBox() {
|
|
SceneApplication.getApplication().enqueue(new Runnable() {
|
|
SceneApplication.getApplication().enqueue(new Runnable() {
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
spatial.setLocalTranslation(v); // It's a bit redundant since it will call #setVector3f() but there's no other way.
|
|
spatial.setLocalTranslation(v); // It's a bit redundant since it will call #setVector3f() but there's no other way.
|
|
- // Plus it will invoke updateSpline() for us.
|
|
|
|
|
|
+ // Plus it will invoke updateSpline() for us.
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
-
|
|
|
|
- // <editor-fold defaultstate="collapsed" desc="Just some boring Overrides ">
|
|
|
|
|
|
+
|
|
|
|
+ // <editor-fold desc="Just some Overrides for Node">
|
|
@Override
|
|
@Override
|
|
public Image getIcon(int type) {
|
|
public Image getIcon(int type) {
|
|
return smallImage;
|
|
return smallImage;
|
|
@@ -167,7 +180,7 @@ public class JmeVector3f extends JmeSpatial {
|
|
public Image getOpenedIcon(int type) {
|
|
public Image getOpenedIcon(int type) {
|
|
return smallImage;
|
|
return smallImage;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public Action[] getActions(boolean context) {
|
|
public Action[] getActions(boolean context) {
|
|
return new Action[]{
|
|
return new Action[]{
|
|
@@ -176,22 +189,22 @@ public class JmeVector3f extends JmeSpatial {
|
|
SystemAction.get(MoveDownAction.class)
|
|
SystemAction.get(MoveDownAction.class)
|
|
};
|
|
};
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public boolean canRename() {
|
|
public boolean canRename() {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public boolean canDestroy() {
|
|
public boolean canDestroy() {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public boolean canCut() {
|
|
public boolean canCut() {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public boolean canCopy() {
|
|
public boolean canCopy() {
|
|
return false;
|
|
return false;
|
|
@@ -200,26 +213,25 @@ public class JmeVector3f extends JmeSpatial {
|
|
@Override
|
|
@Override
|
|
public void destroy() throws IOException {
|
|
public void destroy() throws IOException {
|
|
detachBox(spatial);
|
|
detachBox(spatial);
|
|
-
|
|
|
|
|
|
+
|
|
/* These are mandatory:
|
|
/* These are mandatory:
|
|
* Without them the Node looks like it's undeletable
|
|
* Without them the Node looks like it's undeletable
|
|
* (since it stays in the Motion Path and gets readded everytime)
|
|
* (since it stays in the Motion Path and gets readded everytime)
|
|
*/
|
|
*/
|
|
- parent.remove(new Node[] { this });
|
|
|
|
|
|
+ parent.remove(new Node[]{this});
|
|
parent.refreshChildren(true);
|
|
parent.refreshChildren(true);
|
|
jmeMotionPath.updateSpline(true);
|
|
jmeMotionPath.updateSpline(true);
|
|
super.destroy();
|
|
super.destroy();
|
|
}
|
|
}
|
|
|
|
+ // </editor-fold>
|
|
|
|
|
|
-// </editor-fold>
|
|
|
|
-
|
|
|
|
/* For Properties */
|
|
/* For Properties */
|
|
public int getChildIndex() {
|
|
public int getChildIndex() {
|
|
int idx = parent.indexOf(this);
|
|
int idx = parent.indexOf(this);
|
|
setDisplayName("Waypoint " + idx);
|
|
setDisplayName("Waypoint " + idx);
|
|
return idx;
|
|
return idx;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
protected Sheet createSheet() {
|
|
protected Sheet createSheet() {
|
|
Sheet sheet = Sheet.createDefault();
|
|
Sheet sheet = Sheet.createDefault();
|
|
@@ -227,104 +239,109 @@ public class JmeVector3f extends JmeSpatial {
|
|
set.setDisplayName("Vector3f");
|
|
set.setDisplayName("Vector3f");
|
|
set.setName(Vector3f.class.getName());
|
|
set.setName(Vector3f.class.getName());
|
|
set.setShortDescription("These are the Properties of the Motion Paths's Waypoint (Vector3f). Feel free to either edit the floats seperately or use the [x, y, z] way. Make sure that you defocus and focus this Node again in order to have the Properties be reloaded");
|
|
set.setShortDescription("These are the Properties of the Motion Paths's Waypoint (Vector3f). Feel free to either edit the floats seperately or use the [x, y, z] way. Make sure that you defocus and focus this Node again in order to have the Properties be reloaded");
|
|
-
|
|
|
|
|
|
+
|
|
if (v == null) {
|
|
if (v == null) {
|
|
return sheet;
|
|
return sheet;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
Property p = makeEmbedProperty(this, getExplorerNodeClass(), float.class, "getX", "setX", "X");
|
|
Property p = makeEmbedProperty(this, getExplorerNodeClass(), float.class, "getX", "setX", "X");
|
|
p.setShortDescription("The Vector3f's X-Value");
|
|
p.setShortDescription("The Vector3f's X-Value");
|
|
set.put(p);
|
|
set.put(p);
|
|
-
|
|
|
|
|
|
+
|
|
p = makeEmbedProperty(this, getExplorerNodeClass(), float.class, "getY", "setY", "Y");
|
|
p = makeEmbedProperty(this, getExplorerNodeClass(), float.class, "getY", "setY", "Y");
|
|
p.setShortDescription("The Vector3f's Y-Value");
|
|
p.setShortDescription("The Vector3f's Y-Value");
|
|
set.put(p);
|
|
set.put(p);
|
|
-
|
|
|
|
|
|
+
|
|
p = makeEmbedProperty(this, getExplorerNodeClass(), float.class, "getZ", "setZ", "Z");
|
|
p = makeEmbedProperty(this, getExplorerNodeClass(), float.class, "getZ", "setZ", "Z");
|
|
p.setShortDescription("The Vector3f's Z-Value");
|
|
p.setShortDescription("The Vector3f's Z-Value");
|
|
set.put(p);
|
|
set.put(p);
|
|
-
|
|
|
|
|
|
+
|
|
p = makeEmbedProperty(this, getExplorerNodeClass(), int.class, "getChildIndex", null, "Child Index");
|
|
p = makeEmbedProperty(this, getExplorerNodeClass(), int.class, "getChildIndex", null, "Child Index");
|
|
p.setShortDescription("The Index of this Node inside of the MotionPath's Children");
|
|
p.setShortDescription("The Index of this Node inside of the MotionPath's Children");
|
|
set.put(p);
|
|
set.put(p);
|
|
-
|
|
|
|
|
|
+
|
|
createFields(Vector3f.class, set, v);
|
|
createFields(Vector3f.class, set, v);
|
|
-
|
|
|
|
|
|
+
|
|
sheet.put(set);
|
|
sheet.put(set);
|
|
return sheet;
|
|
return sheet;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* This is a conveniance method to access the internal Vector3f.
|
|
* This is a conveniance method to access the internal Vector3f.
|
|
- * Currently it's even unused.
|
|
|
|
|
|
+ *
|
|
* @return The Vector3f representated by this Node
|
|
* @return The Vector3f representated by this Node
|
|
*/
|
|
*/
|
|
public Vector3f getVector3f() {
|
|
public Vector3f getVector3f() {
|
|
return v;
|
|
return v;
|
|
}
|
|
}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * This is the callback which will be called by the Geometry.
|
|
|
|
- * It is used to update the DataStructure with the Debug Box Position
|
|
|
|
- * @param to
|
|
|
|
|
|
+ * This is the callback which will be called by the Geometry. It is used to
|
|
|
|
+ * update the DataStructure with the Debug Box Position
|
|
|
|
+ *
|
|
|
|
+ * @param to
|
|
*/
|
|
*/
|
|
public void setVector3f(Vector3f to) {
|
|
public void setVector3f(Vector3f to) {
|
|
v.set(to);
|
|
v.set(to);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/* The following 6 methods are just so we know when the user typed in some properties.
|
|
/* The following 6 methods are just so we know when the user typed in some properties.
|
|
* Note: A PropertyChangeListener would also be appropriate and even less code.
|
|
* Note: A PropertyChangeListener would also be appropriate and even less code.
|
|
*/
|
|
*/
|
|
- //<editor-fold defaultstate="collapsed" desc="The Setters for the Properties Panel">
|
|
|
|
|
|
+ //<editor-fold desc="The Setters for the Properties Panel">
|
|
public void setX(float x) {
|
|
public void setX(float x) {
|
|
//v.x = x;
|
|
//v.x = x;
|
|
v.setX(x);
|
|
v.setX(x);
|
|
moveBox();
|
|
moveBox();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void setY(float y) {
|
|
public void setY(float y) {
|
|
v.y = y;
|
|
v.y = y;
|
|
moveBox();
|
|
moveBox();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void setZ(float z) {
|
|
public void setZ(float z) {
|
|
v.z = z;
|
|
v.z = z;
|
|
moveBox();
|
|
moveBox();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public float getX() {
|
|
public float getX() {
|
|
return v.x;
|
|
return v.x;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public float getY() {
|
|
public float getY() {
|
|
return v.y;
|
|
return v.y;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public float getZ() {
|
|
public float getZ() {
|
|
return v.z;
|
|
return v.z;
|
|
}
|
|
}
|
|
//</editor-fold>
|
|
//</editor-fold>
|
|
-
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public Class getExplorerObjectClass() {
|
|
public Class getExplorerObjectClass() {
|
|
return Vector3f.class;
|
|
return Vector3f.class;
|
|
}
|
|
}
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public Class getExplorerNodeClass() {
|
|
public Class getExplorerNodeClass() {
|
|
return JmeVector3f.class;
|
|
return JmeVector3f.class;
|
|
}
|
|
}
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public org.openide.nodes.Node[] createNodes(Object key, DataObject key2, boolean cookie) {
|
|
public org.openide.nodes.Node[] createNodes(Object key, DataObject key2, boolean cookie) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
private class DebugBoxGeometry extends Geometry {
|
|
private class DebugBoxGeometry extends Geometry {
|
|
|
|
+
|
|
JmeVector3f self;
|
|
JmeVector3f self;
|
|
-
|
|
|
|
|
|
+
|
|
public DebugBoxGeometry(String s, float extents, JmeVector3f jme) {
|
|
public DebugBoxGeometry(String s, float extents, JmeVector3f jme) {
|
|
super(s, new Box(extents, extents, extents));
|
|
super(s, new Box(extents, extents, extents));
|
|
self = jme;
|
|
self = jme;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void setLocalTranslation(float x, float y, float z) {
|
|
public void setLocalTranslation(float x, float y, float z) {
|
|
this.setLocalTranslation(new Vector3f(x, y, z));
|
|
this.setLocalTranslation(new Vector3f(x, y, z));
|
|
@@ -338,9 +355,10 @@ public class JmeVector3f extends JmeSpatial {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Since the usual translation updates the spline and hence triggers setModified,
|
|
|
|
- * we need an internal method (e.g. for the Constructor)
|
|
|
|
- * @param localTranslation the translation to set.
|
|
|
|
|
|
+ * Since the usual translation updates the spline and hence triggers
|
|
|
|
+ * setModified, we need an internal method (e.g. for the Constructor)
|
|
|
|
+ *
|
|
|
|
+ * @param localTranslation the translation to set.
|
|
*/
|
|
*/
|
|
public void setInternalLocalTranslation(Vector3f localTranslation) {
|
|
public void setInternalLocalTranslation(Vector3f localTranslation) {
|
|
super.setLocalTranslation(localTranslation);
|
|
super.setLocalTranslation(localTranslation);
|