Author Topic: Dragging object3d with mouse  (Read 878 times)

Offline elhoce

  • byte
  • *
  • Posts: 16
    • View Profile
Dragging object3d with mouse
« 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.

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: Dragging object3d with mouse
« Reply #1 on: March 14, 2012, 10:16:41 pm »
Look at this, here is something similar, but object is translated by touch

Offline elhoce

  • byte
  • *
  • Posts: 16
    • View Profile
Re: Dragging object3d with mouse
« Reply #2 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Dragging object3d with mouse
« Reply #3 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.