Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (601)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (649)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  a small probelm with picking  (Read 937 times)
0 Members and 1 Guest are viewing this topic.
Offline SamJ

Senior Newbie

Java games rock!

« Posted 2005-03-17 20:01:52 »

Hi, I've got a picking algorithm implemented that is essentially the same as the example by Thomas Bladh( The only difference is in how I process hits, and the fact that I have to pass an IntBuffer with glSelectBuffer(), instead of an int array. The method for processing the hits reads through the returned IntBuffer and outputs the contents on the screen. It also displays the number of reported hits. The problem appears to be with either accessing the IntBuffer's contents or with glSelectBuffer recording the wrong information to the buffer. When an object is clicked, the console presents the correct number of hits and then prints out strange numbers for the values on the hit list. For example, output for the second object might be something like:
"number of hits: 1
hits: 2  -141016064  -118963712  1  2  0  0  0 0 0 0" with the rest of the intbuffer being empty. I would expect output along the lines of:
"number of hits: 1
hits: 2  0  0  0  0  0  0  0 0 0 0"
The hit list gets even weirder when multiple hits are recorded.
Is there something obvious that I'm doing wrong? I think it might have something to do with unsigned ints but I really have no idea.
I'm running all of this on mac os x with a JOGL  release from over the summer.
Any help would be greatly appreciated.

The big print giveth. The small print taketh away.
Offline Ken Russell

JGO Coder

Java games rock!

« Reply #1 - Posted 2005-03-17 20:35:51 »

The strange-looking values are the scaled Z-coordinates of your hits expressed as unsigned integer values. Thomas Bladh's example converts the hits back to floating-point depth values, but I'm not 100% sure the conversion is correct. You might need to do something like this:
float depth = ((float) (buffer.get(offset) & 0x00000000FFFFFFFFL) / 0x00000000FFFFFFFFL));

Offline SamJ

Senior Newbie

Java games rock!

« Reply #2 - Posted 2005-03-17 20:38:46 »

Thank you, that was very helpful.

The big print giveth. The small print taketh away.
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Riven (29 views)
2015-07-27 16:38:00

Riven (16 views)
2015-07-27 15:35:20

Riven (20 views)
2015-07-27 12:26:13

Riven (10 views)
2015-07-27 12:23:39

BurntPizza (27 views)
2015-07-25 00:14:37

BurntPizza (39 views)
2015-07-24 22:06:39

BurntPizza (22 views)
2015-07-24 06:06:53

NoxInc (25 views)
2015-07-22 22:16:53

NoxInc (17 views)
2015-07-22 22:13:39

Jesse (39 views)
2015-07-22 03:10:36
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!