• Create Account

## Q: Implementating a Physics System

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

### #1Sphet  Members

631
Like
Likes
Like

Posted 17 August 2001 - 08:44 AM

Hello, I''ve started working on a really small simulation that I hope will lead to other projects. What I am trying to do is have a collection of conveyor belts (defined simply by two points and a velocity vector), and a box. The box should obey the laws of gravity, falling from one conveyor belt to the other. What I am wondering is how best to implement the physics engine. Although all of my data is stored as 3D point data (I am using direct 3d for visualization), I am only concerned with a 2D side view. Does the normal collision sphere followed by triangle intersection test seem the best way to go? Can someone give me a basic rundown on the right way to do a physics engine.. how does one decide what order to check all the objects in the world, when is it done, etc. Also, if I have a couple of conveyor belts that are attached in a V, how do I figure out that, as movement on one length of the belt is finished, the box moves to the next.. I''m pretty new to all this, having implemented simple gravity in 2D side scrollers in a really simple way before. Many thanks.

### #2liquiddark  Members

340
Like
Likes
Like

Posted 19 August 2001 - 10:00 AM

If your boxes aren''t rotating as they fall and your belts are horizontal, just use the standard box test. Roughly, in pseudocode:
if (bottom of box <= top of collision object) &&   (top of box >= top of collision object) &&   (left side of box is within horizontal range of collision object) ||   (right side of box is within horizontal range of collision object)   // Collide objects here

Otherwise, a circle test should work just fine. It''s like the sphere test but without the z-value. Note that you must constrain your objects'' speed per step or else use a trace-style intersection wherein you test the volume through which an object moves rather than the object itself. This applies to collision volumes as well.

A good physics engine will have a clock independent of (but preferably as fast as or faster than) its graphical counterpart. Testing collisions in the immediate area only (and, if you want, in "action areas", ie areas where interesting things are happening) will reduce the required processing power. I would suggest to you that you try using a graph of objects and a list of active objects. Populate the list with all active objects within the graph, and if a particular interaction affects a deactivated object, reactivate it, but wait until the next time step to work out the effect. Make sure that all your reactions are constrained, if possible, since you otherwise will get perpetual rattling, by which I mean objects will interact every frame and will not settle.

If you take a look at many last-generation FPS engines, a box or cylinder test is all that is used - no triangle intersection is calculated. Of course, for a physics-heavy game (see Hitman), triangle intersection is more important.

As to the V arrangement, use the circle test and use a physics clock to run your system. Run the clock at all times, of course.

ld

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.