How to create a dynamic hollow container box/crate?

I know I could use 5 dynamic thin collision box shapes, but that is not good right? too much cpu, memory, if I have several crates it will be a problem.

I was thinking if I could use a simple mesh of a crate, and make objects inside it have physics somehow?

I wonder if that dynamic box collider could be a new physics space, where objects inside would be limited by it, but would still follow the physics of the world, so if the box moves, the inside objects inertia would make them pile on the inner side of the crate.
And if objects reach the top face of the box (the open one), they would be grabbed by the world physics directly again?

Can this be done in some way? even with some tricky code? I mean, I can make the tests, I just need to know if it is possible or I will just loose my time, any idea and tips?

(ugh… I would prefer to just edit my post but it is locked…)

float fWallHalfWidth=0.015f;

CompoundCollisionShape ccs = new CompoundCollisionShape();
new BoxCollisionShape(new Vector3f(fWallHalfWidth,0.25f,0.50f)),new Vector3f( 0.25f,0,0));
new BoxCollisionShape(new Vector3f(fWallHalfWidth,0.25f,0.50f)),new Vector3f(-0.25f,0,0));
new BoxCollisionShape(new Vector3f(0.25f,0.25f,fWallHalfWidth)),new Vector3f(0,0, 0.50f));
new BoxCollisionShape(new Vector3f(0.25f,0.25f,fWallHalfWidth)),new Vector3f(0,0,-0.50f));
new BoxCollisionShape(new Vector3f(0.25f,fWallHalfWidth,0.5f)),new Vector3f(0,-0.25f,0));

bulletAppState.getPhysicsSpace().add(new RigidBodyControl(ccs,1));

I use stacked physicspaces, and one óf the jme tests has local physics as well.

The inertia stuff then needs to be done by code, but is somewhat straight forward.

1 Like

@EmpirePhoenix I thought it was not possible, have to try, thx!