www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: MegasXLS on February 10, 2011, 08:02:25 pm

Title: Picking Objects (Pegando Objetos)
Post by: MegasXLS on February 10, 2011, 08:02:25 pm
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
Title: Re: Picking Objects (Pegando Objetos)
Post by: EgonOlsen on February 10, 2011, 09:45:10 pm
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.
Title: Re: Picking Objects (Pegando Objetos)
Post by: Kaiidyn on February 10, 2011, 10:05:09 pm
getY() - 24 might help. 24 is about the default height for a title bar, taskbar etc etc.
Title: Re: Picking Objects (Pegando Objetos)
Post by: MegasXLS on February 10, 2011, 10:53:11 pm
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/
Title: Re: Picking Objects (Pegando Objetos)
Post by: EgonOlsen on February 10, 2011, 10:56:15 pm
You can get the insets from a frame. That's better than using fixed values that will change from OS to OS.