OSGHUD: add some debug info
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@8934 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: b893d770193541d8b82d70d7d31e21d589bac497 Former-commit-id: ccadda1b0d630291c1effb248b41554594dc6072
This commit is contained in:
parent
fc58bf682a
commit
9aa433216f
1 changed files with 130 additions and 123 deletions
|
@ -1144,6 +1144,8 @@ void SDHUD::CreateHUD(int scrH, int scrW)
|
|||
|
||||
GfLogDebug("OSGHUD: Hud Scale is: %f\n", hudScale);
|
||||
|
||||
GfLogDebug("OSGHUD: Generating the HUD from the xml file.\n");
|
||||
|
||||
//generate the hud from the relative xml file
|
||||
camera->addChild(generateHudFromXmlFile(scrH, scrW));
|
||||
|
||||
|
@ -1879,137 +1881,142 @@ void SDHUD::Refresh(tSituation *s, const SDFrameInfo* frameInfo,
|
|||
changeImageAlpha(hudImgElements["trackdata-weathericon-rainy"], 1.0f);
|
||||
}
|
||||
//shifting leds
|
||||
//read the car handle //engine section//torque data points
|
||||
GfParmGetNum(currCar->_carHandle, SECT_ENGINE, ARR_DATAPTS, NULL, 0.0f);
|
||||
if (hudWidgets["shiftlightsWidget"]->getNodeMask()){
|
||||
//read the car handle //engine section//torque data points
|
||||
GfParmGetNum(currCar->_carHandle, SECT_ENGINE, ARR_DATAPTS, NULL, 0.0f);
|
||||
|
||||
//get the number of datapoint in the engine section
|
||||
std::string dataPointsPath = SECT_ENGINE "/" ARR_DATAPTS;
|
||||
int dataPointsCount = GfParmGetEltNb(currCar->_carHandle, dataPointsPath.c_str());
|
||||
|
||||
//engine data point values will be stored here
|
||||
float rpm = 0.0f;
|
||||
float torque = 0.0f;
|
||||
//get the number of datapoint in the engine section
|
||||
std::string dataPointsPath = SECT_ENGINE "/" ARR_DATAPTS;
|
||||
int dataPointsCount = GfParmGetEltNb(currCar->_carHandle, dataPointsPath.c_str());
|
||||
|
||||
//engine data point values will be stored here
|
||||
float rpm = 0.0f;
|
||||
float torque = 0.0f;
|
||||
|
||||
//values from previous datapoint
|
||||
float prevrpm = 0.0f;
|
||||
float prevtorque = 0.0f;
|
||||
//values from previous datapoint
|
||||
float prevrpm = 0.0f;
|
||||
float prevtorque = 0.0f;
|
||||
|
||||
float intermediaterpm = 0.0f;
|
||||
float intermediatetorque = 0.0f;
|
||||
float intermediaterpm = 0.0f;
|
||||
float intermediatetorque = 0.0f;
|
||||
|
||||
//get the data points
|
||||
//we do this one time (when a new car is selected)
|
||||
if (carHasChanged)
|
||||
{
|
||||
//empty and than resize the vector to match the new maxrpm (we will have a datapoint for each rpm)
|
||||
horsepowerPoints.clear();
|
||||
horsepowerPoints.resize((int)currCar->_enginerpmMax);
|
||||
|
||||
//fill it with data, for each datapoint
|
||||
for (int i = 1; i <= dataPointsCount; i++)
|
||||
{
|
||||
std::string dataPointPath = dataPointsPath+"/"+ std::to_string(i);
|
||||
//get the data points
|
||||
//we do this one time (when a new car is selected)
|
||||
if (carHasChanged)
|
||||
{
|
||||
//empty and than resize the vector to match the new maxrpm (we will have a datapoint for each rpm)
|
||||
GfLogDebug("OSGHUD: Resizing the horsepowerVector...\n");
|
||||
horsepowerPoints.clear();
|
||||
horsepowerPoints.resize((int)currCar->_enginerpmMax);
|
||||
GfLogDebug("OSGHUD: Resizing the horsepowerVector...done\n");
|
||||
|
||||
rpm = GfParmGetNum(currCar->_carHandle, dataPointPath.c_str(), PRM_RPM, (char*) NULL, 0.0f/*RevsMax*/);
|
||||
torque = GfParmGetNum(currCar->_carHandle, dataPointPath.c_str(), PRM_TQ, (char*) NULL, 0.0f);
|
||||
|
||||
//fill it with data, for each datapoint
|
||||
for (int i = 1; i <= dataPointsCount; i++)
|
||||
{
|
||||
std::string dataPointPath = dataPointsPath+"/"+ std::to_string(i);
|
||||
|
||||
//if the current data point has the same value of the previous datapoint; skip it
|
||||
if (rpm > 0.0f && rpm == prevrpm){
|
||||
continue;
|
||||
}
|
||||
rpm = GfParmGetNum(currCar->_carHandle, dataPointPath.c_str(), PRM_RPM, (char*) NULL, 0.0f/*RevsMax*/);
|
||||
torque = GfParmGetNum(currCar->_carHandle, dataPointPath.c_str(), PRM_TQ, (char*) NULL, 0.0f);
|
||||
|
||||
// insert the horsepower value at the given rpm
|
||||
auto position = horsepowerPoints.begin() + rpm;
|
||||
float value = torque * rpm;
|
||||
horsepowerPoints.insert(position, value);
|
||||
|
||||
//calculate intermediate point/values from previous to current datapoin
|
||||
for( int h = 1+prevrpm; h < (int)rpm; h++)
|
||||
{
|
||||
if(h > (int)currCar->_enginerpmMax) {break;}//quit the for cicle when we reach the rpmMax
|
||||
intermediaterpm = h;
|
||||
intermediatetorque = prevtorque + (((torque-prevtorque) / (rpm - prevrpm)) * (h-prevrpm));
|
||||
//GfLogInfo("Intermediate Point %i - rpm %i - torque %f \n", 0, (int)intermediaterpm, intermediatetorque);
|
||||
//if the current data point has the same value of the previous datapoint; skip it
|
||||
if (rpm > 0.0f && rpm == prevrpm){
|
||||
continue;
|
||||
}
|
||||
|
||||
// insert the horsepower value at the given rpm
|
||||
auto position = horsepowerPoints.begin() + intermediaterpm;
|
||||
float value = intermediatetorque * intermediaterpm;
|
||||
horsepowerPoints.insert(position, value);
|
||||
}
|
||||
|
||||
prevrpm = rpm;
|
||||
prevtorque = torque;
|
||||
}
|
||||
}
|
||||
/*
|
||||
GfLogInfo("RPM %i \n", (int)currCar->_enginerpm);
|
||||
GfLogInfo("Gear %f - GearRation %f \n", (float)currCar->_gear, (float)currCar->_gearRatio[(int) (currCar->_gear + currCar->_gearOffset)]);
|
||||
GfLogInfo("nextGear %f - GearRation %f \n", (float)(currCar->_gear + 1.0), (float)currCar->_gearRatio[(int) (currCar->_gear + currCar->_gearOffset +1)]);
|
||||
*/
|
||||
//only do this when engine rpm is not 0 and the gear is not neutral
|
||||
//otherwise we get infinite values
|
||||
if(currCar->_enginerpm > 0 && currCar->_gear >= 1.0 ){
|
||||
float nextRpm = currCar->_enginerpm / currCar->_gearRatio[(int) (currCar->_gear + currCar->_gearOffset)] * currCar->_gearRatio[(int) (currCar->_gear + currCar->_gearOffset +1)];
|
||||
|
||||
//reset all the led to off, we will turn on what's needed later
|
||||
hudImgElements["light1-on"]->setNodeMask(0);
|
||||
hudImgElements["light2-on"]->setNodeMask(0);
|
||||
hudImgElements["light3-on"]->setNodeMask(0);
|
||||
hudImgElements["light4-on"]->setNodeMask(0);
|
||||
hudImgElements["light5-on"]->setNodeMask(0);
|
||||
hudImgElements["light6-on"]->setNodeMask(0);
|
||||
hudImgElements["light7-on"]->setNodeMask(0);
|
||||
hudImgElements["light8-on"]->setNodeMask(0);
|
||||
hudImgElements["light9-on"]->setNodeMask(0);
|
||||
hudImgElements["light10-on"]->setNodeMask(0);
|
||||
hudImgElements["light11-on"]->setNodeMask(0);
|
||||
hudImgElements["light12-on"]->setNodeMask(0);
|
||||
|
||||
float horsepowerCurr = horsepowerPoints.at((int)currCar->_enginerpm);
|
||||
float horsepowerNext = horsepowerPoints.at((int)nextRpm);
|
||||
//GfLogInfo("Curr gear %i (%f) - RPM %i - CurrPower %f \n", currCar->_gear, currCar->_gearRatio[(int) (currCar->_gear + currCar->_gearOffset)], (int)RADS2RPM(currCar->_enginerpm), horsepowerCurr);
|
||||
//GfLogInfo("Next gear %i (%f)- RPM %i - nextPower %f \n", currCar->_gear+1, currCar->_gearRatio[(int) (currCar->_gear + currCar->_gearOffset+1)], (int)RADS2RPM(nextRpm), horsepowerNext);
|
||||
// insert the horsepower value at the given rpm
|
||||
auto position = horsepowerPoints.begin() + rpm;
|
||||
float value = torque * rpm;
|
||||
horsepowerPoints.insert(position, value);
|
||||
|
||||
//calculate intermediate point/values from previous to current datapoin
|
||||
for( int h = 1+prevrpm; h < (int)rpm; h++)
|
||||
{
|
||||
if(h > (int)currCar->_enginerpmMax) {break;}//quit the for cicle when we reach the rpmMax
|
||||
intermediaterpm = h;
|
||||
intermediatetorque = prevtorque + (((torque-prevtorque) / (rpm - prevrpm)) * (h-prevrpm));
|
||||
//GfLogInfo("Intermediate Point %i - rpm %i - torque %f \n", 0, (int)intermediaterpm, intermediatetorque);
|
||||
|
||||
//green leds
|
||||
if( horsepowerNext > horsepowerCurr * 80/100){
|
||||
hudImgElements["light1-on"]->setNodeMask(1);
|
||||
}
|
||||
if( horsepowerNext > horsepowerCurr * 82/100){
|
||||
hudImgElements["light2-on"]->setNodeMask(1);
|
||||
}
|
||||
if( horsepowerNext > horsepowerCurr * 84/100){
|
||||
hudImgElements["light3-on"]->setNodeMask(1);
|
||||
}
|
||||
if( horsepowerNext > horsepowerCurr * 86/100){
|
||||
hudImgElements["light4-on"]->setNodeMask(1);
|
||||
}
|
||||
//red leds
|
||||
if( horsepowerNext > horsepowerCurr * 88/100){
|
||||
hudImgElements["light5-on"]->setNodeMask(1);
|
||||
}
|
||||
if( horsepowerNext > horsepowerCurr * 90/100){
|
||||
hudImgElements["light6-on"]->setNodeMask(1);
|
||||
}
|
||||
if( horsepowerNext > horsepowerCurr * 92/100){
|
||||
hudImgElements["light7-on"]->setNodeMask(1);
|
||||
}
|
||||
if( horsepowerNext > horsepowerCurr * 94/100){
|
||||
hudImgElements["light8-on"]->setNodeMask(1);
|
||||
}
|
||||
//purple leds
|
||||
if( horsepowerNext > horsepowerCurr * 96/100){
|
||||
hudImgElements["light9-on"]->setNodeMask(1);
|
||||
}
|
||||
if( horsepowerNext > horsepowerCurr * 98/100){
|
||||
hudImgElements["light10-on"]->setNodeMask(1);
|
||||
}
|
||||
if( horsepowerNext > horsepowerCurr * 100/100){
|
||||
hudImgElements["light11-on"]->setNodeMask(1);
|
||||
}
|
||||
if( horsepowerNext > horsepowerCurr * 102/100){
|
||||
hudImgElements["light12-on"]->setNodeMask(1);
|
||||
}
|
||||
}
|
||||
// insert the horsepower value at the given rpm
|
||||
auto position = horsepowerPoints.begin() + intermediaterpm;
|
||||
float value = intermediatetorque * intermediaterpm;
|
||||
horsepowerPoints.insert(position, value);
|
||||
}
|
||||
|
||||
prevrpm = rpm;
|
||||
prevtorque = torque;
|
||||
}
|
||||
}
|
||||
/*
|
||||
GfLogInfo("RPM %i \n", (int)currCar->_enginerpm);
|
||||
GfLogInfo("Gear %f - GearRation %f \n", (float)currCar->_gear, (float)currCar->_gearRatio[(int) (currCar->_gear + currCar->_gearOffset)]);
|
||||
GfLogInfo("nextGear %f - GearRation %f \n", (float)(currCar->_gear + 1.0), (float)currCar->_gearRatio[(int) (currCar->_gear + currCar->_gearOffset +1)]);
|
||||
*/
|
||||
//only do this when engine rpm is not 0 and the gear is not neutral
|
||||
//otherwise we get infinite values
|
||||
if(currCar->_enginerpm > 0 && currCar->_gear >= 1.0 ){
|
||||
float nextRpm = currCar->_enginerpm / currCar->_gearRatio[(int) (currCar->_gear + currCar->_gearOffset)] * currCar->_gearRatio[(int) (currCar->_gear + currCar->_gearOffset +1)];
|
||||
|
||||
//reset all the led to off, we will turn on what's needed later
|
||||
hudImgElements["light1-on"]->setNodeMask(0);
|
||||
hudImgElements["light2-on"]->setNodeMask(0);
|
||||
hudImgElements["light3-on"]->setNodeMask(0);
|
||||
hudImgElements["light4-on"]->setNodeMask(0);
|
||||
hudImgElements["light5-on"]->setNodeMask(0);
|
||||
hudImgElements["light6-on"]->setNodeMask(0);
|
||||
hudImgElements["light7-on"]->setNodeMask(0);
|
||||
hudImgElements["light8-on"]->setNodeMask(0);
|
||||
hudImgElements["light9-on"]->setNodeMask(0);
|
||||
hudImgElements["light10-on"]->setNodeMask(0);
|
||||
hudImgElements["light11-on"]->setNodeMask(0);
|
||||
hudImgElements["light12-on"]->setNodeMask(0);
|
||||
|
||||
float horsepowerCurr = horsepowerPoints.at((int)currCar->_enginerpm);
|
||||
float horsepowerNext = horsepowerPoints.at((int)nextRpm);
|
||||
//GfLogInfo("Curr gear %i (%f) - RPM %i - CurrPower %f \n", currCar->_gear, currCar->_gearRatio[(int) (currCar->_gear + currCar->_gearOffset)], (int)RADS2RPM(currCar->_enginerpm), horsepowerCurr);
|
||||
//GfLogInfo("Next gear %i (%f)- RPM %i - nextPower %f \n", currCar->_gear+1, currCar->_gearRatio[(int) (currCar->_gear + currCar->_gearOffset+1)], (int)RADS2RPM(nextRpm), horsepowerNext);
|
||||
|
||||
//green leds
|
||||
if( horsepowerNext > horsepowerCurr * 80/100){
|
||||
hudImgElements["light1-on"]->setNodeMask(1);
|
||||
}
|
||||
if( horsepowerNext > horsepowerCurr * 82/100){
|
||||
hudImgElements["light2-on"]->setNodeMask(1);
|
||||
}
|
||||
if( horsepowerNext > horsepowerCurr * 84/100){
|
||||
hudImgElements["light3-on"]->setNodeMask(1);
|
||||
}
|
||||
if( horsepowerNext > horsepowerCurr * 86/100){
|
||||
hudImgElements["light4-on"]->setNodeMask(1);
|
||||
}
|
||||
//red leds
|
||||
if( horsepowerNext > horsepowerCurr * 88/100){
|
||||
hudImgElements["light5-on"]->setNodeMask(1);
|
||||
}
|
||||
if( horsepowerNext > horsepowerCurr * 90/100){
|
||||
hudImgElements["light6-on"]->setNodeMask(1);
|
||||
}
|
||||
if( horsepowerNext > horsepowerCurr * 92/100){
|
||||
hudImgElements["light7-on"]->setNodeMask(1);
|
||||
}
|
||||
if( horsepowerNext > horsepowerCurr * 94/100){
|
||||
hudImgElements["light8-on"]->setNodeMask(1);
|
||||
}
|
||||
//purple leds
|
||||
if( horsepowerNext > horsepowerCurr * 96/100){
|
||||
hudImgElements["light9-on"]->setNodeMask(1);
|
||||
}
|
||||
if( horsepowerNext > horsepowerCurr * 98/100){
|
||||
hudImgElements["light10-on"]->setNodeMask(1);
|
||||
}
|
||||
if( horsepowerNext > horsepowerCurr * 100/100){
|
||||
hudImgElements["light11-on"]->setNodeMask(1);
|
||||
}
|
||||
if( horsepowerNext > horsepowerCurr * 102/100){
|
||||
hudImgElements["light12-on"]->setNodeMask(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// debug info
|
||||
temp.str("");
|
||||
|
@ -2353,7 +2360,7 @@ void SDHUD::ToggleHUD()
|
|||
hudElementsVisibilityStatus["deltaWidget"] = (int)hudWidgets["deltaWidget"]->getNodeMask();
|
||||
hudElementsVisibilityStatus["rpmWidget"] = (int)hudWidgets["rpmWidget"]->getNodeMask();
|
||||
hudElementsVisibilityStatus["trackdataWidget"] = (int)hudWidgets["trackdataWidget"]->getNodeMask();
|
||||
hudElementsVisibilityStatus["shiftlightsWidget"] = (int)hudWidgets["shiftlightsWidget"]->getNodeMask();
|
||||
hudElementsVisibilityStatus["shiftlightsWidget"] = (int)hudWidgets["shiftlightsWidget"]->getNodeMask();
|
||||
|
||||
hudWidgets["boardWidget"]->setNodeMask(0);
|
||||
hudWidgets["racepositionWidget"]->setNodeMask(0);
|
||||
|
|
Loading…
Reference in a new issue