Repository navigation
curves.tbl
Revision information OFP Revision: #114 Set the revision to your PR when your PR changes what this page documents. Leave it alone for edits that only fix or improve the documentation.
The curves.tbl defines curves: mappings from an X value to a Y value. Other tables use them in many places, and what X and Y mean depends on where the curve is used. When a curve is used, an X value goes in and the Y value comes out.
This table is one of the Modular Tables and can be extended with xxx-crv.tbm.
Code: /math/curve.cpp. See Tables for every table.
Badges show the version a field or behavior was added in.
Field index (every field, in table order; click one to jump to it)
Constant | Linear | Polynomial | Circular | Any other previously defined curve
This section defines the individual curve functions.
The unique name to identify this particular curve.
- Names are case-sensitive and can't contain parentheses (that's an error).
- A name that already exists, including a built-in curve's, replaces that curve's keyframes.
- Required once for a curve, to begin listing its keyframes with the following syntax:
(X, Y): Interpolation function, any parameters...
- Entries like the above can be repeated as many times as necessary
- The X values must come in ascending order. A keyframe with a smaller X than the one before it logs a warning and is skipped.
- The last X value must be at least 1. If it isn't, a warning is logged and a (1, 1) keyframe is added. (This check is skipped for the last curve in a table, the one followed by
#End.) Example:
(0, 1): Polynomial, 2, true
Interpolation functions define how the curve should change in between keyframes. There are several basic interpolation functions, but note that any previously defined curve can itself be used as an interpolation function. The engine provides quite a few non-basic curves as well.
Function names are case-sensitive: Constant, Linear, Polynomial, Circular. Any other name is looked up as a curve; one that isn't defined yet logs a warning and that keyframe is skipped.
The simplest interpolation, the output Y value is equal to the keyframe's Y value for its entire domain.
- No parameters.
A slightly less simple interpolation, the output Y value is a straight line between the keyframe's Y value and the next keyframe's Y value.
- No parameters.
A smooth interpolation gentle at one end, harsh on the other. The output Y value is a polynomial curve of the given degree from the keyframe's Y value and the next keyframe's Y value. Parameters:
- Float, Degree. A degree 2 polynomial is quadratic, degree 3 is cubic, etc. High degree makes the 'gentle' end even gentler and the 'harsh' end even harsher.
- Boolean, "Ease in". Defaults to true. Whether to "ease in" or "ease out". Easing in means the slow, gentle end is first and then the function harshly goes to the next Y value. Easing out does the opposite, it harshly goes to the next Y value, and spends most of the time gradually arriving.
A smooth interpolation function which takes the form of a (possibly stretched) circular segment. Parameters:
- Boolean, "Ease in". Defaults to true. Whether to "ease in" or "ease out". Easing in means the slow, gentle end is first and then the function harshly goes to the next Y value. Easing out does the opposite, it harshly goes to the next Y value, and spends most of the time gradually arriving.
Provided the curve has already been defined (in this table, an earlier one, or a built-in curve), another curve may be nested into new ones. This keyframe's X and Y values will be used as 0, 0 in the original curve, and the next keyframe's X and Y values will be used as 1, 1 in the original curve.
- No parameters.
Many functions from Easing functions are provided built-in, each going from 0 to 1 as X goes from 0 to 1:
| Quad | Cubic | Quart | Quint | Circ | |
|---|---|---|---|---|---|
| Ease in | EaseInQuad |
EaseInCubic |
EaseInQuart |
EaseInQuint |
EaseInCirc |
| Ease out | EaseOutQuad |
EaseOutCubic |
EaseOutQuart |
EaseOutQuint |
EaseOutCirc |
| Ease in and out | EaseInOutQuad |
EaseInOutCubic |
EaseInOutQuart |
EaseInOutQuint |
EaseInOutCirc |
Each also has a reversed version, going from 1 to 0, with Rev added to the name: EaseInOutQuadRev. The names are case-sensitive, so they must be written exactly as shown (easings.net writes them starting in lowercase, which won't work here).
#Curves
$Name: test1
$KeyFrames:
(0, 1): Polynomial, 2, true
(1, 0): Constant
$Name: test2
$KeyFrames:
(0, 0): Circular
(0.5, 1): EaseInQuad
(1, 0): Constant
#End
In all places where the engine and other tables ask for a curve by name, it is also possible to define a curve inline. Defining curves inline is less powerful, but can be less of a hassle. Inline curves always follow the same pattern:
(keyframe-X,keyframe-Y) operator (keyframe-X,keyframe-Y) ...
with as many keyframes and operators chained together as required. The curve ends at the first keyframe without an operator after it. Possible operators are:
-- Linear Interpolation
-| Constant Interpolation
-/ Square (Polynomial 2) Interpolation with Ease In
/- Square (Polynomial 2) Interpolation with Ease Out
#Primary Weapons
$Name: @Subach HL-7
+nocreate
$Lifetime Curve:
+Input: Lifetime
+Output: Laser Radius Mult
+Curve Name: (0,0) -- (0.5,1000) -- (1,0)
$Lifetime Curve:
+Input: Lifetime
+Output: Laser Glow R Mult
+Curve Name: (0,0) -- (0.5,1000) -- (1,0)
#End
Getting Started
Features
SEXPs
Lua Scripting
Tables
-
Tables
- ai.tbl
- Animation (-anim.tbm)
- armor.tbl
- asteroid.tbl
- autopilot.tbl
- cheats.tbl
- colors.tbl
- controlconfigdefaults.tbl
- coordinate_points.tbl
- credits.tbl
- curves.tbl
- cutscenes.tbl
- Decals (-dcl.tbm)
- default_settings.tbl
- Dynamic SEXPs (-sexp.tbm)
- editor.tbl
- fireball.tbl
- fonts.tbl
- game_settings.tbl
- generated_nebula.tbl
- glowpoints.tbl
- help.tbl
- hud_gauges.tbl
- icons.tbl
- iff_defs.tbl
- intel.tbl
- lighting_profiles.tbl
- lightning.tbl
- mainhall.tbl
- medals.tbl
- messages.tbl
- mflash.tbl
- mission_profiles.tbl
- music.tbl
- nebula.tbl
- objecttypes.tbl
- Particle Effects (-part.tbm)
- post_processing.tbl
- props.tbl
- rank.tbl
- scripting.tbl
- ships.tbl
- sounds.tbl
- species_defs.tbl
- ssm.tbl
- stars.tbl
- strings.tbl
- tips.tbl
- traitor.tbl
- tstrings.tbl
- virtual_pofs.tbl
- weapons.tbl