From f1fdd21d89e59e7a59e54284ef5fb8949b089e8e Mon Sep 17 00:00:00 2001 From: andrewsumner Date: Tue, 18 Nov 2008 23:42:30 +0000 Subject: [PATCH] Fixes for compiling under Windows (const char * errors), and my "driven wheel slip creating smoke" patch, probably needs a little work. Accelerate a powerful car with steer on full lock (in other words, do a "donut") and you'll now see smoke from the tires whereas before you didn't. git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@278 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 27b46ae34a35bff6f8db6a68c21742664fb19893 Former-commit-id: 6d5a6f892463ddf6461104af227832e49a009460 --- src/modules/graphic/ssggraph/grboard.cpp | 2 +- src/modules/graphic/ssggraph/grcar.cpp | 5 +++-- src/modules/graphic/ssggraph/grsmoke.cpp | 16 ++++++++++------ src/modules/graphic/ssggraph/grsound.cpp | 2 +- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/modules/graphic/ssggraph/grboard.cpp b/src/modules/graphic/ssggraph/grboard.cpp index ced53b8f0..f0e023f6a 100644 --- a/src/modules/graphic/ssggraph/grboard.cpp +++ b/src/modules/graphic/ssggraph/grboard.cpp @@ -244,7 +244,7 @@ cGrBoard::grDrawGauge(tdble X1, tdble Y1, tdble H, float *clr1, float *clr2, tdb glVertex2f(X1 + THNSSFG, Y1 + curH); glVertex2f(X1 - THNSSFG, Y1 + curH); glEnd(); - GfuiPrintString(title, grBlue, GFUI_FONT_MEDIUM, (int)X1, (int)(Y1 - THNSSBG - GfuiFontHeight(GFUI_FONT_MEDIUM)), GFUI_ALIGN_HC_VB); + GfuiPrintString((char *)title, grBlue, GFUI_FONT_MEDIUM, (int)X1, (int)(Y1 - THNSSBG - GfuiFontHeight(GFUI_FONT_MEDIUM)), GFUI_ALIGN_HC_VB); } void diff --git a/src/modules/graphic/ssggraph/grcar.cpp b/src/modules/graphic/ssggraph/grcar.cpp index 70c5d4dba..9030dc6cf 100644 --- a/src/modules/graphic/ssggraph/grcar.cpp +++ b/src/modules/graphic/ssggraph/grcar.cpp @@ -472,7 +472,7 @@ grInitShadow(tCarElt *car) grCarInfo[car->index].shadowBase = new ssgVtxTableShadow(GL_TRIANGLE_STRIP, shd_vtx, shd_nrm, shd_tex, shd_clr); grMipMap = 0; - grCarInfo[car->index].shadowBase->setState(grSsgLoadTexState(shdTexName)); + grCarInfo[car->index].shadowBase->setState(grSsgLoadTexState((char *)shdTexName)); grCarInfo[car->index].shadowCurr = (ssgVtxTableShadow *)grCarInfo[car->index].shadowBase->clone(SSG_CLONE_GEOMETRY); grCarInfo[car->index].shadowAnchor->addKid(grCarInfo[car->index].shadowCurr); ShadowAnchor->addKid(grCarInfo[car->index].shadowAnchor); @@ -598,6 +598,7 @@ grInitCar(tCarElt *car) lg += sprintf(grFilePath + lg, "drivers/%s/%d/%s;", car->_modName, car->_driverIndex, car->_carName); lg += sprintf(grFilePath + lg, "drivers/%s/%d;", car->_modName, car->_driverIndex); lg += sprintf(grFilePath + lg, "drivers/%s/%s;", car->_modName, car->_carName); + lg += sprintf(grFilePath + lg, "drivers/%d/%s;", car->_driverIndex, car->_carName); lg += sprintf(grFilePath + lg, "drivers/%s;", car->_modName); lg += sprintf(grFilePath + lg, "cars/%s", car->_carName); @@ -605,7 +606,7 @@ grInitCar(tCarElt *car) if (strlen(param) != 0) { grGammaValue = 1.8; grMipMap = 0; - grCarInfo[index].wheelTexture = grSsgLoadTexState(param); + grCarInfo[index].wheelTexture = grSsgLoadTexState((char *)param); /*if (grCarInfo[index].wheelTexture->getRef() > 0) { grCarInfo[index].wheelTexture->deRef(); }*/ diff --git a/src/modules/graphic/ssggraph/grsmoke.cpp b/src/modules/graphic/ssggraph/grsmoke.cpp index b7bb2d440..5912f45ef 100644 --- a/src/modules/graphic/ssggraph/grsmoke.cpp +++ b/src/modules/graphic/ssggraph/grsmoke.cpp @@ -295,10 +295,12 @@ void grAddSmoke(tCarElt *car, double t) smoke_life_coefficient = smoke_life_coefficient * (1.0f - urandom()*urandom()); tdble spd_fx=tanh(0.001f*car->_reaction[i])*smoke_speed_coefficient*sqrt(spd2); - if (car->_skid[i] + 0.025f*urandom()*spd_fx>urandom() + threshold) {// instead of 0.3, to randomize - - float init_speed_z = 0.1f; - float stretch_factor = 0.5f; + double slip = MAX(0.0, ((car->_wheelSpinVel(i) * car->_wheelRadius(i)) - fabs(car->_speed_x)) - 10.0); + if (car->_skid[i] + 0.025f*urandom()*spd_fx>urandom() + threshold || // instead of 0.3, to randomize + slip > 0.0) // smoke from driven wheel spin + { + float init_speed_z = 0.1f + (float) (slip/20); + float stretch_factor = 0.2f: tdble sinCarYaw = sin(car->_yaw); tdble cosCarYaw = cos(car->_yaw); @@ -321,6 +323,8 @@ void grAddSmoke(tCarElt *car, double t) tmp->smoke->vvy = cosCarYaw * car->_wheelSlipSide(i); tmp->smoke->vvx += cosCarYaw * car->_wheelSlipAccel(i); tmp->smoke->vvy += sinCarYaw * car->_wheelSlipAccel(i); + tmp->smoke->vvy += cosCarYaw * slip; + tmp->smoke->vvy += sinCarYaw * slip; tmp->smoke->vvz = init_speed_z; @@ -331,7 +335,7 @@ void grAddSmoke(tCarElt *car, double t) //printf("%f\n", car->_reaction[i]); tmp->smoke->max_life = grSmokeLife * - (car->_skid[i]*sqrt(spd2)+urandom()*spd_fx)/ smoke_life_coefficient; + ((car->_skid[i])*sqrt(spd2)+urandom()*spd_fx)/ smoke_life_coefficient; for (int c = 0; c < 3; c++) { tmp->smoke->cur_col[c] = cur_clr[c]; } @@ -342,7 +346,7 @@ void grAddSmoke(tCarElt *car, double t) tmp->smoke->sizez = VZ_INIT + 0.1f * spd_fx; tmp->smoke->init_alpha = 1.0/(1.0+0.1*spd_fx); - tmp->smoke->vexp = V_EXPANSION+(car->_skid[i]+.1*spd_fx)*(((float)rand()/(float)RAND_MAX)); + tmp->smoke->vexp = V_EXPANSION+((car->_skid[i]+slip/3)+.1*spd_fx)*(((float)rand()/(float)RAND_MAX)); tmp->smoke->smokeType = SMOKE_TYPE_TIRE; tmp->smoke->smokeTypeStep = 0; tmp->next = NULL; diff --git a/src/modules/graphic/ssggraph/grsound.cpp b/src/modules/graphic/ssggraph/grsound.cpp index d9b8e0979..6be76eeb7 100644 --- a/src/modules/graphic/ssggraph/grsound.cpp +++ b/src/modules/graphic/ssggraph/grsound.cpp @@ -55,7 +55,7 @@ void grInitSound(tSituation* s, int ncars) char fnbuf[1024]; sprintf(fnbuf, "%s%s", GetLocalDir(), GR_SOUND_PARM_CFG); void *paramHandle = GfParmReadFile(fnbuf, GFPARM_RMODE_REREAD | GFPARM_RMODE_CREAT); - const char *optionName = GfParmGetStr(paramHandle, GR_SCT_SOUND, GR_ATT_SOUND_STATE, soundOpenALStr); + const char *optionName = GfParmGetStr(paramHandle, GR_SCT_SOUND, GR_ATT_SOUND_STATE, (char *)soundOpenALStr); float global_volume = GfParmGetNum(paramHandle, GR_SCT_SOUND, GR_ATT_SOUND_VOLUME, "%", 100.0f); if (!strcmp(optionName, soundDisabledStr)) { sound_mode = DISABLED;