Class SailController
Manages sail physics by calculating and applying lift and drag forces based on sail geometry, orientation, and wind conditions. Uses four corner transforms (a, b, c, d) to define sail shape, enabling dynamic sail configurations including furling and multi-part sails. Calculates apparent wind from true wind and vessel velocity, then applies aerodynamic forces at the sail's surface-weighted center. The corner transforms follow a clockwise pattern: a (bottom left/front), b (top left/front), c (top right/rear), d (bottom right/rear). Corner transforms can be attached to different parents to enable sail furling or complex rigging systems. Use SailRotator for user-controlled sail rotation. Requires a WindGenerator in the scene and a SailPreset for aerodynamic coefficients.
Namespace: NWH.DWP2.SailController
Assembly: NWH.DWP2.dll
Syntax
public class SailController : MonoBehaviour
Fields
| Edit this page View Sourcea
Bottom left corner of the sail for square sails, or bottom front corner for triangular sails. First point in the clockwise corner definition pattern. Can be attached to any parent transform to enable dynamic sail configurations.
Declaration
[Tooltip("Bottom left sail corner if square sail.\r\nOtherwise bottom front.")]
public Transform a
Field Value
| Type | Description |
|---|---|
| Transform |
airDensity
Air density in kg/m³ used in aerodynamic force calculations. Standard sea level value is 1.225 kg/m³. Can be adjusted as a multiplier to scale all sail forces uniformly without modifying the preset.
Declaration
[Tooltip("The air density. Can also be used\r\nas a force coefficient as this affects both lift and drag forces equally.")]
public float airDensity
Field Value
| Type | Description |
|---|---|
| float |
b
Top left corner of the sail for square sails, or top front corner for triangular sails. Second point in the clockwise corner definition pattern. Can be attached to any parent transform to enable dynamic sail configurations.
Declaration
[Tooltip("Top left sail corner if square sail.\r\nOtherwise top front.")]
public Transform b
Field Value
| Type | Description |
|---|---|
| Transform |
c
Top right corner of the sail for square sails, or top rear corner for triangular sails. Third point in the clockwise corner definition pattern. Can be attached to any parent transform to enable dynamic sail configurations.
Declaration
[Tooltip("Top right sail corner if square sail.\r\nOtherwise top rear.")]
public Transform c
Field Value
| Type | Description |
|---|---|
| Transform |
d
Bottom right corner of the sail for square sails, or bottom rear corner for triangular sails. Fourth point in the clockwise corner definition pattern. Can be attached to any parent transform to enable dynamic sail configurations.
Declaration
[Tooltip("Bottom right sail corner if square sail.\r\nOtherwise bottom rear.")]
public Transform d
Field Value
| Type | Description |
|---|---|
| Transform |
sailPreset
Defines the aerodynamic characteristics of the sail through lift and drag coefficient curves. Contains the relationship between angle of attack and force coefficients.
Declaration
public SailPreset sailPreset
Field Value
| Type | Description |
|---|---|
| SailPreset |
Properties
| Edit this page View SourceAngleOfAttack
Angle in degrees between the sail's forward direction and the apparent wind direction. Measured on the horizontal plane using Vector3.up as the reference axis. Used to determine lift and drag coefficients from the SailPreset curves. Positive values indicate wind from the starboard side, negative values from port side.
Declaration
public float AngleOfAttack { get; }
Property Value
| Type | Description |
|---|---|
| float |
ApparentWind
Wind experienced by the sail relative to the moving vessel. Calculated as the vector difference between true wind and vessel velocity. This is the effective wind that generates aerodynamic forces on the sail. Measured in meters per second.
Declaration
public Vector3 ApparentWind { get; }
Property Value
| Type | Description |
|---|---|
| Vector3 |
SailArea
Total surface area of the sail in square meters. Calculated from the quadrilateral formed by corner points a, b, c, and d. Used in aerodynamic force calculations along with dynamic pressure.
Declaration
public float SailArea { get; }
Property Value
| Type | Description |
|---|---|
| float |
SailCenter
Surface-weighted center point of the sail in world space. All aerodynamic forces are applied at this position. Calculated from the quadrilateral formed by corner points a, b, c, and d.
Declaration
public Vector3 SailCenter { get; }
Property Value
| Type | Description |
|---|---|
| Vector3 |
SailForce
Total aerodynamic force vector applied to the vessel at the sail center point. Combines lift and drag forces based on sail geometry, apparent wind, and aerodynamic coefficients. Measured in Newtons.
Declaration
public Vector3 SailForce { get; }
Property Value
| Type | Description |
|---|---|
| Vector3 |
SailForward
Forward direction vector of the sail in world space. Determined by the vector from corner point d to corner point a. Used to calculate the angle of attack relative to the apparent wind.
Declaration
public Vector3 SailForward { get; }
Property Value
| Type | Description |
|---|---|
| Vector3 |
SailRight
Right direction vector of the sail in world space. Derived from the cross product of SailUp and SailForward. Defines the direction of lift force generation perpendicular to the sail plane.
Declaration
public Vector3 SailRight { get; }
Property Value
| Type | Description |
|---|---|
| Vector3 |
SailUp
Up direction vector of the sail in world space. Calculated from the average of the top edge to the average of the bottom edge. Used to determine sail orientation and compensate for heel angle.
Declaration
public Vector3 SailUp { get; }
Property Value
| Type | Description |
|---|---|
| Vector3 |
ShipVelocity
Current velocity of the vessel's Rigidbody in world space. Used to calculate apparent wind by combining with true wind. Measured in meters per second.
Declaration
public Vector3 ShipVelocity { get; }
Property Value
| Type | Description |
|---|---|
| Vector3 |
TrueWind
True wind vector from the WindGenerator, representing the actual environmental wind. Does not account for vessel motion. Measured in meters per second.
Declaration
public Vector3 TrueWind { get; }
Property Value
| Type | Description |
|---|---|
| Vector3 |