Revision: 1492
          http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=1492&view=rev
Author:   rorthomas
Date:     2010-07-22 21:22:01 +0000 (Thu, 22 Jul 2010)

Log Message:
-----------
reverted to old dust mode, to be improved later, fixes non-working particle 
system after 9 months :(
closes #352

Modified Paths:
--------------
    trunk/source/main/Beam.cpp
    trunk/source/main/Beam.h
    trunk/source/main/DustManager.cpp
    trunk/source/main/DustManager.h
    trunk/source/main/DustPool.cpp
    trunk/source/main/DustPool.h
    trunk/source/main/RoRFrameListener.cpp
    trunk/source/main/WaterOld.h
    trunk/source/main/buoyance.cpp
    trunk/source/main/buoyance.h
    trunk/source/main/collisions.cpp
    trunk/source/main/collisions.h
    trunk/source/main/screwprop.cpp
    trunk/source/main/screwprop.h

Modified: trunk/source/main/Beam.cpp
===================================================================
--- trunk/source/main/Beam.cpp  2010-07-22 21:18:09 UTC (rev 1491)
+++ trunk/source/main/Beam.cpp  2010-07-22 21:22:01 UTC (rev 1492)
@@ -569,6 +569,13 @@
        collisions=icollisions;
        pointCD = new PointColDetector();
 
+       dustp   = DustManager::getSingleton().getDustPool("dust");
+       dripp   = DustManager::getSingleton().getDustPool("dripp");
+       sparksp = DustManager::getSingleton().getDustPool("sparks");
+       clumpp  = DustManager::getSingleton().getDustPool("clump");
+       splashp = DustManager::getSingleton().getDustPool("splash");
+       ripplep = DustManager::getSingleton().getDustPool("ripple");
+
        disable_smoke=(SETTINGS.getSetting("Engine smoke")=="No");
        heathaze=(SETTINGS.getSetting("HeatHaze")=="Yes");
        if(heathaze && disable_smoke)
@@ -8011,10 +8018,10 @@
                if (nodes[i].wetstate==DRIPPING && !nodes[i].contactless)
                {
                        nodes[i].wettime+=dt;
-                       //if (nodes[i].wettime>5.0) nodes[i].wetstate=DRY; 
//dry!
-                       //if (!nodes[i].iswheel && dripp) 
dripp->alloc(nodes[i].smoothpos, nodes[i].Velocity, ColourValue::ZERO, 
nodes[i].wettime);
+                       if (nodes[i].wettime>5.0) nodes[i].wetstate=DRY; //dry!
+                       if (!nodes[i].iswheel && dripp) 
dripp->allocDrip(nodes[i].smoothpos, nodes[i].Velocity, nodes[i].wettime);
                        //also for hot engine
-                       //if (nodes[i].isHot && dustp) 
dustp->alloc(nodes[i].smoothpos, nodes[i].Velocity, ColourValue::ZERO, 
nodes[i].wettime);
+                       if (nodes[i].isHot && dustp) 
dustp->allocVapour(nodes[i].smoothpos, nodes[i].Velocity, nodes[i].wettime);
                }
                //locked nodes
                if (nodes[i].lockednode)
@@ -8041,12 +8048,31 @@
                                        collisions->nodeCollision(&nodes[i], 
i==cinecameranodepos[currentcamera], contacted, nodes[i].colltesttimer, &ns, 
&gm))
                                {
                                        //FX
-                                       if (gm && doUpdate && 
!nodes[i].disable_particles)
+                                       if (gm && doUpdate && dustp)
                                        {
-                                               DustPool *dp = 
DustManager::getSingleton().getGroundModelDustPool(gm);
-                                               if(dp)
+                                               if (gm->fx_type==FX_DUSTY)
                                                {
-                                                       
dp->alloc(nodes[i].AbsPosition, nodes[i].Velocity, gm->fx_colour);
+                                                       if(dustp) 
dustp->alloc(nodes[i].AbsPosition, nodes[i].Velocity/2.0, gm->fx_colour);
+                                               }else if (gm->fx_type==FX_HARD)
+                                               {
+                                                       float thresold=10.0;
+                                                       //smokey
+                                                       if (nodes[i].iswheel && 
ns>thresold)
+                                                       {
+                                                               if(dustp) 
dustp->allocSmoke(nodes[i].AbsPosition, nodes[i].Velocity);
+                                                               
ssm->modulate(trucknum, SS_MOD_SCREETCH, (ns-thresold)/thresold);
+                                                               
ssm->trigOnce(trucknum, SS_TRIG_SCREETCH);
+                                                       }
+
+                                                       //sparks
+                                                       if (!nodes[i].iswheel 
&& ns>1.0 && !nodes[i].disable_particles)
+                                                       {
+                                                               // friction < 
10 will remove the 'f' nodes from the spark generation nodes
+                                                               if(sparksp) 
sparksp->allocSparks(nodes[i].AbsPosition, nodes[i].Velocity);
+                                                       }
+                                               } else if 
(gm->fx_type==FX_CLUMPY)
+                                               {
+                                                       if (clumpp && 
nodes[i].Velocity.squaredLength()>1.0) clumpp->allocClump(nodes[i].AbsPosition, 
nodes[i].Velocity/2.0, gm->fx_colour);
                                                }
                                        }
 
@@ -8141,14 +8167,11 @@
                                        
nodes[i].Forces-=(DEFAULT_WATERDRAG*velocityLength)*nodes[i].Velocity;
                                        
nodes[i].Forces+=nodes[i].buoyancy*Vector3::UNIT_Y;
                                        //basic splashing
-                                       // TODO: FIX SPLASH!
-                                       /*
-                                       if (splashp && 
water->getHeight()-nodes[i].AbsPosition.y<0.2 && velocityLength>2.0)
+                                       if (splashp && 
water->getHeight()-nodes[i].AbsPosition.y<0.2 && 
nodes[i].Velocity.squaredLength()>4.0)
                                        {
-                                               
splashp->alloc(nodes[i].AbsPosition, nodes[i].Velocity);
-                                               
ripplep->alloc(nodes[i].AbsPosition, nodes[i].Velocity);
+                                               
splashp->allocSplash(nodes[i].AbsPosition, nodes[i].Velocity);
+                                               
ripplep->allocRipple(nodes[i].AbsPosition, nodes[i].Velocity);
                                        }
-                                       */
                                        //engine stall
                                        if (i==cinecameranodepos[0] && engine) 
engine->stop();
                                        //wetness
@@ -9934,14 +9957,8 @@
 
        //dust
        DustManager::getSingleton().update(WheelSpeed);
-       /*
-       if (dustp && state==ACTIVATED) dustp->update(WheelSpeed);
-       if (dripp) dripp->update(WheelSpeed);
-       if (splashp) splashp->update(WheelSpeed);
-       if (ripplep) ripplep->update(WheelSpeed);
-       if (sparksp) sparksp->update(WheelSpeed);
-       if (clumpp) clumpp->update(WheelSpeed);
-       */
+
+
        //update custom particle systems
        for (int i=0; i<free_cparticle; i++)
        {

Modified: trunk/source/main/Beam.h
===================================================================
--- trunk/source/main/Beam.h    2010-07-22 21:18:09 UTC (rev 1491)
+++ trunk/source/main/Beam.h    2010-07-22 21:22:01 UTC (rev 1492)
@@ -643,7 +643,15 @@
        void sendStreamSetup();
        void receiveStreamData(unsigned int &type, int &source, unsigned int 
&streamid, char *buffer, unsigned int &len);
 
+       // dustpools
+       DustPool *dustp;
+    DustPool *dripp;
+    DustPool *sparksp;
+    DustPool *clumpp;
+    DustPool *splashp;
+    DustPool *ripplep;
 
+
        // SLIDE NODES 
/////////////////////////////////////////////////////////////
        //! Stores all the SlideNodes available on this truck
        std::vector< SlideNode > mSlideNodes;

Modified: trunk/source/main/DustManager.cpp
===================================================================
--- trunk/source/main/DustManager.cpp   2010-07-22 21:18:09 UTC (rev 1491)
+++ trunk/source/main/DustManager.cpp   2010-07-22 21:22:01 UTC (rev 1492)
@@ -44,6 +44,21 @@
 DustManager::DustManager(Ogre::SceneManager *mSceneMgr) : 
mSceneMgr(mSceneMgr), mEnabled(false)
 {
        mEnabled = (SETTINGS.getSetting("Dust") == "Yes");
+
+       
+       if (SETTINGS.getSetting("Dust")=="Yes")
+       {
+               dustpools["dust"]   = new DustPool("tracks/Dust", 20, 
mSceneMgr->getRootSceneNode(), mSceneMgr, w);
+               dustpools["clump"]  = new DustPool("tracks/Clump", 20, 
mSceneMgr->getRootSceneNode(), mSceneMgr, w);
+               dustpools["sparks"] = new DustPool("tracks/Sparks", 10, 
mSceneMgr->getRootSceneNode(), mSceneMgr, w);
+       }
+       if (SETTINGS.getSetting("Spray")=="Yes")
+       {
+               dustpools["drip"]   = new DustPool("tracks/Drip", 50, 
mSceneMgr->getRootSceneNode(), mSceneMgr, w);
+               dustpools["splash"] = new DustPool("tracks/Splash", 20, 
mSceneMgr->getRootSceneNode(), mSceneMgr, w);
+               dustpools["ripple"] = new DustPool("tracks/Ripple", 20, 
mSceneMgr->getRootSceneNode(), mSceneMgr, w);
+       }
+
 }
 
 DustManager::~DustManager()
@@ -62,6 +77,10 @@
 
 DustPool *DustManager::getGroundModelDustPool(ground_model_t *g)
 {
+       return 0;
+
+       /*
+       // disabled for now...
        if(!mEnabled) return 0;
 
        // if we have a non particle type, then return 0
@@ -74,8 +93,10 @@
        }
        // return the entry we have
        return dustpools[pname];
+       */
 }
 
+/*
 void DustManager::addNewDustPool(ground_model_t *g)
 {
        if(!mEnabled) return;
@@ -94,6 +115,7 @@
                                                                mSceneMgr);
        dustpools[pname] = dp;
 }
+*/
 
 void DustManager::update(float wspeed)
 {
@@ -125,3 +147,10 @@
                it->second->setVisible(visible);
        }
 }
+
+DustPool *DustManager::getDustPool(Ogre::String name)
+{
+       if(dustpools.find(name) == dustpools.end())
+               return 0;
+       return dustpools[name];
+}

Modified: trunk/source/main/DustManager.h
===================================================================
--- trunk/source/main/DustManager.h     2010-07-22 21:18:09 UTC (rev 1491)
+++ trunk/source/main/DustManager.h     2010-07-22 21:22:01 UTC (rev 1492)
@@ -42,13 +42,15 @@
        void update(float wspeed);
        void setWater(Water *w);
        void setVisible(bool visible);
+
+       DustPool *getDustPool(Ogre::String name);
        
 protected:
        Ogre::SceneManager *mSceneMgr;
        Water *w;
        bool mEnabled;
        std::map < Ogre::String , DustPool * > dustpools;
-       void addNewDustPool(ground_model_t *g);
+       //void addNewDustPool(ground_model_t *g);
 };
 
 #endif //GUI_FRICTION_H__

Modified: trunk/source/main/DustPool.cpp
===================================================================
--- trunk/source/main/DustPool.cpp      2010-07-22 21:18:09 UTC (rev 1491)
+++ trunk/source/main/DustPool.cpp      2010-07-22 21:22:01 UTC (rev 1492)
@@ -6,7 +6,7 @@
 For more information, see http://www.rigsofrods.com/
 
 Rigs of Rods is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License version 3, as
+it under the terms of the GNU General Public License version 3, as 
 published by the Free Software Foundation.
 
 Rigs of Rods is distributed in the hope that it will be useful,
@@ -20,98 +20,263 @@
 #include "DustPool.h"
 #include "water.h"
 
-#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
-#pragma GCC diagnostic ignored "-Wfloat-equal"
-#endif //OGRE_PLATFORM_LINUX
-
-DustPool::DustPool(String dname, int dsize, float minvelo, float maxvelo, 
float fadeco, float timedelta, float velofac, float ttl, SceneNode *parent, 
SceneManager *smgr, Water *mw) : w(mw), smgr(smgr), dustAtomsVec(), 
parentNode(parent), dname(dname), size(dsize), allocated(0), minvelo(minvelo), 
maxvelo(maxvelo), fadeco(fadeco), timedelta(timedelta), velofac(velofac), 
ttl(ttl)
+DustPool::DustPool(char* dname, int dsize, SceneNode *parent, SceneManager 
*smgr, Water *mw)
 {
-       //dustAtomsVec.resize(size);
-       for(int i=0; i<size;i++)
+       w=mw;
+       size=dsize;
+       allocated=0;
+       int i;
+       for (i=0; i<size; i++)
        {
-               // per class values
-               String dename = "Dust " + dname + StringConverter::toString(i);
-               dustatom_t da = dustatom_t();
-               da.node = parent->createChildSceneNode();
-               da.ps = smgr->createParticleSystem(dename, dname);
-               da.node->attachObject(da.ps);
-               da.ps->setCastShadows(false);
-               da.ps->getEmitter(0)->setEnabled(false);
-               dustAtomsVec.push_back(da);
-       }
-}
-
-DustPool::~DustPool()
-{
-       for (int i=0; i<size; i++)
-       {
-               if(dustAtomsVec[i].ps)
+               char dename[256];
+               sprintf(dename,"Dust %s %i", dname, i);
+               sns[i]=parent->createChildSceneNode();
+               pss[i]=smgr->createParticleSystem(dename, dname);
+               if (pss[i]) 
                {
-                       smgr->destroyParticleSystem(dustAtomsVec[i].ps);
-                       dustAtomsVec[i].ps = 0;
+                       sns[i]->attachObject(pss[i]);
+                       pss[i]->setCastShadows(false);
+                       //can't do this
+//                             if (w) 
((DeflectorPlaneAffector*)(pss[i]->getAffector(0)))->setPlanePoint(Vector3(0, 
w->getHeight(), 0));
                }
-               if(dustAtomsVec[i].node)
-               {
-                       dustAtomsVec[i].node->removeAndDestroyAllChildren();
-                       //dustAtomsVec[i] = 0;
-               }
        }
 
-}
+};
 
 void DustPool::setVisible(bool s)
 {
-       for (int i=0; i<size; i++)
+       int i;
+       for (i=0; i<size; i++) 
        {
-               dustAtomsVec[i].ps->setVisible(s);
+               pss[i]->setVisible(s ^ (types[i]==DUST_RIPPLE));
        }
 }
 
-void DustPool::alloc(Vector3 pos, Vector3 vel, ColourValue col, float time)
+//Dust
+void DustPool::alloc(Vector3 pos, Vector3 vel, ColourValue col)
 {
-       if(allocated == size) return; // discard then
-       if(vel.length() < minvelo || vel.length() > maxvelo) return;
+       if (allocated==size) return;
+       positions[allocated]=pos;
+       velocities[allocated]=vel;
+       colours[allocated]=col;
+       types[allocated]=DUST_NORMAL;
+       allocated++;
+}
 
-       dustAtomsVec[allocated].colour = col;
-       dustAtomsVec[allocated].velocity = vel;
-       dustAtomsVec[allocated].position = pos;
-       if(time > 0)
-               dustAtomsVec[allocated].rate = timedelta - time;
+//Clumps
+void DustPool::allocClump(Vector3 pos, Vector3 vel, ColourValue col)
+{
+       if (allocated==size) return;
+       positions[allocated]=pos;
+       velocities[allocated]=vel;
+       colours[allocated]=col;
+       types[allocated]=DUST_CLUMP;
        allocated++;
 }
 
+//Rubber smoke
+void DustPool::allocSmoke(Vector3 pos, Vector3 vel)
+{
+       if (allocated==size) return;
+       positions[allocated]=pos;
+       velocities[allocated]=vel;
+       types[allocated]=DUST_RUBBER;
+       allocated++;
+}
+
+//
+void DustPool::allocSparks(Vector3 pos, Vector3 vel)
+{
+       if(vel.length() < 0.1) return; // try to prevent emitting sparks while 
standing
+       if (allocated==size) return;
+       positions[allocated]=pos;
+       velocities[allocated]=vel;
+       types[allocated]=DUST_SPARKS;
+       allocated++;
+}
+
+//Water vapour
+void DustPool::allocVapour(Vector3 pos, Vector3 vel, float time)
+{
+       if (allocated==size) return;
+       positions[allocated]=pos;
+       velocities[allocated]=vel;
+       types[allocated]=DUST_VAPOUR;
+       rates[allocated]=5.0-time;
+       allocated++;
+}
+
+void DustPool::allocDrip(Vector3 pos, Vector3 vel, float time)
+{
+       if (allocated==size) return;
+       positions[allocated]=pos;
+       velocities[allocated]=vel;
+       types[allocated]=DUST_DRIP;
+       rates[allocated]=5.0-time;
+       allocated++;
+}
+
+void DustPool::allocSplash(Vector3 pos, Vector3 vel)
+{
+       if (allocated==size) return;
+       positions[allocated]=pos;
+       velocities[allocated]=vel;
+       types[allocated]=DUST_SPLASH;
+       allocated++;
+}
+
+void DustPool::allocRipple(Vector3 pos, Vector3 vel)
+{
+       if (allocated==size) return;
+       positions[allocated]=pos;
+       velocities[allocated]=vel;
+       types[allocated]=DUST_RIPPLE;
+       allocated++;
+}
+
 void DustPool::update(float gspeed)
 {
+       int i;
        gspeed=fabs(gspeed);
-       // walk the queue
-       for(int i=0; i<allocated; i++)
+       for (i=0; i<allocated; i++)
        {
-               dustatom_t *da = &dustAtomsVec[i];
-
-               ParticleEmitter *emit = da->ps->getEmitter(0);
-               Vector3 ndir = da->velocity;
-               ndir.y = 0;
-               ndir = ndir * velofac;
-               // XXX: whats this for?!
-               //if (ndir.y<0) ndir.y=-ndir.y;
-               Real vel = ndir.length();
-               //ndir.y+=vel/5.5;
-               if(vel == 0) vel += 0.0001; // fix division thorugh zero
-               ndir = ndir / vel;
-               emit->setEnabled(true);
-               da->node->setPosition(da->position);
-               emit->setDirection(ndir);
-               emit->setParticleVelocity(vel);
+               if (types[i]==DUST_NORMAL)
+               {
+                       ParticleEmitter *emit=pss[i]->getEmitter(0);
+                       Vector3 ndir=velocities[i];
+                       ndir.y=0;
+                       ndir=ndir/2.0;
+                       //if (ndir.y<0) ndir.y=-ndir.y;
+                       Real vel=ndir.length();
+                       if(vel == 0)
+                               vel += 0.0001;
+                       ndir=ndir/vel;
+                       emit->setEnabled(true);
+                       sns[i]->setPosition(positions[i]);
+                       emit->setDirection(ndir);
+                       emit->setParticleVelocity(vel);
 //                     emit->setColour(ColourValue(0.65, 0.55, 
0.53,(vel+(gspeed/10.0))*0.05));
-               ColourValue col = da->colour;
-               if(fadeco >= 0)
-                       col.a = (((vel+(gspeed/10.0))*0.05) * fadeco);
-               emit->setColour(col);
-               // TODO: FIX below
-               emit->setTimeToLive((vel+(gspeed/10.0)) * ttl);
-
+                       ColourValue col=colours[i];
+                       col.a=(vel+(gspeed/10.0))*0.05;
+                       emit->setColour(col);
+                       emit->setTimeToLive((vel+(gspeed/10.0))*0.05/0.1);
+               }
+               if (types[i]==DUST_CLUMP)
+               {
+                       ParticleEmitter *emit=pss[i]->getEmitter(0);
+                       Vector3 ndir=velocities[i];
+                       //ndir.y=0;
+                       ndir=ndir/2.0;
+                       if (ndir.y<0) ndir.y=-ndir.y;
+                       Real vel=ndir.length();
+                       ndir.y+=vel/5.5;
+                       vel=ndir.length();
+                       if(vel == 0)
+                               vel += 0.0001;
+                       ndir=ndir/vel;
+                       emit->setEnabled(true);
+                       sns[i]->setPosition(positions[i]);
+                       emit->setDirection(ndir);
+                       emit->setParticleVelocity(vel);
+                       ColourValue col=colours[i];
+                       col.a=1.0;
+                       emit->setColour(col);
+               }
+               else if (types[i]==DUST_RUBBER)
+               {
+                       ParticleEmitter *emit=pss[i]->getEmitter(0);
+                       Vector3 ndir=velocities[i];
+                       ndir.y=0;
+                       ndir=ndir/4.0;
+                       //if (ndir.y<0) ndir.y=-ndir.y;
+                       Real vel=ndir.length();
+                       if(vel == 0)
+                               vel += 0.0001;
+                       ndir=ndir/vel;
+                       emit->setEnabled(true);
+                       sns[i]->setPosition(positions[i]);
+                       emit->setDirection(ndir);
+                       emit->setParticleVelocity(vel);
+                       emit->setColour(ColourValue(0.9, 0.9, 0.9,vel*0.05));
+                       emit->setTimeToLive(vel*0.05/0.1);
+               }
+               else if (types[i]==DUST_SPARKS)
+               {
+                       ParticleEmitter *emit=pss[i]->getEmitter(0);
+                       Vector3 ndir=-velocities[i];
+                       //ndir.y=-ndir.y;
+                       Real vel=ndir.length();
+                       if(vel == 0)
+                               vel += 0.0001;
+                       ndir=ndir/vel;
+                       emit->setEnabled(true);
+                       sns[i]->setPosition(positions[i]);
+                       emit->setDirection(ndir);
+                       emit->setParticleVelocity(vel);
+               }
+               else if (types[i]==DUST_VAPOUR)
+               {
+                       ParticleEmitter *emit=pss[i]->getEmitter(0);
+                       Vector3 ndir=velocities[i];
+                       Real vel=ndir.length();
+                       if(vel == 0)
+                               vel += 0.0001;
+                       ndir=ndir/vel;
+                       emit->setEnabled(true);
+                       sns[i]->setPosition(positions[i]);
+                       emit->setDirection(ndir);
+                       emit->setParticleVelocity(vel/2.0);
+                       emit->setColour(ColourValue(0.9, 0.9, 
0.9,rates[i]*0.03));
+                       emit->setTimeToLive(rates[i]*0.03/0.1);
+               }
+               else if (types[i]==DUST_DRIP)
+               {
+                       ParticleEmitter *emit=pss[i]->getEmitter(0);
+                       Vector3 ndir=velocities[i];
+                       Real vel=ndir.length();
+                       if(vel == 0)
+                               vel += 0.0001;
+                       ndir=ndir/vel;
+                       emit->setEnabled(true);
+                       sns[i]->setPosition(positions[i]);
+                       emit->setDirection(ndir);
+                       emit->setParticleVelocity(vel);
+                       emit->setEmissionRate(rates[i]);
+               }
+               else if (types[i]==DUST_SPLASH)
+               {
+                       ParticleEmitter *emit=pss[i]->getEmitter(0);
+                       Vector3 ndir=velocities[i];
+                       if (ndir.y<0) ndir.y=-ndir.y/2.0;
+                       ndir=ndir/2.0;
+                       Real vel=ndir.length();
+                       if(vel == 0)
+                               vel += 0.0001;
+                       ndir=ndir/vel;
+                       emit->setEnabled(true);
+                       sns[i]->setPosition(positions[i]);
+                       emit->setDirection(ndir);
+                       emit->setParticleVelocity(vel);
+                       emit->setColour(ColourValue(0.9, 0.9, 0.9,vel*0.05));
+                       emit->setTimeToLive(vel*0.05/0.1);
+               }
+               else if (types[i]==DUST_RIPPLE)
+               {
+                       ParticleEmitter *emit=pss[i]->getEmitter(0);
+                       Real vel=velocities[i].length();
+                       emit->setEnabled(true);
+                       positions[i].y=w->getHeight()-0.02;
+                       sns[i]->setPosition(positions[i]);
+                       emit->setColour(ColourValue(0.9, 0.9, 0.9,vel*0.04));
+                       emit->setTimeToLive(vel*0.04/0.1);
+               }
        }
-       for (int i=allocated; i<size; i++)
-               dustAtomsVec[i].ps->getEmitter(0)->setEnabled(false);
+       for (i=allocated; i<size; i++) pss[i]->getEmitter(0)->setEnabled(false);
        allocated=0;
 }
+
+
+DustPool::~DustPool()
+{
+}
+

Modified: trunk/source/main/DustPool.h
===================================================================
--- trunk/source/main/DustPool.h        2010-07-22 21:18:09 UTC (rev 1491)
+++ trunk/source/main/DustPool.h        2010-07-22 21:22:01 UTC (rev 1492)
@@ -6,7 +6,7 @@
 For more information, see http://www.rigsofrods.com/
 
 Rigs of Rods is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License version 3, as
+it under the terms of the GNU General Public License version 3, as 
 published by the Free Software Foundation.
 
 Rigs of Rods is distributed in the hope that it will be useful,
@@ -23,49 +23,68 @@
 #include <stdio.h>
 #include <math.h>
 
-#include "OgrePrerequisites.h"
-#include "OgreVector3.h"
-#include "OgreColourValue.h"
-#include "rormemory.h"
+#include "Ogre.h"
 //#include "OgreDeflectorPlaneAffector.h"
 
 class Water;
 
-typedef struct dustatom_t
-{
-       Ogre::ParticleSystem *ps;
-       Ogre::SceneNode *node;
-       Ogre::Vector3 position;
-       Ogre::Vector3 velocity;
-       Ogre::ColourValue colour;
-       float rate;
-} dustatom_t;
+using namespace Ogre;
 
-class DustPool : public MemoryAllocatedObject
+#define MAX_DUSTS 100
+
+#define DUST_NORMAL 0
+#define DUST_RUBBER 1
+#define DUST_DRIP   2
+#define DUST_VAPOUR   3
+#define DUST_SPLASH 4
+#define DUST_RIPPLE 5
+#define DUST_SPARKS 6
+#define DUST_CLUMP 7
+
+class DustPool
 {
 protected:
-       Water* w;
-       Ogre::SceneManager *smgr;
-       Ogre::SceneNode *parentNode;
-       Ogre::String dname;
+       ParticleSystem* pss[MAX_DUSTS];
+    SceneNode *sns[MAX_DUSTS];
        int size;
        int allocated;
+       Vector3 positions[MAX_DUSTS];
+       Vector3 velocities[MAX_DUSTS];
+       ColourValue colours[MAX_DUSTS];
+       int types[MAX_DUSTS];
+       float rates[MAX_DUSTS];
+       Water* w;
 
-       std::vector<dustatom_t> dustAtomsVec;
+public:
+       DustPool(char* dname, int dsize, SceneNode *parent, SceneManager *smgr, 
Water *mw);
 
-       float minvelo, maxvelo, fadeco, timedelta, velofac, ttl;
+       void setVisible(bool s);
+       //Dust
+       void alloc(Vector3 pos, Vector3 vel, ColourValue col=ColourValue(0.83, 
0.71, 0.64, 1.0));
+       //clumps
+       void allocClump(Vector3 pos, Vector3 vel, ColourValue 
col=ColourValue(0.83, 0.71, 0.64, 1.0));
+       //Rubber smoke
+       void allocSmoke(Vector3 pos, Vector3 vel);
+       //
+       void allocSparks(Vector3 pos, Vector3 vel);
+       //Water vapour
+       void allocVapour(Vector3 pos, Vector3 vel, float time);
 
-public:
-       DustPool(Ogre::String name, int dsize, float minvelo, float maxvelo, 
float fadeco, float timedelta, float velofac, float ttl, Ogre::SceneNode 
*parent, Ogre::SceneManager *smgr, Water *mw=NULL);
-       ~DustPool();
+       void allocDrip(Vector3 pos, Vector3 vel, float time);
 
-       void alloc(Ogre::Vector3 pos, Ogre::Vector3 vel, Ogre::ColourValue col 
= Ogre::ColourValue::ZERO, float time = -1);
+       void allocSplash(Vector3 pos, Vector3 vel);
+
+       void allocRipple(Vector3 pos, Vector3 vel);
+
        void update(float gspeed);
-
-       void setWater(Water *mw) { this->w = mw; };
-       void setVisible(bool s);
+       void setWater(Water *_w) { w = _w; };
+       ~DustPool();
 };
 
+extern int numdust;
+extern DustPool* dusts[10];
+
+
 #endif
 
 

Modified: trunk/source/main/RoRFrameListener.cpp
===================================================================
--- trunk/source/main/RoRFrameListener.cpp      2010-07-22 21:18:09 UTC (rev 
1491)
+++ trunk/source/main/RoRFrameListener.cpp      2010-07-22 21:22:01 UTC (rev 
1492)
@@ -1227,9 +1227,6 @@
                source = net->getUserID();
 #endif //SOCKETW
 
-       // we need dust before we start the beam factory
-       initDust();
-
        // new beam factory
        new BeamFactory(this, trucks, mSceneMgr, mSceneMgr->getRootSceneNode(), 
mWindow, net, &mapsizex, &mapsizez, collisions, hfinder, w, mCamera, mirror);
 
@@ -6210,31 +6207,6 @@
 #endif //USE_PAGED
 }
 
-void RoRFrameListener::initDust()
-{
-       // fancy new dustmanager takes over the work of manually creating the 
dustpool classes
-       /*
-       //we create dust
-       dustp=0;
-       dripp=0;
-       splashp=0;
-       ripplep=0;
-       sparksp=0;
-       clumpp=0;
-       if (SETTINGS.getSetting("Dust")=="Yes")
-       {
-               dustp=new DustPool("tracks/Dust", 20, 
mSceneMgr->getRootSceneNode(), mSceneMgr);
-               clumpp=new DustPool("tracks/Clump", 20, 
mSceneMgr->getRootSceneNode(), mSceneMgr);
-               sparksp=new DustPool("tracks/Sparks", 10, 
mSceneMgr->getRootSceneNode(), mSceneMgr);
-       }
-       if (SETTINGS.getSetting("Spray")=="Yes")
-       {
-               dripp=new DustPool("tracks/Drip", 50, 
mSceneMgr->getRootSceneNode(), mSceneMgr);
-               splashp=new DustPool("tracks/Splash", 20, 
mSceneMgr->getRootSceneNode(), mSceneMgr);
-               ripplep=new DustPool("tracks/Ripple", 20, 
mSceneMgr->getRootSceneNode(), mSceneMgr);
-       }
-       */
-}
 
 void RoRFrameListener::initTrucks(bool loadmanual, Ogre::String selected, 
Ogre::String selectedExtension, std::vector<Ogre::String> *truckconfig, bool 
enterTruck)
 {

Modified: trunk/source/main/WaterOld.h
===================================================================
--- trunk/source/main/WaterOld.h        2010-07-22 21:18:09 UTC (rev 1491)
+++ trunk/source/main/WaterOld.h        2010-07-22 21:22:01 UTC (rev 1492)
@@ -96,7 +96,6 @@
        void framestep(float dt);
        bool allowUnderWater();
        void setHeight(float value);
-
 };
 
 

Modified: trunk/source/main/buoyance.cpp
===================================================================
--- trunk/source/main/buoyance.cpp      2010-07-22 21:18:09 UTC (rev 1491)
+++ trunk/source/main/buoyance.cpp      2010-07-22 21:22:01 UTC (rev 1492)
@@ -24,6 +24,8 @@
        w=water;
        update=0;
        sink=0;
+       splashp = DustManager::getSingleton().getDustPool("splash");
+       ripplep = DustManager::getSingleton().getDustPool("ripple");
 }
 
 
@@ -76,8 +78,6 @@
        //              drg=(-500.0*surf*vell*cosaoa)*vel;
                        drg=(-500.0*surf*vell*vell*cosaoa)*normal;
                        if (normal.dotProduct(vel/vell)<0) drg=-drg;
-                       /*
-                       // TODO: FIX SPLASH!
                        if (update && splashp)
                        {
                                float fxl=vell*cosaoa*surf;
@@ -90,7 +90,6 @@
                                        else if (w->getHeightWaves(c)-c.y<0.1) 
splashp->alloc(c, fxdir);
                                }
                        }
-                       */
                }
        }
        //okay

Modified: trunk/source/main/buoyance.h
===================================================================
--- trunk/source/main/buoyance.h        2010-07-22 21:18:09 UTC (rev 1491)
+++ trunk/source/main/buoyance.h        2010-07-22 21:22:01 UTC (rev 1492)
@@ -30,6 +30,9 @@
 //#include "DustPool.h"
 #include "Beam.h"
 
+#include "DustPool.h"
+#include "DustManager.h"
+
 #define PI 3.1415926535897932384626433832795
 using namespace Ogre;
 
@@ -43,6 +46,8 @@
        Water *w;
        int update;
        int sink;
+       DustPool *splashp, *ripplep;
+
 public:
 
        Buoyance(Water *water);

Modified: trunk/source/main/collisions.cpp
===================================================================
--- trunk/source/main/collisions.cpp    2010-07-22 21:18:09 UTC (rev 1491)
+++ trunk/source/main/collisions.cpp    2010-07-22 21:22:01 UTC (rev 1492)
@@ -246,6 +246,12 @@
                                {
                                        if(kvalue == "PARTICLE")
                                                ground_models[secName].fx_type 
= FX_PARTICLE;
+                                       else if(kvalue == "HARD")
+                                               ground_models[secName].fx_type 
= FX_HARD;
+                                       else if(kvalue == "DUSTY")
+                                               ground_models[secName].fx_type 
= FX_DUSTY;
+                                       else if(kvalue == "CLUMPY")
+                                               ground_models[secName].fx_type 
= FX_CLUMPY;
                                }
                                else if(kname == "fx_particle_name") 
strncpy(ground_models[secName].particle_name, kvalue.c_str(), 255);
                                else if(kname == "fx_colour") 
ground_models[secName].fx_colour = StringConverter::parseColourValue(kvalue);

Modified: trunk/source/main/collisions.h
===================================================================
--- trunk/source/main/collisions.h      2010-07-22 21:18:09 UTC (rev 1491)
+++ trunk/source/main/collisions.h      2010-07-22 21:22:01 UTC (rev 1492)
@@ -48,9 +48,17 @@
 #define LATEST_GROUND_MODEL_VERSION 3
 #define LATEST_LANDUSE_VERSION 1
 
+//nothing
 #define FX_NONE 0
-#define FX_PARTICLE 1
+//hard surface: rubber burning and sparks
+#define FX_HARD 1
+//dusty surface (with dust colour)
+#define FX_DUSTY 2
+//throws clumps (e.g. snow, grass) with colour
+#define FX_CLUMPY 3
 
+#define FX_PARTICLE 4
+
 typedef struct _eventsource
 {
        char instancename[256];

Modified: trunk/source/main/screwprop.cpp
===================================================================
--- trunk/source/main/screwprop.cpp     2010-07-22 21:18:09 UTC (rev 1491)
+++ trunk/source/main/screwprop.cpp     2010-07-22 21:22:01 UTC (rev 1492)
@@ -28,6 +28,8 @@
        nodeup=nu;
        fullpower=power;
        water=w;
+       splashp = DustManager::getSingleton().getDustPool("splash");
+       ripplep = DustManager::getSingleton().getDustPool("ripple");
        reset();
 }
 
@@ -44,14 +46,11 @@
        rudaxis.normalise();
        dir=(throtle*fullpower)*(Quaternion(Degree(rudder),rudaxis)*dir);
        nodes[noderef].Forces+=dir;
-       // TODO: FIX SPLASH!
-       /*
        if (update && splashp && throtle>0.1)
        {
                if (depth<0.2) splashp->allocSplash(nodes[noderef].AbsPosition, 
10.0*dir/fullpower);
                ripplep->allocRipple(nodes[noderef].AbsPosition, 
10.0*dir/fullpower);
        }
-       */
 }
 
 void Screwprop::setThrotle(float val)

Modified: trunk/source/main/screwprop.h
===================================================================
--- trunk/source/main/screwprop.h       2010-07-22 21:18:09 UTC (rev 1491)
+++ trunk/source/main/screwprop.h       2010-07-22 21:22:01 UTC (rev 1492)
@@ -26,6 +26,8 @@
 using namespace Ogre;
 #include "Beam.h"
 #include "SoundScriptManager.h"
+#include "DustPool.h"
+#include "DustManager.h"
 
 class Screwprop : public MemoryAllocatedObject
 {
@@ -36,6 +38,7 @@
        float fullpower; //in HP
        Water* water;
        int trucknum;
+       DustPool *splashp, *ripplep;
 
 public:
        int noderef;


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel

Reply via email to