Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/ogre_src_v1-9-0/OgreMain/include/OgreParticle.h @ 148

Last change on this file since 148 was 148, checked in by patricwi, 6 years ago

Added new dependencies for ogre1.9 and cegui0.8

File size: 5.7 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-2013 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE SOFTWARE.
26-----------------------------------------------------------------------------
27*/
28#ifndef __Particle_H__
29#define __Particle_H__
30
31#include "OgrePrerequisites.h"
32#include "OgreBillboard.h"
33#include "OgreHeaderPrefix.h"
34
35namespace Ogre {
36
37        /** \addtogroup Core
38        *  @{
39        */
40        /** \addtogroup Effects
41        *  @{
42        */
43        /** Abstract class containing any additional data required to be associated
44                with a particle to perform the required rendering.
45        @remarks
46                Because you can specialise the way that particles are rendered by supplying
47                custom ParticleSystemRenderer classes, you might well need some additional
48                data for your custom rendering routine which is not held on the default particle
49                class. If that's the case, then you should define a subclass of this class,
50                and construct it when asked in your custom ParticleSystemRenderer class.
51        */
52        class _OgreExport ParticleVisualData : public FXAlloc
53        {
54        public:
55                ParticleVisualData() {}
56                virtual ~ParticleVisualData() {}
57
58        };
59
60        /** Class representing a single particle instance. */
61        class _OgreExport Particle : public FXAlloc
62    {
63    protected:
64        /// Parent ParticleSystem
65        ParticleSystem* mParentSystem;
66        /// Additional visual data you might want to associate with the Particle
67        ParticleVisualData* mVisual;
68    public:
69        /// Type of particle
70        enum ParticleType
71        {
72            Visual,
73            Emitter
74        };
75
76        /// Does this particle have it's own dimensions?
77        bool mOwnDimensions;
78        /// Personal width if mOwnDimensions == true
79        Real mWidth;
80        /// Personal height if mOwnDimensions == true
81        Real mHeight;
82        /// Current rotation value
83        Radian rotation;
84        // Note the intentional public access to internal variables
85        // Accessing via get/set would be too costly for 000's of particles
86        /// World position
87        Vector3 position;
88        /// Direction (and speed)
89        Vector3 direction;
90        /// Current colour
91        ColourValue colour;
92        /// Time to live, number of seconds left of particles natural life
93        Real timeToLive;
94        /// Total Time to live, number of seconds of particles natural life
95        Real totalTimeToLive;
96        /// Speed of rotation in radians/sec
97        Radian rotationSpeed;
98        /// Determines the type of particle.
99        ParticleType particleType;
100
101        Particle()
102            : mParentSystem(0), mVisual(0), mOwnDimensions(false), rotation(0), 
103            position(Vector3::ZERO), direction(Vector3::ZERO), 
104            colour(ColourValue::White), timeToLive(10), totalTimeToLive(10), 
105            rotationSpeed(0), particleType(Visual)
106        {
107        }
108
109        /** Sets the width and height for this particle.
110        @remarks
111        Note that it is most efficient for every particle in a ParticleSystem to have the same dimensions. If you
112        choose to alter the dimensions of an individual particle the set will be less efficient. Do not call
113        this method unless you really need to have different particle dimensions within the same set. Otherwise
114        just call the ParticleSystem::setDefaultDimensions method instead.
115        */
116        void setDimensions(Real width, Real height); 
117
118        /** Returns true if this particle deviates from the ParticleSystem's default dimensions (i.e. if the
119        particle::setDimensions method has been called for this instance).
120        @see
121        particle::setDimensions
122        */
123        bool hasOwnDimensions(void) const { return mOwnDimensions; }
124
125        /** Retrieves the particle's personal width, if hasOwnDimensions is true. */
126        Real getOwnWidth(void) const { return mWidth; }
127
128        /** Retrieves the particle's personal width, if hasOwnDimensions is true. */
129        Real getOwnHeight(void) const { return mHeight; }
130       
131        /** Sets the current rotation */
132        void setRotation(const Radian& rad);
133
134        const Radian& getRotation(void) const { return rotation; }
135
136        /** Internal method for notifying the particle of it's owner.
137        */
138        void _notifyOwner(ParticleSystem* owner);
139
140        /** Internal method for notifying the particle of it's optional visual data.
141        */
142                void _notifyVisualData(ParticleVisualData* vis) { mVisual = vis; }
143
144                /// Get the optional visual data associated with the class
145                ParticleVisualData* getVisualData(void) const { return mVisual; }
146
147        /// Utility method to reset this particle
148        void resetDimensions(void);
149    };
150        /** @} */
151        /** @} */
152}
153
154#include "OgreHeaderSuffix.h"
155
156#endif
157
Note: See TracBrowser for help on using the repository browser.