|
@@ -4,7 +4,6 @@
|
|
|
*/
|
|
|
package com.jme3.gde.scenecomposer;
|
|
|
|
|
|
-
|
|
|
import com.jme3.asset.AssetManager;
|
|
|
import com.jme3.bounding.BoundingBox;
|
|
|
import com.jme3.bounding.BoundingVolume;
|
|
@@ -49,27 +48,31 @@ import org.openide.util.Lookup;
|
|
|
* @author Brent Owens
|
|
|
*/
|
|
|
public abstract class SceneEditTool {
|
|
|
-
|
|
|
+
|
|
|
+ protected static Vector3f ARROW_X = new Vector3f(1, 0, 0);
|
|
|
+ protected static Vector3f ARROW_Y = new Vector3f(0, 1, 0);
|
|
|
+ protected static Vector3f ARROW_Z = new Vector3f(0, 0, 1);
|
|
|
+ protected static Vector3f QUAD_XY = new Vector3f(1, 1, 0);
|
|
|
+ protected static Vector3f QUAD_XZ = new Vector3f(1, 0, 1);
|
|
|
+ protected static Vector3f QUAD_YZ = new Vector3f(0, 1, 1);
|
|
|
protected SceneComposerToolController toolController;
|
|
|
protected AssetManager manager;
|
|
|
protected Camera camera;
|
|
|
private boolean overrideCameraControl = false; // if true, you cannot pan/zoom unless you hold SHIFT
|
|
|
-
|
|
|
// the key to load the tool hint text from the resource bundle
|
|
|
protected String toolHintTextKey = "SceneComposerTopComponent.toolHint.default"; // not used yet
|
|
|
-
|
|
|
- protected Spatial selectedSpatial;
|
|
|
- protected Spatial selectionShape;
|
|
|
protected Node toolNode;
|
|
|
protected Node onTopToolNode;
|
|
|
-
|
|
|
protected Node axisMarker;
|
|
|
protected Material redMat, blueMat, greenMat, yellowMat, cyanMat, magentaMat, orangeMat;
|
|
|
-
|
|
|
- protected enum AxisMarkerPickType {axisOnly, planeOnly, axisAndPlane};
|
|
|
+ protected Geometry quadXY, quadXZ, quadYZ;
|
|
|
+
|
|
|
+ protected enum AxisMarkerPickType {
|
|
|
+
|
|
|
+ axisOnly, planeOnly, axisAndPlane
|
|
|
+ };
|
|
|
protected AxisMarkerPickType axisPickType;
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* The tool was selected, start showing the marker.
|
|
|
* @param manager
|
|
@@ -78,61 +81,35 @@ public abstract class SceneEditTool {
|
|
|
public void activate(AssetManager manager, Node toolNode, Node onTopToolNode, Spatial selectedSpatial, SceneComposerToolController toolController) {
|
|
|
this.manager = manager;
|
|
|
this.toolController = toolController;
|
|
|
- this.selectedSpatial = selectedSpatial;
|
|
|
+ //this.selectedSpatial = selectedSpatial;
|
|
|
addMarker(toolNode, onTopToolNode);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected void addMarker(Node toolNode, Node onTopToolNode) {
|
|
|
this.toolNode = toolNode;
|
|
|
this.onTopToolNode = onTopToolNode;
|
|
|
-
|
|
|
+
|
|
|
if (axisMarker == null) {
|
|
|
axisMarker = createAxisMarker();
|
|
|
}
|
|
|
axisMarker.removeFromParent();
|
|
|
this.onTopToolNode.attachChild(axisMarker);
|
|
|
setDefaultAxisMarkerColors();
|
|
|
-
|
|
|
- // create and add the selection shape
|
|
|
- if (selectionShape != null)
|
|
|
- selectionShape.removeFromParent();
|
|
|
-
|
|
|
- selectionShape = createSelectionShape(toolNode, selectedSpatial);
|
|
|
-
|
|
|
- if (selectionShape != null) {
|
|
|
- setDefaultSelectionShapeColors();
|
|
|
- this.toolNode.attachChild(selectionShape);
|
|
|
- axisMarker.setLocalTranslation(selectedSpatial.getWorldTranslation());
|
|
|
- selectionShape.setLocalTranslation(selectedSpatial.getWorldTranslation());
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- protected void replaceSelectionShape(Spatial spatial) {
|
|
|
- if (spatial != null) {
|
|
|
- if (selectionShape != null)
|
|
|
- selectionShape.removeFromParent();
|
|
|
- selectedSpatial = spatial;
|
|
|
- toolController.setSelected(spatial);
|
|
|
- selectionShape = createSelectionShape(toolNode, selectedSpatial);
|
|
|
- setDefaultSelectionShapeColors();
|
|
|
- toolNode.attachChild(selectionShape);
|
|
|
- }
|
|
|
- else {
|
|
|
- if (selectionShape != null)
|
|
|
- selectionShape.removeFromParent();
|
|
|
- selectionShape = null;
|
|
|
+
|
|
|
+
|
|
|
+ if (toolController.getSelectionShape() != null) {
|
|
|
+ axisMarker.setLocalTranslation(toolController.getSelectedSpatial().getWorldTranslation());
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Remove the marker from it's parent (the tools node)
|
|
|
*/
|
|
|
public void hideMarker() {
|
|
|
- if (axisMarker != null)
|
|
|
+ if (axisMarker != null) {
|
|
|
axisMarker.removeFromParent();
|
|
|
- if (selectionShape != null)
|
|
|
- selectionShape.removeFromParent();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public boolean isOverrideCameraControl() {
|
|
@@ -142,46 +119,38 @@ public abstract class SceneEditTool {
|
|
|
public void setOverrideCameraControl(boolean overrideCameraControl) {
|
|
|
this.overrideCameraControl = overrideCameraControl;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Called when the selected spatial has been modified
|
|
|
* outside of the tool.
|
|
|
*/
|
|
|
- public void updateToolsTransformation(final Spatial spatial) {
|
|
|
-
|
|
|
- if (selectionShape == null)
|
|
|
- return;
|
|
|
-
|
|
|
- // has anything changed?
|
|
|
- if (!selectionShape.getLocalTranslation().equals(spatial.getWorldTranslation()) &&
|
|
|
- !selectionShape.getLocalRotation().equals(spatial.getWorldRotation()) &&
|
|
|
- !selectionShape.getLocalScale().equals(spatial.getWorldScale()))
|
|
|
- return;
|
|
|
-
|
|
|
- // something has updated, so update the tools
|
|
|
- selectionShape.setLocalTranslation(spatial.getWorldTranslation());
|
|
|
- selectionShape.setLocalRotation(spatial.getWorldRotation());
|
|
|
- selectionShape.setLocalScale(selectedSpatial.getWorldScale());
|
|
|
-
|
|
|
+ public void updateToolsTransformation() {
|
|
|
+
|
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
|
+
|
|
|
public Object call() throws Exception {
|
|
|
- axisMarker.setLocalTranslation(spatial.getWorldTranslation());
|
|
|
- axisMarker.setLocalRotation(selectedSpatial.getWorldRotation());
|
|
|
+ if (toolController.getSelectedSpatial() != null) {
|
|
|
+ axisMarker.setLocalTranslation(toolController.getSelectedSpatial().getWorldTranslation());
|
|
|
+ axisMarker.setLocalRotation(toolController.getSelectedSpatial().getWorldRotation());
|
|
|
+ } else {
|
|
|
+ axisMarker.setLocalTranslation(Vector3f.ZERO);
|
|
|
+ axisMarker.setLocalRotation(Quaternion.IDENTITY);
|
|
|
+ }
|
|
|
return null;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* The primary action for the tool gets activated
|
|
|
*/
|
|
|
public abstract void actionPrimary(Vector2f screenCoord, boolean pressed, JmeNode rootNode, DataObject dataObject);
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* The secondary action for the tool gets activated
|
|
|
*/
|
|
|
public abstract void actionSecondary(Vector2f screenCoord, boolean pressed, JmeNode rootNode, DataObject dataObject);
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Called when the mouse is moved but not dragged (ie no buttons are pressed)
|
|
|
*/
|
|
@@ -191,13 +160,13 @@ public abstract class SceneEditTool {
|
|
|
* Called when the mouse is moved while the primary button is down
|
|
|
*/
|
|
|
public abstract void draggedPrimary(Vector2f screenCoord, boolean pressed, JmeNode rootNode, DataObject currentDataObject);
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Called when the mouse is moved while the secondary button is down
|
|
|
*/
|
|
|
public abstract void draggedSecondary(Vector2f screenCoord, boolean pressed, JmeNode rootNode, DataObject currentDataObject);
|
|
|
|
|
|
- /**
|
|
|
+ /**
|
|
|
* Call when an action is performed that requires the scene to be saved
|
|
|
* and an undo can be performed
|
|
|
* @param undoer your implementation, probably with a begin and end state for undoing
|
|
@@ -206,8 +175,7 @@ public abstract class SceneEditTool {
|
|
|
Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, undoer);
|
|
|
toolController.setNeedsSave(true);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Given the mouse coordinates, pick the geometry that is closest to the camera.
|
|
|
* @param jmeRootNode to pick from
|
|
@@ -215,13 +183,14 @@ public abstract class SceneEditTool {
|
|
|
*/
|
|
|
protected Spatial pickWorldSpatial(Camera cam, Vector2f mouseLoc, JmeNode jmeRootNode) {
|
|
|
Node rootNode = jmeRootNode.getLookup().lookup(Node.class);
|
|
|
- CollisionResult cr = pick(cam, mouseLoc, rootNode);
|
|
|
- if (cr != null)
|
|
|
+ CollisionResult cr = pick(cam, mouseLoc, rootNode);
|
|
|
+ if (cr != null) {
|
|
|
return cr.getGeometry();
|
|
|
- else
|
|
|
+ } else {
|
|
|
return null;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Given the mouse coordinate, pick the world location where the mouse intersects
|
|
|
* a geometry.
|
|
@@ -232,16 +201,16 @@ public abstract class SceneEditTool {
|
|
|
Node rootNode = jmeRootNode.getLookup().lookup(Node.class);
|
|
|
return pickWorldLocation(cam, mouseLoc, rootNode);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
protected Vector3f pickWorldLocation(Camera cam, Vector2f mouseLoc, Node rootNode) {
|
|
|
CollisionResult cr = pick(cam, mouseLoc, rootNode);
|
|
|
- if (cr != null)
|
|
|
+ if (cr != null) {
|
|
|
return cr.getContactPoint();
|
|
|
- else
|
|
|
+ } else {
|
|
|
return null;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Pick a part of the axis marker. The result is a Vector3f that represents
|
|
|
* what part of the axis was selected.
|
|
@@ -251,48 +220,49 @@ public abstract class SceneEditTool {
|
|
|
* @return null if it did not intersect the marker
|
|
|
*/
|
|
|
protected Vector3f pickAxisMarker(Camera cam, Vector2f mouseLoc, AxisMarkerPickType pickType) {
|
|
|
- if (axisMarker == null)
|
|
|
+ if (axisMarker == null) {
|
|
|
return null;
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
CollisionResult cr = pick(cam, mouseLoc, axisMarker);
|
|
|
- if (cr == null || cr.getGeometry() == null)
|
|
|
+ if (cr == null || cr.getGeometry() == null) {
|
|
|
return null;
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
if (pickType == AxisMarkerPickType.planeOnly) {
|
|
|
- if ("quadXY".equals(cr.getGeometry().getName()) ) {
|
|
|
- return new Vector3f(1,1,0);
|
|
|
- } else if ("quadXZ".equals(cr.getGeometry().getName()) ) {
|
|
|
- return new Vector3f(1,0,1);
|
|
|
- } else if ("quadYZ".equals(cr.getGeometry().getName()) ) {
|
|
|
- return new Vector3f(0,1,1);
|
|
|
+ if ("quadXY".equals(cr.getGeometry().getName())) {
|
|
|
+ return QUAD_XY;
|
|
|
+ } else if ("quadXZ".equals(cr.getGeometry().getName())) {
|
|
|
+ return QUAD_XZ;
|
|
|
+ } else if ("quadYZ".equals(cr.getGeometry().getName())) {
|
|
|
+ return QUAD_YZ;
|
|
|
}
|
|
|
- }
|
|
|
- else if (pickType == AxisMarkerPickType.axisOnly) {
|
|
|
- if ("arrowX".equals(cr.getGeometry().getName()) ) {
|
|
|
- return new Vector3f(1,0,0);
|
|
|
- } else if ("arrowY".equals(cr.getGeometry().getName()) ) {
|
|
|
- return new Vector3f(0,1,0);
|
|
|
- } else if ("arrowZ".equals(cr.getGeometry().getName()) ) {
|
|
|
- return new Vector3f(0,1,0);
|
|
|
+ } else if (pickType == AxisMarkerPickType.axisOnly) {
|
|
|
+ if ("arrowX".equals(cr.getGeometry().getName())) {
|
|
|
+ return ARROW_X;
|
|
|
+ } else if ("arrowY".equals(cr.getGeometry().getName())) {
|
|
|
+ return ARROW_Y;
|
|
|
+ } else if ("arrowZ".equals(cr.getGeometry().getName())) {
|
|
|
+ return ARROW_Z;
|
|
|
}
|
|
|
} else if (pickType == AxisMarkerPickType.axisAndPlane) {
|
|
|
- if ("arrowX".equals(cr.getGeometry().getName()) ) {
|
|
|
- return new Vector3f(1,0,0);
|
|
|
- } else if ("arrowY".equals(cr.getGeometry().getName()) ) {
|
|
|
- return new Vector3f(0,1,0);
|
|
|
- } else if ("arrowZ".equals(cr.getGeometry().getName()) ) {
|
|
|
- return new Vector3f(0,1,0);
|
|
|
- } else if ("quadXY".equals(cr.getGeometry().getName()) ) {
|
|
|
- return new Vector3f(1,1,0);
|
|
|
- } else if ("quadXZ".equals(cr.getGeometry().getName()) ) {
|
|
|
- return new Vector3f(1,0,1);
|
|
|
- } else if ("quadYZ".equals(cr.getGeometry().getName()) ) {
|
|
|
- return new Vector3f(0,1,1);
|
|
|
+ if ("arrowX".equals(cr.getGeometry().getName())) {
|
|
|
+ return ARROW_X;
|
|
|
+ } else if ("arrowY".equals(cr.getGeometry().getName())) {
|
|
|
+ return ARROW_Y;
|
|
|
+ } else if ("arrowZ".equals(cr.getGeometry().getName())) {
|
|
|
+ return ARROW_Z;
|
|
|
+ } else if ("quadXY".equals(cr.getGeometry().getName())) {
|
|
|
+ return QUAD_XY;
|
|
|
+ } else if ("quadXZ".equals(cr.getGeometry().getName())) {
|
|
|
+ return QUAD_XZ;
|
|
|
+ } else if ("quadYZ".equals(cr.getGeometry().getName())) {
|
|
|
+ return QUAD_YZ;
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private CollisionResult pick(Camera cam, Vector2f mouseLoc, Node node) {
|
|
|
CollisionResults results = new CollisionResults();
|
|
|
Ray ray = new Ray();
|
|
@@ -305,7 +275,7 @@ public abstract class SceneEditTool {
|
|
|
CollisionResult result = results.getClosestCollision();
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Show what axis or plane the mouse is currently over and will affect.
|
|
|
* @param axisMarkerPickType
|
|
@@ -313,34 +283,36 @@ public abstract class SceneEditTool {
|
|
|
protected void highlightAxisMarker(Camera camera, Vector2f screenCoord, AxisMarkerPickType axisMarkerPickType) {
|
|
|
setDefaultAxisMarkerColors();
|
|
|
Vector3f picked = pickAxisMarker(camera, screenCoord, axisPickType);
|
|
|
- if (picked == null)
|
|
|
+ if (picked == null) {
|
|
|
return;
|
|
|
-
|
|
|
- if (picked.equals(new Vector3f(1,0,0)))
|
|
|
+ }
|
|
|
+
|
|
|
+ if (picked == ARROW_X) {
|
|
|
axisMarker.getChild("arrowX").setMaterial(orangeMat);
|
|
|
- else if (picked.equals(new Vector3f(0,1,0)))
|
|
|
+ } else if (picked == ARROW_Y) {
|
|
|
axisMarker.getChild("arrowY").setMaterial(orangeMat);
|
|
|
- else if (picked.equals(new Vector3f(0,0,1)))
|
|
|
+ } else if (picked == ARROW_Z) {
|
|
|
axisMarker.getChild("arrowZ").setMaterial(orangeMat);
|
|
|
- else if (picked.equals(new Vector3f(1,1,0)))
|
|
|
+ } else if (picked == QUAD_XY) {
|
|
|
axisMarker.getChild("quadXY").setMaterial(orangeMat);
|
|
|
- else if (picked.equals(new Vector3f(1,0,1)))
|
|
|
+ } else if (picked == QUAD_XZ) {
|
|
|
axisMarker.getChild("quadXZ").setMaterial(orangeMat);
|
|
|
- else if (picked.equals(new Vector3f(0,1,1)))
|
|
|
+ } else if (picked == QUAD_YZ) {
|
|
|
axisMarker.getChild("quadYZ").setMaterial(orangeMat);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Create the axis marker that is selectable
|
|
|
*/
|
|
|
protected Node createAxisMarker() {
|
|
|
float size = 2;
|
|
|
float arrowSize = size;
|
|
|
- float planeSize = size*0.7f;
|
|
|
-
|
|
|
- Quaternion YAW090 = new Quaternion().fromAngleAxis(-FastMath.PI/2, new Vector3f(0,1,0));
|
|
|
- Quaternion PITCH090 = new Quaternion().fromAngleAxis(FastMath.PI/2, new Vector3f(1,0,0));
|
|
|
-
|
|
|
+ float planeSize = size * 0.7f;
|
|
|
+
|
|
|
+ Quaternion YAW090 = new Quaternion().fromAngleAxis(-FastMath.PI / 2, new Vector3f(0, 1, 0));
|
|
|
+ Quaternion PITCH090 = new Quaternion().fromAngleAxis(FastMath.PI / 2, new Vector3f(1, 0, 0));
|
|
|
+
|
|
|
redMat = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
|
|
|
redMat.getAdditionalRenderState().setWireframe(true);
|
|
|
redMat.setColor("Color", ColorRGBA.Red);
|
|
@@ -371,130 +343,60 @@ public abstract class SceneEditTool {
|
|
|
magentaMat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
|
|
|
magentaMat.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off);
|
|
|
//magentaMat.getAdditionalRenderState().setDepthTest(false);
|
|
|
-
|
|
|
+
|
|
|
orangeMat = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
|
|
|
orangeMat.getAdditionalRenderState().setWireframe(false);
|
|
|
- orangeMat.setColor("Color", new ColorRGBA(251f/255f, 130f/255f, 0f, 0.4f));
|
|
|
+ orangeMat.setColor("Color", new ColorRGBA(251f / 255f, 130f / 255f, 0f, 0.4f));
|
|
|
orangeMat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
|
|
|
orangeMat.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off);
|
|
|
-
|
|
|
+
|
|
|
Node axis = new Node();
|
|
|
-
|
|
|
+
|
|
|
// create arrows
|
|
|
- Geometry arrowX = new Geometry("arrowX", new Arrow(new Vector3f(arrowSize,0,0)));
|
|
|
- Geometry arrowY = new Geometry("arrowY", new Arrow(new Vector3f(0,arrowSize,0)));
|
|
|
- Geometry arrowZ = new Geometry("arrowZ", new Arrow(new Vector3f(0,0,arrowSize)));
|
|
|
+ Geometry arrowX = new Geometry("arrowX", new Arrow(new Vector3f(arrowSize, 0, 0)));
|
|
|
+ Geometry arrowY = new Geometry("arrowY", new Arrow(new Vector3f(0, arrowSize, 0)));
|
|
|
+ Geometry arrowZ = new Geometry("arrowZ", new Arrow(new Vector3f(0, 0, arrowSize)));
|
|
|
axis.attachChild(arrowX);
|
|
|
axis.attachChild(arrowY);
|
|
|
axis.attachChild(arrowZ);
|
|
|
-
|
|
|
+
|
|
|
// create planes
|
|
|
- Geometry quadXY = new Geometry("quadXY", new Quad(planeSize, planeSize) );
|
|
|
- Geometry quadXZ = new Geometry("quadXZ", new Quad(planeSize, planeSize) );
|
|
|
+ quadXY = new Geometry("quadXY", new Quad(planeSize, planeSize));
|
|
|
+ quadXZ = new Geometry("quadXZ", new Quad(planeSize, planeSize));
|
|
|
quadXZ.setLocalRotation(PITCH090);
|
|
|
- Geometry quadYZ = new Geometry("quadYZ", new Quad(planeSize, planeSize) );
|
|
|
+ quadYZ = new Geometry("quadYZ", new Quad(planeSize, planeSize));
|
|
|
quadYZ.setLocalRotation(YAW090);
|
|
|
- axis.attachChild(quadXY);
|
|
|
- axis.attachChild(quadXZ);
|
|
|
- axis.attachChild(quadYZ);
|
|
|
-
|
|
|
+// axis.attachChild(quadXY);
|
|
|
+// axis.attachChild(quadXZ);
|
|
|
+// axis.attachChild(quadYZ);
|
|
|
+
|
|
|
axis.setModelBound(new BoundingBox());
|
|
|
return axis;
|
|
|
}
|
|
|
-
|
|
|
- protected void setDefaultAxisMarkerColors() {
|
|
|
- axisMarker.getChild("arrowX").setMaterial(redMat);
|
|
|
- axisMarker.getChild("arrowY").setMaterial(blueMat);
|
|
|
- axisMarker.getChild("arrowZ").setMaterial(greenMat);
|
|
|
- axisMarker.getChild("quadXY").setMaterial(yellowMat);
|
|
|
- axisMarker.getChild("quadXZ").setMaterial(magentaMat);
|
|
|
- axisMarker.getChild("quadYZ").setMaterial(cyanMat);
|
|
|
- }
|
|
|
-
|
|
|
- protected void setDefaultSelectionShapeColors() {
|
|
|
- if (selectionShape != null) {
|
|
|
- Material mat = new Material(SceneApplication.getApplication().getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
|
|
- mat.getAdditionalRenderState().setWireframe(true);
|
|
|
- mat.setColor("Color", new ColorRGBA(0.8f,0.8f,0.8f,0.3f));
|
|
|
- mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
|
|
|
- selectionShape.setMaterial(mat);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- protected Spatial createSelectionShape(Node toolNode, Spatial spat) {
|
|
|
- if (spat == null)
|
|
|
- return null;
|
|
|
- if (selectionShape != null) {
|
|
|
- selectionShape.removeFromParent();
|
|
|
- selectionShape = null;
|
|
|
- }
|
|
|
- if (spat instanceof Geometry) {
|
|
|
- return getGeometrySelection(toolNode, (Geometry) spat);
|
|
|
- } else if (spat.getControl(PhysicsControl.class) != null) {
|
|
|
- return getPhysicsSelection(toolNode, spat);
|
|
|
- } else {
|
|
|
- return getBoxSelection(toolNode, spat);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- protected Geometry getGeometrySelection(Node toolNode, Geometry geom) {
|
|
|
- Mesh mesh = geom.getMesh();
|
|
|
- if (mesh == null) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- Geometry selectionGeometry = new Geometry("selection_geometry_sceneviewer", mesh);
|
|
|
- selectionGeometry.setLocalTransform(geom.getWorldTransform());
|
|
|
- toolNode.attachChild(selectionGeometry);
|
|
|
- return selectionGeometry;
|
|
|
+ protected void displayPlanes() {
|
|
|
+ axisMarker.attachChild(quadXY);
|
|
|
+ axisMarker.attachChild(quadXZ);
|
|
|
+ axisMarker.attachChild(quadYZ);
|
|
|
}
|
|
|
|
|
|
- protected Geometry getBoxSelection(Node toolNode, Spatial geom) {
|
|
|
- BoundingVolume bound = geom.getWorldBound();
|
|
|
- if (bound instanceof BoundingBox) {
|
|
|
- BoundingBox bbox = (BoundingBox) bound;
|
|
|
- Vector3f extent = new Vector3f();
|
|
|
- bbox.getExtent(extent);
|
|
|
- WireBox wireBox=new WireBox();
|
|
|
- wireBox.fromBoundingBox(bbox);
|
|
|
- Geometry selectionGeometry = new Geometry("selection_geometry_sceneviewer", wireBox);
|
|
|
- selectionGeometry.setLocalTransform(geom.getWorldTransform());
|
|
|
- toolNode.attachChild(selectionGeometry);
|
|
|
- return selectionGeometry;
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
+ protected void hidePlanes() {
|
|
|
+ quadXY.removeFromParent();
|
|
|
+ quadXZ.removeFromParent();
|
|
|
+ quadYZ.removeFromParent();
|
|
|
|
|
|
- protected Spatial getPhysicsSelection(Node toolNode, Spatial geom) {
|
|
|
- PhysicsCollisionObject control = geom.getControl(RigidBodyControl.class);
|
|
|
- if (control == null) {
|
|
|
- control = geom.getControl(VehicleControl.class);
|
|
|
- }
|
|
|
- if (control == null) {
|
|
|
- control = geom.getControl(GhostControl.class);
|
|
|
- }
|
|
|
- if (control == null) {
|
|
|
- control = geom.getControl(CharacterControl.class);
|
|
|
- }
|
|
|
- if (control == null) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- Spatial selectionGeometry = DebugShapeFactory.getDebugShape(control.getCollisionShape());
|
|
|
- if (selectionGeometry != null) {
|
|
|
- selectionGeometry.setLocalTransform(geom.getWorldTransform());
|
|
|
- toolNode.attachChild(selectionGeometry);
|
|
|
- return selectionGeometry;
|
|
|
- }
|
|
|
- return null;
|
|
|
}
|
|
|
|
|
|
- protected void detachSelectionShape() {
|
|
|
- if (selectionShape != null) {
|
|
|
- selectionShape.removeFromParent();
|
|
|
- selectionShape = null;
|
|
|
- }
|
|
|
+ protected void setDefaultAxisMarkerColors() {
|
|
|
+ axisMarker.getChild("arrowX").setMaterial(redMat);
|
|
|
+ axisMarker.getChild("arrowY").setMaterial(blueMat);
|
|
|
+ axisMarker.getChild("arrowZ").setMaterial(greenMat);
|
|
|
+ quadXY.setMaterial(yellowMat);
|
|
|
+ quadXZ.setMaterial(magentaMat);
|
|
|
+ quadYZ.setMaterial(cyanMat);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
public Camera getCamera() {
|
|
|
return camera;
|
|
|
}
|
|
@@ -502,7 +404,4 @@ public abstract class SceneEditTool {
|
|
|
public void setCamera(Camera camera) {
|
|
|
this.camera = camera;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|