Cloned original smoke code by hiker to create nitro particles so I can
test and tweak images if needed. xml was wrong but no obvious output in console so missing png was a real headache to figure. Tweaked drifting power loss (0.75 -> 0.5) and default brake power (100 -> 20). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3589 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
87d02728cf
commit
f964dc5723
@ -19,85 +19,65 @@
|
||||
|
||||
#include "graphics/nitro.hpp"
|
||||
|
||||
#include "material_manager.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)
|
||||
: ParticleSystem(200, 0.0f, true, 0.5f),
|
||||
m_kart(kart)
|
||||
#include <cstdio>
|
||||
|
||||
Nitro::Nitro(Kart* kart) : m_kart(kart)
|
||||
{
|
||||
#ifndef HAVE_IRRLICHT
|
||||
|
||||
#ifdef DEBUG
|
||||
setName("nitro");
|
||||
#endif
|
||||
bsphere.setCenter(0, 0, 0);
|
||||
bsphere.setRadius(1000.0f);
|
||||
dirtyBSphere();
|
||||
const float particle_size = 0.5f;
|
||||
m_node = irr_driver->addParticleNode();
|
||||
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_nitro_fire = new ssgSimpleState ();
|
||||
#ifndef HAVE_IRRLICHT
|
||||
m_nitro_fire->setTexture(material_manager->getMaterial("nitro-particle.rgb")->getState()->getTexture());
|
||||
#endif
|
||||
m_nitro_fire -> setTranslucent () ;
|
||||
m_nitro_fire -> enable ( GL_TEXTURE_2D ) ;
|
||||
m_nitro_fire -> setShadeModel ( GL_SMOOTH ) ;
|
||||
m_nitro_fire -> disable ( GL_CULL_FACE ) ;
|
||||
m_nitro_fire -> enable ( GL_BLEND ) ;
|
||||
m_nitro_fire -> disable ( GL_ALPHA_TEST ) ;
|
||||
m_nitro_fire -> enable ( GL_LIGHTING ) ;
|
||||
m_nitro_fire -> setColourMaterial ( GL_EMISSION ) ;
|
||||
m_nitro_fire -> setMaterial ( GL_AMBIENT, 0, 0, 0, 1 ) ;
|
||||
m_nitro_fire -> setMaterial ( GL_DIFFUSE, 0, 0, 0, 1 ) ;
|
||||
m_nitro_fire -> setMaterial ( GL_SPECULAR, 0, 0, 0, 1 ) ;
|
||||
m_nitro_fire -> setShininess ( 0 ) ;
|
||||
m_nitro_fire->ref();
|
||||
m_emitter = m_node->createPointEmitter(core::vector3df(0, 0, 0), // velocity in m/ms
|
||||
5, 10,
|
||||
video::SColor(255,0,0,0),
|
||||
video::SColor(255,255,255,255),
|
||||
400, 400,
|
||||
20 // max angle
|
||||
);
|
||||
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
|
||||
|
||||
setState(m_nitro_fire);
|
||||
#endif
|
||||
scene::IParticleAffector *af = m_node->createFadeOutParticleAffector();
|
||||
m_node->addAffector(af);
|
||||
af->drop();
|
||||
} // KartParticleSystem
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
Nitro::~Nitro()
|
||||
{
|
||||
//ssgDeRefDelete(m_nitro_fire);
|
||||
irr_driver->removeNode(m_node);
|
||||
} // ~Nitro
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Nitro::update(float t)
|
||||
{
|
||||
ParticleSystem::update(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.003f,
|
||||
sin(DEGREE_TO_RAD(rand()%180))*0.003f,
|
||||
sin(DEGREE_TO_RAD(rand()%100))*0.003f);
|
||||
m_emitter->setDirection(dir.toIrrVector());
|
||||
} // update
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Nitro::particle_create(int, Particle *p)
|
||||
void Nitro::setCreationRate(float f)
|
||||
{
|
||||
#ifndef HAVE_IRRLICHT
|
||||
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 = 1.0f;
|
||||
p->m_time_to_live = 0.8f;
|
||||
|
||||
Vec3 xyz = m_kart->getXYZ();
|
||||
const Vec3 vel = -m_kart->getVelocity()*0.2f;
|
||||
sgCopyVec3(p->m_vel, vel.toFloat());
|
||||
sgCopyVec3(p->m_pos, xyz.toFloat());
|
||||
p->m_vel[0] += 2*cos(DEGREE_TO_RAD(rand()% 180));
|
||||
p->m_vel[1] += 2*sin(DEGREE_TO_RAD(rand()% 180));
|
||||
p->m_vel[2] = 0;
|
||||
#endif
|
||||
} // particle_create
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Nitro::particle_update(float delta, int,
|
||||
Particle * particle)
|
||||
{
|
||||
#ifndef HAVE_IRRLICHT
|
||||
particle->m_size -= delta*.2f;
|
||||
particle->m_col[3] -= delta * 2.0f;
|
||||
#endif
|
||||
} // particle_update
|
||||
|
||||
m_emitter->setMinParticlesPerSecond(int(f));
|
||||
m_emitter->setMaxParticlesPerSecond(int(f));
|
||||
} // setCreationRate
|
||||
|
||||
|
@ -20,24 +20,26 @@
|
||||
#ifndef HEADER_NITRO_HPP
|
||||
#define HEADER_NITRO_HPP
|
||||
|
||||
#include "particle_system.hpp"
|
||||
#include "irrlicht.h"
|
||||
using namespace irr;
|
||||
|
||||
class Kart;
|
||||
|
||||
class Nitro: public ParticleSystem
|
||||
class Nitro
|
||||
{
|
||||
private:
|
||||
/** The kart to which this smoke belongs. */
|
||||
Kart *m_kart;
|
||||
/** The texture to use. */
|
||||
//ssgSimpleState *m_nitro_fire;
|
||||
|
||||
/** 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);
|
||||
~Nitro ();
|
||||
virtual void update (float t );
|
||||
virtual void particle_create(int index, Particle* p );
|
||||
virtual void particle_update(float deltaTime, int index, Particle *p );
|
||||
virtual void update (float t);
|
||||
void setCreationRate(float f);
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -243,7 +243,7 @@ Kart::~Kart()
|
||||
sfx_manager->deleteSFX(m_goo_sound );
|
||||
|
||||
if(m_smoke_system) delete m_smoke_system;
|
||||
//if(m_nitro) ssgDeRefDelete(m_nitro);
|
||||
if(m_nitro) delete m_nitro;
|
||||
|
||||
m_animated_node->removeChild(m_shadow->getSceneNode());
|
||||
delete m_shadow;
|
||||
@ -783,7 +783,7 @@ void Kart::updatePhysics (float dt)
|
||||
engine_power *= m_power_reduction/stk_config->m_slowdown_factor;
|
||||
// Lose some traction when skidding, so it is not abused by player
|
||||
if(m_controls.m_drift)
|
||||
engine_power *= 0.75f;
|
||||
engine_power *= 0.5f;
|
||||
m_vehicle->applyEngineForce(engine_power, 2);
|
||||
m_vehicle->applyEngineForce(engine_power, 3);
|
||||
// Either all or no brake is set, so test only one to avoid
|
||||
@ -847,7 +847,7 @@ void Kart::updatePhysics (float dt)
|
||||
// If not giving power (forward or reverse gear), and speed is low
|
||||
// we are "parking" the kart, so in battle mode we can ambush people, eg
|
||||
if(abs(m_speed) < 5.0f) {
|
||||
for(int i=0; i<4; i++) m_vehicle->setBrake(100.0f, i);
|
||||
for(int i=0; i<4; i++) m_vehicle->setBrake(20.0f, i);
|
||||
}
|
||||
#else
|
||||
if(!RaceManager::getWorld()->isStartPhase())
|
||||
@ -1005,7 +1005,6 @@ void Kart::loadData()
|
||||
// Attach Particle System
|
||||
m_smoke_system = new Smoke(this);
|
||||
m_nitro = new Nitro(this);
|
||||
//m_nitro->ref();
|
||||
|
||||
if(m_kart_properties->hasSkidmarks())
|
||||
m_skidmarks = new SkidMarks(*this);
|
||||
|
Loading…
Reference in New Issue
Block a user