Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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  
  Picking in 3D  (Read 1588 times)
0 Members and 1 Guest are viewing this topic.
Offline nech_neb

Junior Member




Java for LIFE !!!


« Posted 2004-07-20 06:27:39 »

Hi all

I'm trying to do picking in a 3D environment using
lwjgl, can't seem to find any examples on the matter

if some one could point me in the right direction, that
would be great. Thanks !!
Offline Orangy Tang

JGO Kernel


Medals: 51
Projects: 11


Monkey for a head


« Reply #1 - Posted 2004-07-20 21:35:48 »

You need a direct int buffer, use the handy-dandy methods in BufferUtils.createIntBuffer() etc.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline nech_neb

Junior Member




Java for LIFE !!!


« Reply #2 - Posted 2004-07-20 21:49:12 »

I don't really understand the difference between a
direct int buffer and other int buffers.


Hmm, when I tried to call viewport.array() when
the viewport is created by BufferUtils.createIntBuffer()
it throws me a java.lang.UnsupportedOperationException

How else can I call
GLU.gluPickMatrix()
to pass in an int[] for viewport if array() is not
implemented?


Thanks for the reply !!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Orangy Tang

JGO Kernel


Medals: 51
Projects: 11


Monkey for a head


« Reply #3 - Posted 2004-07-20 22:19:27 »

Direct buffers are just like regular buffers, except that they actually map to a linear piece of memory, much like a regular C array. Which means its much faster when you want to hand it off to a native lib like OpenGL. For consistancy LWJGL requires direct buffers whenever data needs sending to any native method.

Converting it to an int[] is simple, you just make an int[] as big as needed and fill it with data from your buffer. Buffers provide a whole heap of relative and absolute get methods you can use.

Just be careful with buffers position and limits. LWJGL methods use these when reading or writing data. Generally that means remembering to rewind or flip the buffer before handing it to LWJGL.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Orangy Tang

JGO Kernel


Medals: 51
Projects: 11


Monkey for a head


« Reply #4 - Posted 2004-07-20 23:03:02 »

LWJGL will check glGetError automatically for you every frame (in the Window.update if I remember right) which is handy as it traps when you make a mistake.

'Somewhere' you'll have made an invalid OpenGL call. First find out which one it is (mass commenting usually does the trick) then look it up in the OpenGL docs and find what it means.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline nech_neb

Junior Member




Java for LIFE !!!


« Reply #5 - Posted 2004-07-21 05:32:44 »

I'm not sure by what you mean, mass commenting usually does the trick.

when i comment part of the open gl code I think is causing problems, I get "An unexpected exception has been detected in native code outside the VM." rather than the openGlException

I'm having trouble identifying where the error is.

Does the error code in
org.lwjgl.opengl.OpenGLException: Invalid operation (1282)

mean anything?

EDIT:

I figured out how to locate the line with the error.

org.lwjgl.opengl.Util.checkGLError();

will throw an error when something is wrong,
not wait till Window.update();

The line with the error is apparently...

GL11.glRenderMode(GL11.GL_SELECT);

Now I'm more confused then ever.
Offline Matzon

JGO Knight


Medals: 19
Projects: 2


I'm gonna wring your pants!


« Reply #6 - Posted 2004-07-21 06:33:25 »

did you set up a buffer (glSelectBuffer) BEFORE setting the render mode to GL_SELECT ?

This whole thread brings back some memories - someone else had the *exact* same problems - just can't seem to find the thread...
EDIT
here we go, on the LWJGL boards:
http://puppygames.net/forums/viewtopic.php?t=427&highlight=picking

Offline nech_neb

Junior Member




Java for LIFE !!!


« Reply #7 - Posted 2004-07-21 08:10:37 »

I'm blind and stupid.

The answer was already given to me, and I
just didn't think about it.

I allocated the glSelectBuffer with a
IntBuffer created by IntBuffer.allocate();

I made the change for the viewport buffer.
but didn't think about making the change for
the selectBuffer, probably cause there
was no direct message complaining about it.

Conclusion of the night,
I'm blind and stupid.
Thanks for your help guys !!
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.

xsi3rr4x (54 views)
2014-04-15 18:08:23

BurntPizza (53 views)
2014-04-15 03:46:01

UprightPath (66 views)
2014-04-14 17:39:50

UprightPath (49 views)
2014-04-14 17:35:47

Porlus (66 views)
2014-04-14 15:48:38

tom_mai78101 (90 views)
2014-04-10 04:04:31

BurntPizza (151 views)
2014-04-08 23:06:04

tom_mai78101 (246 views)
2014-04-05 13:34:39

trollwarrior1 (204 views)
2014-04-04 12:06:45

CJLetsGame (211 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!