//--------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------- //-------------------------------- Computation ------------------------------------------ //--------------------------------------------------------------------------------------- // Compute the moving force public void ComputeVehicleMovingForce(float vehicleVelocity, float wheelRadius, double controlsThrottle, double controlsShiftUp, double controlsShiftDown) { /* * RPM cycle */ /**********************************************************************************/ // Compute RPM of the wheels and pass it to the differential double wheelsRpm = (60 * vehicleVelocity) / (2 * wheelRadius * Mathf.PI); differential.SetInputFeedbackRPM(wheelsRpm); // Compute RPM of the differential and pass it to the transmission differential.ComputeOutputFeedbackRPM(); transmission.SetInputFeedbackRPM(differential.GetOutputFeedbackRPM()); // Compute RPM of the transmission and pass it to the engine transmission.ComputeOutputFeedbackRpm(); transmission.ComputeShifting(controlsShiftUp, controlsShiftDown); engine.SetInputFeedbackRPM(transmission.GetOutputFeedbackRPM(), controlsThrottle); /**********************************************************************************/ /* * Torque cycle */ /**********************************************************************************/ // Compute engine torque and pass it to the transmission engine.ComputeOutputTorque(controlsThrottle); transmission.SetInputTorque(engine.GetOutputTorque()); // Compute transmission torque and pass it to the differential transmission.ComputeOutputTorque(); differential.SetInputTorque(transmission.GetOutputTorque()); // Compute differential torque and save it as a moving force differential.ComputeOutputTorque(); this.vehicleMovingForce = differential.GetOutputTorque() / wheelRadius; /**********************************************************************************/ }