Login  Register

Re: questions about picking

Posted by Sven Gothel on Dec 31, 2019; 8:31pm
URL: https://forum.jogamp.org/questions-about-picking-tp4040211p4040212.html

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