The datarefs inside the sim/flightmodel2/wing/ are array indices for each wing on the plane. To understand how these array indices work, we need to consider how X-Plane manages “wings”.
Everything is a wing
In X-Plane, all airfoils (except for those that form propellers and pylons) are “wings”. This includes:
- 8 regular “wings”, each of which comes 4 pairs of left-right.
- 2 horizontal stabilizers, left and right.
- 2 vertical stabilizers (rudders).
- Up to 20 “misc” wings.
For the purpose of this tech note we will use the term ‘wing’ to mean any one of these airfoils.
Each wing is assigned as being on the left or right side of the plane – this is how X-Plane knows whether a left roll moves the ailerons on this part up or down. Left right assignment is automatic for the regular wings and stabilizers, and manual in Plane-Maker for misc wings. (Vertical stabilizers are categorized as right wings, but in practice you should assume that ailerons on vertical stabilizers is a poor idea in X-plane — use a misc wing if you really need this, or tilt the horizontal stabilizers up like the cirrus jet).
Each wing may or may not be used in the actual plane, and if it is used, it is defined into a fixed number of slices running laterally across the airfoil. The airfoil properties are fixed for each wing, but the control surfaces can be set per slice. The control surface deflections and longitudinal geometry (e.g. how deep are the ailerons, where on the wing do the flaps sit) are set globally.
Now here’s where the array comes in: X-Plane calculates one control deflection for:
- Each type of control (rudder 1, rudder 2, aileron 1, aileron 2) crossed by
- Each actual existing wing
Individual control surfaces are then deflected on a per-slice basis by looking up the deflection for that part.
Two sets of everything
X-Plane features two sets of most controls (flaps, ailerons, etc) to allow for different maximum deflections and longitudinal positions. A number of other advanced control surface options can act differently on each set. For example, a plane might have a “small” set of ailerons on the far edge of the wing with small deflections and a small longitudinal size. A second set might be on a different part of the wing with larger deflections and larger longitudinal length.
Wing to Array Index Table
The mapping of array indices to wings is:
0 Left wing 1
1 Right wing 1
2 Left wing 2
3 Right wing 2
4 Left wing 3
5 Right wing 3
6 Left wing 4
7 Right wing 4
8 Left horizontal stabilizer
9 Right horizontal stabilizer
10 Vertical Stabilizer 1
11 Vertical Stabilizer 2
12 Misc Wing 1
13 Misc Wing 2
14 Misc Wing 3
15 Misc Wing 4
16 Misc Wing 5
17 Misc Wing 6
18 Misc Wing 7
19 Misc Wing 8
20 Misc Wing 9
21 Misc Wing 10
22 Misc Wing 11
23 Misc Wing 12
24 Misc Wing 13
25 Misc Wing 14
26 Misc Wing 15
27 Misc Wing 16
28 Misc Wing 17
29 Misc Wing 18
30 Misc Wing 19
31 Misc Wing 20
Using the Wing Datarefs For Animation
The rules for animating via the wing datarefs is:
- use the control deflection array index that corresponds to the part of the wing you are really animating! This addresses several possible problems:
- If the wing you animate is not on the same side of the plane as the dataref index you use, you could have an inverted animation.
- If the wing is not present at all, the dataref might not move at all.
- use the right TYPE of dataref. To animate an aileron that matches aileron 1 in position, use aileron1_deg, not aileron2_deg, yoke_roll, or any other “proxy”. By using the exact right dataref, you guarantee that the animation matches all of X-Plane’s behaviors.
- Do not nest animations!!! X-Plane’s wing control deflection outputs in this dataref are the sum of all control surface activity. For example, if you have a plane that maps ailerons to spoilers at low speed and speed brakes to spoilers, then when both are in effect the spoiler1_deg dataref will be the sum of all deflections. You do not need to nest animations to add up multiple control influences.
- Use the special controls in PlaneMaker to achieve effects like roll spoilers – this way you can follow the rule above.
Custom Control Deflections Via Plugins
As of X-Plane 940, I do not believe that X-Plane will ever write different deflections into different wings, even with special controls. However, it is possible to override sim/operation/override/override_control_surfaces. At this point a large number of datarefs are under plugin control including the wing offsets. In this scenario, a single wing (but not a slice of a wing) could have a deflection that varies from all other parts.
In this way, it is possible to have up to 8 different speed-brake panel deployments (for example) on a single (4-part) airliner wing: a plugin would simply write a different value to each of speedbrake1_deg and speedbrake2_deg for each of the 4 left wings.
In this case it is particularly important for the animated model to match the right array index.