Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Physics For Game Developers

timothy posted more than 12 years ago | from the next-stop-geography dept.

Games 328

Richard Jones writes: "In my opinion, the most difficult aspect of writing a good 3D game is coding complex physics. If you can take away all the flashy graphics, texture maps, light and shadows from a game, and it's still at least 75% as playable and addictive, then you have an excellent game. But too many programmers seem to be ready to concentrate on the graphics, neglecting the underlying physics which make the game playable. If you compare, say, Re-volt with its fabulously detailed models of remote-controlled cars, and Carmageddon which on the N64 at least has sucky physics, well I know which one I'm still playing." He's contributed his review (below) of a book intended to help game programmers make games that aren't sucky.

Programmers who want to get serious about game physics will love David M. Bourg's Physics for Game Developers. As I've said, the subject is inherently very difficult, and the book assumes that you are already familiar with vector and matrix arithmetic up to college level, integration and differentiation, and at least you hazily recall your mechanics/physics lessons from school. You also won't be afraid to wade through Bourg's carefully documented derivations of formulae for various physical effects, and his well-commented source code.

The book starts off by recapping the basic concepts of mass, centre of gravity, moment of inertia and inertia tensors. Bourg assumes that you have a working grasp of these subjects, and I admit that I had to go back to some of my A-level mechanics text books. He then goes straight into kinematics, where he uses standard (but forgotten!) integration techniques to calculate velocities from accelerations and positions from velocities. His examples are excellent, although a few exercises wouldn't have gone amiss. The chapter on forces covers a great many different types of forces such as springs and buoyancy, but curiously omits the important subject of contact forces (the normal force that a table, for instance, exerts on your computer monitor to stop it falling through the floor). In fact contact forces don't appear until much later in the book. Particles, rigid bodies and impulses (forces from collisions) are introduced in chapters 4 and 5.

At this point I have to say I was a little bit confused. What did this have to do with game programming? Everyone knows that games spend most of their time running round a single big "main loop," working out the forces on each object, looking for collisions and working out which keys the user is pressing. It doesn't seem imaginable that a game programmer could completely solve all the equations of motion by pure integration at the beginning of the game, and then just run the positions of the players through the graphics engine like a movie!

I already knew a little about this from what I'd found from the web, but what most games actually do is calculate all the forces on all the objects (players, scenery, etc.) in the game, and then integrate them at each step. Some of these forces will be generated by human players pressing keys on the keyboard or wiggling the joystick, and that's how the objects end up moving. Pure integration isn't usually possible, so the physics engine performs numerical integration - a kind of fast approximation to the pure "closed form" solution. Numerical integration is itself a tricky subject, but it's the meat-and-veg of good game programming. Surprisingly, numerical integration and a realistic main loop doesn't appear until chapter 11 (172 pages into the book). I skipped straight to this section, and I suggest you do so too...

The chapter on numerical integration is excellent and contains the first realistic gaming (or at least simulation) code. Many games I've examined use simple numerical integration, like this:

// At each step ... A = acceleration, dt = time step
Vx += Ax * dt;
Vy += Ay * dt;
Sx += Vx * dt;
Sy += Vy * dt;

Unfortunately this method (Euler's method) is very inaccurate and unstable: if you tried to simulate planets orbiting around a sun using this method, they'd soon fly off into outer space unrealistically. Bourg gives an excellent introduction to better methods such as the "improved Euler" method and the popular Runge-Kutta method, and he covers them in a context which will make it clear how to use these methods in your own programs.

The book reaches a crescendo with three fully developed simulations: two hovercraft which you can drive around and jolt into each other like bumper cars -- they spin around realistically; a flight simulator; and a 3D car which can be crashed into blocks that bounce around. Again the source code is meticulously commented and generally well written. My only two reservations about the code are: It would be nice if Bourg had chosen to use OpenGL instead of Direct3D so that those of us without regular access to Windows could actually compile and run the examples. The book would make an ideal companion to the OpenGL Red Book. And coming firmly from the Windows camp, Bourg's examples are full of all the horrors of Win32 APIs and Hungarian Notation. But maybe that's just my personal preference :-)

So in summary: The Bad Points:

  • Measurement systems: Bourg moves uneasily between the English/US system and the European SI units. So we get examples which combine ft/s, meters, slugs and kilograms, uneasily converting between the two. He should have chosen one system and stuck with it.
  • A common complaint about computer books: I've just spent 25 quid on a book which will sit open on my desk for months. Is it too much to ask that it be ring bound?
  • Some subjects are not explained in enough depth. Particularly: moments, contact forces, impulse methods. Bourg should probably have written a chapter or three on collision detection.
  • The chapters are presented in a very strange order. Move chapters 6-10 until later, or introduce numerical integration earlier.
  • A few of the illustrations are inaccurate.

and The Good Points:

  • Considerably better than the usual round of maths/physics text books which make up this field. In fact, this is really one of only about 2 or 3 significant books in this area which are pitched for game developers as opposed to mathematicians, and it's certainly the best.
  • The areas which are covered are done well, in significant depth, with a good bibliography where you can find out more.
  • The commentary on the difficult equations is good, and Bourg resists the temptation to derive many of the formulae he presents, instead referring interested readers to other references.
  • Code is well documented and explained.

And now I suppose I have no excuse not to resurrect XRacer :-)


You can purchase Physics for Game Developers at Fatbrain

Sorry! There are no comments related to the filter you selected.

First post! (-1, Offtopic)

Anonymous Coward | more than 12 years ago | (#2719774)

Merry Christmas people

The only physics you need to know (-1, Troll)

Anonymous Coward | more than 12 years ago | (#2719778)

Is how fat kids that play games all the time can get.

FIST SPORT!

hmmm.... (0)

dedicke (91848) | more than 12 years ago | (#2719785)

me'sa confused - i likes to play pretty games tho sho nuf!

SXP! (-1, Offtopic)

Anonymous Coward | more than 12 years ago | (#2719790)

Second Xmas Post!

Merry christmas, happy hannukah, happy yule, or whatever.

Here's something 'ring-bound' for you! (-1, Troll)

Anonymous Coward | more than 12 years ago | (#2719804)

The One Ring [goatse.cx]

Baldur's Gate for PS2 (3, Interesting)

sam@caveman.org (13833) | more than 12 years ago | (#2719806)

i've played a lot of games, and gone 'wow' at some of the eye candy, but if you've played baldur's gate for PS2 you know that the coolest thing that has ever been coded for a game is the WATER for this game. you leave a wake behind you when you walk through it, you splash when you jump in, and ripples interact and reflect from the shore. maybe the physics aren't 'perfect' or whatever, but the realism of the water was enough to really 'immerse' myself into the game.

-sam

throw physics out the door... (1, Interesting)

mrroot (543673) | more than 12 years ago | (#2719821)

Somestimes games are actually more fun if they defy the laws of physics. Such as being able to jump 20ft in the air (I can only jump about 2ft myself). Don't get me wrong, it has to be somewhat realistic, but any good game will also be a little unrealistic too.

Re:throw physics out the door... (2, Insightful)

SuzanneA (526699) | more than 12 years ago | (#2719863)

IMO, the best solution is to have the physics definitions modular, or at least programmable. This is one of the advantages of UT, its physics can be overriden fairly easily.

Even on games where there doesn't appear to be any need for modular physics, there will always be some mod author that sees a need. Say you are writing a racer, you might think that the physics should be fixed to real-world physics, but the mod author that wants to write a 'dune buggies on the moon' mod, is going to disagree with you, so keep it modular :)

Re:throw physics out the door... (1)

ackthpt (218170) | more than 12 years ago | (#2719900)

Well, yeah, and what happens in reality if you jump off a twenty foot building is you hit the ground fast. Where Mario the plumber has to jump slowly enough so you can follow him on the screen, essentially playing in slo-mo.

Physics eye-candy is something I've enjoyed in a few games. The actual movement of characters or other objects is smooth, fluid, looks good and might even be coupled with decent sound effects. The last exceptional game I knew by those characteristics was something with an air car on an Amiga. Sadly, I lent the disk to someone who moved and I never saw it again.

Want to become good at pattern games? Play (and die a lot) at high difficulty levels, then go back and play at medium or whatever. Your reaction timing is improved and you'll do better.

To achieve the sharpest blade, use the hardest stone.

Re:throw physics out the door... (1)

Manic Miner (81246) | more than 12 years ago | (#2719917)

I know what you mean, but being able to jump 20ft into the air doesn't mean that you've "thrown the physics out of the door", all it means is that gravity is less in that particular world / game.

Don't get me wrong, I enjoy games that don't stick to realistic simulations. But having objects in the game interact in a way that is based on a real physical environment, albeit with modified constants to keep the game "fun", makes the game much easier to play because the environment behaves in the way you expect, and is predictable.

Re:throw physics out the door... (0)

Anonymous Coward | more than 12 years ago | (#2719961)

It isn't necessarily important that the physics rules be the what we expect. I just want them to be consistent. If I can jump 20 ft in the air, I'd like to be able to kick something of a comparable wait a comparable distance. I just want it all to fit together.

Physics in games (2, Insightful)

shd99004 (317968) | more than 12 years ago | (#2719823)

I remember a good old game called "4D Stunts Driving" or something... That had a pretty interesting physic. Often it was sufficient to just bump into another car and you would go up in flames and millions of pieces. Or, if you reached high enough speed in the jumps, you could get such an angle, you would fly right into the athmosphere, and if you changed the camera POV, you could maybe see the car as a few pixels high in the sky. I think that, though, is part of the charm with this game. That, and the music :)

Re:Physics in games (1)

geekster (87252) | more than 12 years ago | (#2719890)

That and the fast racing car, get it up to maximum speed and it just wouldn't slow down again.

How about "extreme game programming"? (3, Insightful)

YouAreFatMan (470882) | more than 12 years ago | (#2719825)

One idea might be to pair up a design-minded developer with a science-minded programmer. Kind of the right-brain/left-brain thing. Not that there isn't overlap, but usually someone is better at one than the other. And even if someone has both good design and scientific skills, it is hard to practice them at the same time. I know I have to take time to "switch" modes when going from creative stuff to more technical stuff.

So pair up a couple of guys. One to worry about the artistic design, and another to worry about realistic physics.

Re:How about "extreme game programming"? (2)

scott1853 (194884) | more than 12 years ago | (#2719923)

I remember reading a couple years back that some game developer hired an actual physicist to help develop their Golf game. I can't for the life of me remember what company it was though.

I'm with you on switching modes between creative stuff and technical though. Although I guess it depends on what you're doing. If all you're doing is coding, then since that's all logic, physics should fit right in there with it.

My biggest problem is switching between programming and graphic design. Oh the headaches.

Re:How about "extreme game programming"? (1)

Mr. Quick (35198) | more than 12 years ago | (#2719924)

this is a great idea... we implemented XP for our site design... although using J2EE, there is a separatation between presentation layer and logic layer, it turned out that the design of the site worked better when a "holistic" approach was taken... one java developer and one design pro

of course explaining j2ee methodology to artsies was an exercise in patience... hahah ;)

Re:How about "extreme game programming"? (2, Insightful)

_Ash_ (126458) | more than 12 years ago | (#2719952)

This is already going on between companies. For instance, think about John Carmack. He writes 3D engines and produces games with them. However, his last effort, Quake 3 is a bit mediocre. But after a few months games come out that are a lot better which use the Q3 engine.
Actually, Half-Life is based upon the Q2 engine and is a lot better than Quake 2 itself.

Maybe John Carmack should just focus on building 3D engines which game developers could than use to produce brilliant games.

Physics isn't everything (3, Insightful)

alen (225700) | more than 12 years ago | (#2719828)

Some people aren't into super realistic physics. Some don't want to read a 300 page manual for a flight sim and spend weeks figuring out the flight model. They would rather just grab a joystick and start playing like in Wing Commander.

Re:Physics isn't everything (4, Interesting)

arkanes (521690) | more than 12 years ago | (#2719886)

The space sim Terminus is great in this regard - when you start the game, you can select the level of reality in your physics - anywhere from (almost) 0, to full Newtonian. So if you just wanna blow stuff up, go for 0, and if you want to have to worry about carefully calculating your path so you take maximum advantage of gravity and don't waste fuel on course adjustments, you take full. Great stuff. I reccomend the game, BTW, fantastic gameplay even if the graphics lack by todays standards.

Re:Physics isn't everything (2)

foobar104 (206452) | more than 12 years ago | (#2719899)

Some people aren't into super realistic physics. Some don't want to read a 300 page manual for a flight sim and spend weeks figuring out the flight model. They would rather just grab a joystick and start playing like in Wing Commander.

Whether the physics model is realistic or not, every game has to have one. Even if you choose to calculate position, motion, and reaction and stuff in a way very different from the one that applies to the real world, you have to calculate those things somehow.

That's the point of this book.

A better book to read for Game Physics... (3, Insightful)

FortKnox (169099) | more than 12 years ago | (#2719834)

Its called "Physics for Scientists and Engineers".

Lets face it, the best physics is REAL physics.

If you want your game to have good physics, then slap a good physics engine (based on real formulae) into it!

Re:A better book to read for Game Physics... (2)

ChazeFroy (51595) | more than 12 years ago | (#2719852)

Physics for Scientists and Engineers, 5th edition [amazon.com] .
ISBN: 0030317169
Price: $143.00

Re:A better book to read for Game Physics... (0)

Anonymous Coward | more than 12 years ago | (#2719859)

Geez, when I was in school, we were on the 3rd edition (or was it 2nd?). Now I feel old.

But it was a great physics book!

-FK

or try a free one (1)

bcrowell (177657) | more than 12 years ago | (#2719950)

Either pay $143, or try a free book here [theassayer.org] .

Re:A better book to read for Game Physics... (2, Insightful)

whatnotever (116284) | more than 12 years ago | (#2719920)

You can't use real physics. Real physics lives in the continuous time domain, with differential equations and such. Games, on the other hand, live in a strange land of discrete, variable-sized time-steps. You can't just throw your differential equation at it and say "Be realistic!"

Sure, the formulas used are *based* on the regular "scientist" formulas, but they *have* to be approximations. The book tells you how to use do those approximations.

If you give a coder a standard physics textbook and tell him to code a physics engine, he'll either implode or spend ages working out numerical methods for approximating real physics... exactly what is in this book.

Re:A better book to read for Game Physics... (2)

Imabug (2259) | more than 12 years ago | (#2719976)

Numerical Recipies I think would also be a good addition to a game programmer's library wanting to introduce more realistic physics. It covers a good deal of numerical computing algorithms from integration to simulation.

Physics texts cover the physics behind the action, but a book like Numerical Recipies goes over the implementation and would be a very good complementary book.

The other thing to keep in mind is that the more accurate the physics gets, the more computationally intensive the game becomes, so a game may not be able to achieve those 150 fps everybody seems to want when doing accurate physics simulations.

Re:A better book to read for Game Physics... (2)

gowen (141411) | more than 12 years ago | (#2720008)

Numerical Recipies
The trouble with that is I'll either have to by another copy of the book or code my first-person-shooter in FORTRAN...

Re:A better book to read for Game Physics... (2)

Imabug (2259) | more than 12 years ago | (#2720011)

[amazon.com]
Numerical Recipes in C : The Art of Scientific Computing

Comes in a variety of flavours including C++ and Fortran.

Carmageddon (1)

Professeur Shadoko (230027) | more than 12 years ago | (#2719838)

IMHO the game has good physics, if you don't count the car handling himself (who sucks, really)

Re:Carmageddon (2)

British (51765) | more than 12 years ago | (#2719850)

I just started playing Camageddon 3 TDR again(with the cheats ON sice I wanted to try out the missions), and I didn't observe until now, but your car falls in slow motion, ALL THE TIME. heh. Still,, fun game.

Re:Carmageddon (1)

simetra (155655) | more than 12 years ago | (#2720030)

Carmageddon is great. The physics are real enough (i.e., if you fall really far, you get hurt). Plus, there are some fun powerups, like helium-filled zombies, which tweak the physics aspect as well, or Gravity From Jupiter, which makes your car very heavy. This is all on the pc version, I don't know (or care) about console version.

Don't need to be that exact (2, Insightful)

joshv (13017) | more than 12 years ago | (#2719842)

I really doubt that your method of numeric integration is going to be that critical an influence on the quality of game play. In fact I think that you ability to simulate physics without really doing the math would be more important. I doubt anyone is going to be timing a car's drop off of a cliff in Carmegeddon to determine what gravitational constant is used in the game.

I think it is more important to include as many effects as you can: gravity, linear momentum, angular momentum, elastic/inelastic collisions, friction (surface and wind), than it is to model the effects perfectly.

In fact one could argue that it is to the game designer's benefit to use an innaccurate and exaggerated physics model. Most real world collisons with the guard rail on a race course are relatively unspectacular (by design) - but that would be oh so boring in a racing game now wouldn't it?

-josh

Re:Don't need to be that exact (1)

FortKnox (169099) | more than 12 years ago | (#2719880)

You bring up one extremely important point.

Games need to be fun.

Lets look at Revolt and Carmaggedon again. Carmaggedon is a more popular game. Not because of the physics engine, but because it was a more fun game.

With that in mind, its best to decide if physics is important to the game. For stuff like flight sims, yeah, good physics. For stuff like Doom.... not really.

Re:Don't need to be that exact (1)

MrFredBloggs (529276) | more than 12 years ago | (#2719960)

Too much realism is boring...thats why we play games.

When did you last see a film that conformed to reality? I dont think i`ve ever seen any sort of stunt - from cars flying off roofs to something as simple as a guy jumping forward and shooting a gun - without it actually involving a number of cuts/edits; ie the guy jumps forwards, you see him coming down again - suddenly it cuts to another camera and hes now moving down *and forward*.
It doesnt matter! The problem with games isnt that they are unrealistic (!), its that most of them are *me too* games.

Re:Don't need to be that exact (2)

foobar104 (206452) | more than 12 years ago | (#2719962)

I really doubt that your method of numeric integration is going to be that critical an influence on the quality of game play.

If your game lacks a good physics model, players are going to find that it "feels funny." They don't mean that it isn't realistic, rather they mean that your game isn't consistent.

People are incredibly good at figuring out their environment, even if it's a different environment from the one they grew up in. But if the environment isn't consistent (read, "the math is isn't very good") you can tell intuitively.

That's why a good physics model is important.

Re:Don't need to be that exact (5, Insightful)

skoda (211470) | more than 12 years ago | (#2719967)

There's a difference between "unrealistic" and "unstable".

Unrealistic suggests that it doesn't behave as in the real world -- but that doesn't mean it isn't modeled on the same principles (acceleration, momentum, etc.) And you still want to simulate it consistently; it should "feel" right.

But an unstable computation method can "blow up", regardless of realistic or unrealistic "physics."

Consider:
Jump pads in games like Quake or Unreal are "unrealistic". But they are modeled at least partially on physics. But to make them work right, in all their unrealistic glory, the computation method must be stable.

If it wasn't stable, then you might something like:
- Multiple, successive jumps on one would lead to a "blow up" where the player would be wildly, and unexpectedly shot through the roof and to the outer edge of the game universe.

For both realistic and cartoon physics, you need accurate and stable computation methods.

Re:Don't need to be that exact (-1)

CmderTaco (533794) | more than 12 years ago | (#2719971)

It all depends on the game. There are some games that I believe NEED to have as close to real world physics as possible for the best game play. Some you need less real world physics, but at least keep it realistic. Take Unreal Tournement. You can play with fairly realistic physics, or off the wall physics. Getting a sniper rifle and jumping 300ft over everyone to zoom in and shoot them is no fun in my opinion.

Re:Don't need to be that exact (1)

Warvi (544623) | more than 12 years ago | (#2719985)

I think it is more important to include as many effects as you can: gravity, linear momentum, angular momentum, elastic/inelastic collisions, friction (surface and wind), than it is to model the effects perfectly.

And books like this tell you how to implement them (and how to do it right). If you implement a physics engine, you can do a (semi)realistic one. It doesn't take that much more time to do it right. Even more people (me maybe) would have bought carmageddon if it had felt just a little bit more like driving a real car.

Great... (1)

ackthpt (218170) | more than 12 years ago | (#2719844)

I've been lugging my college physics book (Fundamentals of Physics, 3rd Edition, Halliday and Resnick) around for the last week attempting to reassemble my knowledge of physics for my own take on Scorch. Of course both books offer what I need, however college textbooks without the notes (I swear I still have them somewhare) are often difficult to use, as there are gaps, which the lecture usually fills in, which this handy book _should_ cover, thus saving me from reassembling the few equations I'll need.

OTTOH, I'll either need or just make up constants for elasticity, friction, etc., which I used to do to accomdate display restrictions, like on a VT52 or a 600x400 screen. Adapting real math often produces bizarre simulated behavior on the small screen, so fudging is often called for.

This is a shit comment (-1)

cmdr_shithead (527909) | more than 12 years ago | (#2719845)

AMENIA!!NEW YORK!!! hello lameness, your name is malda

Animation and the Cartoon Laws of Physic (0)

Anonymous Coward | more than 12 years ago | (#2719846)

Better check out the Cartoon Laws of Physics [mbhs.edu] . It always amazed me how Chuck Jones and Max Fleischer had such an instinctive, albeit exaggerated, understanding of the laws of physics in their cartoons. You can't be a good animator (or game designer) without understanding of the Cartoon Laws of Physics.

In defense of Carmageddon... (1)

HaveBlue (35622) | more than 12 years ago | (#2719847)

The PC versions of the Carmageddon games (the console versions came out later) have superb physics. It's fun just to explore the course in search of ramps and hills to jump off of. If I remember the game notes correctly, the development team for the first game included someone with a Phd in physics. Heck, the engine for the second game even allowed for magnetism, but the feature never got enabled in the released version (there was a big electromagnet on a crane in the junkyard that you would have been able to drive under and get stuck to - the video that the dev team released looked fantastic). But at any rate, I must agree with the fact that good physics can make or break a game.

Re:In defense of Carmageddon... (2)

Pfhreakaz0id (82141) | more than 12 years ago | (#2719999)

Yeah, the technology wasn't always realistic (how exactly did the balls of flame track down and chase the pedestrians -- I mean zombies) but it was a CONSISTENT model.

I loved pondering... "OK, so I need to get the speed up powerup and hit this ramp at such a speed at this angle to bounce off the wall of the building and fly JUST over the tower to get that platinum power up and land on the building over there."

Re:In defense of Carmageddon... (1)

Gehenna_Gehenna (207096) | more than 12 years ago | (#2720042)

Nothing against carmaggeddon, which is an enjoyable game in it's own right, but if we talk about physics and cars in video games we msut speak on Gran Turimo 3. Superb control , superb physics, superb graphics. GT# is a great example of how realistsic physics can be well incorprated into a game and still keep it fun.

Greatest game of all time... (2, Funny)

Iamthefallen (523816) | more than 12 years ago | (#2719849)

If you can take away all the flashy graphics, texture maps, light and shadows from a game, and it's still at least 75% as playable and addictive, then you have an excellent game.

Is it just me, or does that describe Pong perfectly?

Note: Greatest game of all time referes to the classic version, 2 controls, 1 console, 1 tv, 1 wasted childhood.

Re:Greatest game of all time... (0)

Anonymous Coward | more than 12 years ago | (#2719860)

I'm too young to have played that. I think it got out in 1974, right?

Re:Greatest game of all time... (1)

Iamthefallen (523816) | more than 12 years ago | (#2719901)

According to this page [pong-story.com] it was 1972 :-)

on numerical integatration in programming.. (0, Informative)

Andreas(R) (448328) | more than 12 years ago | (#2719862)

It was actually pretty interesting to see how this aricle mentions that numerical integration is done in computer games by means of Eulers method. But: Good old Euler is slow and inaccurate!

Simpsons method is more accurate method to integrate, since it creates a exponential polynome that more accurately represents the function. The method follows:

S(n) = dX/3(y(0)+4y(1)+2y(2)+4y(3)+ ... + y(n))

Use this in your gameengine the next time, and impress!

Re:on numerical integatration in programming.. (0)

boltar (263391) | more than 12 years ago | (#2719930)

I'd love to ... if you'd care to mention what
the variables in your equation actually stand for.

Well... (1)

Anonymous Coward | more than 12 years ago | (#2719871)

"In my opinion, the most difficult aspect of writing a good 3D game is coding complex physics."


This beleif is why CompUSA is filled with games that suck. This is because, quite simply, the most difficult aspect of writing a good 3D game is NOT coding, it's coming up with a good idea and having good artists and map makers so that the game is worth playing in the first place. This is why the PSX and Game Boys are still popular, even though they have "primitive" graphics.

Lack of physics (-1)

CmderTaco (533794) | more than 12 years ago | (#2719872)

The lack of physics in some games has been turned into a feature of the game. Look at THPS2. It has the lunar gravity cheat so you could do like 1000 tricks in just 1 jump. I don't like it very much because it takes no skill to be able to do, but some people love it.

Rainbow Six was awesome because there was so much you could customize about the physics because it was all stored in an .ini file. You could change gravity, how fast you threw flashbangs and grenades, how far you would throw them, how long till they exploded. It was great!

Grand Prix Legends (2, Interesting)

Anonymous Coward | more than 12 years ago | (#2719876)

The game may be three years old, with (originally) dodgy graphics, but it had the best car physics engine of any PC driving game. You could actually get a feeling for what the car was doing, how it was sliding etc, and in a '67 F1 car, which slides a lot, that was a big help.
It's still one of the most popular games in the driving sim community, with new mods and graphics appearing almost daily, but in the end it's the physics that draws people in. Yah it's hard to drive, but it should be hard to drive, and once you learn it, you'll never look back.

i just bought this book online.... (3, Informative)

Mr. Quick (35198) | more than 12 years ago | (#2719881)

..although i picked the cheapest form of delivery so it won't be here for a bit more time...

i read thru the sample chapter [here] [oreilly.com] it's all about particle physics. i was quite impressive, i enjoy the *conversational* style that most o'reilly books have.

i implemented all of the examples in java using java3d. [j3d.org]

i hope the book meets my expectations....

Producing position from LatG, LongG, and FwdV (2)

DG (989) | more than 12 years ago | (#2719882)

Maybe this book has an answer to a question that's been on my back burner for a while, and for which I've been unable to find a good answer for while surfing.

Suppose you have a device that records lateral acceleration, longnitudnal acceleration, and forward velocity, with 100 samples per second, and stores them in a text file, one sample per line, one value per column.

Given the file parsing routine is a gimme and thus provided the values for elapsed_time, LatG, LongG, and FwdV, produce a function that will return the current X and Y co-ordinates of the vehicle, so that its ground track can be represented in a diagram.

Anybody got any good sources of information (or better yet, an existing library) for how to do this?

No, this is not an exam question. ;)

DG

Re:Producing position from LatG, LongG, and FwdV (1)

SamBeckett (96685) | more than 12 years ago | (#2719906)

You can only do a position function if you know the initial position. The rest is easy-- just use the numerical integration techniques the book talks about. It's simple calculus.

Re:Producing position from LatG, LongG, and FwdV (2)

DG (989) | more than 12 years ago | (#2719933)

Hrm, m/"Calculus" and "simple"/"oxymoron"/ for some people, including me.

My attempts at reproducing this from my old numerical methods textbook produced unrecognisable squiggles

Assume the start position is the origin. Can you post (or link to) example code?

.

Velocity Verlet algorithm (2)

edremy (36408) | more than 12 years ago | (#2720029)

Here's the Velocity Verlet algorithm for this setup. (I have to use the VV algorithm: my PhD advisor invented it :^)

  1. Start with a set of positions r and velocities v at time t, r(t) and v(t) We'll move them in some small timestep of length dt.
  2. Compute the forces F(t) on the particles at position r.
  3. Compute the accelerations a(t) on the particles by F(t)=m*a(t)
  4. Compute new positions at time t+dt by r(t+dt) = r(t) + dt*v(t) +0.5*dt*dt*a(t)
  5. Advance velocities by v(t+1/2dt) = v(t) + 0.5*dt*a(t)
  6. Compute forces at new positions, F(t+dt) and accelerations a(t+dt)
  7. Finish updating velocities by v(t+dt) = v(t+1/2dt) + 0.5*dt*a(t+dt)
  8. Goto step 4 for as long as your CPU doesn't melt.



The VV algorithm has a lot of advantages: it's simple, stable provided dt is small enough, and unlike straight Verlet is self-starting given an initial velocity set.

Eric

Re:Producing position from LatG, LongG, and FwdV (1)

SamBeckett (96685) | more than 12 years ago | (#2720041)

I tried posting sample code, but the lameass lameness filter caught it. Anywho, Calculus is easy. Here is a quick and dirty tutorial:

If you have a polynomial in x, f(x) = a_0 + a_1 x + a_2 x^2 + ..., then

The integral of f(x), F(x) is
a_0 x + (a_1 / 2) x^2 + (a_2 / 3) x^3 + ...

The derivative of f(x), f'(x) is
2 a_1 x + 3 a_2 x^2 + 4 a_3 x^3 + ...

Using this, you can translate that into psuedo code or whatever.. Just remember...

If your acceleration is a(t), your velocity is v(t) = Integral of a(t) plus your initial veloctiy, your position s(t) = Integral of v(t) plus your initial position.

Mmm. Dead. (1)

JMZero (449047) | more than 12 years ago | (#2719951)

Dead reckoning like this produces bad results. Unless you have a laser gyro or something crazy. Any loss in angle measurement is going to compound fast (unless you take angles in some constant way, like via gps - in which case why are you dead reckoning). What sort of project are you doing? I'd make sure you don't have some other way of finding position.

Re:Mmm. Dead. (2)

DG (989) | more than 12 years ago | (#2719983)

I agree with you on the ever-compounding inaccuracy of dead-reckoning.

The good news is that I only have to do it for 30-60 second stretches.

I've also heard that one can correct somehow the wander/error from the integrated acceleration values by examining the forward speed value (which is produced by a separate sensor) - ie, work out the velocity from the accelerometers, and then compare the magnitude to the forward speed sensor, and correct the ground track from that. I haven't a clue on how that works, but I've seen evidence that it can be done.

As for what the project is... see farnorthracing.com :)

.

Re:Producing position from LatG, LongG, and FwdV (1)

ackthpt (218170) | more than 12 years ago | (#2719998)

Ever tried this with polar math? I'm considering doing something this way and wonder if I'm off my rocker.

Re:Producing position from LatG, LongG, and FwdV (2)

interiot (50685) | more than 12 years ago | (#2720009)

There's a variant of that problem used for weapons systems and such... If you combine an intertial sensor with GPS, you get a very accurate version of GPS, without the accumulated integration error. Here's a random link to an intertial GPS system [applanix.com] . The algorithm is somewhat laid out on page 5, but you may be able to find more by looking into this topic.

Who needs physics.... (1)

Wells2k (107114) | more than 12 years ago | (#2719889)

...when you can turn on the "Winds of Space"

--Steven Levy fans will understand...

Decision Making (2, Interesting)

3141 (468289) | more than 12 years ago | (#2719893)

I agree, in some games, realistic physics can make a big difference. I remember when I first played Super Mario Bros. 1 on the NES, seeing how the fireball bounces along in a straight line until it gets to a hole, and actually falls down, I was rather impressed. (Small things, small minds, whatever. I liked it.)

However, in modern 3D-type games, it's important to pick and choose where you spend your time coding in the physics. In a racing game, it's a lot more important to spend time making sure the cars handle correctly than how realistically the trees sway in the background.

Unfortunately, there just isn't the time to make everything about the game perfect, and it's sad to see when a program has missed it's spot because of delays in implementing useless features.

Re:Decision Making (2)

onion2k (203094) | more than 12 years ago | (#2720004)

In a racing game, it's a lot more important to spend time making sure the cars handle correctly than how realistically the trees sway in the background

In my new game the exact opposite is true.. I really hope Ultra Mega Pine Sim is a success..

Not just for games (0)

iiii (541004) | more than 12 years ago | (#2719904)

I'm not a game programmer, but my current project is a simulation with lots of trajectories, global coordinates, points of view, and interactions. This sounds like the perfect reference for what I've been doing. It's going on the xmas list. I only wish the reviewer had told us what language the examples are in.

more fun blowiung up stuff with accurate physics (3, Interesting)

thex23 (206256) | more than 12 years ago | (#2719914)

Realistic physics? Yes, please!

I want a FPS that lets you blow holes in walls, accurately representing physical damage from weapons. Imagine Counter-Strike with realistic bullet physics: ricochets, windage, and weapon recoil that isn't predefined.

Hacking physics though, now that's a job and a half: figuring out a quick and dirty method of approximating the complexities of the real-world, and still have it look natural, making it look like a real environment filled with objects that have familiar properties and behaviours. And then blowing them up, REAL GOOD.

Re:more fun blowiung up stuff with accurate physic (1)

jsonic (458317) | more than 12 years ago | (#2720005)

Try Red Faction. You can blow holes in the ceiling, floor, walls...the game actually depends on you doing this to advance through the levels.

Really fun in deathmatch mode since you can blow a hole in the wall and hide in it.

Richard Jones? (0)

Anonymous Coward | more than 12 years ago | (#2719919)

Wasn't Dick Jones shot out a window by RoboCop?

Damn, that guy's tough if he's still able to write book reviews.

Halo - worst physics I've ever seen (0)

Anonymous Coward | more than 12 years ago | (#2719922)

Is it only me, or Halo (on Xbox) has some of the worst physics engine I've EVER seen? (did you try driving the "jeep"? This thing handles like crap).

Re:Halo - worst physics I've ever seen (0)

boltar (263391) | more than 12 years ago | (#2720016)

Maybe you have to find a garage and get a mechanic to give it a service pack :)

Looks interesting, but could be disappointing (1)

akiaki007 (148804) | more than 12 years ago | (#2719937)

Well, while it covers an important topic which many look over, I don't think that it's going to teach me anything new.

If you are at the stage where you are game programming, I would hope that you know the basics of Newtonian Physics. If you don't, then you didn't really do anything in college, or on your own (whichever way you were educated). In reality, you should have basic understanding of how things work, and be able to code this as well.

You shouldn't be forced to read a book that tells you how to create physics models in your game world. I am hoping that this book does more than just implement the basic acceleration formulae.

articles on physics & collition detection etc (2)

acomj (20611) | more than 12 years ago | (#2719947)

check out gamasutra [gamasutra.com] has a lot of feature [gamasutra.com] articles on many aspects of game design. Dig around them, they are good to read and usfull. I think they require a registraction now to read the articles...

Carmaggedon's physics (1)

Telastyn (206146) | more than 12 years ago | (#2719948)

The game had wonderful physics, just not *realistic* physics. The wildly over the top game would've suffered quite a bit if it was limited by 'the real world'.

Numerical Integration Methods (1)

Ivan Raikov (521143) | more than 12 years ago | (#2719949)

I believe one of the most accurate numerical integration methods is the famous LSODE (Livermore Solver for Ordinary Differential Equations), an implementation of which is available at http://www.netlib.org/odepack/ [netlib.org] .

Another one is VODE, which is based on LSODE. http://citeseer.nj.nec.com/1230.html [nec.com] . I think both are more accurate than Runge-Kutta.

Cmdrtaco raped a penguin! (-1, Troll)

Anonymous Coward | more than 12 years ago | (#2719957)

And he force fed it a "special taco" and "taco snotted all over it!

Tribes 2 (2)

Apreche (239272) | more than 12 years ago | (#2719958)

Tribe 2 has the best game physics ever in my opinion. It's a shame that there arne't people playing it anymore. The only reason it went down the tubes is because there aren't enough non-mod servers. Just about every server runs some variant on the game. As soon as I get a new computer I'm setting up a non-mod Tribes 2 server and me and my friends will rock the house again.

Re:Tribes 2 (2)

British (51765) | more than 12 years ago | (#2720003)

The Shifter mod for Tribes 2 made the game not even worth bothering playing. All the weapons were way too powerful, negating any sort of weapons skill. There were also an excessive amount of classes that seemed to make little sense(Team Fortress Tribes?) and goofy items like the all-white jetpack made the game grossly unbalanced. One seasoned player could keep capping the flag over and over while everyone else was trying to figure out the weapons, classes, and strangely named items.

Different Constants (2)

ZigMonty (524212) | more than 12 years ago | (#2719959)

Some people are saying that games are meant to be unrealistic: jumping higher, unrealistic strength etc. This doesn't mean abandoning physics, it just means changing a few numbers. Lower the gravitational acceleration constant you're using and the player will jump higher while the jump will still look right. Most of the exagerations games use can be done in this way. One exception is being able to change direction while in mid air. In some games it works, in others it just looks really stupid.

There was a good article a while back in one of the mags (Scientific American?) i get about a team putting even more physics into games. If you shoot someone in the shoulder, they spin a bit etc. They were trying to make bullet hits look more real (as in reaction not gore). Anyone have a link?

Must be available as a library (2)

The Cat (19816) | more than 12 years ago | (#2719964)

As fascinating as the book sounds, individual developers or teams that are writing (and debugging, and debugging, and debugging) code to calculate the acceleration of a mass on a curved path are not using their time productively.

These functions are based on laws of physics, and should be the last thing to be reinvented.

Game development as a whole will be of a far higher quality when games don't have to be developed one molecule at a time.

if only I studied physics instead of cs... (1)

jodonn (516010) | more than 12 years ago | (#2719970)

The situation is improving, but unfortunately many CS programs at universities still don't require physics. Physics was optional at mine, so of course I didn't take any, not knowing how critical it could be later in my career.

On the other hand, the inherent problem with domain-specific software is that those who know how to program the software are the ones who don't understand the domain. Computer programmers can't be expected to study everything in the case that they might someday be called upon to code a gene sequencing program or a complex financial application or psychological model. This tends to result in bad software written by people with no training and little experience in software development.

Don't get me wrong--I don't mean to be elitest here, but in the few times that I've had to work on domain-specific programs written by domain-specific people, I've found that the existing code was very difficult to maintain.

Re:if only I studied physics instead of cs... (0)

boltar (263391) | more than 12 years ago | (#2720031)

Most CS people (aside you from it seems) have done science at school. Physics is not a big
deal really , just find the equations from a book then code them up. Just like any other sort of
maths problem. The HARD problems are ones where there is no "simple" plug-in-an-equation type
solution.

Games aren't about realistic physics (4, Redundant)

Captain_Frisk (248297) | more than 12 years ago | (#2719974)

I've noticed alot of comments here about realistic physics in games.

I remember reading an article with a game developer a while back, who pointed out that the key for physics in a game wasn't realism, but consistancy.

He was developing a racing game, and says in order to make the game more fun, he had to sink the center of gravity for all of the cars several feet below the pavement, so that the cars wouldn't tip over when making hi speed turns.

As long as all the cars behaved the same way, it didn't matter that you were "cheating".

When playing your game, the user is entering your world, and learns a new set of rules. As long as you present your set of rules as consitant, it doesn't matter if they don't correspond with how things behave in "real" life.

Captain_Frisk - wannabe game designer.

Chris Hecker's Physics tutorials are FREE! (5, Informative)

strags (209606) | more than 12 years ago | (#2719980)

http://www.d6.com/users/checker/dynamics.htm [d6.com]

provides an excellent, and free alternative to purchasing a weighty tome on the subject. Chris covers the details of rigid body mechanics in a thorough, but light manner.

I went to a physics lecture at GDC, the most memorable part of which was Chris saying:

"Here's how it's going to go... you're going to write your first rigid body dynamics simulator. You're going to simulate a cube dropping onto a plane. You'll run the program, the cube will drop, hit the plane... and disappear."

So, so true.

Super Mario Brothers (1)

M4d D0nkie (463763) | more than 12 years ago | (#2719988)

Games do not need good physics, they need to be fun. Anyone remeber playing Super Mario endlessly? Remember all the jumping forward and pulling yourself back in the air? That game would be damn boring if you couldn't reach half the powerups because it had real physics.

Carmageddon (3, Interesting)

CaseyB (1105) | more than 12 years ago | (#2719989)

Carmageddon which on the N64 at least has sucky physics,

Excepting the possibility that the N64 version is completely different from the PC version, you are completely clueless. Carmageddon, of ALL the games you could have chosen, was a pioneer in game physics. It was the very first game that I played that had a real rigid-body simulator built into the engine.

Say what you will about the gameplay, or the physical settings (gravity was too low), but you can't say it had sucky physics. The cars and environmental objects interacted in an incredibly realistic manner. It was miles ahead of Re-Volt in that department.

Re:Carmageddon (-1)

Anonymous Coward | more than 12 years ago | (#2720013)

Carmageddon is the crappiest game ever written!

Games vs. Simulations (5, Interesting)

dreadpiratemark (450962) | more than 12 years ago | (#2719990)

I don't know that I really agree with the idea that physics need to be wildly realistic in the 'games' that I play. Honestly, I don't want to know what kind of recoil the rocket launcher in Half-Life would inflict on my character. I'm happier just watching the rocket track nice and straight towards my target instead of attempting to pick myself up off of the ground where I slid to a stop from the highly realistic recoil.

On the other hand, when I play a 'simulation' the physics are quite important. The best physics I've found in a sim are in a 3-year-old game: Grand Prix Legends. You're racing 1967-era Formula One cars, which means skinny tires, no downforce, high powered...which is a combination for difficult driving. But the physics engine is spectacular: you touch the gas when in neutral, you can feel the torque twist the body of the car; each wheel has its own model; touch the gas a bit to hard in a corner and be prepared to swap ends of the car, etc., etc.

The graphics are what you'd expect for a 3 year old game, but a dedicated community has sprung up to support the sim with everything from replay analysers [bip.net] , new tracks and graphics [sportplanet.com] , and even a movie maker! [racesim.net]

It seems that if you make a sim with good enough physics behind it, the fans of it can create new 'eye candy' to keep the sim looking good. But if you have crappy gameplay (see: Andretti Racing) and good graphics, the game will quickly be relegated to the bargin bin when something prettier comes along.

-Mark

Who wants realistic physics? (5, Insightful)

Junta (36770) | more than 12 years ago | (#2719994)

I'll bet that in at least 90% of the games out there realistic physics would completely ruin the whole fun. What is the point of interacting with a fake environment when the environment reacts the exact same way real life reacts? Racing games are a good example. People want cares to handle well, generally. They don't want realism, in real life operating cars at high speeds is a lot more difficult than most games.

And in *any* game where people jump, realistic jumping becomes completely pointless. People want to be superhuman. Imagine quake with realistic physics....

Realism is not the high mark of games in all aspects, that is the whole point of games, to escape reality...

Quake II low gravity level (2)

acomj (20611) | more than 12 years ago | (#2719995)

Has anyone else seen the quake II secret level that has less gravity. Jumping, the remains of oponents, those bouncing gernades.. everything was like it was on the moon.. Lots of fun..

Now thats physics

Re:Quake II low gravity level (0)

Anonymous Coward | more than 12 years ago | (#2720036)

that was Quake, not Quake II: level E1M8, Zigurrat Vertigo...

there are companies making this (1)

cornjones (33009) | more than 12 years ago | (#2720000)

my pool-teammate's buddy from ireland (sister's former roomate) works w/ a company (in ireland) that produces physics engines for applications. well I guess it is really one physics engine that they license out to anybody who wants it. obviously game co's are interested but engineering and modelling progs use it too. sorry but I don't remember the name.

Grenade toss gone wrong! (1)

jeff13 (255285) | more than 12 years ago | (#2720006)

Return to Castle Wolfenstein has great physics, as all QuakeIII and such gamers know. But I find the grenade toss of the game somewhat limp. Last night, under heavy fire while a teammate tried to get the M60 firing. I tossed a grenade into a alcove to keep incoming Nazis from cutting us both down. Oops!?! My grenade hit the wall right beside me (but, but, I'm beside the wall!?!? How could I possibly have ... KA-POW!

Game physics. Priceless. ;-D

the age old realism in games debate (0)

Anonymous Coward | more than 12 years ago | (#2720018)

its a fallacy to believe
realistic physics realistic gameplay fun game

some 'old' games are still interesting today and hence being played for no other reason then that their physics system is fundamentally flawed (e.g. the original Quake or QuakeWorld; released over 5 years ago). learning how to exploit these flaws efficiently is what makes those games fun today, with new 'defects' being discovered on a weekly base.

make a game with perfectly realistc physics and it will be perfectly boring; why not do the real thing instead?

how about human motion? (2)

cvd6262 (180823) | more than 12 years ago | (#2720026)

In my opinion, the most difficult aspect of writing a good 3D game is coding complex physics

IMNSHO, getting good human motion is the hardest. Sure, EA does great motion capture for their sports sims, but where else do you see this in the industry? Download the Wolfenstien single player demo and see how stiff the models look (especially in the intro).

I think getting realistic physics is important, but, since most of it can be reduced to math anyway, GHz machines and loads of memory, combined with good programming, should be able to get it right. Making motion look good is far more important to my enjoying the game, and much more difficult.

On a side note....

Has anyone else noticed how this seems to be what sets WETA's effect in LOTR apart from the rest? Instead of generating a digital army, they film a bunch of guys walking in armor, then copy/paste/randomize to make a realistic hoard of warriors.

The cave troll, while the rendering was supurb, was entirly motion-captured. They had some actor plodding around with a big stick and ping-pong balls taped to his joints. They seem to understand that they can make everything look perfect in a still image, but the motion will still look fake.

Basing a whole game around the physics (2, Insightful)

iainl (136759) | more than 12 years ago | (#2720035)

Some of my all time favorite games are great because they move 'right'. Can you imagine playing Spindizzy or Marble Madness with crap physics? I can, on a dire MM ripoff. It was frankly painful. The unexpected coolness that can result from engines that do things properly is very nice - although they cheated on the amount of kickback to do it, rocket jumping would never exist if they hadn't used impulses and momentum to control movement rather than old style 'move forward if the player pushes forward' arcade method.

Physics Fighter (1)

voiceofthewhirlwind (451735) | more than 12 years ago | (#2720043)

What I'd like to play (or code myself when I get out of college) is a fighting game that incorporates a lot of physics:

Instead of a hit just causing the victim to go into a canned fall down sequence, the force imparted by the blow would be computed and the proper response of the impacted body would result in a unique reaction for blows landed on different parts of the body with different ammounts of force.

In addition to reaction to hits, all the moves should be based on biokinematics rather than canned sequences- the fighter would not execute perfect flying whatevers every time, but some phsyics model would cause them to attempt the move and the result would vary by the conditsions it was executed under.

More physics in any kind of game makes for much more interesting and varied play, if the alternatives is just as many sequences as the designers bothered to record.

Carmageddon's physics (1)

rreay (50160) | more than 12 years ago | (#2720044)

Carmageddon didn't have sucky physics, it had goofy cartoony physics. I mean seriously, asking for realistic physics in a game about rocketing through a city at 200 mph running down pedestrians and picking up powerups is just plain silly.

-Rob

It's about what you want for the end result.... (1)

mr-spam-uk (252016) | more than 12 years ago | (#2720046)

Whenever a game is produced it is decided how much physics will go into the game, this is dictated by a lot of factors, some of which are (in no particular order):
1) Possible cost. (Do you buy a prebuilt physics engine? Or spend developer time on it?)
2) How realistic does the game need to be?
3) How realistic can you make the game? With given platform constraints.

It won't be long before people begin to notice not just the graphics/game engine (Such as the famous Q2 and Q3 engines) but also who's physics/mechanics engines are being used...

Background:
I've got a degree (BSc Hons) in Physics, I work at a games development house as a programmer.

Working out the forces of objects (2, Interesting)

Anonymous Canuck (249873) | more than 12 years ago | (#2720048)

"Everyone knows that games spend most of their time running round a single big "main loop," working out the forces on each object, looking for collisions and working out which keys the user is pressing."

Actually, the game is not working out the forces of each object. This is why most objects in 3d fps games are static. Beyond basic collision detection, there is no interaction with the objects. If there are interactive objects in your game, the math involved in calculating the physics of a 3d pack of cigarettes or a 3d can of cola would not only take an enormous ammount of coding to bring to light, but also put undo load on the CPU.
When we worked on Ghost Recon, one of the big problems with physics involved calculating the way the trees swayed in the wind(believe it or not). Part of the solution involved going from multiple wind directions to a single one. The users wouldn't notice it. Heck, we could have made the trees static, thus relieving the system of about 40% of it's performance hit, but we wanted some level of realism in the background and atmosphere.

Load More Comments
Slashdot Login

Need an Account?

Forgot your password?