Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: ShadowWolf_IH on February 12, 2003, 09:45:53 pm

Title: Mods and gravity
Post by: ShadowWolf_IH on February 12, 2003, 09:45:53 pm
I know of about 5 mods out there right now....not including mine, who are going to be using ground attack missions, and are also making grounded missions.....missions where you are on the ground driving a ground vehicle into combat.  Some help here would be great.

This is of course an oversimplification of my thought.  All of the ships in FS2 have mass, and that is what throws us around when we bump, right?  Or what allows one capship to push another.  Well our planet would also have mass.  I am not a coder and have no idea how complex this is, but it seems to me that there are three variables to worry about, mass of object A, mass of Object b, and distance between the objects.  Obviously the more mass of object A, the greater pull it will have at greater distances.  Then again you already knew that.  

The two things that make think about this are the push factor of bumping ships, and special eplosions which "push" you, more importantly, the lessening effect of that push at greater distances.

Is this even feasible? or am i thinking absolutely on the wrong lines?
Title: Mods and gravity
Post by: Galemp on February 12, 2003, 10:33:58 pm
Mass doesn't create gravity in the FS engine. Sorry.
Title: Mods and gravity
Post by: Stryke 9 on February 12, 2003, 10:35:39 pm
Ya'd need to install Newtonian physics.

Well, maybe not, but if you were gonna do this you might as well. It'd be by far the simplest route, and it'd still pretty ****ing hard. Telling the game which way is "down", setting the gravity level and having a function to turn it on and off for different missions, having it dependent on ship size... it'd get very ugly very fast.
Title: Mods and gravity
Post by: ShadowWolf_IH on February 12, 2003, 10:38:10 pm
actually, i was thinking more along the lines of reversing the push effect that you get.  as far as down goes, it is based on the center of the object you are giving gravity to.  As far as gravity level goes, have it based on mass.  That way it would read right off the table...and beneath a certain mass, the object cannot create gravity
Title: Mods and gravity
Post by: Stryke 9 on February 12, 2003, 11:10:16 pm
Quote
Originally posted by GalacticEmperor
Mass doesn't create gravity in the FS engine. Sorry.



That, and last I recall, except for Nephilim everything has a mass of "1".

I don't know what you're talking about "reverse the push effect", seeing as there is no "push effect" constantly in place in the game, or even temporarily, unless you crash into something or get hit by a specific weapon, and neither of those two really create great opportunities for generating a unidirectional, constant force.
Title: Mods and gravity
Post by: ShadowWolf_IH on February 12, 2003, 11:58:21 pm
ok so you don't know what i am talking about.  The subject matter at hand is.......gravity.  If you are saying that my line of thought is wrong, how woudl you do it?
Title: Mods and gravity
Post by: Fury on February 13, 2003, 03:04:48 am
ShadowWolf_IH, good luck with your mod. But I can say that mods like that will not see daylight. FS2 is an arcade space simulator, not First Person Shooter mixup... It is just impossible to make FS2 to be everything.

...Unless I missed something obvious...
Title: Mods and gravity
Post by: LtNarol on February 13, 2003, 07:34:57 am
would it be possible to add 2 tbl flags for something like this? "gravity" and "grav-obj-no-collide"?
Title: Mods and gravity
Post by: ShadowWolf_IH on February 13, 2003, 08:27:29 am
ok so now everyone has told us the ways it can't be done, can anyone tells us the way it can be done?  And actually i like Narol's thinking with the flags.  so, can it be done?
Title: Mods and gravity
Post by: aldo_14 on February 13, 2003, 09:38:04 am
i heard - though I'm not 100% sure - that weapons with a high negative blast can have a gravity effect.

Maybe.... if an object has mass (pof) over a certain limit, it applies a 'pull' effect on objects within a certain radius (defined by mass*somefactor).  This pull effect *could* be a simple modification of the physical location of each object every 1/n seconds (i.e. simply subtracting from the co-ordinate location).  Possibly with n decreasing with proximity to the object (exponential / increasing gravity).  The trick would be - I guess - optimising the maths operations so not to overload the system.. maybe reducing the multiplications required (less ALU ops), or 'fuzzing' co-ordinate values by rounding them.  

One problem could be in actually moving ships without giving the impression of 'jerking' them... maybe a subtle manipulation of the inertia of the ship (using M.O.I. settings I presume)?  If someone could get a working tractor beam coded up, this could provide part of the basis for this...?
Title: Mods and gravity
Post by: Stryke 9 on February 13, 2003, 10:28:15 pm
That'd take a lot of fiddling around, and wouldn't be smooth, anyway- a beam, I think, can't just do a gentle pull, just like you can't have it do only 1HP of damage every other second. They're just not set up that way. It'd be worth a shot, but I wouldn't lay money on it, and at any rate you'd have a hell of a hard time keeping the beam directly under the fighter pointing straight up. And doing that for every vessel in the game.

Shadowwolf: the point is, you can't do gravity gracefully in the FS engine. It's not built for it in every way. I'm sure someone could jury-rig some programming monstrosity onto the physics engine to give everything a gradual pull down, but it'd be iffy whether you could ever turn it off without reinstalling the game, it'd be a beastly piece of programming work for very little return, and frankly you won't find anybody crazy or stupid enough to do it. Maybe, if at some point someone wants to stick in Newtonian physics, they could include the gravity option on their way, but that'd be essentially taking out the current engine in its entirety and replacing it- an even more massive project, and while significantly more worthwhile than just adding gravity, it won't be happening any time soon.

It's not as simple as just adding a table flag- that flag would have to be backed up by part of the physics engine that calculated gravity and would move all objects in one direction when activated. The current FreeSpace physics engine has no provisions for such a thing, which means you'd have to retool half of the engine just to get it to fit in, not to mention actually coding it, which I have no idea personally how you'd do. At the moment, it's just plain not a feasible idea.
Title: Mods and gravity
Post by: LtNarol on February 13, 2003, 10:41:48 pm
Well, the idea of the flags was to minimize the amount of actual physics calculations involved.  The "gravity" flag would tell the engine that the "ship" with that flag should be treated as a gravity source and that all objects accelerate toward it at whatever velocity by is in the flag's first parameter - which would also be the amount of thrust required in a direction away from the center of the object in order to overcome the effects of the object's 'gravity'.  This part is essentially simple addition and subtraction on a given vector.  The flag can have 3 parameters, one for the default pull a second for the amount by which other objects are slowed (I.E. ship_new_max_velocity=ship_tbl_max_velocity - value).  A final flag could be the radius for which other objects are affected.

With ships and fighters, you can have a "gravitate" flag dealy that tells the engine not to ignore the first "gravity" parameter, so the fighter or ship doesn't accelerate toward a planet automatically.  Ships without this parameter ignore the actual gravity, but are still slowed.  Ships with it will use the first "gravity" parameter of whatever object and accelerate towards that object if within range.

A "no-grav-obj-collide" flag would be needed to keep ground units from constantly colliding into the planet, probably with 1 parameter specifying the minimum distance between the center of the ship and the surface of the planet.  Basically, replacing the collision stuff with hovering stuff.

Having no experience with the code of the FS2 engine, I can't go any further in detail but given what I do know about the engine, this shouldn't be impossible.  Difficult perhaps, but worth the effort in my honest opinion; especially if you know what I have in store for you guys if ground units work.
Title: Mods and gravity
Post by: Ace on February 13, 2003, 10:51:31 pm
Two things that would currently work in FS:
The negative mass value "tractor beam" weapon effecting a ship, pulling it to the ground.

The ground object moves upward to a waypoint in the extreme distance, this can be done at a speed and distances so that the vertical limits of a mission boundary do not seem to be lost.
Title: Mods and gravity
Post by: Stryke 9 on February 13, 2003, 10:54:51 pm
Ah, I get it. That'd actually be a lot more graceful a way to do it, provided you didn't mind having a point gravity source rather than a planar one. I'm sure you could set up something with the weapons bit of the engine so that the point would pull every vessel a minute amount every fraction of a second- you'd still be shaking, but not a whole lot, just enough to make it really irritating if you went over about ten to fifteen minutes...
Title: Mods and gravity
Post by: Nico on February 14, 2003, 04:32:55 am
pb is, if you flight horizontally , you'll either go down or up when you're supposed to have a constant altitude...
Title: Mods and gravity
Post by: aldo_14 on February 14, 2003, 04:41:28 am
Quote
Originally posted by Stryke 9
That'd take a lot of fiddling around, and wouldn't be smooth, anyway- a beam, I think, can't just do a gentle pull, just like you can't have it do only 1HP of damage every other second. They're just not set up that way. It'd be worth a shot, but I wouldn't lay money on it, and at any rate you'd have a hell of a hard time keeping the beam directly under the fighter pointing straight up. And doing that for every vessel in the game.


I'm talking about implementing a specialised tracotr-type beam as a simple physics test for applying a subtle MOI change to a specific model.  I.e. you see if the beam can be used to pull a ship towards a specific area (the beam source in this case), and build on top of that.
Title: Mods and gravity
Post by: ShadowWolf_IH on June 12, 2003, 10:22:30 pm
right pulling to a point instead of a plane......that would work
Title: Mods and gravity
Post by: Nico on June 13, 2003, 01:59:05 am
Quote
Originally posted by Venom
pb is, if you flight horizontally , you'll either go down or up when you're supposed to have a constant altitude...


that pb will remain true.
Title: Mods and gravity
Post by: LtNarol on June 13, 2003, 10:08:31 am
Well, if programmers are willing, they could probably create a new flag for objects which are affected by gravity, such that objects without the flag are unaffected.  Thus, a fighter would fly around as normal whereas a tank or hovertank will hug the ground.
Title: Mods and gravity
Post by: LtNarol on July 04, 2003, 01:53:03 pm
(http://www.3dap.com/hlp/hosted/the158th/misc/bump.gif)

still no takers?
Title: Mods and gravity
Post by: Flaser on July 04, 2003, 08:09:21 pm
Let's make this clear what do we want:

Gravity?
 That's gona be a holy hard job, unless you plan to use only a single great source of gravity at any given time.
In these events you could even have an autopilot that would calculate the speed to maintain orbit around it at the current distance.
Implementing it would add a single vector to any ship in any given radius of the planet or sun.
The problem is that you would have to use a huge space-box, to keep everything inside, or you would have to simulate the speed.
It would give an actually realistic orbiting around any given planet or moon though.
Using huge objects for planets or suns would fit into this model.

Orbital Bombardment?
You'd need to make every ship accelerate toward the ground.
This will be a lot simpler than the first case, since all the objects would have the same acceleration and in the same distance.
You could vary that acceleration in FRED, with events. With careful calcualtion you could even simulate a burn-up in the atmosphere if the player fools around too long.
In this case I would still use a huge background object instead a model. The tricky bit would be slowly enlarging this background, though bear in mind, that for most of the time in a "real" bombardment pilots wouldn't notice anything for quite a while.
Targets could be modified waypoints instead, a pilots would have to hit them to score a kill.
Parts of the texture would have to be changed to show the damage.
This would be  a freefall toward the planet.
With somekind of atmosphere simulation based on the effects used for the nebula you could even simulate a reentry to a limited point.

Low Altitude Flight?
This is could be the hardest.
Making the ground move is a nice idea, but it has its own problems.
Ships should indeed hit the ground, though for collision a minimum speed check should be made.
This is a reason why I think giving a constant acceleration to everything would be viable as well.

Big ships shouldn't be in the atmosphere nor most spaceships.
Fighters to be used there should either have vertical thrust - this is already implemented - or be aerodynamical.
Then another upward vector should be given to them depending on their speed - voila! You reinvented the flight sim...
Title: Mods and gravity
Post by: ShadowWolf_IH on July 07, 2003, 10:21:30 am
what do we want?  we want our trucks and tanks to stay on the ground.  I think that's the simplest way to answer it.  

We want to have our ground targets move from Point A to Point B during combat without taking flight.  

I don't see having a big ship orbitting a planet in the game as a practical use.  In order to be realistic it would be quite a distance from the planet and we would be having a ton of high poly models for the planets.

i have ground attack capabilities, but all of my targets have to remain stationary to fight me.......otherwise they keep trying to fly away.   This is the problem that we want to correct.
Title: Mods and gravity
Post by: Flaser on July 07, 2003, 10:32:25 am
I think then it's more a matter of creating a new collision model for the tanks and everything else.
These ground objects should always accelerate toward the ground with a fixed speed, that you could set in FRED as planet gravity, so you could simulate a moon.
You would need to use a huge terrain mesh, to make the whole ordeal realistic.
What the new collision model would do is that it would slow down the objects, so instead bouncing back it would absorb a high ammount of the speed, thereby the objects wouldn't bounce back.
You don't need gravity or fancy tractor beams.
You need objects with a new ground/object collision model and a constant acceleration toward the ground.
Title: Mods and gravity
Post by: Woolie Wool on July 07, 2003, 10:35:43 am
I'm not terribly enthusiastic about the idea of gravity; it sounds like a real pain and more trouble than it's worth. I want a sky nebula for FS2 because I had some ideas for low-altitude combat (Descent-style with no real gravity), but none of them came to fruition because I had no way to simulate an atmosphere.
Title: Mods and gravity
Post by: Woolie Wool on July 07, 2003, 10:39:14 am
Quote
Originally posted by ShadowWolf_IH
what do we want?  we want our trucks and tanks to stay on the ground.  I think that's the simplest way to answer it.  

We want to have our ground targets move from Point A to Point B during combat without taking flight.  

I don't see having a big ship orbitting a planet in the game as a practical use.  In order to be realistic it would be quite a distance from the planet and we would be having a ton of high poly models for the planets.

i have ground attack capabilities, but all of my targets have to remain stationary to fight me.......otherwise they keep trying to fly away.   This is the problem that we want to correct.


If you must do an orbital bombardment mission, you should just use the "fleet" backgrounds available from one of the HLP hosted sites (I forgot which one). They come in Terran, Vasudan, and Shivan varieties and slap them over a planet. Then have Alpha 1 go on a mission to protect them or whatever while they reduce the planet to cinders and use briefings and debriefings to make it more convincing.
Title: Mods and gravity
Post by: LtNarol on July 07, 2003, 10:51:27 am
Woolie, I don't think we're talking about the same thing here; and Flaser, you pretty much just described gravity in your last statement: constant acceleration.

My idea was as follows:

Create 2 new flags so that we don't have to hardcode the terrain models, one flag for a gravity source model, one flag for a ship that is affected by the source.  This is to prevent current fs2 ships from being affected by the gravity source, as then you'd have a lot of things crashing into the planet.

Ships using the affected by grav source flag will accelerate with a constant acceleration rate toward the source, but stop when they come within a certain distance of a polygon on the terrain model.  I was thinking that this radius could be table specified instead of pof specified the way collisions are handled now.  This allows for hovering vehicles.  

With this, tanks should be able to leave the ground for brief moments when using afterburners, but in the end, they'd end up back on the ground.  

This just leaves roll, a tank rolling sideways looks bad to say the least, is there a way to limit the amount a craft can roll in either direction?
Title: Mods and gravity
Post by: ShadowWolf_IH on July 07, 2003, 11:15:02 am
not orbital bombardment.  Literally escorting dropships to the planet so that they can deposit ground forces.  Destroying enemy ground forces.  Very much an atmospheric mission.  

If we use a source of grav, instead of stopping a certain distance from it, why not have a "no collide no fly through" flag.    Basically it would allow the target object to rest against the source model without taking damage or having the effects of a collision.  Other than that I really like the idea of everything being table controlled instead of POF controlled.
Title: Mods and gravity
Post by: Flaser on July 07, 2003, 12:15:41 pm
LtNarol I wasn't speaking of gravity.
A constant acceleration is something entiely different than true gravity.
It would work only if the objects hadn't changed altitude more than a couple of thousand of meters (9km max.) since than the ammount of the acceleration would change as well.
Thank god, we wouldn't have to deal with masses and forces, since the acceleration of an object towards another is only affected by the other object's mass, so in this case it's only the planet's mass that decides how fast things would accelerate.
The hell hard part is that true gravity simulation would have to constantly check the distance and divide the acceleration accordingly.
I don't like the hoveriung idea too much, 'cause it is bypassing the problem and wouldn't result in a truly ground based tank.
By adddin/(replacing) the bouncing collision model with a damping one we could even mnake fighters crash into the ground correctly.
I think fighters too should be affected.
To do an atmosperic mission you would need to fly speacial crafts that are fit to go in the air.
Most FS ships are not - except maybe the Valkyre and the Perseus, but I have my doubts.

So to sum up my "idea":rolleyes::
-New collision model for the ground, this would make the whole distance and hovering problems irrevelant
-Constant FRED assigned acceleration to simulte gravity.
-Special fighters fit for atmosperic flight.
-Special tanks and other ground vechicles.

The later crafts should be the hardest part.
They should be given a new flight model. Basicly they would fly like any other fighter. The difference would be that they would be given a lift.

This is the hardest point in the atmospheric flight model.
Any ariplane uses its wings to create a lift.
So I think a flag should be given to these crafts - has wings - or smg. like that, pluss a factor that would tell the ammount of lift the craft gets compared to its direction of movement and speed.

Here's how I imagine it during "action":
-The plane goes at 80m/s it has wings and a factor of 0.2. With gravity around 10m/s, and  its lift would be 16m/s so it would gain altitude with 6m/s.
-If the fighter does a roll it's lift would still be aplied normal to its course, so it it's in 45 degree bank only 50% of the lift would be aplied to keeping the craft afloat, the rest would actually help it to turn.
So it would loose altitude by 2m/s and it would gain 8m/s of turning speed.

The whole's not that hard to implement.
You give a constant vector to the each and every plane toward the ground.
Plus you give them a vector normal to their currect current direction of flight. So you check their direction of speed, multply that by the factor, and aply the vector normal to the wings.

Tanks wouldn't have wings. They shouldn't have thrusters, so it would make them appear as if they weren't modified ships.
Simply they would always hit the ground, but the new collision model would wimply set their speed normal to the ground zero, instead -1*factor*their original speed.
That would keep them on the ground, but you could even do rally on the terrain, since any speed parallel to the ground wouldn't be affected!
Title: Mods and gravity
Post by: ShadowWolf_IH on July 07, 2003, 12:27:02 pm
I agree on the point that fighters should be affected as well.  But let's not get too far.  Keeping it simple for the first will get get us a lot further than trying to con....er convince the SCP guys to give us a complete newtonian physics work up.  Right now i would be happy if the damned tanks would stay on the ground and still be able to move freely in combat.
Title: Mods and gravity
Post by: LtNarol on July 07, 2003, 12:30:57 pm
Alright, consider yourselves very VERY lucky that I'm desperate to convince flaser.  These models were intended to be used for Exposition just to round out the experience of atmospheric combat, however, due to uncooperative game features (auto-roll and down-pitch when banking) TankWars on PXO never worked out.

I present to you 2 of 4 ground vehicles originally designed for player use: the Jaguar and Jaguar Mk II
Title: Mods and gravity
Post by: LtNarol on July 07, 2003, 12:39:04 pm
How you plan to implement this I can't really understand, but I do ask that you allow for a hover distance (same as a regular distance, only keeping a "hover distance" above the terrain, if you catch my drift).  As for fighters and big ships and the effect radius, I really like the idea of not having an effect radius and just using flags for ships that are affected.  The easiest way to sim atmospheric capability without a whole lotta code is just to ignore the acceleration vector for that ship.
Title: Mods and gravity
Post by: StratComm on July 07, 2003, 12:55:49 pm
One MAJOR concern with that; Freespace wasn't designed as a aerospace flight sim and simply won't act right if you try to force true atmospheric flight conditions on to the existing ships.  You might as well write a seperate engine to deal with this by the time you work out the details.  The ground (and its associated collision system) are another point of concern, as you're going to need a huge polycount model to come close to simulating a playable area.  Plus, to keep land vehicles hugging the ground, if you actually have interesting terrain that is, is another complication that a simple downward acceleration/lift model won't handle.
Title: Mods and gravity
Post by: LtNarol on July 07, 2003, 12:58:37 pm
Atmospheric conditions may be too much to ask, but thats not what we're talking about when we say we want ground units to hug the ground.  We also have our ways of dealing with high polyness ;)
Title: Mods and gravity
Post by: ShadowWolf_IH on July 07, 2003, 01:09:07 pm
I have to go with LT on this one.  We each solved the high poly problem from two different angles......and each one works well.  so yes, terrain and city scapes are easily done. And by the way, we solved those problems last year.
Title: Mods and gravity
Post by: Flaser on July 07, 2003, 01:11:00 pm
So you do want hovertanks? :devil:
That would be harder to code than a normal tank.

What I proposed was the following:
-New collision model
  - I think if someone with good C++/SCP knowledge looked into the issue he wouldn't find my model that hard to implement, since it would be simply a version of the exiting code.
-Adding a vector to each and all crafts in the are = gravity.
-Adding another vector to planes = atmosperic craft.

I think adding a vector is a lot less complicated than cheking the distance.
The problem with the later is that the terrain could be rough, have hills, furthermore you would have to calculate for each and every craft.
With the added vectors, you don't need any sensitive data calculated from a warying none dependable source, in other words IMHO it is easier to implement.

I'm troubled though - creting your hover craft is harder to do without a distance check, let me think about it...
I think the easieast would be adding a vector to them just like to aircraft.
The problematic part is that the hovercraft actually "push themselves off the ground". So there is a distance check - argh! - and that would be hard to implement.
Doing it through a table has its merits, but you'll run into a range of problems with no so plain - and most of all - not so boring terrain.
I have an idea thoug - create the models using an invisible part, that is a box that touches the ground - the collision of that part could simulate howering.
I know it is ugly as hell and would be quite disturbing, but it is what I can come up with during the spur of the moment.
Title: Mods and gravity
Post by: LtNarol on July 07, 2003, 01:48:42 pm
Well if all you need is an invisible polygon, thats easy, what about rolling though?
Title: Mods and gravity
Post by: Flaser on July 07, 2003, 02:06:53 pm
I wonder what would happen if you set rotation time to 0 in the ship.tbl...
Title: Mods and gravity
Post by: LtNarol on July 07, 2003, 02:30:35 pm
Quote
Originally posted by Flaser
I wonder what would happen if you set rotation time to 0 in the ship.tbl...
you mean 999999999999, and yes, it works.  problem is that ships auto-roll and auto-downpitch when they bank

and yes, i still think its better just to have unflagged fighters be unaffected by "gravity", easier to code if you just check one boolean
Title: Mods and gravity
Post by: Flaser on July 07, 2003, 03:34:40 pm
For the first version I believe yoy shouldn't deal with both fighters and gravity - therefore I have to agree with the flagstuff.
I meant 0 as zero.
It's definitly an SCP thing, but I believe they would tell you how to limit/disable those on a fighter/tank.
IMHO the key to the project is still a new collision model.
Title: Mods and gravity
Post by: LtNarol on July 07, 2003, 06:19:22 pm
Since I'm not fluent in the inner workings of the FS2 engine, I'll let you worry about that.  I do know that using a 0 doesn't work however, and 999999999 (etc, etc) does limit rotation on that one axis.