SDK :
- Blender style rotation now rotates objects in world space and parent rotation are correctly taken into account. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9606 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
68e17702e2
commit
3f8d7f0807
@ -166,6 +166,7 @@ public class SelectTool extends SceneEditTool {
|
||||
startScale = null;
|
||||
startMouseCoord = null;
|
||||
startSelectedCoord = null;
|
||||
lastRotAngle = 0;
|
||||
}
|
||||
|
||||
private void recordInitialState(Spatial selected) {
|
||||
@ -229,6 +230,7 @@ public class SelectTool extends SceneEditTool {
|
||||
actionPerformed(undo);
|
||||
toolController.updateSelection(null);// force a re-draw of the bbox shape
|
||||
toolController.updateSelection(selected);
|
||||
|
||||
}
|
||||
clearState(false);
|
||||
}
|
||||
@ -286,44 +288,34 @@ public class SelectTool extends SceneEditTool {
|
||||
private boolean checkAxisKey(KeyInputEvent kie) {
|
||||
if (kie.getKeyCode() == KeyInput.KEY_X) {
|
||||
currentAxis = Vector3f.UNIT_X;
|
||||
MoveManager moveManager = Lookup.getDefault().lookup(MoveManager.class);
|
||||
Quaternion rot = camera.getRotation().mult(new Quaternion().fromAngleAxis(FastMath.PI, Vector3f.UNIT_Y));
|
||||
Quaternion planRot = null;
|
||||
if (rot.dot(MoveManager.XY) < rot.dot(MoveManager.XZ)) {
|
||||
planRot = MoveManager.XY;
|
||||
} else {
|
||||
planRot = MoveManager.XZ;
|
||||
}
|
||||
moveManager.updatePlaneRotation(planRot);
|
||||
checkMovePlane(MoveManager.XY, MoveManager.XZ);
|
||||
return true;
|
||||
} else if (kie.getKeyCode() == KeyInput.KEY_Y) {
|
||||
currentAxis = Vector3f.UNIT_Y;
|
||||
MoveManager moveManager = Lookup.getDefault().lookup(MoveManager.class);
|
||||
Quaternion rot = camera.getRotation().mult(new Quaternion().fromAngleAxis(FastMath.PI, Vector3f.UNIT_Y));
|
||||
Quaternion planRot = null;
|
||||
if (rot.dot(MoveManager.XY) < rot.dot(MoveManager.YZ)) {
|
||||
planRot = MoveManager.XY;
|
||||
} else {
|
||||
planRot = MoveManager.YZ;
|
||||
}
|
||||
moveManager.updatePlaneRotation(planRot);
|
||||
checkMovePlane(MoveManager.XY, MoveManager.YZ);
|
||||
return true;
|
||||
} else if (kie.getKeyCode() == KeyInput.KEY_Z) {
|
||||
currentAxis = Vector3f.UNIT_Z;
|
||||
MoveManager moveManager = Lookup.getDefault().lookup(MoveManager.class);
|
||||
Quaternion rot = camera.getRotation().mult(new Quaternion().fromAngleAxis(FastMath.PI, Vector3f.UNIT_Y));
|
||||
Quaternion planRot = null;
|
||||
if (rot.dot(MoveManager.XZ) < rot.dot(MoveManager.YZ)) {
|
||||
planRot = MoveManager.XZ;
|
||||
} else {
|
||||
planRot = MoveManager.YZ;
|
||||
}
|
||||
moveManager.updatePlaneRotation(planRot);
|
||||
checkMovePlane(MoveManager.XZ, MoveManager.YZ);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void checkMovePlane(Quaternion rot1, Quaternion rot2) {
|
||||
if (currentState == State.translate) {
|
||||
MoveManager moveManager = Lookup.getDefault().lookup(MoveManager.class);
|
||||
Quaternion rot = camera.getRotation().mult(new Quaternion().fromAngleAxis(FastMath.PI, Vector3f.UNIT_Y));
|
||||
Quaternion planRot = null;
|
||||
if (rot.dot(rot1) < rot.dot(rot2)) {
|
||||
planRot = rot1;
|
||||
} else {
|
||||
planRot = rot2;
|
||||
}
|
||||
moveManager.updatePlaneRotation(planRot);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkNumberKey(KeyInputEvent kie) {
|
||||
if (kie.getKeyCode() == KeyInput.KEY_MINUS) {
|
||||
if (numberBuilder.length() > 0) {
|
||||
@ -619,10 +611,9 @@ public class SelectTool extends SceneEditTool {
|
||||
|
||||
Quaternion rotate = new Quaternion();
|
||||
if (axis != Vector3f.UNIT_XYZ) {
|
||||
rotate = rotate.fromAngleAxis(newRotAngle, axis);
|
||||
rotate = rotate.fromAngleAxis(newRotAngle, selected.getWorldRotation().inverse().mult(axis));
|
||||
} else {
|
||||
//Vector3f screen = getCamera().getLocation().subtract(selected.getWorldTranslation()).normalize();
|
||||
rotate = rotate.fromAngleAxis(newRotAngle, getCamera().getDirection());
|
||||
rotate = rotate.fromAngleAxis(newRotAngle, selected.getWorldRotation().inverse().mult(getCamera().getDirection().mult(-1).normalizeLocal()));
|
||||
}
|
||||
selected.setLocalRotation(selected.getLocalRotation().mult(rotate));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user