java3d Picking objects

1.2k views Asked by At

I am building a java3d GUI, using which users can create custom scene graphs, without needing to know the code, i want to pick specific boxes using mouse, and i want to be able to move them around.. so for that i need picking..

There are say, 2 boxes and 2 spheres in my scenegraph. I just want to pick one of them and know which one was picked. I can find out what type of object was clicked, like if i click on specific sphere, or box, i can find that out, but i dont know how can i find out which object was it, so i can process it.

Could anyone suggest me a solution to the problem? All I want is to know which object was picked. That's all.

1

There are 1 answers

0
2am On BEST ANSWER

Ok, for now the problem has been solved.
Whenever u add a box or a sphere into scene graph, you need to add custom userData to these object.

e.g. if u are adding a Box object, then

boxOb.setUserData("box1"); //this can be any datatype

when you retrieve data from picking, you just call getUserData() method on getNode() method. BAMM!! you will get the custom datatype which u set, you can process this further as per your application. Cheers :)