Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (491)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (556)
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  
  Hits and Depth Question (JOGL/OpenGL)  (Read 838 times)
0 Members and 1 Guest are viewing this topic.
Offline Zed Gimbal

Innocent Bystander





« Posted 2009-01-23 17:43:34 »

Hi! I'm not only a new forum member, but also a new OpenGL programmer.

I'm writing a Java/JOGL application which has selecting and picking functionality, and I'm finding that, when processing hits, all of the hit objects are coming back with zero minDepth and maxDepth.

When retrieving the minDepth and maxDepth from the select buffer, I'm getting depthInt = -2147483648, which converts to a float value of 0.0 when using this algorithm:

depthFloat = 1f + (float)((long)depthInt)/0x7fffffff

(The algorithm above is borrowed from page 469 of Andrew Davison's Pro Java 6 3D Game Development.)

My understanding is that, if minDepth is 0.0, then the hit object is thought to be at the near clipping plane, and if minDepth is 1.0, then the object is thought to be at the far clipping plane.

My first thought was that perhaps the camera's frustum spans too much Z space, resulting in lower-than-needed precision when OpenGL tries to determine their depths. This doesn't seem to be a problem, though, because:

* the meshes that I'm displaying have been glScalefed to fit within a 4x4x4 cube
* the meshes all reside within the camera's frustum
* the camera's frustum has a near clipping plane distance of 1.5, and a far clipping plane distance of 20.0

After searching this forum, I stumbled across this post, which suggests that I should ensure that my select buffer should use native byte order.  My buffer is declared as follows:

IntBuffer selectBuffer = BufferUtil.newIntBuffer(4096);

According to the JOGL API JavaDoc, "the returned buffer will have its byte order set to the host platform's native byte order."  So this doesn't seem to be the problem.

The problem seems to occur regardless of the number of meshes that I display.

Does anyone have any suggestions about what I might be doing incorrectly?

Thanks in advance!
Offline Z-Knight

Senior Member


Medals: 1



« Reply #1 - Posted 2009-01-30 16:57:29 »

Welcome to the forum.

I can't answer your question but I wanted to give you a link to another forum that might also be of interest since you mentioned you are new to OpenGL and this might be an OpenGL issue.

Here is the forum for OpenGL that is pretty popular and I would also post there if you think an OpenGL issue is the root cause.

http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=postlist&Board=2&page=1

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

Nickropheliac (15 views)
2014-08-31 22:59:12

TehJavaDev (23 views)
2014-08-28 18:26:30

CopyableCougar4 (29 views)
2014-08-22 19:31:30

atombrot (41 views)
2014-08-19 09:29:53

Tekkerue (39 views)
2014-08-16 06:45:27

Tekkerue (35 views)
2014-08-16 06:22:17

Tekkerue (25 views)
2014-08-16 06:20:21

Tekkerue (36 views)
2014-08-16 06:12:11

Rayexar (72 views)
2014-08-11 02:49:23

BurntPizza (49 views)
2014-08-09 21:09:32
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!