public int ChangeGears(VehicleGears gears, float threshold) { int gear = gears.CurrentGear; if (_rpm > _maxRpmToGearUp && gear < gears.MaxGear) { return(1); } else if (_rpm < _minRpmToGearDown && gear > 1) { return(-1); } /* * NxReal normalTorque = _torqueCurve.getValue(_rpm); * * NxReal lowerGearRatio = gears->getRatio(gear-1); * NxReal normalGearRatio = gears->getCurrentRatio(); * NxReal upperGearRatio = gears->getRatio(gear+1); * NxReal lowerGearRpm = _rpm / normalGearRatio * lowerGearRatio; * NxReal upperGearRpm = _rpm / normalGearRatio * upperGearRatio; * NxReal lowerTorque = _torqueCurve.getValue(lowerGearRpm); * NxReal upperTorque = _torqueCurve.getValue(upperGearRpm); * NxReal lowerWheelTorque = lowerTorque * lowerGearRatio; * NxReal normalWheelTorque = normalTorque * normalGearRatio; * NxReal upperWheelTorque = upperTorque * upperGearRatio; * //printf("%2.3f %2.3f %2.3f\n", lowerWheelTorque, normalWheelTorque, upperWheelTorque); */ return(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); }
public Vehicle(Frame node, PhysicMaterial carMaterial = null, VehicleMotor motor = null, VehicleGears gears = null) : this((Actor)node.Affector, carMaterial, motor, gears) { }