JME Collision Detection without graphics

So I’m having a play around with jme-jbullet, got a couple of sphere’s rolling around, bouncing off one another.

One of the things I’d like to do is have the user aim and click with the mouse to have a sort of “push” effect within a small arc fairly close to the user’s sphere.

So far I haven’t done any collision detection myself at all, just relied on the jme/jbullet “magic” which has worked out well.

Unfortunately in order to get this effect it seems like the engine wants me to create a node and add it to the scene graph.

I was wondering if anyone knew of a reasonable way to test for collisions (or occupancy I suppose) within a space without actually adding a graphical component to the scene graph or a physics component to the physics space?

You can add a CollisionListener to the physicsspace.

I don’t understand… The CollisionListener will handle events, but how do I trigger an event if the spheres are not colliding?

Ah, sorry. You mean something like picking or collision testing. You can use PhysicsSpace.rayTest() and the PhysicsGhostNode for that. The first is for picking and the latter is for “check if something collides with this shape here”. The PhysicsGhostNode has a list of all objects that overlap with it. See the jmetest.bullet.* tests.