particle_effect.h

Go to the documentation of this file.
00001 
00002 //            Copyright (C) 2004-2007 by The Allacrost Project
00003 //                         All Rights Reserved
00004 //
00005 // This code is licensed under the GNU GPL version 2. It is free software 
00006 // and you may modify it and/or redistribute it under the terms of this license.
00007 // See http://www.gnu.org/copyleft/gpl.html for details.
00009 
00010 /*!****************************************************************************
00011  * \file    particle_effect.h
00012  * \author  Raj Sharma, roos@allacrost.org
00013  * \brief   Header file for particle effects
00014  *
00015  * Particle effects are basically nothing more than a collection of particle
00016  * systems. Many effects are just one system. However, for example, if you think
00017  * about a campfire effect, that might actually consist of fire + smoke + embers.
00018  * So, that's an example of an effect that consists of 3 systems.
00019  *
00020  * This file contains two classes: ParticleEffectDef, and ParticleEffect.
00021  *
00022  * ParticleEffectDef is a "definition" class, which holds a list of
00023  *    ParticleSystemDefs.
00024  *
00025  * ParticleEffect is an "instance" class, which holds a list of
00026  *    ParticleSystems.
00027  *
00028  *
00029  * This way, if you have 100 explosions, the properties of the
00030  * effect are stored only once in a ParticleEffectDef, and the only thing that 
00031  * gets repeated 100 times is the ParticleEffect, which holds instance-specific stuff.
00032  *****************************************************************************/
00033 
00034 #ifndef __PARTICLE_EFFECT_HEADER__
00035 #define __PARTICLE_EFFECT_HEADER__
00036 
00037 #include "defs.h"
00038 #include "utils.h"
00039 
00040 namespace hoa_video
00041 {
00042 
00043 using private_video::ParticleSystem;
00044 using private_video::ParticleSystemDef;
00045 
00046 /*!***************************************************************************
00047  *  \brief particle effect definition, just consists of each of its subsystems'
00048  *         definitions. This is basically just a struct, except it has a
00049  *         function to load the structure from a particle file (.lua/.hoa)
00050  *****************************************************************************/
00051 
00052 class ParticleEffectDef
00053 {
00054 public:
00055   
00057   std::list<ParticleSystemDef *> _systems;
00058 };
00059 
00060 
00061 /*!***************************************************************************
00062  *  \brief particle effect, basically one coherent "effect" like an explosion,
00063  *         or snow falling from the sky. Consists of one or more ParticleSystems.
00064  *         An example of using multiple systems to create one effect would be
00065  *         a campfire where you have fire + smoke + glowing embers.
00066  *****************************************************************************/
00067 
00068 class ParticleEffect
00069 {
00070 public:
00071 
00075   ParticleEffect();
00076   
00077 
00086   void Move(float x, float y);
00087   
00088 
00094   void MoveRelative(float dx, float dy);
00095   
00096 
00106   void SetOrientation(float angle);
00107   
00108   
00119   void SetAttractorPoint(float x, float y);
00120 
00121 
00128   bool IsAlive();
00129   
00130   
00139   void Stop(bool kill_immediate = false);
00140 
00141 
00146   int32 GetNumParticles() const;
00147   
00148 
00154   void  GetPosition(float &x, float &y) const;
00155 
00156 
00162   float GetAge() const;
00163 
00164 private:
00165 
00171   bool _Draw();
00172 
00173 
00180   bool _Update(float frame_time);
00181 
00182 
00187   void _Destroy();
00188   
00189   
00191   const ParticleEffectDef *_effect_def; 
00192   
00195   std::list <ParticleSystem *> _systems;
00196   
00198   float _x, _y;
00199 
00201   float _attractor_x, _attractor_y;
00202   
00204   float _orientation;
00205   
00207   bool  _alive;
00208   
00210   float _age; 
00211   
00213   int32 _num_particles;
00214   
00215   friend class private_video::ParticleManager;
00216   
00217 }; // class ParticleEffect
00218 
00219 }  // namespace hoa_video
00220 
00221 #endif  

Generated on Fri Jul 6 23:11:20 2007 for Hero of Allacrost by  doxygen 1.5.1