Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/OgreMain/include/OgreParticle.h @ 5

Last change on this file since 5 was 5, checked in by anonymous, 17 years ago

=hoffentlich gehts jetzt

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