Posted by Stadric on Sat Jun 9th at 3:58am 2007
As I Lay Dying
Posted by Naklajat on Sat Jun 9th at 4:15am 2007
T(torque, not the period) = F/r
g=G(m1)(m2)/d2, G = 6.67*10^-11 (m3)/kg(s2)
And that's all you need to know!
tl;dr
I like the idea of fighting across part of an asteroid belt or the wreckage of a spaceship though. A potential problem for using accurate calculations would certainly be the fact that you need a lot of mass to have gravity substantial enough to hold a person on the ground. UE3 has gravity volumes, I made a roboblitz test map where you can drive on the walls and ceiling, but the transitions make your view do strange things. One thing I found myself wishing for in it was spherical or cylindrical gravity volumes, I wanted to make a space station like the one in 2001: A Space Odyssey.
Naklajat
member
1137 posts
207 snarkmarks
Registered: Nov 15th 2004
Location: Austin, Texas
Occupation: Baron
Posted by Crono on Sat Jun 9th at 6:27am 2007
Or at the least, check out the functions the source engine already provides? (Havok API)
Just to nitpick, the units for these things aren't specifically metric or imperial. For instance, torque can be expressed in Newton per Meter ... Pound per Inch so on and so forth. Of course, generally, the math is easier if expressed in metric.
Posted by Stadric on Sat Jun 9th at 7:01am 2007
As I Lay Dying
Posted by mazemaster on Sat Jun 9th at 9:15am 2007
Some images in this post have been automatically down-sized, click on them to view the full sized versions:
Some images in this post have been automatically down-sized, click on them to view the full sized versions:
Some images in this post have been automatically down-sized, click on them to view the full sized versions:Some images in this post have been automatically down-sized, click on them to view the full sized versions:Some images in this post have been automatically down-sized, click on them to view the full sized versions:
Some images in this post have been automatically down-sized, click on them to view the full sized versions:Ok, so the basic idea for applying gravity is to figure out which surface is closest to the player (calculate the distance from the player to the surface for each surface), and then use the normal to the closest surface as the gravity direction.
I made some images that show how to calculate the distance from the player to any given triangular surface using simple vector operations. Since the operations are all simple vector manipulations, in theory they could be fast enough for real-time gravity calculations.
Now I have no clue how to find all the player positions and surface normals and so forth with the SDK, but theres the underlying strategy.
EDIT: Also, I am betting that a lot of these calculations are already done for the purpose of collision detection (how close is the player to a wall?) among other things, so I might not have to redo these calculations each frame. ?
Posted by wil5on on Sat Jun 9th at 12:23pm 2007
Doesnt look like it will be immensely computationally expensive, considering that yes, most of these vectors will already be generated (I havent seen the SDK myself personally but theyre definitely used for other calculations in-game) and the mathematical operations are fairly straightforward vector ops.
Of course, it will take a bit of testing and experimenting to see if this "feels" right. One case that springs to mind is the idea of just walking up to a wall: if we are calculating distance from the centre of the player, youll fall into the wall youre walking towards once youre less than half your height away (40ish units in HL/HL2), stand up then fall back onto the floor since standing up pushes your centre away from the wall. Cases like this can make or break it, so just be mindful.
Has anyone considered how to calculate view directions? Does anyone understand quarternions (because I don't, and youll probably need them)?
wil5on
member
1733 posts
323 snarkmarks
Registered: Dec 12th 2003
Location: Adelaide

Occupation: Mapper
- My yr11 Economics teacher
Posted by parakeet on Sun Jun 10th at 6:24pm 2007
parakeet
member
544 posts
64 snarkmarks
Registered: Apr 30th 2004
Location: Eastern US

Occupation: n/a
Posted by Crono on Sun Jun 10th at 6:52pm 2007
I think, the easiest way to go about this, that no one has really suggested, would be use some sort of area property, like a hit box, if you want to think of it that way, once entering some mass' area-box you will be affected by it's gravity. Of course, many area-box's can overlap so you just normalize the gravity, and the stronger one wins, generally. If the "planetary" masses are used sparingly, you could just make those physics objects in Source (How many are you really going to have? 10? Ooohh, big deal, that's only 10 physics objects) and you can use this "pull" functionality in addition to the existing physics abilities. As long as the outer world it self doesn't have some gravity constant (currently, in Source, it does, you'd have to overload that), you'll be golden. So golden, that if you launched yourself away from all the masses in the world, you would actually get pulled back towards them if this is done correctly. But this is only if you want to simulate multi-planetary masses with inter-acting gravitational pulls. You could also give them repulsion from one other. After all, you would just negate the force value that is returned from your gravity function.
Posted by wil5on on Mon Jun 11th at 12:07am 2007
View directions are what I always stumble on when playing around with things like this. I agree the rest is fairly easy, which is why I brought it up. I dont have the mathematics to do the proper transformations (I'm guessing you do) so I really dont know.
Note that at no point in the game does the players body actually rotate.
wil5on
member
1733 posts
323 snarkmarks
Registered: Dec 12th 2003
Location: Adelaide

Occupation: Mapper
- My yr11 Economics teacher
Posted by mazemaster on Mon Jun 11th at 2:02am 2007
Posted by Crono on Mon Jun 11th at 5:23am 2007
There's no such thing as an industry standard when it comes to data structures, even if it's the structure most developers use. There are always many options.
Snarkpit v6.1.0 created this page in 0.0197 seconds.

