Bromeon
Particles/Emitter.hpp
Go to the documentation of this file.
00001 
00002 //
00003 // Thor C++ Library
00004 // Copyright (c) 2011 Jan Haller
00005 // 
00006 // This software is provided 'as-is', without any express or implied
00007 // warranty. In no event will the authors be held liable for any damages
00008 // arising from the use of this software.
00009 // 
00010 // Permission is granted to anyone to use this software for any purpose,
00011 // including commercial applications, and to alter it and redistribute it
00012 // freely, subject to the following restrictions:
00013 // 
00014 // 1. The origin of this software must not be misrepresented; you must not
00015 //    claim that you wrote the original software. If you use this software
00016 //    in a product, an acknowledgment in the product documentation would be
00017 //    appreciated but is not required.
00018 // 
00019 // 2. Altered source versions must be plainly marked as such, and must not be
00020 //    misrepresented as being the original software.
00021 // 
00022 // 3. This notice may not be removed or altered from any source distribution.
00023 //
00025 
00028 
00029 #ifndef THOR_EMITTER_HPP
00030 #define THOR_EMITTER_HPP
00031 
00032 #include <Thor/Particles/ParticleInterfaces.hpp>
00033 #include <Thor/Particles/Particle.hpp>
00034 #include <Thor/Vectors/PolarVector.hpp>
00035 #include <Thor/Geometry/Zone.hpp>
00036 #include <Thor/Config.hpp>
00037 
00038 #include <SFML/System/Vector2.hpp>
00039 #include <SFML/Graphics/Color.hpp>
00040 
00041 
00042 namespace thor
00043 {
00044 
00047 
00050 class THOR_API DirectionalEmitter : public Emitter
00051 {
00052     // ---------------------------------------------------------------------------------------------------------------------------
00053     // Public types
00054     public:
00057         typedef std::tr1::shared_ptr<DirectionalEmitter> Ptr;
00058 
00059         
00060     // ---------------------------------------------------------------------------------------------------------------------------
00061     // Public static member functions
00062     public:
00065         static Ptr                  Create(float particlesPerSecond, float particleLifetime);
00066 
00067         
00068     // ---------------------------------------------------------------------------------------------------------------------------
00069     // Public member functions
00070     public:
00075                                     DirectionalEmitter(float particlesPerSecond, float particleLifetime);
00076 
00077         virtual void                Emit(Adder& system, float dt);
00078         
00081         void                        SetParticleVelocity(sf::Vector2f velocity);
00082 
00085         sf::Vector2f                GetParticleVelocity() const;
00086 
00090         void                        SetEmissionAngle(float emissionAngle);
00091 
00095         float                       GetEmissionAngle() const;
00096 
00097 
00098     // ---------------------------------------------------------------------------------------------------------------------------
00099     // Private variables
00100     private:
00101         float                       mEmissionAngle;
00102         sf::Vector2f                mParticleVelocity;
00103 };
00104 
00105 
00108 class THOR_API TargetEmitter : public Emitter
00109 {
00110     // ---------------------------------------------------------------------------------------------------------------------------
00111     // Public types
00112     public:
00115         typedef std::tr1::shared_ptr<TargetEmitter> Ptr;
00116 
00117 
00118     // ---------------------------------------------------------------------------------------------------------------------------
00119     // Public static member functions
00120     public:
00123         static Ptr                  Create(float particlesPerSecond, float particleLifetime);
00124 
00125         
00126     // ---------------------------------------------------------------------------------------------------------------------------
00127     // Public member functions
00128     public:
00133                                     TargetEmitter(float particlesPerSecond, float particleLifetime);
00134 
00135         virtual void                Emit(Adder& system, float dt);
00136 
00140         void                        SetTargetZone(MovedPtr<Zone> zone);
00141 
00144         Zone&                       GetTargetZone();
00145 
00148         const Zone&                 GetTargetZone() const;
00149 
00153         void                        SetParticleSpeed(float speed);
00154 
00158         float                       GetParticleSpeed() const;
00159 
00160 
00161     // ---------------------------------------------------------------------------------------------------------------------------
00162     // Private variables
00163     private:
00164         CopiedPtr<Zone, VirtualClone> mTargetZone;
00165         float                       mParticleSpeed;
00166 };
00167 
00169 
00170 } // namespace thor
00171 
00172 #endif // THOR_EMITTER_HPP