Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Moe

Implementing physics in a 3d engine...

This topic is 5856 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, A few days ago I came across a link to this. I thought it was really quite neat and I haven''t seen anything quite like it before. That got me wondering on how I could make my own good physics in my own engine. I came up with the following: The first step to doing a good physical simulation is good collision detection. A type of bounding volume should be used to check for possible collisions. For this I would like to use oriented bounding boxes (OBB). They can be slightly more accurate than axis aligned bounding boxes (AABB). Once possible collisions are detected, it must be done on a per polygon level to make things nice and accurate. Each object must have several attributes - mass, current velocity, previous velocity (from last frame), and acceleration. The forces in my program (explosions) are calculated based on the distance from the center of force and the strenght of the force. Objects closer to the center of the force will have greater forces acting on them and objects further away from the center of the force will have less force acting on them (this could have a linear falloff to make things interesting). The force and mass of the object is known, so this can be used to calculated the acceleration. Acceleration is basically the change in velocity over time. The change in time is the change in time between frames when the physics is being updated. The initial velocity is known (the velocity from the frame before), the change in time is known, so this means that the new velocity can be calculated. The only thing that I don''t know how to fit in is collisions between objects using the conservation of momentum. I probably don''t remember all this from the physics class that I took last semester. Momentum is mass times velocity. The part I don''t understand is how do I know how much momentum has been transferred between objects during a collision? I also don''t know how to get an object to roll when a force is applied. This is part of the reason why I think OBBs would be well suited to the job. The force can be applied to the corners of the box. Is there a specific formula for force causing rotation? I wish I hadn''t disposed of my physics notes/work from last semester... Moe''s site

Share this post


Link to post
Share on other sites
Advertisement
To get rotation with a force:

CrossProduct(Force,ForcePos-MassCenter)

this compute the Rotation Vector with the length of the Torque.

understand ??

Share this post


Link to post
Share on other sites
Fantasio had roll,
so I''ll take momentum:

Wasn''t it like there are various types of momentum transitions?

One extreme beeing the bouncing balls on strings. One hits the other, stops completely; the other moves of with all the momentum of the first.

The other extreme would be the ball hitting a marshmallow. Ball and marshmallow join their masses and moments and travel of together.

If my memories are correct, the behaviour depends on how solid the objects are.


---------------------------
I may be getting older, but I refuse to grow up

Share this post


Link to post
Share on other sites
Like for Rigid Body Physics.

I can''t rememeber where on gamasutra but there is a couple of demos and good articles by Mr. Andres about this.

It''s pretty cool stuff.

Share this post


Link to post
Share on other sites
So the amount of momentum each object gets/loses depends on the objects 'stiffness'?

As for the cross product - the cross product finds a vector that is perpendicular to the two vectors that are put in, right?
Moe's site

[edited by - Moe on June 27, 2002 11:02:59 PM]

Share this post


Link to post
Share on other sites
Eyup. Cross is perpendicular to the 2 input vectors.
BTW...

u cross v is NOT v cross u.

Same length, opposite directions.
I think you use that for normals, not sure.

Good luck !

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hi, I''m doing 6th form physics now. Conservation of momentum is defined as:

"In any collision or explosion the amount of momentum before equals the final momentum"

Remember momentum is mass times velocity. This means if an object travelling at 10ms-1 with mass of 100kg hits a 150kg object at rest, the first object will have a momentum of 1000Kgms-1 and so will the second object because of the law of conservation of mom.
However, the second objects'' mass can''t change, nor it''s momentum so it''s speed must change. Imagine it were a frictionless world. The second object''s speed would be (P = momentum):

P = mv
V = P/m

= 1000/150
= 7ms-1 (1sf)

I hope this helps. it just means you have to slow the second object down or make it go faster depending on it''s mass, by using the first object''s momentum.
Email me on ryan@pcsoftware.co.nz if you need any more physics help.

btw, on your question for "is there a specific formula for force causing rotation?" the answer is torque which causes a twisting force. This is simply:
Torque = Force (perpendicular to pivot extension) * Distance (from pivot to edge of object)

- Ryan

Share this post


Link to post
Share on other sites
The thing I don''t understand is how do I know how much momentum is passed on to the other object?

Lets suppose we have 2 balls rolling toward eachother (not directly toward eachother, on some sort of angle - like a 90 degree angle between the two directions). The first ball is much larger and is moving faster than the second. When the balls collide, the larger ball should move a bit slower and the smaller ball should probably speed up a little. How do I know how much momentum is passed between the objects?

Moe''s site

Share this post


Link to post
Share on other sites
If you are asking: Given a 90 degree slope, we have a larger ball at the top rolling down and a smaller ball in the middle rolling down, how much momentum would be released into the smaller ball?

Well, since they are moving, you would probably have

P[final] = P[largerball] - P[smallerball].

I would think you would simply find the difference between how fast the two balls are going and what their total force(?) would be in their current direction.

~Dwarf

Share this post


Link to post
Share on other sites
quote:
Original post by Moe
The thing I don''t understand is how do I know how much momentum is passed on to the other object?

This is dependent on the elasticity of the collision.

Take a look at this (linear momentum and collisions).

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!