2008-04-15 09:57:18 -04:00
|
|
|
|
2008-06-20 10:53:00 -04:00
|
|
|
// $Id: dust_cloud.cpp 1681 2008-04-09 13:52:48Z hikerstk $
|
|
|
|
//
|
|
|
|
// SuperTuxKart - a fun racing game with go-kart
|
|
|
|
// Copyright (C) 2006 SuperTuxKart-Team
|
|
|
|
//
|
|
|
|
// 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.
|
2008-04-15 09:57:18 -04:00
|
|
|
|
|
|
|
#include "smoke.hpp"
|
2008-07-02 23:14:27 -04:00
|
|
|
#include "constants.hpp"
|
2008-11-30 23:17:17 -05:00
|
|
|
#include "material_manager.hpp"
|
2008-11-06 23:34:01 -05:00
|
|
|
#include "karts/kart.hpp"
|
2008-04-15 09:57:18 -04:00
|
|
|
|
2008-11-30 23:17:17 -05:00
|
|
|
Smoke::Smoke(Kart* kart)
|
|
|
|
: ParticleSystem(200, 0.0f, true, 0.75f),
|
|
|
|
m_kart(kart)
|
2008-06-20 10:53:00 -04:00
|
|
|
{
|
2008-11-30 23:17:17 -05:00
|
|
|
#ifdef DEBUG
|
|
|
|
setName("smoke");
|
|
|
|
#endif
|
|
|
|
bsphere.setCenter(0, 0, 0);
|
|
|
|
bsphere.setRadius(1000.0f);
|
2008-06-20 10:53:00 -04:00
|
|
|
dirtyBSphere();
|
2008-11-30 23:17:17 -05:00
|
|
|
|
|
|
|
m_smokepuff = new ssgSimpleState ();
|
|
|
|
m_smokepuff->setTexture(material_manager->getMaterial("smoke.rgb")->getState()->getTexture());
|
|
|
|
m_smokepuff -> setTranslucent () ;
|
|
|
|
m_smokepuff -> enable ( GL_TEXTURE_2D ) ;
|
|
|
|
m_smokepuff -> setShadeModel ( GL_SMOOTH ) ;
|
|
|
|
m_smokepuff -> disable ( GL_CULL_FACE ) ;
|
|
|
|
m_smokepuff -> enable ( GL_BLEND ) ;
|
|
|
|
m_smokepuff -> enable ( GL_LIGHTING ) ;
|
|
|
|
m_smokepuff -> setColourMaterial ( GL_EMISSION ) ;
|
|
|
|
m_smokepuff -> setMaterial ( GL_AMBIENT, 0, 0, 0, 1 ) ;
|
|
|
|
m_smokepuff -> setMaterial ( GL_DIFFUSE, 0, 0, 0, 1 ) ;
|
|
|
|
m_smokepuff -> setMaterial ( GL_SPECULAR, 0, 0, 0, 1 ) ;
|
|
|
|
m_smokepuff -> setShininess ( 0 ) ;
|
|
|
|
m_smokepuff->ref();
|
|
|
|
|
|
|
|
setState(m_smokepuff);
|
|
|
|
|
2008-06-20 10:53:00 -04:00
|
|
|
} // KartParticleSystem
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2008-11-30 23:17:17 -05:00
|
|
|
Smoke::~Smoke()
|
2008-06-20 10:53:00 -04:00
|
|
|
{
|
2008-11-30 23:17:17 -05:00
|
|
|
ssgDeRefDelete(m_smokepuff);
|
|
|
|
} // ~Smoke
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void Smoke::update(float t)
|
|
|
|
{
|
2008-06-20 10:53:00 -04:00
|
|
|
ParticleSystem::update(t);
|
|
|
|
} // update
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void Smoke::particle_create(int, Particle *p)
|
|
|
|
{
|
2008-11-30 23:17:17 -05:00
|
|
|
sgSetVec4(p->m_col, 1, 1, 1, 1 ); /* initially white */
|
|
|
|
sgSetVec3(p->m_vel, 0, 0, 0 );
|
|
|
|
sgSetVec3(p->m_acc, 0, 0, 2.0f ); /* Gravity */
|
|
|
|
p->m_size = 0.5f;
|
2008-12-07 20:07:16 -05:00
|
|
|
p->m_time_to_live = 0.4f;
|
2008-06-20 10:53:00 -04:00
|
|
|
|
2008-12-03 00:46:40 -05:00
|
|
|
// Change from left to right wheel and back for each new particle
|
|
|
|
static int wheel_number = 2;
|
|
|
|
wheel_number = 5 - wheel_number;
|
2008-11-30 23:17:17 -05:00
|
|
|
Vec3 xyz=m_kart->getVehicle()->getWheelInfo(wheel_number).m_raycastInfo.m_contactPointWS;
|
2008-06-20 10:53:00 -04:00
|
|
|
|
|
|
|
sgCopyVec3 (p->m_pos, xyz.toFloat());
|
2008-11-30 23:17:17 -05:00
|
|
|
p->m_vel[0] += cos(DEGREE_TO_RAD(rand()%180));
|
|
|
|
p->m_vel[1] += sin(DEGREE_TO_RAD(rand()%180));
|
|
|
|
p->m_vel[2] += sin(DEGREE_TO_RAD(rand()%100));
|
2008-06-20 10:53:00 -04:00
|
|
|
|
2008-11-30 23:17:17 -05:00
|
|
|
bsphere.setCenter ( xyz.getX(), xyz.getY(), xyz.getZ() ) ;
|
2008-06-20 10:53:00 -04:00
|
|
|
} // particle_create
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2008-11-30 23:17:17 -05:00
|
|
|
void Smoke::particle_update(float delta, int,
|
|
|
|
Particle * particle)
|
2008-06-20 10:53:00 -04:00
|
|
|
{
|
2008-11-30 23:17:17 -05:00
|
|
|
particle->m_size -= delta*.2f;
|
2008-06-20 10:53:00 -04:00
|
|
|
particle->m_col[3] -= delta * 2.0f;
|
|
|
|
} // particle_update
|
|
|
|
|