Dragging object3d with mouse

Started by elhoce, March 14, 2012, 09:48:43 PM

Previous topic - Next topic

elhoce

Hi,

I want to drag an object3D , I follow the wiki about how to object it's works but when I try to move the object with the translate method, the object isn't under the mouse :(
my code :
public void mouseMoved(MouseEvent me) {
if(picked==null) return;
                    dest =Interact2D.reproject2D3DWS(world.getCamera(), buffer, me.getX(), me.getY());
                    System.out.println(dir.calcSub(dest).toString() + " " + me.getX() + " " + me.getY());
                    dest.z = 0;
                    dir.z = 0;
                    moveObj3D(picked, dir.calcSub(dest));
                    dir = dest;
}

How can I fix it ?

Thanks for your help.

Thomas.

Look at this, here is something similar, but object is translated by touch

elhoce

Sorry the source doesn't help me :), I need to understand how to simply move a picked object and this object sticks the mouse cursor.

EgonOlsen

The object has a depth (i.e. a z-position). You have to use the reproject-variant that takes this into account.