Inside/Outside Physic Bounds

I'm working on space game. I want to add some levels inside a closed station, but i need to know a good way to manage wall collision detection with JME Physic 2.

Let's say my station is a cube and my spaceships a sphere. The sphere is inside the cube.

If I set physic bound (the sphere have dynamic node and the cube a static one) as usual, the sphere is throw away outside the cube.

I didn't find anything that can inverse this physic, I mean keeping the sphere inside the cube and stop it when it try to go through the cube face. Can you confirm it's not possible ?.

I thought about other solutions:

  • Create a bound for each face of cube. but for complexe shape need a lot of bound so i'll need a lot of CPU. 
  • I know we can shape bound by passing vertex positions, but i don't know if i can make hole in (Like torus). And it's not easy to make it.

    What's solution I can use to manage wall collision in closed space ?

    Thank you for your answer

try to generate the physics geometry for the sphere cube different.

that way my box wasn’t thrown out of the sphere cube.

    // create a physical copy of the existing mesh
    PhysicsMesh mesh = node.createMesh("physics mesh");

instead of

    // create geometry automatically

edit: meant cube instead of sphere

You cannot make holes. Your first solution works - model the walls of your station separately.

Thank you for your answer.

I'll apply the first solution.