- 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();
|
||||
};
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,26 +1,26 @@
|
|||
/*
|
||||
* grsmoke.h
|
||||
*
|
||||
*
|
||||
* Created : Fri Mar 22 23:17:54 CET 2002
|
||||
* Copyright: (C) 2001 by Christophe Guionneau
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301, USA.
|
||||
*
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _GRSMOKE_H_
|
||||
|
@ -43,61 +43,61 @@
|
|||
class ssgVtxTableSmoke : public ssgVtxTable
|
||||
{
|
||||
protected:
|
||||
virtual void copy_from ( ssgVtxTableSmoke *src, int clone_flags ) ;
|
||||
|
||||
virtual void copy_from ( ssgVtxTableSmoke *src, int clone_flags ) ;
|
||||
|
||||
public:
|
||||
inline bool isAlive() const {return cur_life < max_life;}
|
||||
double max_life;
|
||||
double step0_max_life;
|
||||
double step1_max_life;
|
||||
double step2_max_life;
|
||||
double cur_life;
|
||||
tdble vvx, vvy,vvz;
|
||||
sgVec3 cur_col;
|
||||
tdble vexp;
|
||||
int smokeType;
|
||||
int smokeTypeStep;
|
||||
double dt;
|
||||
double lastTime;
|
||||
float sizex;
|
||||
float sizey;
|
||||
float sizez;
|
||||
float init_alpha;
|
||||
int stype;
|
||||
virtual ssgBase *clone ( int clone_flags = 0 ) ;
|
||||
ssgVtxTableSmoke () ;
|
||||
ssgVtxTableSmoke (ssgVertexArray *shd_vtx , float initsize, int type);
|
||||
inline bool isAlive() const {return cur_life < max_life;}
|
||||
double max_life;
|
||||
double step0_max_life;
|
||||
double step1_max_life;
|
||||
double step2_max_life;
|
||||
double cur_life;
|
||||
tdble vvx, vvy,vvz;
|
||||
sgVec3 cur_col;
|
||||
tdble vexp;
|
||||
int smokeType;
|
||||
int smokeTypeStep;
|
||||
double dt;
|
||||
double lastTime;
|
||||
float sizex;
|
||||
float sizey;
|
||||
float sizez;
|
||||
float init_alpha;
|
||||
int stype;
|
||||
virtual ssgBase *clone ( int clone_flags = 0 ) ;
|
||||
ssgVtxTableSmoke () ;
|
||||
ssgVtxTableSmoke (ssgVertexArray *shd_vtx , float initsize, int type);
|
||||
|
||||
void draw_geometry();
|
||||
virtual void drawHighlight ( sgVec4 colour ){ssgVtxTable::drawHighlight(colour);}
|
||||
virtual void drawHighlight ( sgVec4 colour, int i ){ssgVtxTable::drawHighlight(colour,i);}
|
||||
void draw_geometry();
|
||||
virtual void drawHighlight ( sgVec4 colour ){ssgVtxTable::drawHighlight(colour);}
|
||||
virtual void drawHighlight ( sgVec4 colour, int i ){ssgVtxTable::drawHighlight(colour,i);}
|
||||
|
||||
virtual void pick ( int baseName ) { ssgVtxTable::pick(baseName);}
|
||||
virtual void transform ( const sgMat4 m ) { ssgVtxTable::transform(m);}
|
||||
virtual void pick ( int baseName ) { ssgVtxTable::pick(baseName);}
|
||||
virtual void transform ( const sgMat4 m ) { ssgVtxTable::transform(m);}
|
||||
|
||||
virtual void setVertices ( ssgVertexArray *vl ) { ssgVtxTable::setVertices(vl);}
|
||||
virtual void setNormals ( ssgNormalArray *nl ) { ssgVtxTable::setNormals(nl);}
|
||||
virtual void setTexCoords ( ssgTexCoordArray *tl ) { ssgVtxTable::setTexCoords(tl);}
|
||||
virtual void setColours ( ssgColourArray *cl ) { ssgVtxTable::setColours(cl);}
|
||||
virtual void setVertices ( ssgVertexArray *vl ) { ssgVtxTable::setVertices(vl);}
|
||||
virtual void setNormals ( ssgNormalArray *nl ) { ssgVtxTable::setNormals(nl);}
|
||||
virtual void setTexCoords ( ssgTexCoordArray *tl ) { ssgVtxTable::setTexCoords(tl);}
|
||||
virtual void setColours ( ssgColourArray *cl ) { ssgVtxTable::setColours(cl);}
|
||||
|
||||
int getNumVertices () { return vertices -> getNum () ; }
|
||||
int getNumNormals () { return normals -> getNum () ; }
|
||||
int getNumColours () { return colours -> getNum () ; }
|
||||
int getNumTexCoords () { return texcoords -> getNum () ; }
|
||||
int getNumVertices () { return vertices -> getNum () ; }
|
||||
int getNumNormals () { return normals -> getNum () ; }
|
||||
int getNumColours () { return colours -> getNum () ; }
|
||||
int getNumTexCoords () { return texcoords -> getNum () ; }
|
||||
|
||||
int getNumTriangles () { return ssgVtxTable::getNumTriangles();}
|
||||
void getTriangle ( int n, short *v1, short *v2, short *v3 ) { ssgVtxTable::getTriangle(n,v1,v2,v3);}
|
||||
int getNumLines () {return ssgVtxTable::getNumLines();}
|
||||
void getLine ( int n, short *v1, short *v2 ) { ssgVtxTable::getLine(n,v1,v2);}
|
||||
int getNumTriangles () { return ssgVtxTable::getNumTriangles();}
|
||||
void getTriangle ( int n, short *v1, short *v2, short *v3 ) { ssgVtxTable::getTriangle(n,v1,v2,v3);}
|
||||
int getNumLines () {return ssgVtxTable::getNumLines();}
|
||||
void getLine ( int n, short *v1, short *v2 ) { ssgVtxTable::getLine(n,v1,v2);}
|
||||
|
||||
|
||||
virtual ~ssgVtxTableSmoke (void);
|
||||
virtual ~ssgVtxTableSmoke (void);
|
||||
|
||||
virtual const char *getTypeName(void) { return ssgVtxTable::getTypeName();}
|
||||
virtual const char *getTypeName(void) { return ssgVtxTable::getTypeName();}
|
||||
|
||||
virtual void print ( FILE *fd = stderr, char *indent = "", int how_much = 2) { ssgVtxTable::print(fd,indent,how_much);}
|
||||
virtual int load ( FILE *fd ) {return ssgVtxTable::load(fd);}
|
||||
virtual int save ( FILE *fd ) {return ssgVtxTable::save(fd);}
|
||||
virtual void print ( FILE *fd = stderr, char *indent = "", int how_much = 2) { ssgVtxTable::print(fd,indent,how_much);}
|
||||
virtual int load ( FILE *fd ) {return ssgVtxTable::load(fd);}
|
||||
virtual int save ( FILE *fd ) {return ssgVtxTable::save(fd);}
|
||||
};
|
||||
|
||||
|
||||
|
@ -106,11 +106,11 @@ class cSmokeDef;
|
|||
class cGrSmoke
|
||||
{
|
||||
public:
|
||||
bool Add(tCarElt* car, const int i, const double t, int smokeType,
|
||||
const cSmokeDef *sd);
|
||||
void Update(const double t);
|
||||
|
||||
ssgVtxTableSmoke *smoke;
|
||||
bool Add(tCarElt* car, const int i, const double t, int smokeType,
|
||||
const cSmokeDef *sd);
|
||||
void Update(const double t);
|
||||
|
||||
ssgVtxTableSmoke *smoke;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue