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