I don't know if you have managed picking already, in case not, then you'll find many threads on the forum about picking (like this).
After you know which object to move, then you'll have to ask yourself: which is the surface you want your object to move on? As you can imagine, a single pixel on the screen, on which you point your mouse, corresponds to an infinite number of points in 3D space, standing on the line right behind your cursor. Once you know which surface or distance is the one, then you just intersect the ray coming from the eye, through the mouse cursor, with the your surface, and place the object there.
Hope this helps, kp
Ok... I still have the Drop problem... I'm able to pick an object but i don't know how to Drag and drop it....
I want to move Every object together... but only if a certain object is clicked.. now I know if my object is clicked but i really dunno how to make the Drag and drop work
Quote:I want to move Every object together... but only if a certain object is clicked.. now I know if my object is clicked but i really dunno how to make the Drag and drop work
if you just want to move your objects in a plane, you just need to translate all the objects you want to move by the mouse offset from the previous frame. simliar process to dragging a 2d panel. if you want to move your objects in 3d it would be more complicated.
When you detect a mouse down, store the mouse's position and set a boolean value consisting of whether you're in the middle of a drag operation to true. When mouse moves, if that boolean is true then translate the geometry by some function of the difference between the current mouse position and the one that you stored on mouse down. Finally, when you detect a mouse up, you set your drag boolean to false, so that the mouse move won't move the geometry.
"Some function" in this context can mean that you map the geometry's x and y positions to those of the mouse drag vector, for example.
The same basic logic works regardless of how many dimensions the geometry is in.
Yeah i'm already doing that.. except that i'm using a MouseDown instead of boolean
It's really easy to do that in 2D ... What i don't know is how to call the translation.... my world rotate and i know that the mouse moved by X,Y but how many in X,Y,Z
Quote:my world rotate and i know that the mouse moved by X,Y but how many in X,Y,Z
it depends on what kind of movement you're trying to achieve.
eg. if you had a cube sitting on a plane and you want to move the box around on the plane, you'd pick the box, then do repeated mouse-ray-intersect tests with the plane to find your new location until you let go of the mouse button.