Re #139 (Car overall rating and data sheet) Completed 1st proposal : top speed, tire grip and aero grip sliders are now up and running
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@3244 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: a13b51fb2d549a65833e0cc8a507e18c9f4421a7 Former-commit-id: f74bbb9bf9eacc93cd2f02b31c5670212d10e0e5
This commit is contained in:
parent
4b00c8649a
commit
80c59eb4c4
3 changed files with 26 additions and 23 deletions
|
@ -233,7 +233,7 @@ void RmCarSelectMenu::resetCarDataSheet(const std::string& strSelCarId)
|
||||||
ossSpecValue.str().c_str());
|
ossSpecValue.str().c_str());
|
||||||
|
|
||||||
ossSpecValue.str("");
|
ossSpecValue.str("");
|
||||||
ossSpecValue << (long)pSelCar->getMaxPower() << " bhp ("
|
ossSpecValue << (long)(pSelCar->getMaxPower() / 75 / G) << " bhp ("
|
||||||
<< (long)(pSelCar->getMaxPowerSpeed() * 30.0 / PI) << " rpm)";
|
<< (long)(pSelCar->getMaxPowerSpeed() * 30.0 / PI) << " rpm)";
|
||||||
GfuiLabelSetText(GetMenuHandle(), GetDynamicControlId("MaxPowerLabel"),
|
GfuiLabelSetText(GetMenuHandle(), GetDynamicControlId("MaxPowerLabel"),
|
||||||
ossSpecValue.str().c_str());
|
ossSpecValue.str().c_str());
|
||||||
|
@ -255,16 +255,16 @@ void RmCarSelectMenu::resetCarDataSheet(const std::string& strSelCarId)
|
||||||
GfuiProgressbarSetValue(GetMenuHandle(), GetDynamicControlId("TopSpeedProgress"),
|
GfuiProgressbarSetValue(GetMenuHandle(), GetDynamicControlId("TopSpeedProgress"),
|
||||||
pSelCar->getTopSpeed() * 3.6f);
|
pSelCar->getTopSpeed() * 3.6f);
|
||||||
GfuiProgressbarSetValue(GetMenuHandle(), GetDynamicControlId("PowerMassRatioProgress"),
|
GfuiProgressbarSetValue(GetMenuHandle(), GetDynamicControlId("PowerMassRatioProgress"),
|
||||||
pSelCar->getMaxPower() / pSelCar->getMass());
|
pSelCar->getMaxPower() / 75 / G / pSelCar->getMass());
|
||||||
GfuiProgressbarSetValue(GetMenuHandle(), GetDynamicControlId("HighSpeedGripProgress"),
|
|
||||||
pSelCar->getLowSpeedGrip());
|
|
||||||
GfuiProgressbarSetValue(GetMenuHandle(), GetDynamicControlId("LowSpeedGripProgress"),
|
GfuiProgressbarSetValue(GetMenuHandle(), GetDynamicControlId("LowSpeedGripProgress"),
|
||||||
|
pSelCar->getLowSpeedGrip());
|
||||||
|
GfuiProgressbarSetValue(GetMenuHandle(), GetDynamicControlId("HighSpeedGripProgress"),
|
||||||
pSelCar->getHighSpeedGrip());
|
pSelCar->getHighSpeedGrip());
|
||||||
GfuiProgressbarSetValue(GetMenuHandle(), GetDynamicControlId("CorneringProgress"),
|
GfuiProgressbarSetValue(GetMenuHandle(), GetDynamicControlId("CorneringProgress"),
|
||||||
pSelCar->getInvertedZAxisInertia());
|
pSelCar->getInvertedZAxisInertia());
|
||||||
|
|
||||||
GfLogDebug("%s : ts=%f, mpr=%f, lsg=%f, hsg=%f, izi=%f\n", strSelCarId.c_str(),
|
GfLogDebug("%s : ts=%f, mpr=%f, lsg=%f, hsg=%f, izi=%f\n", strSelCarId.c_str(),
|
||||||
pSelCar->getTopSpeed(), pSelCar->getMaxPower() / pSelCar->getMass(),
|
pSelCar->getTopSpeed()*3.6f, pSelCar->getMaxPower() / 75 / G / pSelCar->getMass(),
|
||||||
pSelCar->getLowSpeedGrip(), pSelCar->getHighSpeedGrip(),
|
pSelCar->getLowSpeedGrip(), pSelCar->getHighSpeedGrip(),
|
||||||
pSelCar->getInvertedZAxisInertia());
|
pSelCar->getInvertedZAxisInertia());
|
||||||
}
|
}
|
||||||
|
|
|
@ -313,7 +313,7 @@ void GfCar::load(void* hparmCar)
|
||||||
_fMaxTorque = fTorque;
|
_fMaxTorque = fTorque;
|
||||||
_fMaxTorqueSpeed = fSpeed;
|
_fMaxTorqueSpeed = fSpeed;
|
||||||
}
|
}
|
||||||
const tdble fPower = (tdble)(fTorque * fSpeed / (75 * G));
|
const tdble fPower = (tdble)(fTorque * fSpeed);
|
||||||
if (fPower > _fMaxPower)
|
if (fPower > _fMaxPower)
|
||||||
{
|
{
|
||||||
_fMaxPower = fPower;
|
_fMaxPower = fPower;
|
||||||
|
@ -328,13 +328,12 @@ void GfCar::load(void* hparmCar)
|
||||||
const tdble fMuRear =
|
const tdble fMuRear =
|
||||||
(GfParmGetNum(hparmCar, SECT_REARRGTWHEEL, PRM_MU, (char*)NULL, 1.0)
|
(GfParmGetNum(hparmCar, SECT_REARRGTWHEEL, PRM_MU, (char*)NULL, 1.0)
|
||||||
+ GfParmGetNum(hparmCar, SECT_REARLFTWHEEL, PRM_MU, (char*)NULL, 1.0)) / 2.0f;
|
+ GfParmGetNum(hparmCar, SECT_REARLFTWHEEL, PRM_MU, (char*)NULL, 1.0)) / 2.0f;
|
||||||
// Work in progress.
|
_fLowSpeedGrip =
|
||||||
_fLowSpeedGrip = 0.0f;
|
(_fFrontRearMassRatio * fMuFront + (1.0f - _fFrontRearMassRatio) * fMuRear) * G;
|
||||||
// (_fFrontRearMassRatio * fMuFront + (1.0f - _fFrontRearMassRatio) * fMuRear) * G;
|
|
||||||
|
|
||||||
// "Aerodynamic = High speed" grip (same + with aero down-force).
|
// "Aerodynamic = High speed" grip (same + with aero down-force).
|
||||||
// TODO: Check formula (F/R Clift repartition "guessed" from Kristof's)
|
// TODO: Check formula (F/R Clift repartition "guessed" from Kristof's ; sure it's wrong ;-)
|
||||||
const tdble fRefCarSpeed = 200 * 1000 / 3600.0f;
|
const tdble fRefCarSpeed = 200 / 3.6f;
|
||||||
const tdble fFrontWingArea =
|
const tdble fFrontWingArea =
|
||||||
GfParmGetNum(hparmCar, SECT_FRNTWING, PRM_WINGAREA, (char*)NULL, 0.0);
|
GfParmGetNum(hparmCar, SECT_FRNTWING, PRM_WINGAREA, (char*)NULL, 0.0);
|
||||||
const tdble fRearWingArea =
|
const tdble fRearWingArea =
|
||||||
|
@ -349,19 +348,19 @@ void GfCar::load(void* hparmCar)
|
||||||
GfParmGetNum(hparmCar, SECT_AERODYNAMICS, PRM_RCL, (char*)NULL, 0.0);
|
GfParmGetNum(hparmCar, SECT_AERODYNAMICS, PRM_RCL, (char*)NULL, 0.0);
|
||||||
const double fTotalFrontClift = 2 * fFrontClift + 4.92 * fFrontWingArea * sin(fFrontWingAngle);
|
const double fTotalFrontClift = 2 * fFrontClift + 4.92 * fFrontWingArea * sin(fFrontWingAngle);
|
||||||
const double fTotalRearClift = 2 * fRearClift + 4.92 * fRearWingArea * sin(fRearWingAngle);
|
const double fTotalRearClift = 2 * fRearClift + 4.92 * fRearWingArea * sin(fRearWingAngle);
|
||||||
_fHighSpeedGrip = _fLowSpeedGrip;
|
|
||||||
// Work in progress.
|
// Work in progress.
|
||||||
// _fHighSpeedGrip +=
|
_fHighSpeedGrip =
|
||||||
// fRefCarSpeed * fRefCarSpeed
|
fRefCarSpeed * fRefCarSpeed
|
||||||
// * (tdble)(_fFrontRearMassRatio * fTotalFrontClift
|
* (tdble)(_fFrontRearMassRatio * fTotalFrontClift * fMuFront
|
||||||
// + (1.0 - _fFrontRearMassRatio) * fTotalRearClift) * G;
|
+ (1.0 - _fFrontRearMassRatio) * fTotalRearClift * fMuRear) * G / _fMass;
|
||||||
|
|
||||||
// Inverse of the inertia around the Z axis.
|
// Inverse of the inertia around the Z axis.
|
||||||
const tdble fMassRepCoef = GfParmGetNum(hparmCar, SECT_CAR, PRM_CENTR, (char*)NULL, 1.0);
|
const tdble fMassRepCoef = GfParmGetNum(hparmCar, SECT_CAR, PRM_CENTR, (char*)NULL, 1.0);
|
||||||
const tdble fCarLength = GfParmGetNum(hparmCar, SECT_CAR, PRM_LEN, (char*)NULL, 4.7f);
|
const tdble fCarLength = GfParmGetNum(hparmCar, SECT_CAR, PRM_LEN, (char*)NULL, 4.7f);
|
||||||
const tdble fCarWidth = GfParmGetNum(hparmCar, SECT_CAR, PRM_WIDTH, (char*)NULL, 1.9f);
|
const tdble fCarWidth = GfParmGetNum(hparmCar, SECT_CAR, PRM_WIDTH, (char*)NULL, 1.9f);
|
||||||
_fInvertedZAxisInertia = // Stolen from Simu V2.1, car.cpp, SimCarConfig()
|
_fInvertedZAxisInertia = // Stolen from Simu V2.1, car.cpp, SimCarConfig()
|
||||||
12.0f / (_fMass * fMassRepCoef * fMassRepCoef * (fCarWidth * fCarWidth + fCarLength * fCarLength));
|
12.0f / (_fMass * fMassRepCoef * fMassRepCoef)
|
||||||
|
/ (fCarWidth * fCarWidth + fCarLength * fCarLength);
|
||||||
|
|
||||||
// Theorical top speed on a flat road, assuming the gears are tuned accordingly.
|
// Theorical top speed on a flat road, assuming the gears are tuned accordingly.
|
||||||
const tdble fFrontArea =
|
const tdble fFrontArea =
|
||||||
|
@ -377,9 +376,9 @@ void GfCar::load(void* hparmCar)
|
||||||
muRollRes * _fMass * G / (Cd + muRollRes * (tdble)(fTotalFrontClift + fTotalRearClift));
|
muRollRes * _fMass * G / (Cd + muRollRes * (tdble)(fTotalFrontClift + fTotalRearClift));
|
||||||
const double q = eff * _fMaxPower / (Cd + muRollRes * (tdble)(fTotalFrontClift + fTotalRearClift));
|
const double q = eff * _fMaxPower / (Cd + muRollRes * (tdble)(fTotalFrontClift + fTotalRearClift));
|
||||||
// Work in progress.
|
// Work in progress.
|
||||||
_fTopSpeed = 0.0f;
|
_fTopSpeed =
|
||||||
// (tdble)pow(q/2+sqrt(q*q/4+(pp*pp*pp)/27), 1.0/3)
|
(tdble)pow(q/2+sqrt(q*q/4+pp*pp*pp/27), 1.0/3)
|
||||||
// - (tdble)pow(-q/2+sqrt(q*q/4+(pp*pp*pp)/27), 1.0/3);
|
- (tdble)pow(-q/2+sqrt(q*q/4+pp*pp*pp/27), 1.0/3);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& GfCar::getId() const
|
const std::string& GfCar::getId() const
|
||||||
|
|
|
@ -80,8 +80,12 @@ protected:
|
||||||
|
|
||||||
EDriveTrain _eDriveTrain;
|
EDriveTrain _eDriveTrain;
|
||||||
unsigned _nGears; // Number of gears.
|
unsigned _nGears; // Number of gears.
|
||||||
bool _bTurboCharged;
|
bool _bTurboCharged; // TODO: Move to an enum (Turbo, Compressor, ...)
|
||||||
tdble _fMaxPower, _fMaxPowerSpeed; // Engine max power (bhp) and associated engine speed.
|
// unsigned _nCylinders; // TODO
|
||||||
|
// enum { eV, eW, eFlat, eStraight, eTurbine } EEngineShape;
|
||||||
|
// EEngineShape _eEngineShape; // TODO
|
||||||
|
// tdble fEngineCapacity; // TODO
|
||||||
|
tdble _fMaxPower, _fMaxPowerSpeed; // Engine max power (SI) and associated engine speed.
|
||||||
tdble _fMaxTorque, _fMaxTorqueSpeed; // Engine max torque (Nm) and associated engine speed.
|
tdble _fMaxTorque, _fMaxTorqueSpeed; // Engine max torque (Nm) and associated engine speed.
|
||||||
tdble _fMass; // Total mass (kg).
|
tdble _fMass; // Total mass (kg).
|
||||||
tdble _fFrontRearMassRatio; // Front to rear mass ratio (no unit, inside ]0,1[).
|
tdble _fFrontRearMassRatio; // Front to rear mass ratio (no unit, inside ]0,1[).
|
||||||
|
@ -89,7 +93,7 @@ protected:
|
||||||
tdble _fTopSpeed; // Theorical top speed (m/s)
|
tdble _fTopSpeed; // Theorical top speed (m/s)
|
||||||
tdble _fLowSpeedGrip; // Mechanical grip (~mu*g, but with front/rear mass repartition)
|
tdble _fLowSpeedGrip; // Mechanical grip (~mu*g, but with front/rear mass repartition)
|
||||||
tdble _fHighSpeedGrip; // Aerodynamic grip (same + with aero down-force)
|
tdble _fHighSpeedGrip; // Aerodynamic grip (same + with aero down-force)
|
||||||
tdble _fInvertedZAxisInertia;
|
tdble _fInvertedZAxisInertia; // (SI)
|
||||||
};
|
};
|
||||||
|
|
||||||
class TGFDATA_API GfCars
|
class TGFDATA_API GfCars
|
||||||
|
|
Loading…
Reference in a new issue