/*****************************************************************************
 * $LastChangedDate: 2010-02-03 19:48:51 -0500 (Wed, 03 Feb 2010) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   Explosion particle-system (private implementation of FX class).
 *//*
 * LEGAL:   COPYRIGHT (C) 2008 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 *****************************************************************************/

#ifndef FX_PARTSYS_EXPLOSION_HH
#define FX_PARTSYS_EXPLOSION_HH 1

#include "fx/partsys_big.hh"

namespace fx {

////////////////////////////////////////////////////////////////////////////////
/// @brief Explosion particle.
///
class ExplosionParticle : public BigParticle
{
PREVENT_COPYING(ExplosionParticle)
public:
                    ExplosionParticle( const Sprite::Args& spriteArgs,
                                       const fp explosionRadius );
                    ~ExplosionParticle();
    virtual void    Tick( const Milliseconds millisecElapsed );

private:
    const fp        mExplosionRadius;   ///< radius of entire explosion
    WorldVertex     mStep;              ///< direction of particle's movement
    int             mFadeDec;           ///< decrements color (fade-out)
    int             mTickCount;         ///< used for sub-tick granularity
    fp              mSpinRadian;        ///< +/- roll
};

////////////////////////////////////////////////////////////////////////////////
/// @brief Explosion particle-system (private implementation of FX class).
///
/// Clients should use the interface FX::MakeExplosion().
/// Explosion class is private to FX (FX contains Explosion objects).
///
class ExplosionParticleSystem : public BigParticleSystem
{
PREVENT_COPYING(ExplosionParticleSystem)
typedef BigParticleSystem Parent;
friend class FX; friend class shptr<ExplosionParticleSystem>;
private:
                    ExplosionParticleSystem( const Milliseconds lifetime,
                                             const WorldVertex& position,
                                             const fp radius );
                    ~ExplosionParticleSystem();
    virtual void    Tick( const Milliseconds millisecElapsed );
    void            MakeParticles( const uint count );

private:
    const WorldVertex           mPosition;          ///< center of explosion
    const fp                    mRadius;            ///< radius of explosion
    const Milliseconds          mTimeOfDeath;       ///< time when particle system expires
    Milliseconds                mTimeOfPrevTick;    ///< previous tick
    const RefPtr<osg::StateSet> mStateSet;          ///< particles share one stateset
};

} // namespace fx

#endif // FX_PARTSYS_EXPLOSION_HH
