some fixes to the SDK manipulation tool
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9460 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
855676173a
commit
0b7a92cc38
@ -51,7 +51,6 @@ public class SceneToolController implements AppState {
|
|||||||
protected Spatial selectionShape;
|
protected Spatial selectionShape;
|
||||||
protected AssetManager manager;
|
protected AssetManager manager;
|
||||||
protected Material blueMat;
|
protected Material blueMat;
|
||||||
protected Vector3f selctionShapeOffset = new Vector3f(0, 0, 0);
|
|
||||||
|
|
||||||
public SceneToolController(AssetManager manager) {
|
public SceneToolController(AssetManager manager) {
|
||||||
this.toolsNode = new Node("ToolsNode");
|
this.toolsNode = new Node("ToolsNode");
|
||||||
@ -143,6 +142,22 @@ public class SceneToolController implements AppState {
|
|||||||
selected = spat;
|
selected = spat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void rebuildSelectionBox() {
|
||||||
|
if (SceneApplication.getApplication().isAwt()) {
|
||||||
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
||||||
|
public Object call() throws Exception {
|
||||||
|
doUpdateSelection(selected);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (selected != null) {
|
||||||
|
attachSelectionShape(selected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setCursorLocation(final Vector3f location) {
|
public void setCursorLocation(final Vector3f location) {
|
||||||
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
||||||
|
|
||||||
@ -178,7 +193,6 @@ public class SceneToolController implements AppState {
|
|||||||
selectionShape.removeFromParent();
|
selectionShape.removeFromParent();
|
||||||
selectionShape = null;
|
selectionShape = null;
|
||||||
}
|
}
|
||||||
selctionShapeOffset.set(Vector3f.ZERO);
|
|
||||||
if (spat instanceof ParticleEmitter) {
|
if (spat instanceof ParticleEmitter) {
|
||||||
attachBoxSelection(spat);
|
attachBoxSelection(spat);
|
||||||
|
|
||||||
@ -232,16 +246,23 @@ public class SceneToolController implements AppState {
|
|||||||
bbox.getExtent(extent);
|
bbox.getExtent(extent);
|
||||||
WireBox wireBox = new WireBox();
|
WireBox wireBox = new WireBox();
|
||||||
wireBox.fromBoundingBox(bbox);
|
wireBox.fromBoundingBox(bbox);
|
||||||
selctionShapeOffset.set(bbox.getCenter()).subtractLocal(geom.getWorldTranslation());
|
|
||||||
final Geometry selectionGeometry = new Geometry("selection_geometry_sceneviewer", wireBox);
|
final Geometry selectionGeometry = new Geometry("selection_geometry_sceneviewer", wireBox);
|
||||||
selectionGeometry.setMaterial(blueMat);
|
selectionGeometry.setMaterial(blueMat);
|
||||||
selectionGeometry.setLocalTransform(geom.getWorldTransform());
|
selectionGeometry.setLocalTranslation( bbox.getCenter().subtract(geom.getWorldTranslation()) );
|
||||||
selectionGeometry.setLocalTranslation(bbox.getCenter());
|
//Vector3f scale = new Vector3f(1,1,1);
|
||||||
selectionShape = selectionGeometry;
|
//scale.x = 1/geom.getWorldScale().x;
|
||||||
|
//scale.y = 1/geom.getWorldScale().y;
|
||||||
|
//scale.z = 1/geom.getWorldScale().z;
|
||||||
|
selectionShape = new Node("SelectionParent");
|
||||||
|
((Node)selectionShape).attachChild(selectionGeometry);
|
||||||
|
//selectionShape.setLocalTransform(geom.getWorldTransform());
|
||||||
|
//selectionShape.setLocalTranslation(geom.getWorldTranslation());
|
||||||
|
//selectionGeometry.setLocalScale(scale);
|
||||||
|
|
||||||
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
||||||
|
|
||||||
public Object call() throws Exception {
|
public Object call() throws Exception {
|
||||||
toolsNode.attachChild(selectionGeometry);
|
toolsNode.attachChild(selectionShape);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -394,12 +415,10 @@ public class SceneToolController implements AppState {
|
|||||||
if (selected == null || selectionShape == null) {
|
if (selected == null || selectionShape == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TempVars vars = TempVars.get();
|
|
||||||
vars.vect1.set(selctionShapeOffset);
|
selectionShape.setLocalTranslation(selected.getWorldTranslation());
|
||||||
selectionShape.setLocalTranslation(vars.vect1.addLocal(selected.getWorldTranslation()));
|
|
||||||
vars.release();
|
|
||||||
selectionShape.setLocalRotation(selected.getWorldRotation());
|
selectionShape.setLocalRotation(selected.getWorldRotation());
|
||||||
selectionShape.setLocalScale(selected.getWorldScale());
|
//selectionShape.setLocalScale(selected.getWorldScale());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,9 +22,13 @@ import com.jme3.gde.scenecomposer.tools.MoveTool;
|
|||||||
import com.jme3.gde.scenecomposer.tools.RotateTool;
|
import com.jme3.gde.scenecomposer.tools.RotateTool;
|
||||||
import com.jme3.gde.scenecomposer.tools.ScaleTool;
|
import com.jme3.gde.scenecomposer.tools.ScaleTool;
|
||||||
import com.jme3.gde.scenecomposer.tools.SelectTool;
|
import com.jme3.gde.scenecomposer.tools.SelectTool;
|
||||||
|
import com.jme3.input.awt.AwtKeyInput;
|
||||||
|
import com.jme3.input.event.KeyInputEvent;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
import com.jme3.scene.Spatial;
|
import com.jme3.scene.Spatial;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.KeyListener;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
@ -253,7 +253,7 @@ public class SelectTool extends SceneEditTool {
|
|||||||
|
|
||||||
private boolean checkCommandKey(KeyInputEvent kie) {
|
private boolean checkCommandKey(KeyInputEvent kie) {
|
||||||
if (kie.getKeyCode() == KeyInput.KEY_D) {
|
if (kie.getKeyCode() == KeyInput.KEY_D) {
|
||||||
if (ctrlDown && shiftDown) {
|
if (shiftDown) {
|
||||||
duplicateSelected();
|
duplicateSelected();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -383,6 +383,7 @@ public class SelectTool extends SceneEditTool {
|
|||||||
actionPerformed(scaling);
|
actionPerformed(scaling);
|
||||||
scaling = null;
|
scaling = null;
|
||||||
clearState(false);
|
clearState(false);
|
||||||
|
toolController.rebuildSelectionBox();
|
||||||
} else if (rotating != null) {
|
} else if (rotating != null) {
|
||||||
rotating.after = selected.getLocalRotation().clone();
|
rotating.after = selected.getLocalRotation().clone();
|
||||||
actionPerformed(rotating);
|
actionPerformed(rotating);
|
||||||
@ -408,7 +409,12 @@ public class SelectTool extends SceneEditTool {
|
|||||||
if (pressed) {
|
if (pressed) {
|
||||||
// mouse down
|
// mouse down
|
||||||
|
|
||||||
if (!wasDraggingR && !wasDownR) { // wasn't dragging and was not down already
|
if (moving != null) {
|
||||||
|
moving.sceneUndo();
|
||||||
|
moving = null;
|
||||||
|
clearState();
|
||||||
|
}
|
||||||
|
else if (!wasDraggingR && !wasDownR) { // wasn't dragging and was not down already
|
||||||
// pick on the spot
|
// pick on the spot
|
||||||
Spatial s = pickWorldSpatial(camera, screenCoord, rootNode);
|
Spatial s = pickWorldSpatial(camera, screenCoord, rootNode);
|
||||||
if (!toolController.selectTerrain() && isTerrain(s) ) {
|
if (!toolController.selectTerrain() && isTerrain(s) ) {
|
||||||
@ -454,6 +460,9 @@ public class SelectTool extends SceneEditTool {
|
|||||||
* TODO: use userData to determine the actual model's parent.
|
* TODO: use userData to determine the actual model's parent.
|
||||||
*/
|
*/
|
||||||
private Spatial findModelNodeParent(Spatial child) {
|
private Spatial findModelNodeParent(Spatial child) {
|
||||||
|
if (child == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
if (child instanceof Node)
|
if (child instanceof Node)
|
||||||
return child;
|
return child;
|
||||||
|
|
||||||
@ -785,6 +794,8 @@ public class SelectTool extends SceneEditTool {
|
|||||||
* Recursive call.
|
* Recursive call.
|
||||||
*/
|
*/
|
||||||
protected boolean isTerrain(Spatial s) {
|
protected boolean isTerrain(Spatial s) {
|
||||||
|
if (s == null)
|
||||||
|
return false;
|
||||||
if (s instanceof Terrain)
|
if (s instanceof Terrain)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user