1 /* 2 ----------------------------------------------------------------------------- 3 This source file is part of OGRE 4 (Object-oriented Graphics Rendering Engine) 5 For the latest info, see http://www.ogre3d.org/ 6 7 Copyright (c) 2000-2014 Torus Knot Software Ltd 8 9 Permission is hereby granted, free of charge, to any person obtaining a copy 10 of this software and associated documentation files (the "Software"), to deal 11 in the Software without restriction, including without limitation the rights 12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 copies of the Software, and to permit persons to whom the Software is 14 furnished to do so, subject to the following conditions: 15 16 The above copyright notice and this permission notice shall be included in 17 all copies or substantial portions of the Software. 18 19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 THE SOFTWARE. 26 ----------------------------------------------------------------------------- 27 */ 28 #ifndef __AreaEmitter_H__ 29 #define __AreaEmitter_H__ 30 31 #include "OgreParticleFXPrerequisites.h" 32 #include "OgreParticleEmitter.h" 33 34 namespace Ogre { 35 36 /** \addtogroup Plugins Plugins 37 * @{ 38 */ 39 /** \defgroup ParticleFX ParticleFX 40 * Particle Effects (Emmiters, Affectors) 41 * @{ 42 */ 43 44 /** Particle emitter which emits particles randomly from points inside 45 an area (box, sphere, ellipsoid whatever subclasses choose to be). 46 @remarks 47 This is an empty superclass and needs to be subclassed. Basic particle 48 emitter emits particles from/in an (unspecified) area. The 49 initial direction of these particles can either be a single direction 50 (i.e. a line), a random scattering inside a cone, or a random 51 scattering in all directions, depending the 'angle' parameter, which 52 is the angle across which to scatter the particles either side of the 53 base direction of the emitter. 54 */ 55 class _OgreParticleFXExport AreaEmitter : public ParticleEmitter 56 { 57 public: 58 /** Command object for area emitter size (see ParamCommand).*/ 59 class CmdWidth : public ParamCommand 60 { 61 public: 62 String doGet(const void* target) const; 63 void doSet(void* target, const String& val); 64 }; 65 /** Command object for area emitter size (see ParamCommand).*/ 66 class CmdHeight : public ParamCommand 67 { 68 public: 69 String doGet(const void* target) const; 70 void doSet(void* target, const String& val); 71 }; 72 /** Command object for area emitter size (see ParamCommand).*/ 73 class CmdDepth : public ParamCommand 74 { 75 public: 76 String doGet(const void* target) const; 77 void doSet(void* target, const String& val); 78 }; 79 80 AreaEmitter(ParticleSystem * psys)81 AreaEmitter(ParticleSystem* psys) : ParticleEmitter(psys) {} 82 83 84 /** See ParticleEmitter. */ 85 unsigned short _getEmissionCount(Real timeElapsed); 86 87 /** Overloaded to update the trans. matrix */ 88 void setDirection( const Vector3& direction ); 89 90 /** Sets the size of the area from which particles are emitted. 91 @param 92 size Vector describing the size of the area. The area extends 93 around the center point by half the x, y and z components of 94 this vector. The box is aligned such that it's local Z axis points 95 along it's direction (see setDirection) 96 */ 97 void setSize(const Vector3& size); 98 99 /** Sets the size of the area from which particles are emitted. 100 @param x,y,z 101 Individual axis lengths describing the size of the area. The area 102 extends around the center point by half the x, y and z components 103 of this vector. The box is aligned such that it's local Z axis 104 points along it's direction (see setDirection) 105 */ 106 void setSize(Real x, Real y, Real z); 107 108 /** Sets the width (local x size) of the emitter. */ 109 void setWidth(Real width); 110 /** Gets the width (local x size) of the emitter. */ 111 Real getWidth(void) const; 112 /** Sets the height (local y size) of the emitter. */ 113 void setHeight(Real Height); 114 /** Gets the height (local y size) of the emitter. */ 115 Real getHeight(void) const; 116 /** Sets the depth (local y size) of the emitter. */ 117 void setDepth(Real Depth); 118 /** Gets the depth (local y size) of the emitter. */ 119 Real getDepth(void) const; 120 121 protected: 122 /// Size of the area 123 Vector3 mSize; 124 125 /// Local axes, not normalised, their magnitude reflects area size 126 Vector3 mXRange, mYRange, mZRange; 127 128 /// Internal method for generating the area axes 129 void genAreaAxes(void); 130 /** Internal for initializing some defaults and parameters 131 @return True if custom parameters need initialising 132 */ 133 bool initDefaults(const String& mType); 134 135 /// Command objects 136 static CmdWidth msWidthCmd; 137 static CmdHeight msHeightCmd; 138 static CmdDepth msDepthCmd; 139 140 141 142 }; 143 /** @} */ 144 /** @} */ 145 } 146 147 #endif 148 149