|
|
@ -57,13 +57,13 @@ public class PickManager { |
|
|
|
spatial = selectedSpatial; |
|
|
|
spatial = selectedSpatial; |
|
|
|
startSpatialLocation = selectedSpatial.getWorldTranslation().clone(); |
|
|
|
startSpatialLocation = selectedSpatial.getWorldTranslation().clone(); |
|
|
|
|
|
|
|
|
|
|
|
setTransformation(planeRotation, type); |
|
|
|
setTransformation(planeRotation, type, camera); |
|
|
|
plane.setLocalTranslation(startSpatialLocation); |
|
|
|
plane.setLocalTranslation(startSpatialLocation); |
|
|
|
|
|
|
|
|
|
|
|
startPickLoc = SceneEditTool.pickWorldLocation(camera, screenCoord, plane, null); |
|
|
|
startPickLoc = SceneEditTool.pickWorldLocation(camera, screenCoord, plane, null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setTransformation(Quaternion planeRotation, SceneComposerToolController.TransformationType type) { |
|
|
|
public void setTransformation(Quaternion planeRotation, SceneComposerToolController.TransformationType type, Camera camera) { |
|
|
|
Quaternion rot = new Quaternion(); |
|
|
|
Quaternion rot = new Quaternion(); |
|
|
|
transformationType = type; |
|
|
|
transformationType = type; |
|
|
|
if (transformationType == SceneComposerToolController.TransformationType.local) { |
|
|
|
if (transformationType == SceneComposerToolController.TransformationType.local) { |
|
|
@ -74,12 +74,18 @@ public class PickManager { |
|
|
|
rot.set(planeRotation); |
|
|
|
rot.set(planeRotation); |
|
|
|
origineRotation = new Quaternion(Quaternion.IDENTITY); |
|
|
|
origineRotation = new Quaternion(Quaternion.IDENTITY); |
|
|
|
} else if (transformationType == SceneComposerToolController.TransformationType.camera) { |
|
|
|
} else if (transformationType == SceneComposerToolController.TransformationType.camera) { |
|
|
|
rot.set(planeRotation); |
|
|
|
rot.set(camera.getRotation()); |
|
|
|
origineRotation = planeRotation.clone(); |
|
|
|
origineRotation = camera.getRotation().clone(); |
|
|
|
} |
|
|
|
} |
|
|
|
plane.setLocalRotation(rot); |
|
|
|
plane.setLocalRotation(rot); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param camera |
|
|
|
|
|
|
|
* @param screenCoord |
|
|
|
|
|
|
|
* @return true if the the new picked location is set, else return false. |
|
|
|
|
|
|
|
*/ |
|
|
|
public boolean updatePick(Camera camera, Vector2f screenCoord) { |
|
|
|
public boolean updatePick(Camera camera, Vector2f screenCoord) { |
|
|
|
if(transformationType == SceneComposerToolController.TransformationType.camera){ |
|
|
|
if(transformationType == SceneComposerToolController.TransformationType.camera){ |
|
|
|
origineRotation = camera.getRotation(); |
|
|
|
origineRotation = camera.getRotation(); |
|
|
@ -131,12 +137,7 @@ public class PickManager { |
|
|
|
* @return the Quaternion rotation in the WorldSpace |
|
|
|
* @return the Quaternion rotation in the WorldSpace |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Quaternion getRotation() { |
|
|
|
public Quaternion getRotation() { |
|
|
|
Vector3f v1, v2; |
|
|
|
return getRotation(Quaternion.IDENTITY); |
|
|
|
v1 = startPickLoc.subtract(startSpatialLocation).normalize(); |
|
|
|
|
|
|
|
v2 = finalPickLoc.subtract(startSpatialLocation).normalize(); |
|
|
|
|
|
|
|
Vector3f axis = v1.cross(v2); |
|
|
|
|
|
|
|
float angle = v1.angleBetween(v2); |
|
|
|
|
|
|
|
return new Quaternion().fromAngleAxis(angle, axis); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -144,10 +145,18 @@ public class PickManager { |
|
|
|
* @return the Quaternion rotation in the ToolSpace |
|
|
|
* @return the Quaternion rotation in the ToolSpace |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Quaternion getLocalRotation() { |
|
|
|
public Quaternion getLocalRotation() { |
|
|
|
|
|
|
|
return getRotation(origineRotation.inverse()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Get the Rotation into a specific custom space. |
|
|
|
|
|
|
|
* @param transforme the rotation to the custom space (World to Custom space) |
|
|
|
|
|
|
|
* @return the Rotation in the custom space |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public Quaternion getRotation(Quaternion transforme) { |
|
|
|
Vector3f v1, v2; |
|
|
|
Vector3f v1, v2; |
|
|
|
Quaternion rot = origineRotation.inverse(); |
|
|
|
v1 = transforme.mult(startPickLoc.subtract(startSpatialLocation).normalize()); |
|
|
|
v1 = rot.mult(startPickLoc.subtract(startSpatialLocation).normalize()); |
|
|
|
v2 = transforme.mult(finalPickLoc.subtract(startSpatialLocation).normalize()); |
|
|
|
v2 = rot.mult(finalPickLoc.subtract(startSpatialLocation).normalize()); |
|
|
|
|
|
|
|
Vector3f axis = v1.cross(v2); |
|
|
|
Vector3f axis = v1.cross(v2); |
|
|
|
float angle = v1.angleBetween(v2); |
|
|
|
float angle = v1.angleBetween(v2); |
|
|
|
return new Quaternion().fromAngleAxis(angle, axis); |
|
|
|
return new Quaternion().fromAngleAxis(angle, axis); |
|
|
@ -178,7 +187,6 @@ public class PickManager { |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Vector3f getLocalTranslation(Vector3f axisConstrainte) { |
|
|
|
public Vector3f getLocalTranslation(Vector3f axisConstrainte) { |
|
|
|
//return plane.getWorldRotation().inverse().mult(getTranslation(axisConstrainte));
|
|
|
|
|
|
|
|
return getTranslation(origineRotation.inverse().mult(axisConstrainte)); |
|
|
|
return getTranslation(origineRotation.inverse().mult(axisConstrainte)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|