Few years ago I tried to make a simple 3D game - billiards. Completed like 50%, stuck with physics. Basically, I only need to calculate balls rolling over flat surface, but it would be nice to make something more flexible. I know all the formulas and laws (most of them, anyway). the problem is I have no idea of how to make good physics engine architecture-wise. I tried google and other forums but didn't find what I was looking for. The only suggestion was to look at open-source engine, but I'm not that good a programmer to make heads or tails out of it...

  • 1
    \$\begingroup\$ I wrote some things about the involved solid-body dynamics here physics.stackexchange.com/questions/13220, but as you say you know the formulas and laws this probably won't help you so much. \$\endgroup\$ Aug 30, 2011 at 17:59
  • 3
    \$\begingroup\$ I'd recommend buying a game physics book. They introduce you to all/most physics concepts one at a time, and provide the data structures you'll need. You only need to plug in the components you require, to keep it simple. They usually cover how to structure an engine too. I don't know what book is considered the 'best' however. \$\endgroup\$ Aug 30, 2011 at 18:49
  • \$\begingroup\$ @Doug, thats an answer. \$\endgroup\$ Aug 30, 2011 at 19:21
  • 9
    \$\begingroup\$ If you can't make heads or tails out of existing code, you should probably get a book about programming, not about physics... \$\endgroup\$
    – bummzack
    Aug 31, 2011 at 7:13
  • 3
    \$\begingroup\$ I'm not entirely sure there is a question here, or rather if there is, it's way too broad. \$\endgroup\$
    – user1430
    Mar 26, 2012 at 17:24

1 Answer 1


How to start an Architecture/Design Task: With pen and paper.

Get yourself a large sheet of paper and start drawing out the components and items that will exist within your engine. What properties each entity will need so that you can model the physical interaction.

You'll need to figure out what entities your code will have to deal with, which entity has the responsibility of running the physics simulation (and which bit of the simulation).

Then you'll have to figure out how the entities are interacting. Use colours.

Now go to sleep. leave the design for a few days and do other stuff. If you have some friends you can talk to, this is a good time to ask them about what they think.

Return to you design. You'll see some obvious problems and will feel the urge to make it more elegant. Do it.

Start coding from your second design. Rinse and repeat until you feel proud of your design and implementation. Then ask for criticism from people whose technical skills you respect, and realise that you've barely scratched the surface and that your engine is held together with duct tape. Rinse and repeat.

Some points:

  • There is no perfect formula for architectural systems like this. It's a matter of experience and a taste for elegance. Books may help you by exposing you to interesting ideas, but if you're comfortable with the physics, you're no more or less qualified than anyone else to design an engine.

  • Don't worry about a good engine worry about about getting an engine that runs, and move towards good from there. (even if it means you're hitting polynomial complexity )

  • Worry more about being able to communicate the way your engine works to someone else. Until you can explain your code to your mum, you don't understand what you're doing.

That last point is most important. When you get stuck, try to explain what your engine should do to a friend, on IRC, or in an email to someone whose work you respect. The act of trying to explain it to someone else will often reveal what your problem was in the first place. (You don't actually have to hit the "send" button, if you feel shy...)

If you want a good book on architecture, try The Architecture of Open Source Applications which you can read for free online. You could also watch Rich Hickey talk about how he designed Clojure: Hammock Driven Development for inspiration.

  • \$\begingroup\$ This is probably going to be shot down in flames, but nevermind... \$\endgroup\$
    – brice
    Mar 26, 2012 at 17:20
  • \$\begingroup\$ Not really, this is great advice! \$\endgroup\$
    – Amplify91
    Mar 26, 2012 at 17:28
  • \$\begingroup\$ Great advice, but doesn't really answer the question \$\endgroup\$ Mar 27, 2012 at 5:58
  • \$\begingroup\$ @VioletGiraffe because there's no answer to your question. So that's the answer: "there's no answer to your question". It'd be like answering "how do I write a poem?". You gotta be thankful he actually gave some extra insight :) \$\endgroup\$
    – kaoD
    Mar 27, 2012 at 9:40
  • \$\begingroup\$ @kaoD: I don't exactly agree, but fair enough :) \$\endgroup\$ Mar 27, 2012 at 14:32

Not the answer you're looking for? Browse other questions tagged .