D'oh, I am stuck on a logical problem and need some help:
In my application I move an object while holding the right MouseButton (the object follows the mouse; it's like pulling an object in a scenegraph-editor). This works smooth. The bad thing however is: everything is dependent on the Terrain getting hit by a Ray.
Now if I want to translate objects without any Terrain the object doesn't move anymore - because there are no "intersectionpoints" anymore.
My first approach to achieve a translation on either x/y/z axis again was to create 3 giant planes on xy,xz,yz-Axes and catch the intersectionpoint on the appropriate plane. Though I think this solution would be too dirty and I somehow feel that this approach is "wrong".
This is my current code to handle the mouse-Action:
InputAction mouseAction2 = new InputAction(){
public void performAction(InputActionEvent iae2){
if(iae2.getTriggerPressed()==true) //for "MouseButton _pressed_"
{
// get Intersectionpoint with Terrain,
// and setLocation of Object equal to Intersectionpoint
}
else //for "MouseButton _released_"
//do nothing
}
};
//set to "true" to allow repeating trigger
inputModes.addAction(mouseAction2,InputHandler.DEVICE_MOUSE,1,InputHandler.AXIS_NONE,true);
I already tried something like InputHandler.AXIS_ALL so that the Intersectionpoints are created while solely moving the mouse but then again - it was dependent on the TerrainIntersection. Now how can I achieve a movement in "empty space" without being dependent on the intersectionpoints?
Sadly it doesn't work the way I hoped. I guess I am missing something in my understanding and therefore in the calculation.
Though I am also confused in this line: worldCoords = DisplaySystem.getDisplaySystem().getWorldCoordinates(mouse_xy,dist);
I am not sure that I am allowed to fill in here the distance because...
the API claims: public Vector3f getWorldCoordinates(Vector2f screenPosition,float zPos)
screenPosition - Vector2f representing the screen position with 0,0 at the bottom left.
zPos - The z position away from the viewing plane, between 0 and 1
on the other Hand HelloMousePick.java-Tutorial says: "The 3rd float I pass in, 0, is the distance away from the screen’s position that this 3D position will take. 0 would be the screen position right in front of you. 10 would be the screen position 10 units away from you."
So if I use a value between 0 and 1 in my example the spatial *slides* on the x-Axis when holding the right MouseButton (however not the way I wanted it because when moving the mouse slightly left or right from the centerposition of the screen the spatial slides away very fast at 1 and very slow at 0). If I use a value greater than 1 however (e.g. the distance value) my Spatial makes only 1 single move.
Also when I check the worldCoords of the Mouse (when using the distance value as zPos, I expected the mouse Position somewhere in 3d space with a distance of "dist" units away from the camera position) - but when I print the worldCoords they are the same as the camCoords! How come that? What is the zPos now? And where are the worldCoords of the MousePosition really?
:?
(If I only knew how MW3D did spatial translations, but can't find the file which handles the translation calculations :'()