Picking Objects (Pegando Objetos)

Started by MegasXLS, February 10, 2011, 08:02:25 PM

Previous topic - Next topic

MegasXLS

Hello everybody,

would like a hint of you forum,
I like to picking objects in my world(one applet)?

I'm using these instructions:

SimpleVector dir = Interact2D.reproject2D3DWS (world.getCamera (), buffer, e.getX (), e.getY ());
  Object [] res = world.calcMinDistanceAndObject3D (world.getCamera (). GetPosition (), dir, 1000 / * or whatever * /);

I can even take a 3D object, but not very accurately, need to click under the object3D to get your res [1].

after i use:

if (res [1] == Object3D) {
System.out.println ("I'm clicking on the object");
}

Thanks in advance

EgonOlsen

The usual reason for this is, that your x/y-coordinates are not the ones that you think they are. Maybe parts of the framebuffer are hidden by a window's title bar or similar (happens if you blit directly into a frame for example). So that 0,0 in the window actually is something like 2,10 in the framebuffer.

Kaiidyn

getY() - 24 might help. 24 is about the default height for a title bar, taskbar etc etc.
Clean code is simple and direct. Clean code reads like well-written prose. Clean code never obscures the designer's intent but rather is full of crisp abstractions and straightforward lines of control. - Grady Booch

MegasXLS

Thanks guys.

The solutions was: SimpleVector dir=Interact2D.reproject2D3DWS(world.getCamera(), buffer, e.getX(), e.getY() + 30);

Olsen, congratulations for the JPCT. This is awesome.

Thanks too Kaiidyn. /o/

EgonOlsen

You can get the insets from a frame. That's better than using fixed values that will change from OS to OS.