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