- Update OsgBrake (car update)
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@6166 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 363c892fb5bce002c2791e57bddd32fba5c50011 Former-commit-id: 51bae1154f16bc34a5a030fbb6b5b087db137480
This commit is contained in:
parent
9ae0a3831a
commit
b3329926c0
4 changed files with 608 additions and 533 deletions
|
@ -32,7 +32,7 @@ void SDBrakes::setCar(tCarElt * car)
|
|||
this->car = car;
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::Geode> SDBrakes::initBrake(int wheelIndex)
|
||||
osg::Node *SDBrakes::initBrake(int wheelIndex)
|
||||
{
|
||||
float alpha;
|
||||
osg::Vec3 vtx;
|
||||
|
@ -43,7 +43,7 @@ osg::ref_ptr<osg::Geode> SDBrakes::initBrake(int wheelIndex)
|
|||
tdble curAngle = 0.0;
|
||||
int i;
|
||||
|
||||
osg::ref_ptr<osg::Geode> pBrake = new osg::Geode;
|
||||
osg::Geode *pBrake = new osg::Geode;
|
||||
|
||||
pBrake->setName("Brake Assembly");
|
||||
pBrake->setCullingActive(false);
|
||||
|
@ -88,9 +88,9 @@ osg::ref_ptr<osg::Geode> SDBrakes::initBrake(int wheelIndex)
|
|||
}
|
||||
|
||||
/* hub */
|
||||
osg::ref_ptr<osg::Vec3Array> hub_vtx = new osg::Vec3Array();
|
||||
osg::ref_ptr<osg::Vec4Array> hub_clr = new osg::Vec4Array();
|
||||
osg::ref_ptr<osg::Vec3Array> hub_nrm = new osg::Vec3Array();
|
||||
osg::Vec3Array *hub_vtx = new osg::Vec3Array();
|
||||
osg::Vec4Array *hub_clr = new osg::Vec4Array();
|
||||
osg::Vec3Array *hub_nrm = new osg::Vec3Array();
|
||||
|
||||
tdble hubRadius;
|
||||
|
||||
|
@ -129,21 +129,23 @@ osg::ref_ptr<osg::Geode> SDBrakes::initBrake(int wheelIndex)
|
|||
|
||||
hub_nrm->push_back(nrm);
|
||||
|
||||
osg::ref_ptr<osg::Geometry> pHub = new osg::Geometry;
|
||||
osg::Geometry *pHub = new osg::Geometry;
|
||||
pHub->setName("Hub");
|
||||
pHub->addPrimitiveSet( new osg::DrawArrays(osg::PrimitiveSet::TRIANGLE_FAN, 0, brakeBranch+1 ));
|
||||
pHub->setVertexArray(hub_vtx.get());
|
||||
pHub->setNormalArray(hub_nrm.get());
|
||||
pHub->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
pHub->setColorArray(hub_clr.get());
|
||||
pHub->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
|
||||
pBrake->addDrawable(pHub.get());
|
||||
pHub->setVertexArray(hub_vtx);
|
||||
pHub->setColorArray(hub_clr);
|
||||
pHub->setNormalArray(hub_nrm);
|
||||
|
||||
pHub->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
pHub->setNormalBinding(osg::Geometry::BIND_OFF);
|
||||
|
||||
pBrake->addDrawable(pHub);
|
||||
|
||||
/* Brake disk */
|
||||
osg::ref_ptr<osg::Vec3Array> brk_vtx = new osg::Vec3Array();
|
||||
osg::ref_ptr<osg::Vec4Array> brk_clr = new osg::Vec4Array();
|
||||
osg::ref_ptr<osg::Vec3Array> brk_nrm = new osg::Vec3Array();
|
||||
osg::Vec3Array *brk_vtx = new osg::Vec3Array();
|
||||
brk_clr = new osg::Vec4Array();
|
||||
osg::Vec3Array *brk_nrm = new osg::Vec3Array();
|
||||
|
||||
for (i = 0; i < (brakeBranch / 2 + 2); i++)
|
||||
{
|
||||
|
@ -163,24 +165,26 @@ osg::ref_ptr<osg::Geode> SDBrakes::initBrake(int wheelIndex)
|
|||
brk_clr->push_back(clr);
|
||||
brk_nrm->push_back(nrm);
|
||||
|
||||
osg::ref_ptr<osg::Geometry> pBDisc = new osg::Geometry;
|
||||
osg::Geometry *pBDisc = new osg::Geometry;
|
||||
pBDisc->setName("Disc Brake");
|
||||
|
||||
pBDisc->addPrimitiveSet( new osg::DrawArrays(osg::PrimitiveSet::TRIANGLE_STRIP, 0, brakeBranch+4 ));
|
||||
pBDisc->setVertexArray(brk_vtx.get());
|
||||
pBDisc->setNormalArray(brk_nrm.get());
|
||||
pBDisc->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
|
||||
pBDisc->setVertexArray(brk_vtx);
|
||||
pBDisc->setColorArray(brk_clr.get());
|
||||
pBDisc->setNormalArray(brk_nrm);
|
||||
|
||||
pBDisc->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
pBDisc->setNormalBinding(osg::Geometry::BIND_OFF);
|
||||
|
||||
pBrake->addDrawable(pBDisc.get());
|
||||
pBrake->addDrawable(pBDisc);
|
||||
|
||||
this->brake_disks[wheelIndex] = pBDisc.get();
|
||||
this->brake_disks[wheelIndex] = pBDisc;
|
||||
|
||||
/* Brake caliper */
|
||||
osg::ref_ptr<osg::Vec3Array> cal_vtx = new osg::Vec3Array();
|
||||
cal_clr = new osg::Vec4Array();
|
||||
osg::ref_ptr<osg::Vec3Array> cal_nrm = new osg::Vec3Array();
|
||||
osg::Vec3Array *cal_vtx = new osg::Vec3Array();
|
||||
osg::Vec4Array *cal_clr = new osg::Vec4Array();
|
||||
osg::Vec3Array *cal_nrm = new osg::Vec3Array();
|
||||
|
||||
for (i = 0; i < (brakeBranch / 2 - 2); i++)
|
||||
{
|
||||
|
@ -202,18 +206,21 @@ osg::ref_ptr<osg::Geode> SDBrakes::initBrake(int wheelIndex)
|
|||
cal_clr->push_back(clr);
|
||||
cal_nrm->push_back(nrm);
|
||||
|
||||
osg::ref_ptr<osg::Geometry> pCaliper = new osg::Geometry;
|
||||
osg::Geometry *pCaliper = new osg::Geometry;
|
||||
pCaliper->setName("Caliper");
|
||||
pCaliper->addPrimitiveSet( new osg::DrawArrays(osg::PrimitiveSet::TRIANGLE_STRIP, 0, brakeBranch-4 ));
|
||||
pCaliper->setVertexArray(cal_vtx.get());
|
||||
pCaliper->setNormalArray(cal_nrm.get());
|
||||
pCaliper->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
pCaliper->setColorArray(cal_clr.get());
|
||||
|
||||
pCaliper->setVertexArray(cal_vtx);
|
||||
pCaliper->setColorArray(cal_clr);
|
||||
pCaliper->setNormalArray(cal_nrm);
|
||||
|
||||
pCaliper->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
pCaliper->setNormalBinding(osg::Geometry::BIND_OFF);
|
||||
|
||||
pBrake->addDrawable(pCaliper.get());
|
||||
|
||||
return pBrake.get();
|
||||
pBrake->addDrawable(pCaliper);
|
||||
|
||||
return pBrake;
|
||||
}
|
||||
|
||||
void SDBrakes::updateBrakes()
|
||||
|
@ -226,9 +233,10 @@ void SDBrakes::updateBrakes()
|
|||
clr[1] = 0.1 + car->_brakeTemp(i) * 0.3;
|
||||
clr[2] = 0.1 - car->_brakeTemp(i) * 0.3;
|
||||
clr[3] = 1.0;
|
||||
cal_clr->push_back(clr);
|
||||
(*brk_clr)[0] = clr;
|
||||
brk_clr->dirty();
|
||||
|
||||
this->brake_disks[i]->setColorArray(cal_clr.get(), osg::Array::BIND_PER_VERTEX);
|
||||
this->brake_disks[i]->setColorArray(brk_clr.get(), osg::Array::BIND_PER_VERTEX);
|
||||
//GfLogInfo("brake temp %i = %f\n", i, car->_brakeTemp(i) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,11 +28,11 @@ class SDBrakes
|
|||
private :
|
||||
tCarElt *car;
|
||||
osg::ref_ptr<osg::Geometry> brake_disks[4];
|
||||
osg::ref_ptr<osg::Vec4Array> cal_clr;
|
||||
osg::ref_ptr<osg::Vec4Array> brk_clr;
|
||||
|
||||
public :
|
||||
void setCar(tCarElt * car);
|
||||
osg::ref_ptr<osg::Geode> initBrake(int wheelIndex);
|
||||
osg::Node *initBrake(int wheelIndex);
|
||||
void updateBrakes();
|
||||
};
|
||||
|
||||
|
|
|
@ -98,26 +98,32 @@ grInitSmoke(const int index)
|
|||
|
||||
grFireDeltaT = grSmokeDeltaT * 8;
|
||||
|
||||
if (!timeSmoke) {
|
||||
if (!timeSmoke)
|
||||
{
|
||||
timeSmoke = new double[index * 4];
|
||||
memset(timeSmoke, 0, sizeof(double) * index * 4);
|
||||
}
|
||||
|
||||
if (!timeFire) {
|
||||
if (!timeFire)
|
||||
{
|
||||
timeFire = new double[index];
|
||||
memset(timeFire, 0 , sizeof(double) * index);
|
||||
}
|
||||
|
||||
if (!smokeList) {
|
||||
if (!smokeList)
|
||||
{
|
||||
smokeList = new std::list<cGrSmoke>;
|
||||
}
|
||||
|
||||
char buf[256];
|
||||
// add temp object to get a reference on the states
|
||||
if (!mst) {
|
||||
if (!mst)
|
||||
{
|
||||
sprintf(buf, "data/textures;data/img;.");
|
||||
mst = (ssgSimpleState*)grSsgLoadTexStateEx("smoke.png", buf, FALSE, FALSE);
|
||||
if (mst) {
|
||||
|
||||
if (mst)
|
||||
{
|
||||
mst->disable(GL_LIGHTING);
|
||||
mst->enable(GL_BLEND);
|
||||
mst->disable(GL_CULL_FACE);
|
||||
|
@ -126,10 +132,13 @@ grInitSmoke(const int index)
|
|||
}//if mst
|
||||
}//if !mst
|
||||
|
||||
if (!mstf0) {
|
||||
if (!mstf0)
|
||||
{
|
||||
sprintf(buf, "data/textures;data/img;.");
|
||||
mstf0 = (ssgSimpleState*)grSsgLoadTexStateEx("fire0.png", buf, FALSE, FALSE);
|
||||
if (mstf0) {
|
||||
|
||||
if (mstf0)
|
||||
{
|
||||
mstf0->disable(GL_LIGHTING);
|
||||
mstf0->enable(GL_BLEND);
|
||||
mstf0->disable(GL_CULL_FACE);
|
||||
|
@ -138,10 +147,13 @@ grInitSmoke(const int index)
|
|||
}//if mstf0
|
||||
}//if !mstf0
|
||||
|
||||
if (!mstf1) {
|
||||
if (!mstf1)
|
||||
{
|
||||
sprintf(buf, "data/textures;data/img;.");
|
||||
mstf1 = (ssgSimpleState*)grSsgLoadTexStateEx("fire1.png", buf, FALSE, FALSE);
|
||||
if (mstf1) {
|
||||
|
||||
if (mstf1)
|
||||
{
|
||||
mstf1->disable(GL_LIGHTING);
|
||||
mstf1->enable(GL_BLEND);
|
||||
mstf1->disable(GL_CULL_FACE);
|
||||
|
@ -163,11 +175,14 @@ grInitSmoke(const int index)
|
|||
void
|
||||
grUpdateSmoke(const double t)
|
||||
{
|
||||
if(grSmokeMaxNumber) {
|
||||
if(grSmokeMaxNumber)
|
||||
{
|
||||
for(std::list<cGrSmoke>::iterator it = smokeList->begin();
|
||||
it != smokeList->end();
|
||||
it++) {
|
||||
if (!it->smoke->isAlive()) {
|
||||
it++)
|
||||
{
|
||||
if (!it->smoke->isAlive())
|
||||
{
|
||||
//Smoke too old, get rid of it.
|
||||
SmokeAnchor->removeKid(it->smoke);
|
||||
it = smokeList->erase(it);
|
||||
|
@ -175,7 +190,9 @@ grUpdateSmoke(const double t)
|
|||
if (it == smokeList->end())
|
||||
break;
|
||||
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
//Update the smoke
|
||||
it->Update(t);
|
||||
}//if !it->smoke->isAlive
|
||||
|
@ -196,37 +213,56 @@ grUpdateSmoke(const double t)
|
|||
void
|
||||
grAddSmoke(tCarElt *car, const double t)
|
||||
{
|
||||
if(grSmokeMaxNumber) {
|
||||
if(grSmokeMaxNumber)
|
||||
{
|
||||
//Speed ^ 2
|
||||
tdble spd2 = car->_speed_x * car->_speed_x + car->_speed_y * car->_speed_y;
|
||||
|
||||
//!Add smoke from spinning/skidding wheels
|
||||
if (spd2 > 0.001f) { //If the car is moving
|
||||
for(int i = 0; i < 4; i++) { //Loop through all 4 wheels
|
||||
if ((int)smokeList->size() < grSmokeMaxNumber) { //If there is space for more smoke
|
||||
if (spd2 > 0.001f)
|
||||
{ //If the car is moving
|
||||
for(int i = 0; i < 4; i++)
|
||||
{ //Loop through all 4 wheels
|
||||
if ((int)smokeList->size() < grSmokeMaxNumber)
|
||||
{ //If there is space for more smoke
|
||||
//If the car's smoke is not too current, let's add it.
|
||||
if ((t - timeSmoke[car->index * 4 + i]) > grSmokeDeltaT) {
|
||||
if ((t - timeSmoke[car->index * 4 + i]) > grSmokeDeltaT)
|
||||
{
|
||||
timeSmoke[car->index * 4 + i] = t;
|
||||
|
||||
//!Different smoke for different surfaces
|
||||
cSmokeDef sd;//(0.8f, 0.8f, 0.8f, 0.01f, 0.1f, 30.0f, 0.0f);
|
||||
if (car->priv.wheel[i].seg) { // sanity check
|
||||
const char* surface = car->priv.wheel[i].seg->surface->material;
|
||||
if (strstr(surface, "sand")) {
|
||||
|
||||
if (strstr(surface, "sand"))
|
||||
{
|
||||
sd.Init(0.8f, 0.7f + urandom() * 0.1f, 0.4f + urandom() * 0.2f,
|
||||
0.5f, 0.05f, 12.5f, 0.25f);
|
||||
} else if (strstr(surface, "dirt")) {
|
||||
}
|
||||
else if (strstr(surface, "dirt"))
|
||||
{
|
||||
sd.Init(0.7f + urandom() * 0.1f, 0.6f + urandom() * 0.1f, 0.5f + urandom() * 0.1f, 0.45f, 0.0f, 10.0f, 0.5f);
|
||||
} else if (strstr(surface,"mud")) {
|
||||
}
|
||||
else if (strstr(surface,"mud"))
|
||||
{
|
||||
sd.Init(0.25f, 0.17f + urandom() * 0.02f, 0.05f + urandom() * 0.02f, 0.2f, 0.25f, 15.0f, 0.25f);
|
||||
} else if (strstr(surface,"gravel")) {
|
||||
}
|
||||
else if (strstr(surface,"gravel"))
|
||||
{
|
||||
sd.Init(0.6f, 0.6f, 0.6f,
|
||||
0.35f, 0.1f, 20.0f, 0.1f);
|
||||
} else if (strstr(surface,"grass")) {
|
||||
}
|
||||
else if (strstr(surface,"grass"))
|
||||
{
|
||||
sd.Init(0.4f + urandom() * 0.2f, 0.5f + urandom() * 0.1f, 0.3f + urandom() * 0.1f, 0.3f, 0.1f, 25.0f, 0.0f);
|
||||
} else if (strstr(surface,"snow")) {
|
||||
}
|
||||
else if (strstr(surface,"snow"))
|
||||
{
|
||||
sd.Init(0.75f, 0.75f + urandom() * 0.1f, 0.75f + urandom() * 0.1f, 0.35f, 0.0f, 8.0f, 0.4f);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
sd.Init(0.8f, 0.8f, 0.8f,
|
||||
0.01f, 0.1f, 30.0f, 0.0f);
|
||||
}
|
||||
|
@ -242,7 +278,8 @@ grAddSmoke(tCarElt *car, const double t)
|
|||
|
||||
//!Add smoke
|
||||
cGrSmoke tmp;
|
||||
if(tmp.Add(car, i, t, SMOKE_TYPE_TIRE, &sd)) {
|
||||
if(tmp.Add(car, i, t, SMOKE_TYPE_TIRE, &sd))
|
||||
{
|
||||
smokeList->push_back(tmp);
|
||||
}//if tmp.Add
|
||||
}//if t
|
||||
|
@ -251,11 +288,14 @@ grAddSmoke(tCarElt *car, const double t)
|
|||
}//if spd2
|
||||
|
||||
//!Add exhaust fire smoke
|
||||
if (car->_exhaustNb && (spd2 > 10.0)) { //If the car has exhaust pipes and is moving
|
||||
if ((int)smokeList->size() < grSmokeMaxNumber) { //If there is space for more smoke
|
||||
if (car->_exhaustNb && (spd2 > 10.0))
|
||||
{ //If the car has exhaust pipes and is moving
|
||||
if ((int)smokeList->size() < grSmokeMaxNumber)
|
||||
{ //If there is space for more smoke
|
||||
const int index = car->index; //current car's index
|
||||
//If the car's enxhaust smoke is not too current, let's add it.
|
||||
if ((t - timeFire[index]) > grFireDeltaT) {
|
||||
if ((t - timeFire[index]) > grFireDeltaT)
|
||||
{
|
||||
timeFire[index] = t;
|
||||
//!The need for exhaust fire is calculated from the RPM change
|
||||
//Only need to display exhaust fire when the gear is changing backwards
|
||||
|
@ -263,16 +303,21 @@ grAddSmoke(tCarElt *car, const double t)
|
|||
tdble val = ((*(curInst->monitored) - curInst->minValue)
|
||||
- (curInst->rawPrev - curInst->minValue)) / curInst->maxValue;
|
||||
curInst->rawPrev = *(curInst->monitored);
|
||||
if (val > 0.1 && val < 0.5) {//need upper limit to prevent multiple exhaust fires at race starts
|
||||
|
||||
if (val > 0.1 && val < 0.5)
|
||||
{//need upper limit to prevent multiple exhaust fires at race starts
|
||||
grCarInfo[index].fireCount = (int)(10.0 * val * car->_exhaustPower);
|
||||
}
|
||||
|
||||
if (grCarInfo[index].fireCount) {
|
||||
if (grCarInfo[index].fireCount)
|
||||
{
|
||||
grCarInfo[index].fireCount--;
|
||||
//Add fire to each exhaust
|
||||
for (int i = 0; i < car->_exhaustNb; i++) {
|
||||
for (int i = 0; i < car->_exhaustNb; i++)
|
||||
{
|
||||
cGrSmoke tmp;
|
||||
if(tmp.Add(car, i, t, SMOKE_TYPE_ENGINE, NULL)) {
|
||||
if(tmp.Add(car, i, t, SMOKE_TYPE_ENGINE, NULL))
|
||||
{
|
||||
smokeList->push_back(tmp);
|
||||
}//if tmp.Add
|
||||
}//for i
|
||||
|
@ -293,9 +338,11 @@ grShutdownSmoke()
|
|||
{
|
||||
GfOut("-- grShutdownSmoke\n");
|
||||
|
||||
if(grSmokeMaxNumber) {
|
||||
if(grSmokeMaxNumber)
|
||||
{
|
||||
SmokeAnchor->removeAllKids();
|
||||
if (smokeList) {
|
||||
if (smokeList)
|
||||
{
|
||||
//~ std::list<cGrSmoke>::iterator tmp = smokeList->begin();
|
||||
//~ while(tmp != smokeList->end())
|
||||
//~ {
|
||||
|
@ -390,13 +437,18 @@ void ssgVtxTableSmoke::draw_geometry ()
|
|||
offset[0] = offset[1] = offset[2] = 0.0f;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
int j = i;
|
||||
int k;
|
||||
for (k = 0; k < 4; k++, j+=4) {
|
||||
if (k != 3) {
|
||||
for (k = 0; k < 4; k++, j+=4)
|
||||
{
|
||||
if (k != 3)
|
||||
{
|
||||
offset[i] += modelView[j] * vx[0][k];
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
offset[i] += modelView[j];
|
||||
}
|
||||
}
|
||||
|
@ -439,15 +491,20 @@ void ssgVtxTableSmoke::draw_geometry ()
|
|||
|
||||
glBegin ( gltype ) ;
|
||||
|
||||
if (dist < 50.0f) {
|
||||
if (dist < 50.0f)
|
||||
{
|
||||
alpha *= (1.0f - exp(-0.1f * dist));
|
||||
}
|
||||
|
||||
glColor4f(cur_col[0],cur_col[1],cur_col[2],alpha);
|
||||
if (num_colours == 1) {
|
||||
|
||||
if (num_colours == 1)
|
||||
{
|
||||
glColor4fv(cl[0]);
|
||||
}
|
||||
if (num_normals == 1) {
|
||||
|
||||
if (num_normals == 1)
|
||||
{
|
||||
glNormal3fv(nm[0]);
|
||||
}
|
||||
|
||||
|
@ -484,16 +541,21 @@ cGrSmoke::Update(const double t)
|
|||
smoke->sizex += smoke->dt * smoke->vexp * 2.0f;
|
||||
|
||||
//!Exhaust fire can change shape, hence the need for two bitmaps
|
||||
if (smoke->smokeType == SMOKE_TYPE_ENGINE) {
|
||||
if (smoke->smokeTypeStep == 0) {
|
||||
if (smoke->cur_life >= smoke->step0_max_life) {
|
||||
if (smoke->smokeType == SMOKE_TYPE_ENGINE)
|
||||
{
|
||||
if (smoke->smokeTypeStep == 0)
|
||||
{
|
||||
if (smoke->cur_life >= smoke->step0_max_life)
|
||||
{
|
||||
// changing from fire to smoke
|
||||
smoke->smokeTypeStep = 1;
|
||||
smoke->setState(mstf1);
|
||||
}
|
||||
}
|
||||
else if (smoke->smokeTypeStep == 1) {
|
||||
if (smoke->cur_life >= smoke->step1_max_life) {
|
||||
else if (smoke->smokeTypeStep == 1)
|
||||
{
|
||||
if (smoke->cur_life >= smoke->step1_max_life)
|
||||
{
|
||||
// changing from fire to smoke
|
||||
smoke->smokeTypeStep = 2;
|
||||
smoke->setState(mst);
|
||||
|
@ -543,7 +605,8 @@ cGrSmoke::Add(tCarElt *car, const int i, const double t,
|
|||
{
|
||||
bool ret = false;
|
||||
|
||||
if(type == SMOKE_TYPE_TIRE) {
|
||||
if(type == SMOKE_TYPE_TIRE)
|
||||
{
|
||||
//!Add tire smoke
|
||||
tdble sinCarYaw = sin(car->_yaw);
|
||||
tdble cosCarYaw = cos(car->_yaw);
|
||||
|
@ -553,7 +616,8 @@ cGrSmoke::Add(tCarElt *car, const int i, const double t,
|
|||
double slip = MAX(0.0, ((car->_wheelSpinVel(i) * car->_wheelRadius(i)) - fabs(car->_speed_x)) - 9.0);
|
||||
bool skidsmoke = (car->_skid[i] + 0.025f * urandom() * spd_fx > urandom() + sd->threshold); // instead of 0.3, to randomize
|
||||
|
||||
if (skidsmoke || slip > 0.0) { // smoke from driven wheel spin
|
||||
if (skidsmoke || slip > 0.0)
|
||||
{ // smoke from driven wheel spin
|
||||
float init_speed_z = 0.1f + (float) (slip/20);
|
||||
float stretch_factor = 0.2f;
|
||||
|
||||
|
@ -597,7 +661,8 @@ cGrSmoke::Add(tCarElt *car, const int i, const double t,
|
|||
smoke->max_life = grSmokeLife *
|
||||
((slip/10)*sqrt(spd2)+urandom()*spd_fx)/ smoke_life_coefficient;
|
||||
|
||||
for (int c = 0; c < 3; c++) {
|
||||
for (int c = 0; c < 3; c++)
|
||||
{
|
||||
smoke->cur_col[c] = sd->cur_clr[c];
|
||||
}
|
||||
|
||||
|
@ -618,7 +683,9 @@ cGrSmoke::Add(tCarElt *car, const int i, const double t,
|
|||
SmokeAnchor->addKid(smoke);
|
||||
ret = true;
|
||||
}//if skidsmoke || slip
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
//!Add engine fire
|
||||
//Smoke originates from the exhaust pipe
|
||||
sgVec3 vtx;
|
||||
|
|
Loading…
Reference in a new issue