First: you guys have my undying gratitude for your dedication to maintaining JOGL, etc. My app (https://vzome.com) would have died many years ago without your hard work. Harvey has been particularly helpful, and he even showcased vZome as a Java3d app once, I think at SIGGRAPH.
Now, I'm finally eliminating Java3d from vZome and using JOGL directly, and using it without the fixed function pipeline. So far, the results are very gratifying, and I haven't even looked at the memory profiling yet. All the easy stuff is done, but I have a few thorny tasks left. The biggest one is to implement picking. I've been digging around, looking for a reasonably straightforward sample. I found Julien's SO post, which led me to this sample of Sven's, which is perfect in size and scope, but it uses the deprecated OpenGL built-in picking, and the fixed-function pipeline. My hope is to modernize that sample; I have already forked java-demos. I was able to build and run the picking demo on my Mac, but it has a defect at the moment: the picking seems to be using the wrong coordinates, so that the results don't match the mouse location. QUESTION 1: Does anyone know if that demo works correctly on other platforms? QUESTION 2: Does anyone have or know of a good demo of picking using FloatUtil.mapWinToRay or FloatUtil.makePick, or really any modern demo of picking with JOGL? I hope to prove out picking in a sample, before I try to get it working in my more complicated application. I'll be happy to "give back" and submit a pull request, if I'm successful. |
Administrator
|
Look at GraphUI's SceneUIController.pickShapeImpl:
com.jogamp.opengl.test.junit.graph.demos.ui.SceneUIController.pickShapeImpl(int, int, float[]) (in jogl's git repo) This method utilizes com.jogamp.opengl.math.FloatUtil.mapWinToRay(float, float, float, float, float[], int, float[], int, int[], int, Ray, float[], float[], float[]) In the git repo's history you will also find a previous method to use false color rendering (color = object-id) to pick the object. Hope it helps. ~Sven On 12/31/19 9:18 PM, vorth [via jogamp] wrote: > First: you guys have my undying gratitude for your dedication to maintaining > JOGL, etc. My app (https://vzome.com) would have died many years ago without > your hard work. Harvey has been particularly helpful, and he even showcased > vZome as a Java3d app once, I think at SIGGRAPH. > > Now, I'm finally eliminating Java3d from vZome and using JOGL directly, and > using it without the fixed function pipeline. So far, the results are very > gratifying, and I haven't even looked at the memory profiling yet. All the > easy stuff is done, but I have a few thorny tasks left. The biggest one is to > implement picking. > > I've been digging around, looking for a reasonably straightforward sample. I > found Julien's SO post > <https://stackoverflow.com/questions/23907413/how-to-pick-objects-using-jogl>, > which led me to this sample of Sven's > <https://github.com/sgothel/jogl-demos/blob/master/src/demos/misc/Picking.java>, > which is perfect in size and scope, but it uses the deprecated OpenGL built-in > picking, and the fixed-function pipeline. > > My hope is to modernize that sample; I have already forked java-demos. I was > able to build and run the picking demo on my Mac, but it has a defect at the > moment: the picking seems to be using the wrong coordinates, so that the > results don't match the mouse location. QUESTION 1: Does anyone know if that > demo works correctly on other platforms? > > QUESTION 2: Does anyone have or know of a good demo of picking using > FloatUtil.mapWinToRay > <https://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/opengl/math/FloatUtil.html#mapWinToRay(float,%20float,%20float,%20float,%20float[],%20int,%20float[],%20int,%20int[],%20int,%20com.jogamp.opengl.math.Ray,%20float[],%20float[],%20float[])> or > FloatUtil.makePick > <https://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/opengl/math/FloatUtil.html#makePick(float[],%20int,%20float,%20float,%20float,%20float,%20int[],%20int,%20float[])>, > or really any modern demo of picking with JOGL? > > I hope to prove out picking in a sample, before I try to get it working in my > more complicated application. I'll be happy to "give back" and submit a pull > request, if I'm successful. > |
Administrator
|
In reply to this post by scott+jogamp@vorthmann.org
And of course: thank you for your kind words
+ nice to see your project being maintained. ~Sven On 12/31/19 9:18 PM, vorth [via jogamp] wrote: > First: you guys have my undying gratitude for your dedication to maintaining > JOGL, etc. My app (https://vzome.com) would have died many years ago without > your hard work. Harvey has been particularly helpful, and he even showcased > vZome as a Java3d app once, I think at SIGGRAPH. > > Now, I'm finally eliminating Java3d from vZome and using JOGL directly, and > using it without the fixed function pipeline. So far, the results are very > gratifying, and I haven't even looked at the memory profiling yet. |
In reply to this post by Sven Gothel
Thank you, Sven!
I may be confused. I thought that PMVMatrix could only be used with he fixed-function pipeline. Is it just emulating that pipeline, to allow picking to use the same logic as rendering? If so, that’s clever, but I don’t benefit from the emulation, since I’m not rendering with that pipeline. Still, I think I can see how to apply this to my geometry. My only question is: how is the PMVMatrix initialized? I’m having trouble tracking that through your source. Is this what Julien referred to as “software rendering”, in that long, painful thread from 2014? The GPU seems completely uninvolved. For vZome, I’ll be looking through potentially tens of thousands of objects, so I hope it can perform well. Scott |
Administrator
|
Hello
Sorry for the late reply. Some frameworks, libraries and engines using JOGL prefer implementing picking without using hardware acceleration, yes the GPU seems completely uninvolved in this case.
Julien Gouesse | Personal blog | Website
|
Thank you, Julien.
I finally understood how to create and use the Ray, and my picking is now working correctly, at least for objects where I can use AABBoxes (e.g. connector balls). For struts and panels, I don't think the AABBox approach will give good results, so I'll just do my own triangle intersection tests, assuming I can figure that out. Surprisingly, I can pick from among 100,000 objects without appreciable delay, so I guess I can see why OpenGL doesn't want to support it any more. I'm sure most game engines do it with physics engines anyway. |
Administrator
|
You're welcome.
(J)Bullet supports advanced collision detection, both discrete and continuous collision detection as far as I remember.
Julien Gouesse | Personal blog | Website
|
Free forum by Nabble | Edit this page |