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-2006 Torus Knot Software Ltd |
---|
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 | You may alternatively use this source under the terms of a specific version of |
---|
25 | the OGRE Unrestricted License provided you have obtained such a license from |
---|
26 | Torus Knot Software Ltd. |
---|
27 | ----------------------------------------------------------------------------- |
---|
28 | */ |
---|
29 | #ifndef __BillboardParticleRenderer_H__ |
---|
30 | #define __BillboardParticleRenderer_H__ |
---|
31 | |
---|
32 | #include "OgrePrerequisites.h" |
---|
33 | #include "OgreParticleSystemRenderer.h" |
---|
34 | #include "OgreBillboardSet.h" |
---|
35 | |
---|
36 | namespace Ogre { |
---|
37 | |
---|
38 | /** Specialisation of ParticleSystemRenderer to render particles using |
---|
39 | a BillboardSet. |
---|
40 | @remarks |
---|
41 | This renderer has a few more options than the standard particle system, |
---|
42 | which will be passed to it automatically when the particle system itself |
---|
43 | does not understand them. |
---|
44 | */ |
---|
45 | class _OgreExport BillboardParticleRenderer : public ParticleSystemRenderer |
---|
46 | { |
---|
47 | protected: |
---|
48 | /// The billboard set that's doing the rendering |
---|
49 | BillboardSet* mBillboardSet; |
---|
50 | public: |
---|
51 | BillboardParticleRenderer(); |
---|
52 | ~BillboardParticleRenderer(); |
---|
53 | |
---|
54 | /** Command object for billboard type (see ParamCommand).*/ |
---|
55 | class _OgrePrivate CmdBillboardType : public ParamCommand |
---|
56 | { |
---|
57 | public: |
---|
58 | String doGet(const void* target) const; |
---|
59 | void doSet(void* target, const String& val); |
---|
60 | }; |
---|
61 | /** Command object for billboard origin (see ParamCommand).*/ |
---|
62 | class _OgrePrivate CmdBillboardOrigin : public ParamCommand |
---|
63 | { |
---|
64 | public: |
---|
65 | String doGet(const void* target) const; |
---|
66 | void doSet(void* target, const String& val); |
---|
67 | }; |
---|
68 | /** Command object for billboard rotation type (see ParamCommand).*/ |
---|
69 | class _OgrePrivate CmdBillboardRotationType : public ParamCommand |
---|
70 | { |
---|
71 | public: |
---|
72 | String doGet(const void* target) const; |
---|
73 | void doSet(void* target, const String& val); |
---|
74 | }; |
---|
75 | /** Command object for common direction (see ParamCommand).*/ |
---|
76 | class _OgrePrivate CmdCommonDirection : public ParamCommand |
---|
77 | { |
---|
78 | public: |
---|
79 | String doGet(const void* target) const; |
---|
80 | void doSet(void* target, const String& val); |
---|
81 | }; |
---|
82 | /** Command object for common up-vector (see ParamCommand).*/ |
---|
83 | class _OgrePrivate CmdCommonUpVector : public ParamCommand |
---|
84 | { |
---|
85 | public: |
---|
86 | String doGet(const void* target) const; |
---|
87 | void doSet(void* target, const String& val); |
---|
88 | }; |
---|
89 | /** Command object for point rendering (see ParamCommand).*/ |
---|
90 | class _OgrePrivate CmdPointRendering : public ParamCommand |
---|
91 | { |
---|
92 | public: |
---|
93 | String doGet(const void* target) const; |
---|
94 | void doSet(void* target, const String& val); |
---|
95 | }; |
---|
96 | /** Command object for accurate facing(see ParamCommand).*/ |
---|
97 | class _OgrePrivate CmdAccurateFacing : public ParamCommand |
---|
98 | { |
---|
99 | public: |
---|
100 | String doGet(const void* target) const; |
---|
101 | void doSet(void* target, const String& val); |
---|
102 | }; |
---|
103 | |
---|
104 | /** Sets the type of billboard to render. |
---|
105 | @remarks |
---|
106 | The default sort of billboard (BBT_POINT), always has both x and y axes parallel to |
---|
107 | the camera's local axes. This is fine for 'point' style billboards (e.g. flares, |
---|
108 | smoke, anything which is symmetrical about a central point) but does not look good for |
---|
109 | billboards which have an orientation (e.g. an elongated raindrop). In this case, the |
---|
110 | oriented billboards are more suitable (BBT_ORIENTED_COMMON or BBT_ORIENTED_SELF) since they retain an independant Y axis |
---|
111 | and only the X axis is generated, perpendicular to both the local Y and the camera Z. |
---|
112 | @param bbt The type of billboard to render |
---|
113 | */ |
---|
114 | void setBillboardType(BillboardType bbt); |
---|
115 | |
---|
116 | /** Returns the billboard type in use. */ |
---|
117 | BillboardType getBillboardType(void) const; |
---|
118 | |
---|
119 | /// @copydoc BillboardSet::setUseAccurateFacing |
---|
120 | void setUseAccurateFacing(bool acc); |
---|
121 | /// @copydoc BillboardSet::getUseAccurateFacing |
---|
122 | bool getUseAccurateFacing(void) const; |
---|
123 | |
---|
124 | /** Sets the point which acts as the origin point for all billboards in this set. |
---|
125 | @remarks |
---|
126 | This setting controls the fine tuning of where a billboard appears in relation to it's |
---|
127 | position. It could be that a billboard's position represents it's center (e.g. for fireballs), |
---|
128 | it could mean the center of the bottom edge (e.g. a tree which is positioned on the ground), |
---|
129 | the top-left corner (e.g. a cursor). |
---|
130 | @par |
---|
131 | The default setting is BBO_CENTER. |
---|
132 | @param |
---|
133 | origin A member of the BillboardOrigin enum specifying the origin for all the billboards in this set. |
---|
134 | */ |
---|
135 | void setBillboardOrigin(BillboardOrigin origin) { mBillboardSet->setBillboardOrigin(origin); } |
---|
136 | |
---|
137 | /** Gets the point which acts as the origin point for all billboards in this set. |
---|
138 | @returns |
---|
139 | A member of the BillboardOrigin enum specifying the origin for all the billboards in this set. |
---|
140 | */ |
---|
141 | BillboardOrigin getBillboardOrigin(void) const { return mBillboardSet->getBillboardOrigin(); } |
---|
142 | |
---|
143 | /** Sets billboard rotation type. |
---|
144 | @remarks |
---|
145 | This setting controls the billboard rotation type, you can deciding rotate the billboard's vertices |
---|
146 | around their facing direction or rotate the billboard's texture coordinates. |
---|
147 | @par |
---|
148 | The default settings is BBR_TEXCOORD. |
---|
149 | @param |
---|
150 | rotationType A member of the BillboardRotationType enum specifying the rotation type for all the billboards in this set. |
---|
151 | */ |
---|
152 | void setBillboardRotationType(BillboardRotationType rotationType); |
---|
153 | |
---|
154 | /** Sets billboard rotation type. |
---|
155 | @returns |
---|
156 | A member of the BillboardRotationType enum specifying the rotation type for all the billboards in this set. |
---|
157 | */ |
---|
158 | BillboardRotationType getBillboardRotationType(void) const; |
---|
159 | |
---|
160 | /** Use this to specify the common direction given to billboards of type BBT_ORIENTED_COMMON. |
---|
161 | @remarks |
---|
162 | Use BBT_ORIENTED_COMMON when you want oriented billboards but you know they are always going to |
---|
163 | be oriented the same way (e.g. rain in calm weather). It is faster for the system to calculate |
---|
164 | the billboard vertices if they have a common direction. |
---|
165 | @param vec The direction for all billboards. |
---|
166 | */ |
---|
167 | void setCommonDirection(const Vector3& vec); |
---|
168 | |
---|
169 | /** Gets the common direction for all billboards (BBT_ORIENTED_COMMON) */ |
---|
170 | const Vector3& getCommonDirection(void) const; |
---|
171 | |
---|
172 | /** Use this to specify the common up-vector given to billboards of type BBT_PERPENDICULAR_SELF. |
---|
173 | @remarks |
---|
174 | Use BBT_PERPENDICULAR_SELF when you want oriented billboards perpendicular to their own |
---|
175 | direction vector and doesn't face to camera. In this case, we need an additional vector |
---|
176 | to determine the billboard X, Y axis. The generated X axis perpendicular to both the own |
---|
177 | direction and up-vector, the Y axis will coplanar with both own direction and up-vector, |
---|
178 | and perpendicular to own direction. |
---|
179 | @param vec The up-vector for all billboards. |
---|
180 | */ |
---|
181 | void setCommonUpVector(const Vector3& vec); |
---|
182 | |
---|
183 | /** Gets the common up-vector for all billboards (BBT_PERPENDICULAR_SELF) */ |
---|
184 | const Vector3& getCommonUpVector(void) const; |
---|
185 | |
---|
186 | /// @copydoc BillboardSet::setPointRenderingEnabled |
---|
187 | void setPointRenderingEnabled(bool enabled); |
---|
188 | |
---|
189 | /// @copydoc BillboardSet::isPointRenderingEnabled |
---|
190 | bool isPointRenderingEnabled(void) const; |
---|
191 | |
---|
192 | |
---|
193 | |
---|
194 | /// @copydoc ParticleSystemRenderer::getType |
---|
195 | const String& getType(void) const; |
---|
196 | /// @copydoc ParticleSystemRenderer::_updateRenderQueue |
---|
197 | void _updateRenderQueue(RenderQueue* queue, |
---|
198 | std::list<Particle*>& currentParticles, bool cullIndividually); |
---|
199 | /// @copydoc ParticleSystemRenderer::_setMaterial |
---|
200 | void _setMaterial(MaterialPtr& mat); |
---|
201 | /// @copydoc ParticleSystemRenderer::_notifyCurrentCamera |
---|
202 | void _notifyCurrentCamera(Camera* cam); |
---|
203 | /// @copydoc ParticleSystemRenderer::_notifyParticleRotated |
---|
204 | void _notifyParticleRotated(void); |
---|
205 | /// @copydoc ParticleSystemRenderer::_notifyParticleResized |
---|
206 | void _notifyParticleResized(void); |
---|
207 | /// @copydoc ParticleSystemRenderer::_notifyParticleQuota |
---|
208 | void _notifyParticleQuota(size_t quota); |
---|
209 | /// @copydoc ParticleSystemRenderer::_notifyAttached |
---|
210 | void _notifyAttached(Node* parent, bool isTagPoint = false); |
---|
211 | /// @copydoc ParticleSystemRenderer::_notifyDefaultDimensions |
---|
212 | void _notifyDefaultDimensions(Real width, Real height); |
---|
213 | /// @copydoc ParticleSystemRenderer::setRenderQueueGroup |
---|
214 | void setRenderQueueGroup(uint8 queueID); |
---|
215 | /// @copydoc ParticleSystemRenderer::setKeepParticlesInLocalSpace |
---|
216 | void setKeepParticlesInLocalSpace(bool keepLocal); |
---|
217 | /// @copydoc ParticleSystemRenderer::_getSortMode |
---|
218 | SortMode _getSortMode(void) const; |
---|
219 | |
---|
220 | /// Access BillboardSet in use |
---|
221 | BillboardSet* getBillboardSet(void) const { return mBillboardSet; } |
---|
222 | |
---|
223 | protected: |
---|
224 | static CmdBillboardType msBillboardTypeCmd; |
---|
225 | static CmdBillboardOrigin msBillboardOriginCmd; |
---|
226 | static CmdBillboardRotationType msBillboardRotationTypeCmd; |
---|
227 | static CmdCommonDirection msCommonDirectionCmd; |
---|
228 | static CmdCommonUpVector msCommonUpVectorCmd; |
---|
229 | static CmdPointRendering msPointRenderingCmd; |
---|
230 | static CmdAccurateFacing msAccurateFacingCmd; |
---|
231 | |
---|
232 | |
---|
233 | }; |
---|
234 | |
---|
235 | /** Factory class for BillboardParticleRenderer */ |
---|
236 | class _OgreExport BillboardParticleRendererFactory : public ParticleSystemRendererFactory |
---|
237 | { |
---|
238 | public: |
---|
239 | /// @copydoc FactoryObj::getType |
---|
240 | const String& getType() const; |
---|
241 | /// @copydoc FactoryObj::createInstance |
---|
242 | ParticleSystemRenderer* createInstance( const String& name ); |
---|
243 | /// @copydoc FactoryObj::destroyInstance |
---|
244 | void destroyInstance( ParticleSystemRenderer* inst); |
---|
245 | }; |
---|
246 | |
---|
247 | } |
---|
248 | |
---|
249 | #endif |
---|
250 | |
---|