Bromeon
Particles/Emitter.hpp
Go to the documentation of this file.
00001 
00002 //
00003 // Thor C++ Library
00004 // Copyright (c) 2011-2012 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/Time.hpp>
00039 #include <SFML/System/Vector2.hpp>
00040 #include <SFML/Graphics/Color.hpp>
00041 
00042 
00043 namespace thor
00044 {
00045 
00048 
00051 class THOR_API DirectionalEmitter : public Emitter
00052 {
00053     // ---------------------------------------------------------------------------------------------------------------------------
00054     // Public types
00055     public:
00058         typedef std::tr1::shared_ptr<DirectionalEmitter> Ptr;
00059 
00060         
00061     // ---------------------------------------------------------------------------------------------------------------------------
00062     // Public static member functions
00063     public:
00066         static Ptr                  Create(float particlesPerSecond, sf::Time particleLifetime);
00067 
00068         
00069     // ---------------------------------------------------------------------------------------------------------------------------
00070     // Public member functions
00071     public:
00076                                     DirectionalEmitter(float particlesPerSecond, sf::Time particleLifetime);
00077 
00078         virtual void                Emit(Adder& system, sf::Time dt);
00079         
00082         void                        SetParticleVelocity(sf::Vector2f velocity);
00083 
00086         sf::Vector2f                GetParticleVelocity() const;
00087 
00091         void                        SetEmissionAngle(float emissionAngle);
00092 
00096         float                       GetEmissionAngle() const;
00097 
00098 
00099     // ---------------------------------------------------------------------------------------------------------------------------
00100     // Private variables
00101     private:
00102         float                       mEmissionAngle;
00103         sf::Vector2f                mParticleVelocity;
00104 };
00105 
00106 
00109 class THOR_API TargetEmitter : public Emitter
00110 {
00111     // ---------------------------------------------------------------------------------------------------------------------------
00112     // Public types
00113     public:
00116         typedef std::tr1::shared_ptr<TargetEmitter> Ptr;
00117 
00118 
00119     // ---------------------------------------------------------------------------------------------------------------------------
00120     // Public static member functions
00121     public:
00124         static Ptr                  Create(float particlesPerSecond, sf::Time particleLifetime);
00125 
00126         
00127     // ---------------------------------------------------------------------------------------------------------------------------
00128     // Public member functions
00129     public:
00134                                     TargetEmitter(float particlesPerSecond, sf::Time particleLifetime);
00135 
00136         virtual void                Emit(Adder& system, sf::Time dt);
00137 
00141         void                        SetTargetZone(Emitter::ZonePtr zone);
00142 
00145         Zone&                       GetTargetZone();
00146 
00149         const Zone&                 GetTargetZone() const;
00150 
00154         void                        SetParticleSpeed(float speed);
00155 
00159         float                       GetParticleSpeed() const;
00160 
00161 
00162     // ---------------------------------------------------------------------------------------------------------------------------
00163     // Private variables
00164     private:
00165         CopiedPtr<Zone, VirtualClone> mTargetZone;
00166         float                       mParticleSpeed;
00167 };
00168 
00170 
00171 } // namespace thor
00172 
00173 #endif // THOR_EMITTER_HPP