Difference between revisions of "API:FlightGlobals"
From Kerbal Space Program Wiki
m (*code syntax highlighted; *use default box style;) |
m (Bodies is of the type System.Collections.Generic.List<CelestialBody>, as opposed to CelestialBody(which is just a singe body)) |
||
Line 23: | Line 23: | ||
{{Method|returntype=double|name=getStaticPressure|args={{type|Vector3d}} position, {{type|CelestialBody}} body|desc=The air pressure of body's atmosphere at position, in some arbitrary units (likely atmospheres).}} | {{Method|returntype=double|name=getStaticPressure|args={{type|Vector3d}} position, {{type|CelestialBody}} body|desc=The air pressure of body's atmosphere at position, in some arbitrary units (likely atmospheres).}} | ||
{{Property|type=Vessel|name=ActiveVessel|hasget=1|desc=The vessel currently being controlled by the player.}} | {{Property|type=Vessel|name=ActiveVessel|hasget=1|desc=The vessel currently being controlled by the player.}} | ||
− | {{Property|type=CelestialBody|array=[]|name=Bodies|hasget=1|desc=An array containing all the celestial bodies in the universe.}} | + | {{Property|type=List<CelestialBody>|array=[]|name=Bodies|hasget=1|desc=An array containing all the celestial bodies in the universe.}} |
{{Property|type=float|name=DragMultiplier|hasget=1|desc=A proportionality constant that scales the strength of aerodynamic drag forces.}} | {{Property|type=float|name=DragMultiplier|hasget=1|desc=A proportionality constant that scales the strength of aerodynamic drag forces.}} | ||
{{Property|type=List|array=<{{type|Vessel}}>|name=Vessels|hasget=1|desc=A list of all the Vessels in the universe.}} | {{Property|type=List|array=<{{type|Vessel}}>|name=Vessels|hasget=1|desc=A list of all the Vessels in the universe.}} |
Latest revision as of 23:46, 24 March 2019
The FlightGlobals class contains a number of useful static functions and fields.
Useful members
A number of FlightGlobals functions have two versions: one that takes a CelestialBody as an argument and one that doesn't. Presumably the second version uses the mainBody of the active vessel. Below are listed only the versions that take an explicit CelestialBody argument.
Signature | Description |
---|---|
float GetAltitudeAtPos(Vector3 position, CelestialBody body) | Gives the altitude of a given world position above body's sea level. |
double getAtmDensity(double pressure) | Calculates an atmospheric density in some arbitrary units (likely kg/m3). Presumably it's meant to take as input the output of FlightGlobals.getStaticPressure. The following code seems to work quite well to compute the drag force on a part and may in fact be the game's drag formula:
|
Vector3d getGeeForceAtPosition(Vector3d pos) | The gravitational acceleration (not force) at the position pos. Does this compute which SOI pos is in or does it assume that pos is in the SOI of the active vessel's mainBody? |
double getStaticPressure(Vector3d position, CelestialBody body) | The air pressure of body's atmosphere at position, in some arbitrary units (likely atmospheres). |
Vessel ActiveVessel { get; } | The vessel currently being controlled by the player. |
List<CelestialBody> Bodies { get; } | An array containing all the celestial bodies in the universe. |
float DragMultiplier { get; } | A proportionality constant that scales the strength of aerodynamic drag forces. |
List Vessels { get; } | A list of all the Vessels in the universe. |