Colliding Physical objects with interior of geometry

Hi all,



As part of a data visualization tool I’m putting together in jME3, I’d like to put geometries (initially spheres) with attached dynamic RigidBodyControls on the interior of other, larger geometries with transparent textures (initially just bigger spheres). I’d like the enclosed geometries to collide with the interior of the enclosing geometry (so that they stay enclosed!), so my first thought was to give the enclosing geometry a RigidBodyControl and make it a kinematic object. However, the available CollisionShapes seem to trigger bullet collisions only when approached from the exterior, so the enclosed geometries can escape.



Is there a way to create a “shell” CollisionShape which can trap dynamic physical objects inside, or will I need to use a more involved approach such as checking for collisions and applying impulses to the enclosed objects manually when they touch the enclosing geometry?



Thanks!

Meshes, you can just not move them then.

Thanks normen, I got it working. I assume you mean to use a MeshCollisionShape created by the CollisionShapeFactory.createMeshShape method.



I had tried this before, but couldn’t figure out how to avoid the IllegalStateException(“Dynamic rigidbody can not have mesh collision shape!”) message. I tried to make a RigidBodyControl using the no argument constructor, then call setKinematic(true) on it before setting the collision shape, but was getting a NPE in PhysicsRigidBody. I haven’t quite figured that one out, but from looking at the source code realized I could use the RigidBodyControl(CollisionShape shape, float mass) constructor, but needed to set the mass to zero. Now things work fine.



If I understand correctly, I guess by setting mass to zero, I am creating a static physical object, not a kinematic one. So it appears the moral of the story is that MeshCollisionShapes can’t be used with either dynamic or kinematic physical objects, only static ones.

1 Like

Yes, exactly

Thanks again!