Simulate the flow of air around an airfoil. This class applies passive forces on a flight object, such as lift and drag. It only applies these forces based on the current state of the wing, but never changes the actual wing itself (so no flapping).
Inheritance: FlightObject
Ejemplo n.º 1
0
 void OnEnable()
 {
     if (flightObject == null)
     {
         string msg = "Unable to display stat information: No flight object set for " + gameObject.name;
         msg += " Please set the \'Flight Object\' variable to an object which has the \'FreeFlight\' script attached";
         Debug.LogWarning(msg);
         this.enabled = false;
     }
     if (ff == null)
     {
         ff = flightObject.GetComponent <FreeFlight>();
     }
     if (ff == null)
     {
         string msg = "GameObject '" + flightObject.name + "' doesn't have the 'FreeFlight' script attached. Unable " +
                      "to display flight statistics.";
         Debug.LogWarning(msg);
         this.enabled = false;
     }
     if (ff != null)
     {
         ffp = ff.flightPhysics;
     }
 }
Ejemplo n.º 2
0
    public override void OnInspectorGUI()
    {
        FreeFlight        ff = (FreeFlight)target;
        FreeFlightPhysics fp = ff.flightPhysics;


        if (_showFlightControls = EditorGUILayout.Foldout(_showFlightControls, "Flight Controls"))
        {
            editorFlightControls(ff);
        }
        if (_showGroundControls = EditorGUILayout.Foldout(_showGroundControls, "Ground Controls"))
        {
            editorGroundControls(ff);
        }
        if (_showTakeoffLanding = EditorGUILayout.Foldout(_showTakeoffLanding, "Takeoff/Landing Controls"))
        {
            editorTakeoffLanding(ff);
        }
        if (_showPhysics = EditorGUILayout.Foldout(_showPhysics, "Physics"))
        {
            editorPhysics(ff, fp);
        }
        if (_showProperties = EditorGUILayout.Foldout(_showProperties, "Wing Properties"))
        {
            editorWingProperties(fp);
        }

        //save the free flight object if the user has made changes
        if (GUI.changed)
        {
            EditorUtility.SetDirty(ff);
        }
    }
Ejemplo n.º 3
0
 void editorPhysics(FreeFlight ff, FreeFlightPhysics fp)
 {
     ff.state = (FreeFlight.FlightState)EditorGUILayout.EnumPopup("Flight State", ff.state);
     ff.applyFlightPhysicsOnGround = EditorGUILayout.Toggle("Flight Physics on Ground", ff.applyFlightPhysicsOnGround);
     fp.liftEnabled    = EditorGUILayout.Toggle("Lift", fp.liftEnabled);
     fp.dragEnabled    = EditorGUILayout.Toggle("Drag", fp.dragEnabled);
     fp.gravityEnabled = EditorGUILayout.Toggle("Gravity", fp.gravityEnabled);
 }
Ejemplo n.º 4
0
 void editorWingProperties(FreeFlightPhysics fp)
 {
     fp.Unit        = (UnitConverter.Units)EditorGUILayout.EnumPopup(fp.Unit);
     fp.Preset      = (FlightObject.Presets)EditorGUILayout.EnumPopup(fp.Preset);
     fp.WingSpan    = EditorGUILayout.FloatField("Wing Span (" + fp.getLengthType() + ")", fp.WingSpan);
     fp.WingChord   = EditorGUILayout.FloatField("Wing Chord (" + fp.getLengthType() + ")", fp.WingChord);
     fp.WingArea    = EditorGUILayout.FloatField("Wing Area (" + fp.getAreaType() + ")", fp.WingArea);
     fp.AspectRatio = EditorGUILayout.Slider("Aspect Ratio", fp.AspectRatio, 1, 16);
     fp.Weight      = EditorGUILayout.FloatField("Weight (" + fp.getWeightType() + ")", fp.Weight);
     if (GUILayout.Button("Align To Wing Dimensions"))
     {
         fp.setFromWingDimensions();
     }
     if (GUILayout.Button("Align Dimensions From Area & AR"))
     {
         fp.setWingDimensions();
     }
 }
Ejemplo n.º 5
0
 void OnEnable()
 {
     if (flightObject == null) {
         string msg = "Unable to display stat information: No flight object set for " + gameObject.name;
         msg += " Please set the \'Flight Object\' variable to an object which has the \'FreeFlight\' script attached";
         Debug.LogWarning (msg);
         this.enabled = false;
     }
     if (ff == null)
         ff = flightObject.GetComponent<FreeFlight>();
     if (ff == null) {
         string msg = "GameObject '"+ flightObject.name + "' doesn't have the 'FreeFlight' script attached. Unable " +
             "to display flight statistics.";
         Debug.LogWarning (msg);
         this.enabled = false;
     }
     if (ff != null)
         ffp = ff.flightPhysics;
 }
 void editorPhysics(FreeFlight ff, FreeFlightPhysics fp)
 {
     ff.state = (FreeFlight.FlightState) EditorGUILayout.EnumPopup("Flight State", ff.state);
     ff.applyFlightPhysicsOnGround = EditorGUILayout.Toggle ("Flight Physics on Ground", ff.applyFlightPhysicsOnGround);
     fp.liftEnabled = EditorGUILayout.Toggle ("Lift", fp.liftEnabled);
     fp.dragEnabled = EditorGUILayout.Toggle ("Drag", fp.dragEnabled);
     fp.gravityEnabled = EditorGUILayout.Toggle ("Gravity", fp.gravityEnabled);
 }
 void editorWingProperties(FreeFlightPhysics fp)
 {
     fp.Unit = (UnitConverter.Units) EditorGUILayout.EnumPopup (fp.Unit);
     fp.Preset = (FlightObject.Presets)EditorGUILayout.EnumPopup (fp.Preset);
     fp.WingSpan = EditorGUILayout.FloatField ("Wing Span (" + fp.getLengthType() + ")", fp.WingSpan);
     fp.WingChord = EditorGUILayout.FloatField ("Wing Chord (" + fp.getLengthType() + ")", fp.WingChord);
     fp.WingArea = EditorGUILayout.FloatField ("Wing Area (" + fp.getAreaType() + ")", fp.WingArea);
     fp.AspectRatio = EditorGUILayout.Slider ("Aspect Ratio", fp.AspectRatio, 1, 16);
     fp.Weight = EditorGUILayout.FloatField ("Weight (" + fp.getWeightType() + ")", fp.Weight);
     if( GUILayout.Button("Align To Wing Dimensions" ) ) 		{fp.setFromWingDimensions ();}
     if (GUILayout.Button ("Align Dimensions From Area & AR") ) 	{fp.setWingDimensions ();}
 }