www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: elhoce on March 14, 2012, 09:48:43 pm

Title: Dragging object3d with mouse
Post by: elhoce on March 14, 2012, 09:48:43 pm
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.
Title: Re: Dragging object3d with mouse
Post by: Thomas. on March 14, 2012, 10:16:41 pm
Look at this (http://www.jpct.net/forum2/index.php/topic,2622.0.html), here is something similar, but object is translated by touch
Title: Re: Dragging object3d with mouse
Post by: elhoce on March 14, 2012, 11:14:59 pm
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.
Title: Re: Dragging object3d with mouse
Post by: EgonOlsen on March 15, 2012, 12:16:34 am
The object has a depth (i.e. a z-position). You have to use the reproject-variant that takes this into account.