1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| if ((id == MouseEvent.MOUSE_DRAGGED) &&
!evt.isMetaDown() && !evt.isAltDown() && !evt.isControlDown()) {
x = evt.getX();
y = evt.getY();
dx = x - x_last;
dy = y - y_last;
if (!reset) {
x_angle = dy * y_factor;
AxisAngle4f axis = new AxisAngle4f(1, 0, 0, (float) (x_angle));
transformX.set(axis);
transformGroup.getTransform(currXform);
Matrix4d mat = new Matrix4d();
// Remember old matrix
currXform.get(mat);
// Translate to origin
if (invert) {
currXform.mul(currXform, transformX);
} else {
currXform.mul(transformX, currXform);
}
// Set old translation back
Vector3d translation = new Vector3d(mat.m03, mat.m13, mat.m23);
currXform.setTranslation(translation);
// Update xform
transformGroup.setTransform(currXform);
transformChanged(currXform);
if (callback != null) {
callback.transformChanged(MouseBehaviorCallback.ROTATE,
currXform);
}
} else {
reset = false;
}
x_last = x;
y_last = y;
} else if (id == MouseEvent.MOUSE_PRESSED) {
x_last = evt.getX();
y_last = evt.getY();
} |
Partager