示例#1
0
    /// <summary>
    /// Calculates the force of the wind acting on the cloth
    /// </summary>
    /// <param name="a"></param>
    void CalcAeroForce(AeroDynamics a)
    {
        Vector3 velocity = (a.p1.m_Velocity + a.p2.m_Velocity + a.p3.m_Velocity) / 3;
        Vector3 relativeVelocity = velocity - Air;

        Vector3 v = a.p2.transform.position - a.p1.transform.position;
        Vector3 w = a.p3.transform.position - a.p1.transform.position;
        Vector3 vNorm = v.normalized;
        Vector3 wNorm = w.normalized;
        Vector3 u = Vector3.Cross(vNorm, wNorm);                                    //Normal of the triangle

        Vector3 area = 0.5f * u;
        a.a = area * (Vector3.Dot(relativeVelocity, u));

        Vector3 aForce = -0.5f * p * (relativeVelocity.magnitude) * Cd * a.a;
        Vector3 splitForce = aForce / 3;

        a.p1.m_Force += splitForce;
        a.p2.m_Force += splitForce;
        a.p3.m_Force += splitForce;
    }
示例#2
0
    void Awake()
    {
        aeroDynamics = GetComponent <AeroDynamics>();
        brakes       = GetComponent <Brakes>();
        engine       = GetComponent <Engine>();
        steering     = GetComponent <Steering>();
        suspension   = GetComponent <Suspension>();
        transmission = GetComponent <Transmission>();
        userInput    = GetComponent <UserInput>();


        // set the physics clock to 120 Hz
        Time.fixedDeltaTime = 0.008333f;
        // Find the wheel colliders and put them in an array
        // Do not re-order the CD_Colliders in the vehicle model, everything depends on them being RL RR FL FR
        // WC sequence RL RR FL FR
        wC = gameObject.GetComponentsInChildren <WheelCollider>();
        // Get and configure the vehicle rigidbody
        rB               = GetComponent <Rigidbody>();
        rB.mass          = mass;
        rB.centerOfMass  = coG;
        rB.inertiaTensor = inertiaTensor;
        rB.isKinematic   = false;
    }