Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Exactly how much more expensive, and while we're at it, difficult, is it to have non-axis aligned bounding boxes in your framework?

I realise that it very much depends on what you're trying to do, so here's a little bit of detail; My small demo framework has a number of bots running around shooting each other. when they die, they explode into cubes. When they're hit, or the bullets miss and hit a wall; more cubes.

At the moment I'm taking advantage of the fact that my framework has no floor, just walls, so you can't really tell if the cubes are resting exactly on the floor or not - as a result I'm using bounding spheres as a cheats collision detection. The main visual problem is when a bot dies from a point blank shot; the middle of the agent blows out backwards but the bottom and top parts sort of collapse into a little pile of cubes.

I'd love to be able to have much more realistic physics on all the cubes so they collide and tumble realistically over one-another.

How would I go about achieving this? and how feasible is it? to have a little physics engine which is just cube on cube.

share|improve this question
up vote 2 down vote accepted

The bounding sphere solution is an excellent start. I suggest having two spheres instead, one of radius a×sqrt(3)/2 (when those spheres do not collide, you know your cubes do not collide) and one of radius a/2 (when those spheres do collide, you know your cubes also collide).

Bounding box collision checks are not trivial, but they aren't that difficult. Usually one uses the separating axis theorem, which works with any convex shape: if an axis can be found where the projection of the two boxes do not overlap, then the boxes do not collide. Dynamic Collision Detection using Oriented Bounding Boxes from Geometric Tools is a comprehensive paper on the subject. You may also find the object/object intersection table useful because it links to sample code, too, and covers much more than box/box collisions.

As for your final question, I believe a cube/cube physics engine will be difficult. Right now you seem to be doing only static collision checks but you will soon need dynamic collisions with moving, and, worse, rotating objects, together with friction. Luckily you are not the first one to try to implement this! A good, opensource library that does rigid body physics is Bullet. There is also ODE but the project is a lot less active.

Since you are apparently writing your framework, I recommend that you try to implement your own physics engine, because you will learn and understand a lot more than if you use a third-party framework. But it will take some time. Just search online for "rigid-body" and "physics" and you will get all the documentation you need.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.