Author Topic: Picking  (Read 2958 times)

Offline Disastorm

  • long
  • ***
  • Posts: 161
    • View Profile
Picking
« on: November 08, 2010, 11:15:38 am »
I tried out the collision method for picking on the wiki and it works good when the object is close to my camera, but when its a little further it gets harder to pick my target object.  Instead, it keeps picking the "level" object instead of the character im trying to pick.  Strangely enough if I pick below where the character appears on the screen sometimes it will then pick the character even if the location i clicked doesnt have any part of the character there.  Do you know how I can fix this?  I believe I experienced this same thing when I used the regular picking method, as well.

Thanks.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Picking
« Reply #1 on: November 08, 2010, 12:57:49 pm »
Might be an offset between the mouse coordinates relative to the window and the pixel positions. Check, if the upper left corner of the window really is 0/0 of the frame buffer. The window border might add some overhead. The picking method is actually pretty accurate itself.

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
Re: Picking
« Reply #2 on: November 08, 2010, 02:35:24 pm »
If you use interact2d, you can screen out the level object by making it non-selectable, but it doesn't work for compiled objects, I guess.  Another thing I do is addAdditionalColor(color.WHITE), so it's easier to tell an object has been picked when it's hovering over it.  You should be able to exclude the level during picking with the index number. I know Interact2d is near perfect because I can trace around a character with the mouse, even when it's small, and it's right on.
« Last Edit: November 08, 2010, 02:47:04 pm by fireside »
click here->Fireside 7 Games<-

Offline Disastorm

  • long
  • ***
  • Posts: 161
    • View Profile
Re: Picking
« Reply #3 on: November 08, 2010, 07:13:06 pm »
Hey thanks, i fixed it, however I don't know why my coords are different than what you mentioned they should be.  My upper left is not 0,0 its instead 0,768 (height of window).  I just made mouseY = Math.abs(mouseY - 768) and it works now.

is it possible one of these methods messed up my coords, i don't actually know what they do i think i just copied them from somewhere.
            GL11.glMatrixMode(GL11.GL_PROJECTION);
            GL11.glLoadIdentity();
            GLU.gluOrtho2D(0, 1024, 0, 768);
            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glLoadIdentity();
            GL11.glViewport(0, 0, 1024, 768);
« Last Edit: November 08, 2010, 07:20:24 pm by Disastorm »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Picking
« Reply #4 on: November 08, 2010, 10:06:00 pm »
Why exactly are you doing this? Messing around with GL directly, i.e. bypassing jPCT, might cause problems as jPCT expects to be responsible for the GL setup. Unless you are cleaning this up afterwards, you are asking for trouble...

Offline Disastorm

  • long
  • ***
  • Posts: 161
    • View Profile
Re: Picking
« Reply #5 on: November 09, 2010, 07:02:16 am »
dunno i think it was in a fenggui example so i just copied it from there. should i just remove all of that stuff?

*edit even after removing it i still have these weird coordinates.   oh well at least i got it to function properly.
« Last Edit: November 09, 2010, 07:19:12 am by Disastorm »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Picking
« Reply #6 on: November 09, 2010, 07:27:39 am »
The coordinates are fine. It's the way LWJGL reports them. I was just wondering why you are using that code snippet.