diff --git a/src/graphics/nitro.cpp b/src/graphics/nitro.cpp deleted file mode 100644 index a35860960..000000000 --- a/src/graphics/nitro.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// $Id: nitro.cpp 1681 2008-04-09 13:52:48Z hikerstk $ -// -// SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2008 Joerg Henrichs -// -// 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 3 -// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "graphics/nitro.hpp" - -#include "graphics/material_manager.hpp" -#include "graphics/irr_driver.hpp" -#include "io/file_manager.hpp" -#include "karts/kart.hpp" -#include "utils/constants.hpp" - -Nitro::Nitro(Kart* kart) : m_kart(kart) -{ - const float particle_size = 0.25f; - m_node = irr_driver->addParticleNode(); -#ifdef DEBUG - std::string debug_name = m_kart->getIdent()+" (nitro)"; - m_node->setName(debug_name.c_str()); -#endif - m_node->setParent(m_kart->getNode()); - m_node->setPosition(core::vector3df(0, particle_size*0.25f, -m_kart->getKartLength()*0.5f)); - Material *m= material_manager->getMaterial("nitro-particle.png"); - m->setMaterialProperties(&(m_node->getMaterial(0))); - m_node->setMaterialTexture(0, m->getTexture()); - - m_emitter = m_node->createBoxEmitter(core::aabbox3df(-m_kart->getKartWidth()*0.3f, 0.1f, -m_kart->getKartLength()*0.1f, - m_kart->getKartWidth()*0.3f, 0.1f + m_kart->getKartHeight()*0.5f, -m_kart->getKartLength()*0.3f), - core::vector3df(0.0f, 0.03f, 0.0f), - 5, 10, - video::SColor(255,0,0,0), - video::SColor(255,255,255,255), - 150, 250, // Min max life milisec - 40, // Angle - core::dimension2df(particle_size/2.0f, particle_size/2.0f), - core::dimension2df(particle_size*2.0f, particle_size*2.0f) - ); - m_emitter->setMinStartSize(core::dimension2df(particle_size/2.0f, particle_size/2.0f)); - m_emitter->setMaxStartSize(core::dimension2df(particle_size*2.0f, particle_size*2.0f)); - m_node->setEmitter(m_emitter); // this grabs the emitter - m_emitter->drop(); // so we can drop our reference - - scene::IParticleAffector *af = m_node->createFadeOutParticleAffector(video::SColor(0, 0, 0, 0), 2500); - m_node->addAffector(af); - af->drop(); -} // KartParticleSystem - -//----------------------------------------------------------------------------- -Nitro::~Nitro() -{ - irr_driver->removeNode(m_node); -} // ~Nitro - -//----------------------------------------------------------------------------- -void Nitro::update(float t) -{ - // No particles to emit, no need to change the speed - if(m_emitter->getMinParticlesPerSecond()==0) - return; - // There seems to be no way to randomise the velocity for particles, - // so we have to do this manually, by changing the default velocity. - // Irrlicht expects velocity (called 'direction') in m/ms!! - Vec3 dir(cos(DEGREE_TO_RAD*(rand()%180))*0.001f, - sin(DEGREE_TO_RAD*(rand()%180))*0.001f, - sin(DEGREE_TO_RAD*(rand()%100))*0.001f); - m_emitter->setDirection(dir.toIrrVector()); -} // update - -//----------------------------------------------------------------------------- -void Nitro::setCreationRate(float f) -{ - m_emitter->setMinParticlesPerSecond(int(f)); - m_emitter->setMaxParticlesPerSecond(int(f)); -} // setCreationRate - diff --git a/src/graphics/nitro.hpp b/src/graphics/nitro.hpp deleted file mode 100644 index 9431fd0b6..000000000 --- a/src/graphics/nitro.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// $Id: nitro.hpp 1681 2008-04-09 13:52:48Z hikerstk $ -// -// SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2008 Joerg Henrichs -// -// 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 3 -// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef HEADER_NITRO_HPP -#define HEADER_NITRO_HPP - -#include "utils/no_copy.hpp" - -#include "irrlicht.h" -using namespace irr; - -class Kart; - -/** - * \brief Handles nitro particle effects - * \ingroup graphics - */ -class Nitro : public NoCopy -{ -private: - /** The kart to which this nitro belongs. */ - Kart *m_kart; - /** Irrlicht's particle systems. */ - scene::IParticleSystemSceneNode *m_node; - /** The emitter. Access to this is needed to adjust the number of - * particles per second. */ - scene::IParticleEmitter *m_emitter; -public: - Nitro (Kart* kart); - virtual ~Nitro (); - virtual void update (float t); - void setCreationRate(float f); -}; -#endif - diff --git a/src/graphics/smoke.cpp b/src/graphics/particle_emitter.cpp similarity index 50% rename from src/graphics/smoke.cpp rename to src/graphics/particle_emitter.cpp index dce67db1a..3f73ee280 100644 --- a/src/graphics/smoke.cpp +++ b/src/graphics/particle_emitter.cpp @@ -1,7 +1,7 @@ -// $Id: smoke.cpp 1681 2008-04-09 13:52:48Z hikerstk $ +// $Id$ // // SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2009 Joerg Henrichs +// Copyright (C) 2011 Joerg Henrichs, Marianne Gagnon // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -17,89 +17,96 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#include "graphics/smoke.hpp" +#include "graphics/particle_emitter.hpp" +#include "graphics/material.hpp" #include "graphics/material_manager.hpp" #include "graphics/irr_driver.hpp" #include "io/file_manager.hpp" -#include "karts/kart.hpp" -#include "physics/btKart.hpp" #include "utils/constants.hpp" -Smoke::Smoke(Kart* kart) : m_kart(kart), m_particle_size(0.33f) +ParticleEmitter::ParticleEmitter(float particleSize, core::vector3df position, Material* material, + int minParticlesPerSecond, int maxParticlesPerSecond, + video::SColor minStartColor, video::SColor maxStartColor, + int lifeTimeMin, int lifeTimeMax, int maxAngle, int fadeOutTime, + float directionMultiplier, float minSize, float maxSize, scene::ISceneNode* parent) { + m_direction_multiplier = directionMultiplier; m_node = irr_driver->addParticleNode(); + #ifdef DEBUG - std::string debug_name = m_kart->getIdent()+" (smoke)"; + std::string debug_name = std::string("particles(") + material->getTexture()->getName().getPath().c_str() + ")"; m_node->setName(debug_name.c_str()); #endif + + if (parent != NULL) + { + m_node->setParent(parent); + } + // Note: the smoke system is NOT child of the kart, since bullet // gives the position of the wheels on the ground in world coordinates. // So it's easier not to move the particle system with the kart, and set // the position directly from the wheel coordinates. - m_node->setPosition(core::vector3df(-m_kart->getKartWidth()*0.35f, - m_particle_size*0.25f, - -m_kart->getKartLength()*0.5f)); - Material *m= material_manager->getMaterial("smoke.png"); - m->setMaterialProperties(&(m_node->getMaterial(0))); - m_node->setMaterialTexture(0, m->getTexture()); - - m_emitter = m_node->createPointEmitter(core::vector3df(0, 0, 0), // velocity in m/ms - 5, // minParticlesPerSecond - 10, // maxParticlesPerSecond - video::SColor(255,0,0,0), // minStartColor - video::SColor(255,255,255,255), // maxStartColor - 300, // lifeTimeMin - 500, // lifeTimeMax - 20 // max angle (degrees) + m_node->setPosition(position); + material->setMaterialProperties(&(m_node->getMaterial(0))); + m_node->setMaterialTexture(0, material->getTexture()); + + // FIXME: does the maxAngle param work at all?? + + m_emitter = m_node->createPointEmitter(core::vector3df(0.0f, 0.3f, 0.0f), // velocity in m/ms + minParticlesPerSecond, maxParticlesPerSecond, + minStartColor, maxStartColor, + lifeTimeMin, lifeTimeMax, + maxAngle ); - m_emitter->setMinStartSize(core::dimension2df(m_particle_size/1.5f, m_particle_size/1.5f)); - m_emitter->setMaxStartSize(core::dimension2df(m_particle_size*1.5f, m_particle_size*1.5f)); + m_emitter->setMinStartSize(core::dimension2df(minSize, minSize)); + m_emitter->setMaxStartSize(core::dimension2df(maxSize, maxSize)); m_node->setEmitter(m_emitter); // this grabs the emitter m_emitter->drop(); // so we can drop our references - - scene::IParticleFadeOutAffector *af = m_node->createFadeOutParticleAffector(video::SColor(0, 255, 0, 0), 500); + + // FIXME: fade-out color doesn't seem to quite work + scene::IParticleFadeOutAffector *af = m_node->createFadeOutParticleAffector(video::SColor(0, 255, 0, 0), fadeOutTime); m_node->addAffector(af); af->drop(); - + } // KartParticleSystem //----------------------------------------------------------------------------- /** Destructor, removes */ -Smoke::~Smoke() +ParticleEmitter::~ParticleEmitter() { irr_driver->removeNode(m_node); -} // ~Smoke +} // ~ParticleEmitter //----------------------------------------------------------------------------- -void Smoke::update(float t) +void ParticleEmitter::update() { // No particles to emit, no need to change the speed - if(m_emitter->getMinParticlesPerSecond()==0) - return; - static int left=1; - left = 1-left; - const btWheelInfo &wi = m_kart->getVehicle()->getWheelInfo(2+left); - Vec3 c=wi.m_raycastInfo.m_contactPointWS; - - // FIXME: the X position is not yet always accurate. - m_node->setPosition(core::vector3df(c.getX()+m_particle_size*0.25f * (left?+1:-1), - c.getY(), - c.getZ()+m_particle_size*0.25f)); - + if (m_emitter->getMinParticlesPerSecond() == 0) return; + // There seems to be no way to randomise the velocity for particles, // so we have to do this manually, by changing the default velocity. // Irrlicht expects velocity (called 'direction') in m/ms!! - Vec3 dir(cos(DEGREE_TO_RAD*(rand()%180))*0.002f, - sin(DEGREE_TO_RAD*(rand()%100))*0.002f, - sin(DEGREE_TO_RAD*(rand()%180))*0.002f); + Vec3 dir(cos(DEGREE_TO_RAD*(rand()%180))*m_direction_multiplier, + sin(DEGREE_TO_RAD*(rand()%100))*m_direction_multiplier, + sin(DEGREE_TO_RAD*(rand()%180))*m_direction_multiplier); + m_emitter->setDirection(dir.toIrrVector()); } // update //----------------------------------------------------------------------------- -void Smoke::setCreationRate(float f) + +void ParticleEmitter::setCreationRate(float f) { m_emitter->setMinParticlesPerSecond(int(f)); m_emitter->setMaxParticlesPerSecond(int(f)); } // setCreationRate + +//----------------------------------------------------------------------------- + +void ParticleEmitter::setPosition(core::vector3df pos) +{ + m_node->setPosition(pos); +} diff --git a/src/graphics/smoke.hpp b/src/graphics/particle_emitter.hpp similarity index 56% rename from src/graphics/smoke.hpp rename to src/graphics/particle_emitter.hpp index dcf30701a..b481db90d 100644 --- a/src/graphics/smoke.hpp +++ b/src/graphics/particle_emitter.hpp @@ -1,7 +1,7 @@ -// $Id: dust_cloud.hpp 1681 2008-04-09 13:52:48Z hikerstk $ +// $Id$ // // SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2009 Joerg Henrichs +// Copyright (C) 2011 Joerg Henrichs, Marianne Gagnon // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -25,29 +25,41 @@ #include "irrlicht.h" using namespace irr; -class Kart; +class Material; /** - * \brief manages smoke particle effects - * \ingroup graphics - */ -class Smoke : public NoCopy + * \brief manages smoke particle effects + * \ingroup graphics + */ +class ParticleEmitter : public NoCopy { private: - /** The kart to which this smoke belongs. */ - const Kart *m_kart; + /** Irrlicht's particle systems. */ scene::IParticleSystemSceneNode *m_node; /* left wheel */ + /** The emitters. Access to these is needed to adjust the number of * particles per second. */ scene::IParticleEmitter *m_emitter; + /** Size of the particles. */ - const float m_particle_size; + float m_particle_size; + + float m_direction_multiplier; + public: - Smoke (Kart* kart); - virtual ~Smoke (); - virtual void update (float t); + ParticleEmitter (float particleSize, core::vector3df position, Material* material, + int minParticlesPerSeconds, int maxParticlesPerSecond, + video::SColor minStartColor, video::SColor maxStartColor, + int lifeTimeMin, int lifeTimeMax, int maxAngle, int fadeOutTime, + float directionMultiplier, float minSize, float maxSize, + scene::ISceneNode* parent = NULL); + virtual ~ParticleEmitter(); + virtual void update (); void setCreationRate(float f); + + void setPosition(core::vector3df pos); }; #endif + diff --git a/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj b/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj index 13707a9c5..b0c39c1c4 100644 --- a/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj +++ b/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj @@ -43,10 +43,8 @@ 952A1549103F66D600B1895D /* material_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 952A1535103F66D600B1895D /* material_manager.cpp */; }; 952A154A103F66D600B1895D /* mesh_tools.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 952A1537103F66D600B1895D /* mesh_tools.cpp */; }; 952A154B103F66D600B1895D /* moving_texture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 952A1539103F66D600B1895D /* moving_texture.cpp */; }; - 952A154C103F66D600B1895D /* nitro.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 952A153B103F66D600B1895D /* nitro.cpp */; }; 952A154D103F66D600B1895D /* shadow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 952A153D103F66D600B1895D /* shadow.cpp */; }; 952A154E103F66D600B1895D /* skid_marks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 952A153F103F66D600B1895D /* skid_marks.cpp */; }; - 952A154F103F66D600B1895D /* smoke.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 952A1541103F66D600B1895D /* smoke.cpp */; }; 952A1550103F66D600B1895D /* water_splash.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 952A1543103F66D600B1895D /* water_splash.cpp */; }; 952A1554103F68D000B1895D /* profile_world.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 952A1552103F68D000B1895D /* profile_world.cpp */; }; 953789730FC7829100DD1F8E /* graph_node.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 953789720FC7829100DD1F8E /* graph_node.cpp */; }; @@ -58,6 +56,7 @@ 95395A77129DFE130079BCE7 /* message_dialog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95395A75129DFE130079BCE7 /* message_dialog.cpp */; }; 953C304E12BEF384005BB4CD /* tutorial_data.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 953C304C12BEF384005BB4CD /* tutorial_data.cpp */; }; 953F8B2111F7C13C00205E66 /* scalable_font.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 953F8B1F11F7C13C00205E66 /* scalable_font.cpp */; }; + 9542FC7712D3BDB000C00366 /* particle_emitter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9542FC7512D3BDB000C00366 /* particle_emitter.cpp */; }; 95453ACA11808B8700A155B9 /* emergency_animation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95453AC811808B8700A155B9 /* emergency_animation.cpp */; }; 9545ABCA11E3E38300D3C37A /* progress_bar_widget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9545ABC811E3E38300D3C37A /* progress_bar_widget.cpp */; }; 954E486A11B19C4100B1DF63 /* fribidi.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 954E486911B19C4100B1DF63 /* fribidi.framework */; }; @@ -405,14 +404,10 @@ 952A1538103F66D600B1895D /* mesh_tools.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = mesh_tools.hpp; path = ../../graphics/mesh_tools.hpp; sourceTree = SOURCE_ROOT; }; 952A1539103F66D600B1895D /* moving_texture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = moving_texture.cpp; path = ../../graphics/moving_texture.cpp; sourceTree = SOURCE_ROOT; }; 952A153A103F66D600B1895D /* moving_texture.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = moving_texture.hpp; path = ../../graphics/moving_texture.hpp; sourceTree = SOURCE_ROOT; }; - 952A153B103F66D600B1895D /* nitro.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = nitro.cpp; path = ../../graphics/nitro.cpp; sourceTree = SOURCE_ROOT; }; - 952A153C103F66D600B1895D /* nitro.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = nitro.hpp; path = ../../graphics/nitro.hpp; sourceTree = SOURCE_ROOT; }; 952A153D103F66D600B1895D /* shadow.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = shadow.cpp; path = ../../graphics/shadow.cpp; sourceTree = SOURCE_ROOT; }; 952A153E103F66D600B1895D /* shadow.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = shadow.hpp; path = ../../graphics/shadow.hpp; sourceTree = SOURCE_ROOT; }; 952A153F103F66D600B1895D /* skid_marks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = skid_marks.cpp; path = ../../graphics/skid_marks.cpp; sourceTree = SOURCE_ROOT; }; 952A1540103F66D600B1895D /* skid_marks.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = skid_marks.hpp; path = ../../graphics/skid_marks.hpp; sourceTree = SOURCE_ROOT; }; - 952A1541103F66D600B1895D /* smoke.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = smoke.cpp; path = ../../graphics/smoke.cpp; sourceTree = SOURCE_ROOT; }; - 952A1542103F66D600B1895D /* smoke.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = smoke.hpp; path = ../../graphics/smoke.hpp; sourceTree = SOURCE_ROOT; }; 952A1543103F66D600B1895D /* water_splash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = water_splash.cpp; path = ../../graphics/water_splash.cpp; sourceTree = SOURCE_ROOT; }; 952A1544103F66D600B1895D /* water_splash.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = water_splash.hpp; path = ../../graphics/water_splash.hpp; sourceTree = SOURCE_ROOT; }; 952A1552103F68D000B1895D /* profile_world.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = profile_world.cpp; path = ../../modes/profile_world.cpp; sourceTree = SOURCE_ROOT; }; @@ -442,6 +437,8 @@ 953F8B2011F7C13C00205E66 /* scalable_font.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = scalable_font.hpp; path = ../../guiengine/scalable_font.hpp; sourceTree = SOURCE_ROOT; }; 9540E2560FD5F8FD002985B8 /* ptr_vector.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = ptr_vector.hpp; path = ../../utils/ptr_vector.hpp; sourceTree = SOURCE_ROOT; }; 9540E2570FD5F8FD002985B8 /* no_copy.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = no_copy.hpp; path = ../../utils/no_copy.hpp; sourceTree = SOURCE_ROOT; }; + 9542FC7512D3BDB000C00366 /* particle_emitter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = particle_emitter.cpp; path = ../../graphics/particle_emitter.cpp; sourceTree = SOURCE_ROOT; }; + 9542FC7612D3BDB000C00366 /* particle_emitter.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = particle_emitter.hpp; path = ../../graphics/particle_emitter.hpp; sourceTree = SOURCE_ROOT; }; 95453AC811808B8700A155B9 /* emergency_animation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = emergency_animation.cpp; path = ../../karts/emergency_animation.cpp; sourceTree = SOURCE_ROOT; }; 95453AC911808B8700A155B9 /* emergency_animation.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = emergency_animation.hpp; path = ../../karts/emergency_animation.hpp; sourceTree = SOURCE_ROOT; }; 9545ABC811E3E38300D3C37A /* progress_bar_widget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = progress_bar_widget.cpp; path = ../../guiengine/widgets/progress_bar_widget.cpp; sourceTree = SOURCE_ROOT; }; @@ -1252,16 +1249,14 @@ 952A1538103F66D600B1895D /* mesh_tools.hpp */, 952A1539103F66D600B1895D /* moving_texture.cpp */, 952A153A103F66D600B1895D /* moving_texture.hpp */, - 952A153B103F66D600B1895D /* nitro.cpp */, - 952A153C103F66D600B1895D /* nitro.hpp */, + 9542FC7512D3BDB000C00366 /* particle_emitter.cpp */, + 9542FC7612D3BDB000C00366 /* particle_emitter.hpp */, 952A153D103F66D600B1895D /* shadow.cpp */, 952A153E103F66D600B1895D /* shadow.hpp */, 952A153F103F66D600B1895D /* skid_marks.cpp */, 952A1540103F66D600B1895D /* skid_marks.hpp */, 95DFC5001106933B00A043A9 /* slip_stream.cpp */, 95DFC5011106933B00A043A9 /* slip_stream.hpp */, - 952A1541103F66D600B1895D /* smoke.cpp */, - 952A1542103F66D600B1895D /* smoke.hpp */, 95C9C97010E93456005A418D /* stars.cpp */, 95C9C97110E93456005A418D /* stars.hpp */, 952A1543103F66D600B1895D /* water_splash.cpp */, @@ -2659,10 +2654,8 @@ 952A1549103F66D600B1895D /* material_manager.cpp in Sources */, 952A154A103F66D600B1895D /* mesh_tools.cpp in Sources */, 952A154B103F66D600B1895D /* moving_texture.cpp in Sources */, - 952A154C103F66D600B1895D /* nitro.cpp in Sources */, 952A154D103F66D600B1895D /* shadow.cpp in Sources */, 952A154E103F66D600B1895D /* skid_marks.cpp in Sources */, - 952A154F103F66D600B1895D /* smoke.cpp in Sources */, 952A1550103F66D600B1895D /* water_splash.cpp in Sources */, 952A1554103F68D000B1895D /* profile_world.cpp in Sources */, 9524739610497C75000C197E /* dynamic_ribbon_widget.cpp in Sources */, @@ -2732,6 +2725,7 @@ 9538E2BA12C25D6800172896 /* network_http.cpp in Sources */, 951B50AE12C9698B004F6993 /* xml_writer.cpp in Sources */, 9538A56012CD094200CE3220 /* addon.cpp in Sources */, + 9542FC7712D3BDB000C00366 /* particle_emitter.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index c9fa6d5cc..f9d45d339 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -30,11 +30,10 @@ #include "config/user_config.hpp" #include "graphics/camera.hpp" #include "graphics/material_manager.hpp" -#include "graphics/nitro.hpp" +#include "graphics/particle_emitter.hpp" #include "graphics/shadow.hpp" #include "graphics/skid_marks.hpp" #include "graphics/slip_stream.hpp" -#include "graphics/smoke.hpp" #include "graphics/water_splash.hpp" #include "modes/world.hpp" #include "io/file_manager.hpp" @@ -56,6 +55,8 @@ # pragma warning(disable:4355) #endif +const float SMOKE_PARTICLE_SIZE = 0.33f; + /** The kart constructor. * \param ident The identifier for the kart model to use. * \param position The position (or rank) for this kart (between 1 and @@ -730,11 +731,11 @@ void Kart::update(float dt) //smoke drawing control point if ( UserConfigParams::m_graphical_effects ) { - m_smoke_system->update(dt); + m_smoke_system->update(); m_water_splash_system->update(dt); } // UserConfigParams::m_graphical_effects - m_nitro->update(dt); + m_nitro->update(); updatePhysics(dt); @@ -1439,13 +1440,29 @@ void Kart::loadData() createPhysics(); // Attach Particle System - if ( UserConfigParams::m_graphical_effects ) + if (UserConfigParams::m_graphical_effects) { - m_smoke_system = new Smoke(this); + core::vector3df position(-getKartWidth()*0.35f, SMOKE_PARTICLE_SIZE*0.25f, -getKartLength()*0.5f); + m_smoke_system = new ParticleEmitter(SMOKE_PARTICLE_SIZE, position, material_manager->getMaterial("smoke.png"), + 5 /* min particles */, 10 /* max particles */, + video::SColor(255,0,0,0) /* min color */, + video::SColor(255,255,255,255) /* max color */, + 300 /* lifeTimeMin */, 500 /* lifeTimeMax */, 20 /* max angle */, + 500 /* fade-out time */, 0.003f, SMOKE_PARTICLE_SIZE/1.5f, SMOKE_PARTICLE_SIZE*1.5f); } m_water_splash_system = new WaterSplash(this); - m_nitro = new Nitro(this); - m_slipstream = new SlipStream(this); + + const float particle_size = 0.25f; + core::vector3df position(0, particle_size*0.25f, -getKartLength()*0.5f); + m_nitro = new ParticleEmitter(particle_size, position, material_manager->getMaterial("nitro-particle.png"), + 5 /* min particles */, 10 /* max particles */, + video::SColor(255,0,0,0) /* min color */, + video::SColor(255,255,255,255) /* max color */, + 150 /* lifeTimeMin */, 250 /* lifeTimeMax */, 40 /* max angle */, + 2500 /* fade-out time */, 0.003f, particle_size/1.5f, particle_size*2.0f, + getNode()); + + m_slipstream = new SlipStream(this); if(m_kart_properties->hasSkidmarks()) m_skidmarks = new SkidMarks(*this); @@ -1533,6 +1550,18 @@ void Kart::updateGraphics(const Vec3& offset_xyz, isOnGround() ) f=250.0f; m_smoke_system->setCreationRate((m_skidding-1)*f); + + static int left = 1; + left = 1 - left; + const btWheelInfo &wi = getVehicle()->getWheelInfo(2 + left); + Vec3 c = wi.m_raycastInfo.m_contactPointWS; + + // FIXME: instead of constantly moving the emitter around, just make it a child of the kart node + // FIXME: the X position is not yet always accurate. + m_smoke_system->setPosition(core::vector3df(c.getX() + SMOKE_PARTICLE_SIZE*0.25f * (left ? +1 : -1), + c.getY(), + c.getZ() + SMOKE_PARTICLE_SIZE*0.25f)); + } if(m_water_splash_system) { @@ -1541,11 +1570,13 @@ void Kart::updateGraphics(const Vec3& offset_xyz, : 0.0f; m_water_splash_system->setCreationRate(f); } - if(m_nitro) + if (m_nitro) + { // fabs(speed) is important, otherwise the negative number will // become a huge unsigned number in the particle scene node! m_nitro->setCreationRate(m_controls.m_nitro && isOnGround() && m_collected_energy>0 ? (10.0f + fabsf(getSpeed())*20.0f) : 0); + } // For testing purposes mis-use the nitro graphical effects to show // then the slipstream becomes usable. diff --git a/src/karts/kart.hpp b/src/karts/kart.hpp index 5f3586651..a14266a54 100644 --- a/src/karts/kart.hpp +++ b/src/karts/kart.hpp @@ -42,14 +42,13 @@ class btUprightConstraint; class btVehicleTuning; class Camera; class Item; -class Nitro; class Quad; class Shadow; class SFXBase; class SkidMarks; class SlipStream; -class Smoke; class WaterSplash; +class ParticleEmitter; /** The main kart class. All type of karts are of this object, but with * different controllers. The controllers are what turn a kart into a @@ -127,36 +126,37 @@ private: // Graphical effects // ----------------- /** The shadow of a kart. */ - Shadow *m_shadow; + Shadow *m_shadow; /** If a kart is flying, the shadow is disabled (since it is * stuck to the kart, i.e. the shadow would be flying, too). */ - bool m_shadow_enabled; + bool m_shadow_enabled; /** Smoke from skidding. */ - Smoke *m_smoke_system; + ParticleEmitter *m_smoke_system; /** Water splash when driving in water. */ - WaterSplash *m_water_splash_system; + WaterSplash *m_water_splash_system; /** Graphical effect when using a nitro. */ - Nitro *m_nitro; + ParticleEmitter *m_nitro; /** Handles all slipstreaming. */ - SlipStream *m_slipstream; + SlipStream *m_slipstream; - float m_wheel_rotation; + float m_wheel_rotation; + /** For each wheel it stores the suspension length after the karts are at * the start position, i.e. the suspension will be somewhat compressed. * The bullet suspensionRestLength is the value when the suspension is not * at all compressed. */ - float m_default_suspension_length[4]; + float m_default_suspension_length[4]; /** The skidmarks object for this kart. */ - SkidMarks *m_skidmarks; + SkidMarks *m_skidmarks; - float m_finish_time; - bool m_finished_race; + float m_finish_time; + bool m_finished_race; /** When a kart has its view blocked by the plunger, this variable will be * > 0 the number it contains is the time left before removing plunger. */