示例#1
0
    static void Main(string[] args)
    {
        Engine      E1   = new Engine(200, "chev", 1, true);
        FuelStorage F1   = new FuelStorage(20, 11.5, true);
        Wheel       W1   = new Wheel(1, "Left back", true);
        Wheel       W2   = new Wheel(1, "Left front", true);
        Wheel       W3   = new Wheel(1, "Right front", false);
        Wheel       W4   = new Wheel(1, "Right back", true);
        Wheels      Car1 = new Wheels();

        Car1.Add(W1);
        Car1.Add(W2);
        Car1.Add(W3);
        Car1.Add(W4);
        Car1.WheelsStatus();
        E1.Start(F1);
        Creation C1 = new Creation("Chevrolet", "USA", 2001, 7);
        Machine  M1 = new Machine(E1, F1, Car1, C1);

        M1.starting(E1, F1, Car1);

        Engine      E2   = new Engine(500, "bwm", 1, true);
        FuelStorage F2   = new FuelStorage(25, 0, true);
        Wheel       W5   = new Wheel(1, "Left back", true);
        Wheel       W6   = new Wheel(1, "Left front", true);
        Wheel       W7   = new Wheel(1, "Right front", true);
        Wheel       W8   = new Wheel(1, "Right back", true);
        Wheels      Car2 = new Wheels();

        Car2.Add(W5);
        Car2.Add(W6);
        Car2.Add(W7);
        Car2.Add(W8);
        Car2.WheelsStatus();
        E2.Start(F2);
        Creation C2 = new Creation("BMW", "USA", 2008, 12);
        Machine  M2 = new Machine(E2, F2, Car2, C2);

        M2.starting(E2, F2, Car2);

        Engine      E3   = new Engine(350, "mustang", 1, false);
        FuelStorage F3   = new FuelStorage(15, 5, true);
        Wheel       W9   = new Wheel(1, "Left back", true);
        Wheel       W10  = new Wheel(1, "Left front", true);
        Wheel       W11  = new Wheel(1, "Right front", true);
        Wheel       W12  = new Wheel(1, "Right back", true);
        Wheels      Car3 = new Wheels();

        Car3.Add(W9);
        Car3.Add(W10);
        Car3.Add(W11);
        Car3.Add(W12);
        Car3.WheelsStatus();
        E3.Start(F3);
        Creation C3 = new Creation("Mustang", "USA", 1998, 4);
        Machine  M3 = new Machine(E3, F3, Car3, C3);

        M3.starting(E3, F3, Car3);
    }
示例#2
0
        public void SetupDefaultWheels()
        {
            if (Chassis == null)
            {
                return;
            }

            Chassis.GetDims(out var min, out var max);

            var mass  = Chassis.Body.Mass;
            var mass4 = 0.25f * mass;

            var axis = Vector3.Up;

            var spring = mass4 * _gravity / (_wheelRestingFrac * _wheelTravel);

            var wheelMass = 0.03f * mass;
            var inertia   = 0.5f * (_wheelRadius * _wheelRadius) * wheelMass;

            var damping = 2.0f * (float)System.Math.Sqrt(spring * mass);

            damping *= 0.25f;
            damping *= _wheelDampingFrac;


            min.X += 3.0f * _wheelRadius;
            max.X -= 3.1f * _wheelRadius;
            min.Z += _wheelRadius * 0.35f;
            max.Z -= _wheelRadius * 0.35f;

            var delta = max - min;

            min.Y += _wheelZOffset;

            var brPos = min;
            var frPos = min + new Vector3(delta.X, 0.0f, 0.0f);
            var blPos = min + new Vector3(0.0f, 0.0f, delta.Z);
            var flPos = min + new Vector3(delta.X, 0.0f, delta.Z);

            Wheels ??= new List <Wheel>();

            if (Wheels.Count == 0)
            {
                Wheels.Add(new Wheel());
                Wheels.Add(new Wheel());
                Wheels.Add(new Wheel());
                Wheels.Add(new Wheel());
            }


            Wheels[(int)WheelId.WheelBr].Setup(this, brPos, axis, spring, _wheelTravel, inertia, _wheelRadius, _wheelSideFriction, _wheelFwdFriction, damping, _wheelNumRays);
            Wheels[(int)WheelId.WheelFr].Setup(this, frPos, axis, spring, _wheelTravel, inertia, _wheelRadius, _wheelSideFriction, _wheelFwdFriction, damping, _wheelNumRays);
            Wheels[(int)WheelId.WheelBl].Setup(this, blPos, axis, spring, _wheelTravel, inertia, _wheelRadius, _wheelSideFriction, _wheelFwdFriction, damping, _wheelNumRays);
            Wheels[(int)WheelId.WheelFl].Setup(this, flPos, axis, spring, _wheelTravel, inertia, _wheelRadius, _wheelSideFriction, _wheelFwdFriction, damping, _wheelNumRays);
        }
 public void AddWheel(Wheel wheel)
 {
     if (Wheels.Count < MaxWheels)
     {
         Wheels.Add(wheel);
     }
     else
     {
         throw new System.InvalidOperationException(string.Format("Already has {0} wheels", MaxWheels));
     }
 }