Semi-realistic power curve engine
1 post • Page 1 of 1
Semi-realistic power curve engine
It's shipped with a lot of custom variables:
_accelRatio - acceleration pedal 0..1
_maxRPM - max engine possible RPM without any load and full accel
_idleRPM - engine speed on idle
_minRPM - minimum of possible RPM before stall
_maxTorque - maximum value of torque at _maxRPM/2
_maxEBTorque - maximum value of torque if engine brake happened (at _maxRPM withour acceleration)
_idleTorque - maximum value of torque on idle at _idleRPM/2
Power curve is approximated as parabola and as linear funcion on engine braking.
You can just copy that code and paste into hinge's script window.
_accelRatio - acceleration pedal 0..1
_maxRPM - max engine possible RPM without any load and full accel
_idleRPM - engine speed on idle
_minRPM - minimum of possible RPM before stall
_maxTorque - maximum value of torque at _maxRPM/2
_maxEBTorque - maximum value of torque if engine brake happened (at _maxRPM withour acceleration)
_idleTorque - maximum value of torque on idle at _idleRPM/2
Power curve is approximated as parabola and as linear funcion on engine braking.
You can just copy that code and paste into hinge's script window.
- Code: Select all
_accelRatio = 0.0;
_maxRPM = 300.0;
_idleRPM = 30.0;
_minRPM = 5.0;
_maxTorque = 100.0;
_maxEBTorque = 50.0;
_idleTorque = 10.0;
_torque = (x) =>{
x2 := owner -> {_idleRPM + (_maxRPM - _idleRPM) * _accelRatio};
x > x2 ? {
owner._maxEBTorque * (x2 - x) / owner._maxRPM
} : {
x0 := owner._minRPM;
x1 := (x0 + x2) / 2;
y1 := owner -> {_idleTorque + (_maxTorque - _idleTorque) * _accelRatio};
(y1) * (x - x0) * (x - x2) / (x1 - x0) / (x1 - x2)
}
};
_rpm = {hinge := readable(owner);
angvel := (readable(Scene.entityByGeomID(hinge.geom1))).angvel - (readable(Scene.entityByGeomID(hinge.geom0))).angvel;
angvel * 9.5492966
};
motorTorque = {owner._torque(owner._rpm)};
autoBrake = {owner.motorTorque < 0};
motorSpeed = 52.359879;
motor = true;
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
1 post • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 7 guests




