Ejemplo n.º 1
0
        public Vehicle(Actor actor, PhysicMaterial carMaterial = null, VehicleMotor motor = null, VehicleGears gears = null)
        {
            if (actor == null)
            {
                throw new ArgumentNullException("actor");
            }

            _transmissionEfficiency = 1.0f;
            _differentialRatio      = 1.0f;
            _maxVelocity            = 80;

            _bodyActor   = actor;
            _scene       = actor.Scene;
            _carMaterial = carMaterial;
            _bodyActor.SleepEnergyThreshold = 0.05f;
            _vehicleMotor = motor;
            _vehicleGears = gears;

            if (carMaterial == null)
            {
                PhysicMaterialDesc matDesc = new PhysicMaterialDesc();
                matDesc.DynamicFriction          = 0.4f;
                matDesc.StaticFriction           = 0.4f;
                matDesc.Restitution              = 0;
                _carMaterial                     = actor.Scene.CreateMaterial(matDesc);
                _carMaterial.FrictionCombineMode = CombineMode.MULTIPLY;
            }

            foreach (var shape in actor.Shapes)
            {
                if (shape.Material.Index == 0)
                {
                    shape.Material = _carMaterial;
                }
                if (shape is WheelShape)
                {
                    RayCastWheel wheel = new RayCastWheel((WheelShape)shape);
                    _wheels.Add(wheel);
                }
            }
            _bodyActor.UserData = this;
            _motorForce         = 0;

            SetDefaulValues();

            Control(0, true, 0, true, false);
        }
Ejemplo n.º 2
0
 public Vehicle(Frame node, PhysicMaterial carMaterial = null, VehicleMotor motor = null, VehicleGears gears = null) :
     this((Actor)node.Affector, carMaterial, motor, gears)
 {
 }