Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (741)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (823)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Java Game APIs & Engines / JOGL Development / Re: Collision/intersection help on: 2012-01-27 15:50:55
Right, yea I just want picking, but I want to know the x,y,z coordinate of the intersection, Im not sure how to determine this given the depth-value returned by the GL_SELECTION method.
2  Java Game APIs & Engines / JOGL Development / Re: Collision/intersection help on: 2012-01-27 15:31:53
Yea thats how I was using it but I would like to get the 3d coordinate of the object im picking, instead it seems to just give the 3d coordinates of my mouse.

I think i may just rely on manually casting a ray and seeing what it intersects (unforunately wont work for complex objects), though I thought there would be a simple way to do this.
3  Java Game APIs & Engines / JOGL Development / Re: Collision/intersection help on: 2012-01-27 14:24:31

i used the following instead which seemed to compile for me:

    private DoubleBuffer getMousePosition(int mouseX, int mouseY, GL GL11) {
        IntBuffer viewport = BufferUtil.newIntBuffer(16);
        DoubleBuffer modelview = BufferUtil.newDoubleBuffer(16);
        DoubleBuffer projection = BufferUtil.newDoubleBuffer(16);
        DoubleBuffer winZ = BufferUtil.newDoubleBuffer(1);
        DoubleBuffer position = BufferUtil.newDoubleBuffer(3);

        GL11.glGetDoublev(GL11.GL_MODELVIEW_MATRIX, modelview);
        GL11.glGetDoublev(GL11.GL_PROJECTION_MATRIX, projection);
        GL11.glGetIntegerv(GL11.GL_VIEWPORT, viewport);

        GL11.glReadPixels(mouseX, mouseY, 1, 1, GL11.GL_DEPTH_COMPONENT, GL11.GL_DOUBLE, winZ);

        if (winZ.get(0) == 1) {
            return null;

        glu.gluUnProject((double)mouseX, (double)mouseY, (double)winZ.get(0), modelview, projection, viewport, position);

        System.out.println(position.get(0)+" "+position.get(1)+" "+position.get(2)+" "+winZ.get(0));
        return position;

Thanks for your reply man but it didn't give me the correct z positions. I had a simple sphere, and used a mouse click coordinates to run the getMousePosition method, however it only ever returned winZ as 0 (converting to a projection.get(2) of 0.5 for everything). Whereas i want to know the different z-values for different parts of the sphere.


Ive been trying to use openGL picking but have been getting depth-values of like 1578192816 and even after reading about glSelectBuffer I still don't know how to turn this into a z-coordinate. I know to divide by 2^31 but even then im not sure what it means.
4  Java Game APIs & Engines / JOGL Development / Collision/intersection help on: 2012-01-27 09:20:24

Im trying to do some simple picking.

Ive got a number of different objects, spheres/triangles and some oddly shaped objects. Given a 3d vector i want to know the 3d locations where the vector intersects any of the objects. For example from location 0,0,0 looking at direction 1,1,1 at what x,y,z location (if any) does this vector intersect my teapot.

Ive tried using GL_SELECT but that doesn't give me x,y,z locations where a ray would intersect.

Thanks for your help
Pages: [1]
xxMrPHDxx (17 views)
2017-11-21 16:21:00

xxMrPHDxx (11 views)
2017-11-21 16:14:31

xxMrPHDxx (14 views)
2017-11-21 16:10:57

Ecumene (114 views)
2017-09-30 02:57:34

theagentd (148 views)
2017-09-26 18:23:31

cybrmynd (248 views)
2017-08-02 12:28:51

cybrmynd (247 views)
2017-08-02 12:19:43

cybrmynd (244 views)
2017-08-02 12:18:09

Sralse (258 views)
2017-07-25 17:13:48

Archive (878 views)
2017-04-27 17:45:51
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51 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!