Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (429)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (467)
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 16: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 16: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 15:24:31
@theagentd

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

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
    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.

@gouessej

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 10:20:24
Hi,

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]
 

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 (81 views)
2014-04-15 18:08:23

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

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

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

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

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

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

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

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

CJLetsGame (223 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!