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-2005 The OGRE Team
|
---|
8 | Also see acknowledgements in Readme.html
|
---|
9 |
|
---|
10 | This program is free software; you can redistribute it and/or modify it under
|
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
13 | version.
|
---|
14 |
|
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
18 |
|
---|
19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
23 | -----------------------------------------------------------------------------
|
---|
24 | */
|
---|
25 | #ifndef __Particle_H__
|
---|
26 | #define __Particle_H__
|
---|
27 |
|
---|
28 | #include "OgrePrerequisites.h"
|
---|
29 | #include "OgreBillboard.h"
|
---|
30 |
|
---|
31 | namespace Ogre {
|
---|
32 |
|
---|
33 | /** Abstract class containing any additional data required to be associated
|
---|
34 | with a particle to perform the required rendering.
|
---|
35 | @remarks
|
---|
36 | Because you can specialise the way that particles are renderered by supplying
|
---|
37 | custom ParticleSystemRenderer classes, you might well need some additional
|
---|
38 | data for your custom rendering routine which is not held on the default particle
|
---|
39 | class. If that's the case, then you should define a subclass of this class,
|
---|
40 | and construct it when asked in your custom ParticleSystemRenderer class.
|
---|
41 | */
|
---|
42 | class _OgreExport ParticleVisualData
|
---|
43 | {
|
---|
44 | public:
|
---|
45 | ParticleVisualData() {}
|
---|
46 | virtual ~ParticleVisualData() {}
|
---|
47 |
|
---|
48 | };
|
---|
49 |
|
---|
50 | /** Class representing a single particle instance. */
|
---|
51 | class _OgreExport Particle
|
---|
52 | {
|
---|
53 | protected:
|
---|
54 | /// Parent ParticleSystem
|
---|
55 | ParticleSystem* mParentSystem;
|
---|
56 | /// Additional visual data you might want to associate with the Particle
|
---|
57 | ParticleVisualData* mVisual;
|
---|
58 | public:
|
---|
59 | /// Does this particle have it's own dimensions?
|
---|
60 | bool mOwnDimensions;
|
---|
61 | /// Personal width if mOwnDimensions == true
|
---|
62 | Real mWidth;
|
---|
63 | /// Personal height if mOwnDimensions == true
|
---|
64 | Real mHeight;
|
---|
65 | /// Current rotation value
|
---|
66 | Radian rotation;
|
---|
67 | // Note the intentional public access to internal variables
|
---|
68 | // Accessing via get/set would be too costly for 000's of particles
|
---|
69 | /// World position
|
---|
70 | Vector3 position;
|
---|
71 | /// Direction (and speed)
|
---|
72 | Vector3 direction;
|
---|
73 | /// Current colour
|
---|
74 | ColourValue colour;
|
---|
75 | /// Time to live, number of seconds left of particles natural life
|
---|
76 | Real timeToLive;
|
---|
77 | /// Total Time to live, number of seconds of particles natural life
|
---|
78 | Real totalTimeToLive;
|
---|
79 | /// Speed of rotation in radians/sec
|
---|
80 | Radian rotationSpeed;
|
---|
81 |
|
---|
82 |
|
---|
83 | Particle()
|
---|
84 | : mParentSystem(0), mVisual(0), mOwnDimensions(false), rotation(0),
|
---|
85 | position(Vector3::ZERO), direction(Vector3::ZERO),
|
---|
86 | colour(ColourValue::White), timeToLive(10), totalTimeToLive(10),
|
---|
87 | rotationSpeed(0)
|
---|
88 | {
|
---|
89 | }
|
---|
90 |
|
---|
91 | /** Sets the width and height for this particle.
|
---|
92 | @remarks
|
---|
93 | Note that it is most efficient for every particle in a ParticleSystem to have the same dimensions. If you
|
---|
94 | choose to alter the dimensions of an individual particle the set will be less efficient. Do not call
|
---|
95 | this method unless you really need to have different particle dimensions within the same set. Otherwise
|
---|
96 | just call the ParticleSystem::setDefaultDimensions method instead.
|
---|
97 | */
|
---|
98 | void setDimensions(Real width, Real height);
|
---|
99 |
|
---|
100 | /** Returns true if this particle deviates from the ParticleSystem's default dimensions (i.e. if the
|
---|
101 | particle::setDimensions method has been called for this instance).
|
---|
102 | @see
|
---|
103 | particle::setDimensions
|
---|
104 | */
|
---|
105 | bool hasOwnDimensions(void) const { return mOwnDimensions; }
|
---|
106 |
|
---|
107 | /** Retrieves the particle's personal width, if hasOwnDimensions is true. */
|
---|
108 | Real getOwnWidth(void) const { return mWidth; }
|
---|
109 |
|
---|
110 | /** Retrieves the particle's personal width, if hasOwnDimensions is true. */
|
---|
111 | Real getOwnHeight(void) const { return mHeight; }
|
---|
112 |
|
---|
113 | /** Sets the current rotation */
|
---|
114 | void setRotation(const Radian& rad);
|
---|
115 |
|
---|
116 | const Radian& getRotation(void) const { return rotation; }
|
---|
117 |
|
---|
118 | /** Internal method for notifying the particle of it's owner.
|
---|
119 | */
|
---|
120 | void _notifyOwner(ParticleSystem* owner);
|
---|
121 |
|
---|
122 | /** Internal method for notifying the particle of it's optional visual data.
|
---|
123 | */
|
---|
124 | void _notifyVisualData(ParticleVisualData* vis) { mVisual = vis; }
|
---|
125 |
|
---|
126 | /// Get the optional visual data associated with the class
|
---|
127 | ParticleVisualData* getVisualData(void) const { return mVisual; }
|
---|
128 |
|
---|
129 | /// Utility method to reset this particle
|
---|
130 | void resetDimensions(void);
|
---|
131 |
|
---|
132 |
|
---|
133 | };
|
---|
134 | }
|
---|
135 |
|
---|
136 | #endif
|
---|
137 |
|
---|