Main Menu

Picking

Started by Disastorm, November 08, 2010, 11:15:38 AM

Previous topic - Next topic

Disastorm

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.

EgonOlsen

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.

fireside

#2
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.
click here->Fireside 7 Games<-

Disastorm

#3
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);

EgonOlsen

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...

Disastorm

#5
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.

EgonOlsen

The coordinates are fine. It's the way LWJGL reports them. I was just wondering why you are using that code snippet.