improved fire particles

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2557 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2008-12-02 23:55:48 +00:00
parent 61ecea6bbf
commit 49b6691474

View File

@ -1,40 +1,40 @@
// $Id: nitro.cpp 1681 2008-04-09 13:52:48Z hikerstk $ // $Id: nitro.cpp 1681 2008-04-09 13:52:48Z hikerstk $
// //
// SuperTuxKart - a fun racing game with go-kart // SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2008 Joerg Henrichs // Copyright (C) 2008 Joerg Henrichs
// //
// This program is free software; you can redistribute it and/or // This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License // modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3 // as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version. // of the License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "graphics/nitro.hpp" #include "graphics/nitro.hpp"
#include "constants.hpp" #include "constants.hpp"
#include "material_manager.hpp" #include "material_manager.hpp"
#include "karts/kart.hpp" #include "karts/kart.hpp"
Nitro::Nitro(Kart* kart) Nitro::Nitro(Kart* kart)
: ParticleSystem(200, 0.0f, true, 0.5f), : ParticleSystem(200, 0.0f, true, 0.5f),
m_kart(kart) m_kart(kart)
{ {
#ifdef DEBUG #ifdef DEBUG
setName("nitro"); setName("nitro");
#endif #endif
bsphere.setCenter(0, 0, 0); bsphere.setCenter(0, 0, 0);
bsphere.setRadius(1000.0f); bsphere.setRadius(1000.0f);
dirtyBSphere(); dirtyBSphere();
m_nitro_fire = new ssgSimpleState (); m_nitro_fire = new ssgSimpleState ();
m_nitro_fire->setTexture(material_manager->getMaterial("flames.rgb")->getState()->getTexture()); m_nitro_fire->setTexture(material_manager->getMaterial("fireparticle.rgb")->getState()->getTexture());
m_nitro_fire -> setTranslucent () ; m_nitro_fire -> setTranslucent () ;
m_nitro_fire -> enable ( GL_TEXTURE_2D ) ; m_nitro_fire -> enable ( GL_TEXTURE_2D ) ;
m_nitro_fire -> setShadeModel ( GL_SMOOTH ) ; m_nitro_fire -> setShadeModel ( GL_SMOOTH ) ;
@ -47,47 +47,47 @@ Nitro::Nitro(Kart* kart)
m_nitro_fire -> setMaterial ( GL_SPECULAR, 0, 0, 0, 1 ) ; m_nitro_fire -> setMaterial ( GL_SPECULAR, 0, 0, 0, 1 ) ;
m_nitro_fire -> setShininess ( 0 ) ; m_nitro_fire -> setShininess ( 0 ) ;
m_nitro_fire->ref(); m_nitro_fire->ref();
setState(m_nitro_fire); setState(m_nitro_fire);
} // KartParticleSystem } // KartParticleSystem
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
Nitro::~Nitro() Nitro::~Nitro()
{ {
ssgDeRefDelete(m_nitro_fire); ssgDeRefDelete(m_nitro_fire);
} // ~Nitro } // ~Nitro
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void Nitro::update(float t) void Nitro::update(float t)
{ {
ParticleSystem::update(t); ParticleSystem::update(t);
} // update } // update
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void Nitro::particle_create(int, Particle *p) void Nitro::particle_create(int, Particle *p)
{ {
sgSetVec4(p->m_col, 1, 1, 1, 1 ); /* initially white */ sgSetVec4(p->m_col, 1, 1, 1, 1 ); /* initially white */
sgSetVec3(p->m_vel, 0, 0, 0 ); sgSetVec3(p->m_vel, 0, 0, 0 );
sgSetVec3(p->m_acc, 0, 0, 2.0f ); /* Gravity */ sgSetVec3(p->m_acc, 0, 0, 2.0f ); /* Gravity */
p->m_size = 0.5f; p->m_size = 0.5f;
p->m_time_to_live = 0.8f; p->m_time_to_live = 0.8f;
Vec3 xyz = m_kart->getXYZ(); Vec3 xyz = m_kart->getXYZ();
const Vec3 vel = -m_kart->getVelocity()*0.2f; const Vec3 vel = -m_kart->getVelocity()*0.2f;
sgCopyVec3(p->m_vel, vel.toFloat()); sgCopyVec3(p->m_vel, vel.toFloat());
sgCopyVec3(p->m_pos, xyz.toFloat()); sgCopyVec3(p->m_pos, xyz.toFloat());
p->m_vel[0] += cos(DEGREE_TO_RAD(rand()% 10)); p->m_vel[0] += cos(DEGREE_TO_RAD(rand()% 10));
p->m_vel[1] += sin(DEGREE_TO_RAD(rand()% 80)); p->m_vel[1] += sin(DEGREE_TO_RAD(rand()% 80));
p->m_vel[2] = 0; p->m_vel[2] = 0;
} // particle_create } // particle_create
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void Nitro::particle_update(float delta, int, void Nitro::particle_update(float delta, int,
Particle * particle) Particle * particle)
{ {
particle->m_size -= delta*.2f; particle->m_size -= delta*.2f;
particle->m_col[3] -= delta * 2.0f; particle->m_col[3] -= delta * 2.0f;
} // particle_update } // particle_update