コード例 #1
0
    private void Start()
    {
        tail = new PhysicsEngineForFun.AeroForceOnRigidBody(
            new PhysicsEngineForFun.Matrix3(0, 0, 0, -1, -0.5f, 0, 0, 0, -0.1f),
            new PhysicsEngineForFun.Vector3(2.0f, 0, 0),
            PhysicsEngineWindSpeed);

        left_wing = new PhysicsEngineForFun.AeroForceControlOnRigidBody(
            new PhysicsEngineForFun.Matrix3(0, 0, 0, -1, -0.5f, 0, 0, 0, 0),
            new PhysicsEngineForFun.Matrix3(0, 0, 0, -1.005f, -0.5f, 0, 0, 0, 0),
            new PhysicsEngineForFun.Matrix3(0, 0, 0, -0.995f, -0.5f, 0, 0, 0, 0),
            new PhysicsEngineForFun.Vector3(-1, 0, -2),
            PhysicsEngineWindSpeed);
        left_wing.controlSetting = 0;

        right_wing = new PhysicsEngineForFun.AeroForceControlOnRigidBody(
            new PhysicsEngineForFun.Matrix3(0, 0, 0, -1, -0.5f, 0, 0, 0, 0),
            new PhysicsEngineForFun.Matrix3(0, 0, 0, -1.005f, -0.5f, 0, 0, 0, 0),
            new PhysicsEngineForFun.Matrix3(0, 0, 0, -0.995f, -0.5f, 0, 0, 0, 0),
            new PhysicsEngineForFun.Vector3(-1, 0, 2),
            PhysicsEngineWindSpeed);
        right_wing.controlSetting = 0;

        rudder = new PhysicsEngineForFun.AeroForceControlOnRigidBody(
            new PhysicsEngineForFun.Matrix3(0, 0, 0, 0, 0, 0, 0, 0, 0),
            new PhysicsEngineForFun.Matrix3(0, 0, 0, 0, 0, 0, -0.01f, 0, 0),
            new PhysicsEngineForFun.Matrix3(0, 0, 0, 0, 0, 0, 0.01f, 0, 0),
            new PhysicsEngineForFun.Vector3(2.0f, 0.5f, 0),
            PhysicsEngineWindSpeed);
        rudder.controlSetting = 0f;
        ResetAircraft();

        PhysicsEngineForFun.Matrix3 i = new PhysicsEngineForFun.Matrix3();
        i.SetBlockInertiaTensor(new PhysicsEngineForFun.Vector3(2, 1, 1), 1);

        aircraft.SetMass(2.5f);
        aircraft.SetInertiaTensor(i);
        aircraft.linearDamping = aircraft.angularDamping = 0.8f;
        aircraft.acceleration  = new PhysicsEngineForFun.Vector3(0, -9.8f, 0);
        aircraft.CalculateDerivedData();

        registry.Add(aircraft, left_wing);
        registry.Add(aircraft, right_wing);
        registry.Add(aircraft, rudder);
        registry.Add(aircraft, tail);
    }
コード例 #2
0
    private void OnDestroy()
    {
        if (left_wing != null)
        {
            left_wing.Dispose();
            left_wing = null;
        }

        if (right_wing != null)
        {
            right_wing.Dispose();
            right_wing = null;
        }

        if (rudder != null)
        {
            rudder.Dispose();
            rudder = null;
        }

        if (tail != null)
        {
            tail.Dispose();
            tail = null;
        }

        if (aircraft != null)
        {
            aircraft.Dispose();
        }

        if (registry != null)
        {
            registry.Dispose();
        }

        if (PhysicsEngineWindSpeed != null)
        {
            PhysicsEngineWindSpeed.Dispose();
        }
    }