Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
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 831 times)
0 Members and 1 Guest are viewing this topic.
Offline SamJ

Senior Newbie




Java games rock!


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

Hi, I've got a picking algorithm implemented that is essentially the same as the example by Thomas Bladh(http://www.sm.luth.se/~david/classes/smm009/TestPrograms/Picking.java). 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 21: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:
1  
float depth = ((float) (buffer.get(offset) & 0x00000000FFFFFFFFL) / 0x00000000FFFFFFFFL));

Offline SamJ

Senior Newbie




Java games rock!


« Reply #2 - Posted 2005-03-17 21: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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

ctomni231 (39 views)
2014-07-18 06:55:21

Zero Volt (36 views)
2014-07-17 23:47:54

danieldean (29 views)
2014-07-17 23:41:23

MustardPeter (32 views)
2014-07-16 23:30:00

Cero (47 views)
2014-07-16 00:42:17

Riven (48 views)
2014-07-14 18:02:53

OpenGLShaders (38 views)
2014-07-14 16:23:47

Riven (37 views)
2014-07-14 11:51:35

quew8 (33 views)
2014-07-13 13:57:52

SHC (70 views)
2014-07-12 17:50:04
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org 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‑gaming.org
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!