Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

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

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...

share|improve this question

closed as not a real question by Josh Petrie, Nicol Bolas, Tetrad Mar 27 '12 at 16:56

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

I wrote some things about the involved solid-body dynamics here, but as you say you know the formulas and laws this probably won't help you so much. – leftaroundabout Aug 30 '11 at 17:59
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. – Doug.McFarlane Aug 30 '11 at 18:49
@Doug, thats an answer. – dcousens Aug 30 '11 at 19:21
If you can't make heads or tails out of existing code, you should probably get a book about programming, not about physics... – bummzack Aug 31 '11 at 7:13
I'm not entirely sure there is a question here, or rather if there is, it's way too broad. – Josh Petrie Mar 26 '12 at 17:24
up vote 10 down vote accepted

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.

share|improve this answer
This is probably going to be shot down in flames, but nevermind... – brice Mar 26 '12 at 17:20
Not really, this is great advice! – Amplify91 Mar 26 '12 at 17:28
Great advice, but doesn't really answer the question – Violet Giraffe Mar 27 '12 at 5:58
@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 :) – kaoD Mar 27 '12 at 9:40
@kaoD: I don't exactly agree, but fair enough :) – Violet Giraffe Mar 27 '12 at 14:32

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