[Odejava] picking objects and GeomRay

Hi all,

I’m playing around with Odejava and it seems sweet! I would like to create a app where the user selects objects with the mouse and throws them around.
My approach is to construct a direction vector from the camera position heading to where the user clicked (converted to 3D-coords) and then send a GeomRay in that direction to see if I collided with something.

Is this a good way of doing it or should I think again? Anyone who has done this using Ode (or not using Ode) are more than welcome to post code snippets :slight_smile:

Sounds like the typical approach. What graphics API are you using? I use Xith3D to generate a pick ray then test for interstections with the scene objects. I can then apply apply a force to the picked object proportional to the mouse drag length, object mass, local pick location, etc…

Edit:
Oh yeah, the force direction should probably be parallel to the view plane.

Hi, thx for the reply.
I’m using AgentFX from http://www.agency9.se. I was sort of hoping to do this stand alone from the graphics API.

Creating the pick ray can be tricky and requires some intimate knowledge of the graphics API. You need to take into account aspect ratio, field of view, projection policy, etc. I can’t think of any reason your approach won’t work provided you can create a correct pick ray and know the direction of the mouse drag.