Improve wather splash : 1) remove old unused class 2) the splash should only occur when touching the surface, and not keep on splashing when you're underwater

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7755 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2011-02-27 19:49:32 +00:00
parent cd29d26a4e
commit 42626329b3
7 changed files with 17 additions and 176 deletions

View File

@@ -89,8 +89,6 @@ supertuxkart_SOURCES = \
graphics/slip_stream.hpp \
graphics/stars.cpp \
graphics/stars.hpp \
graphics/water_splash.hpp \
graphics/water_splash.cpp \
guiengine/CGUISpriteBank.cpp \
guiengine/CGUISpriteBank.h \
guiengine/abstract_state_manager.cpp \

View File

@@ -191,9 +191,6 @@ public:
* gfx. See m_below_surface for more details. */
bool isSurface () const { return m_surface; }
// ------------------------------------------------------------------------
/** Returns true if this material should have water splashes. */
bool hasWaterSplash () const { return m_graphical_effect==GE_WATER;}
// ------------------------------------------------------------------------
/** Returns the name of a special sfx to play while a kart is on this
* terrain. The string will be "" if no special sfx exists. */
const std::string &

View File

@@ -1,106 +0,0 @@
// $Id$
//
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2009 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/water_splash.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"
WaterSplash::WaterSplash(Kart* kart) : m_kart(kart), m_particle_size(0.75f)
{
m_node = irr_driver->addParticleNode();
#ifdef DEBUG
std::string debug_name = m_kart->getIdent()+" (water-splash)";
m_node->setName(debug_name.c_str());
#endif
// 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("water-splash.png");
m->setMaterialProperties(&(m_node->getMaterial(0)));
m_node->setMaterialTexture(0, m->getTexture());
m_emitter = m_node->createPointEmitter(core::vector3df(0, 0.05f, 0), // velocity in m/ms
5, 10,
video::SColor(255,0,0,0),
video::SColor(255,255,255,255),
300, 500,
60 // max angle
);
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_node->setEmitter(m_emitter); // this grabs the emitter
m_emitter->drop(); // so we can drop it now
scene::IParticleFadeOutAffector *fade_af =
m_node->createFadeOutParticleAffector(video::SColor(0, 255, 0, 0), 500);
m_node->addAffector(fade_af);
fade_af->drop();
scene::IParticleGravityAffector *gaf =
m_node->createGravityAffector();
m_node->addAffector(gaf);
gaf->drop();
} // KartParticleSystem
//-----------------------------------------------------------------------------
/** Destructor, removes
*/
WaterSplash::~WaterSplash()
{
irr_driver->removeNode(m_node);
} // ~WaterSplash
//-----------------------------------------------------------------------------
void WaterSplash::update(float t)
{
// No particles to emit, no need to change the speed
if(m_emitter->getMinParticlesPerSecond()==0)
return;
// Cycle through all four wheels
static int left=1;
static int rear=1;
left = 1-left;
if(left==0) rear = 1-rear;
const btWheelInfo &wi = m_kart->getVehicle()->getWheelInfo(rear*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));
} // update
//-----------------------------------------------------------------------------
void WaterSplash::setCreationRate(float f)
{
m_emitter->setMinParticlesPerSecond(int(f));
m_emitter->setMaxParticlesPerSecond(int(f));
} // setCreationRate

View File

@@ -1,53 +0,0 @@
// $Id$
//
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2009 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_WATER_SPLASH_HPP
#define HEADER_WATER_SPLASH_HPP
#include "utils/no_copy.hpp"
#include "irrlicht.h"
using namespace irr;
class Kart;
/**
* \brief Handles a water-splash particle effect
* \ingroup graphics
*/
class WaterSplash : 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;
public:
WaterSplash (Kart* kart);
virtual ~WaterSplash();
virtual void update (float t);
void setCreationRate(float f);
}; // WaterSplash
#endif

View File

@@ -46,7 +46,6 @@
952A154B103F66D600B1895D /* moving_texture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 952A1539103F66D600B1895D /* moving_texture.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 */; };
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 */; };
953789820FC7831400DD1F8E /* quad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 953789810FC7831400DD1F8E /* quad.cpp */; };
@@ -440,8 +439,6 @@
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; };
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; };
952A1553103F68D000B1895D /* profile_world.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = profile_world.hpp; path = ../../modes/profile_world.hpp; sourceTree = SOURCE_ROOT; };
953789710FC7829100DD1F8E /* graph_node.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = graph_node.hpp; path = ../../tracks/graph_node.hpp; sourceTree = SOURCE_ROOT; };
@@ -1384,8 +1381,6 @@
95DFC5011106933B00A043A9 /* slip_stream.hpp */,
95C9C97010E93456005A418D /* stars.cpp */,
95C9C97110E93456005A418D /* stars.hpp */,
952A1543103F66D600B1895D /* water_splash.cpp */,
952A1544103F66D600B1895D /* water_splash.hpp */,
);
name = graphics;
path = ../../graphics;
@@ -2795,7 +2790,6 @@
952A154B103F66D600B1895D /* moving_texture.cpp in Sources */,
952A154D103F66D600B1895D /* shadow.cpp in Sources */,
952A154E103F66D600B1895D /* skid_marks.cpp in Sources */,
952A1550103F66D600B1895D /* water_splash.cpp in Sources */,
952A1554103F68D000B1895D /* profile_world.cpp in Sources */,
9524739610497C75000C197E /* dynamic_ribbon_widget.cpp in Sources */,
9551DB34104CABFC001C53E5 /* race_over_dialog.cpp in Sources */,

View File

@@ -37,7 +37,6 @@
#include "graphics/shadow.hpp"
#include "graphics/skid_marks.hpp"
#include "graphics/slip_stream.hpp"
#include "graphics/water_splash.hpp"
#include "modes/world.hpp"
#include "io/file_manager.hpp"
#include "items/item_manager.hpp"
@@ -1012,13 +1011,26 @@ void Kart::handleMaterialGFX()
surface_material->getParticlesWhen(Material::EMIT_ON_DRIVE);
if(pk && !m_flying)
{
const float distance = xyz.distance2(from);
m_terrain_particles->setParticleType(pk);
m_terrain_particles->setPosition(xyz.toIrrVector());
const float speed = fabsf(getSpeed());
float rate = (speed>=0.5f) ? speed/m_kart_properties->getMaxSpeed()
: 0;
//const float speed = fabsf(getSpeed());
//float rate = (speed>=0.5f) ? speed/m_kart_properties->getMaxSpeed()
// : 0;
float create = pk->getMinRate()*(1-rate) + pk->getMaxRate()*rate;
float create;
if (distance < 2.0f)
{
create = pk->getMaxRate();
}
else if (distance < 4.0f)
{
create = pk->getMinRate() + (pk->getMaxRate() - pk->getMinRate())*(distance - 2.0f)/2.0f;
}
else
{
create = 0.0f;
}
m_terrain_particles->setCreationRate(create);
}
//if (m_camera != NULL) m_camera->setFallMode(true);

View File

@@ -47,7 +47,6 @@ class Shadow;
class SFXBase;
class SkidMarks;
class SlipStream;
class WaterSplash;
class ParticleEmitter;
class Rain;