Simple boundingbox collision detection and prevention


I have tried to get my head around simple collision prevention for ages now, without really nailing it. Hopefully, you can help.

Our situation is this: There is a room, surrounded by walls (which are created by Box objects). In this room, we have furniture, each piece of furniture has its own bounding box. The furniture can be dragged around by using the mouse.

What I want to avoid is for any of these furniture pieces to overlap, and none of them should be able to "exit" the room either.

Shouldn't this be simple?

Collision detection is built into jME, but not collision response…

For that you will either need to use a physics implementation or write your own response algorithm…

(or maybe this will help: