How to represent forces and such

Started by
3 comments, last by shadow12345 20 years ago
I have absolutely no clue how to represent real forces the ''real way'' in a computer program. In the loop I''ve got right now, every object moves when the loop gets to it, and it tries to collide with where ever the other objects are currently at (first come, first serve basis). That''s the first problem. The second problem is trying to get forces to persist over multiple frames. For example, I''ve got a playable demo where you run around quake3 maps trying to shoot bert. When you actually shoot a bullet and hit bert''s arm I''m trying to get it so that his arm will rotate backwards. Obviously the force is basically applied instantaneously, but the effect needs to persist over multiple frames until the forward force of his arm can make his arm swing forward back to the normal position. I''m looking into scene graphs for representing objects but I''m not really sure how to go about this the real way.
Why don't alcoholics make good calculus teachers?Because they don't know their limits!Oh come on, Newton wasn't THAT smart...
Advertisement
not sure I understand what you are looking for, but I''ll give it a try.

a bullet hit produces an impulse, and is not a persistant force. the impulse will generate a linear and angular momentum on the object (the object will start to rotate), and given no friction is applied, the object will keep on rotating until you produce another impulse that cancels out the angular velocity (ever shoot the other arm, or shoot the same arm from the other side). That can be handled by basic rigid body dynamics.

Collison impulses generate a change in momentum instantaneously (as soon as a collision is found). force fields, like gravity, well, you can keep track of them inside each bodies.

Everything is better with Metal.

yeah, that''s exactly what I''m doing. I guess I just don''t know the right way to actually do that in code. Can you show me some psuedo code of how and when your physics is handled in your code?
Why don't alcoholics make good calculus teachers?Because they don't know their limits!Oh come on, Newton wasn't THAT smart...
For things like these there''s the "logic loop" of your game. Aiming for independent speed on different pcs is generally a good idea, so you''ll have to separate the graphics stuff from the logics. And the physics do absolutely fit into the logic part. As for me, I have my update() method for each Actor / Object, and this is where the collision detection will be handled, the A.I. (if any), the physics, ...


Indeterminatus

--si tacuisses, philosophus mansisses--
Indeterminatus--si tacuisses, philosophus mansisses--
3D rigid body example

plus a bunch of other demos from my home page...

Home

Everything is better with Metal.

This topic is closed to new replies.

Advertisement