www.jpct.net
jPCT - a 3d engine for Java => Support => Topic started 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
-
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.
-
getY() - 24 might help. 24 is about the default height for a title bar, taskbar etc etc.
-
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/
-
You can get the insets from a frame. That's better than using fixed values that will change from OS to OS.