Jump to content
  • Advertisement


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


Game Engine and Physics...

This topic is 5233 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

"Frist Pr0st!" I''ve been slowly working on the idea of a space life simulation with fairly broad design ideas and such, and after looking at a few articles on SDL and engine development it''s beginning to look like a complicated, but possible goal. I just have a couple of questions concerning physics, and implementing them in a game engine. Most game engines seem to work on the principal that down (-y) is where things should fall in a game, and for the most part this is applicable. The ground is down, so things will fall to the ground. However, the idea I''m working on needs to have gravity not default to -y, but where there is an object with a gravitational relationship to other objects in the scene, e.g. the earth and a space craft. If you were "upside-down" in the craft, with earth about 100,000 km''s above you, then your ship should fall "up", while internally the craft''s artificial gravity would keep you on the floor, or let you float if it failed. To summarise, I''m trying to find information on how to put gravity, friction, atmospheric interaction, inertia, and other real-world physics into a program. "I go, I come back."

Share this post

Link to post
Share on other sites
Well, I''ve been thinking about the same concepts (physics in an engine).

I think the best ides would be to use forces! Simply a force would be pointing at the object creating the gravitational field. The object that the force is acting on would then move that way.

F = a * m
a = F/m

so if you know Force and Mass of your object, you can calculate the acceleration at which it''ll be moving...


s= (at^2)/2

and you can use these two equations and put acceleration and time and viola - you know know how much/with what speed the object pulled by gravity is moving

Why I would go with forces is because you can solve a lot (though probably not all) problems with them. You can use them with friction and other stuff. When you have a lot of forces acting on an object, you just calculate the net force and apply it on the object... plain and simple...

but of course, there are things which would have to be done differently. Like collision of moving objects... you''d probably have to calculate the momentum and know the flexibility of the colliding object... hmm... hmm...

Share this post

Link to post
Share on other sites
Yep, forces are cool Newton was on a good thing.

For calculating the gravity force between two objects, you use the formula:

F = GMm/(r^2)

Where, G is the gravitational constant (6.67 x 10^-34, I think), M and m are the respective masses, and r is the distance between the centre of masses of the two objects.

- Xavier

Share this post

Link to post
Share on other sites
You simply have to use 3d vectors. Do you know them?

For example, regarding on what Koobazaur has wrote.

Planet1 position in space expressed by coordinates: x1, y1, z1
Planet2 : x2, y2, z2

The three numbers can be ideally grouped toghether to form a vector:

p1 = (x1, y1, z1) // vector object
p2 = (x2, y2, z2) // vector object

The distance between the planets is the *length* of the vector r, difference between p1 and p2

r = (rx, ry, rz) = p1 - p2 = ( x1 - x2, y1 - y2, z1 - z2)

|r| = sqrt( rx*rx + ry*ry + rz*rz ) // float, always > 0, it's a distance

In the formula supplied by Koobazaur u need r^2 so you can also avoid sqrt(.)

|r|^2 = rx*rx + ry*ry + rz*rz // float

ps: |.| indicates thelength of a vector

btw if you dont know vectors you havet o study them, take a book or search google they are part of algebra

[edited by - Frankesk on March 21, 2004 8:34:05 AM]

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!