RigsofRods
Soft-body Physics Simulation
OgreShaderParticleRenderer.h
Go to the documentation of this file.
1 #pragma once
2 #ifndef __OGRE_SHADER_PARTICLE_RENDERER_H__
3 #define __OGRE_SHADER_PARTICLE_RENDERER_H__
4 
5 
6 #include <OgreParticleSystemRenderer.h>
7 #include <OgreVector2.h>
8 
9 namespace Ogre {
10 
13 
16 
24  class ShaderParticleRenderer : public ParticleSystemRenderer, public Renderable
25  {
26  protected:
28  MaterialPtr mMaterial;
29  VertexData* mVertexData;
30  IndexData* mIndexData;
32 
50  size_t mVertexSize;
51  Vector2 mTexCoordTable[4];
52 
55  Node* mParentNode;
56  SortMode mSortMode;
57  mutable LightList mLightList;
58  mutable ulong mLightListUpdated;
59  Real mRadius;
62 
63  public:
65  virtual ~ShaderParticleRenderer();
66 
70  class _OgrePrivate CmdVertexFormatColour : public ParamCommand
71  {
72  public:
73  String doGet(const void* target) const;
74  void doSet(void* target, const String& val);
75  };
76 
78  class _OgrePrivate CmdVertexFormatTexture : public ParamCommand
79  {
80  public:
81  String doGet(const void* target) const;
82  void doSet(void* target, const String& val);
83  };
84 
86  class _OgrePrivate CmdVertexFormatSize : public ParamCommand
87  {
88  public:
89  String doGet(const void* target) const;
90  void doSet(void* target, const String& val);
91  };
92 
94  class _OgrePrivate CmdVertexFormatRotation : public ParamCommand
95  {
96  public:
97  String doGet(const void* target) const;
98  void doSet(void* target, const String& val);
99  };
100 
102  class _OgrePrivate CmdVertexFormatRotationSpeed : public ParamCommand
103  {
104  public:
105  String doGet(const void* target) const;
106  void doSet(void* target, const String& val);
107  };
108 
110  class _OgrePrivate CmdVertexFormatDirection : public ParamCommand
111  {
112  public:
113  String doGet(const void* target) const;
114  void doSet(void* target, const String& val);
115  };
116 
118  class _OgrePrivate CmdVertexFormatTTL : public ParamCommand
119  {
120  public:
121  String doGet(const void* target) const;
122  void doSet(void* target, const String& val);
123  };
124 
126  class _OgrePrivate CmdVertexFormatTotalTTL : public ParamCommand
127  {
128  public:
129  String doGet(const void* target) const;
130  void doSet(void* target, const String& val);
131  };
132 
134  class _OgrePrivate CmdVertexFormatTimeFrag : public ParamCommand
135  {
136  public:
137  String doGet(const void* target) const;
138  void doSet(void* target, const String& val);
139  };
140 
142  class _OgrePrivate CmdVertexFormatTimeFragInv : public ParamCommand
143  {
144  public:
145  String doGet(const void* target) const;
146  void doSet(void* target, const String& val);
147  };
148 
150  // getters / setters
151  void setVertexFormatColour(bool bUse) { mVertexFormatColour = bUse; }
153 
154  void setVertexFormatTexture(bool bUse) { mVertexFormatTexture = bUse; }
156 
157  void setVertexFormatSize(bool bUse) { mVertexFormatSize = bUse; }
158  bool getVertexFormatSize() const { return mVertexFormatSize; }
159 
160  void setVertexFormatRotation(bool bUse) { mVertexFormatRotation = bUse; }
162 
165 
168 
169  void setVertexFormatTTL(bool bUse) { mVertexFormatTTL = bUse; }
170  bool getVertexFormatTTL() const { return mVertexFormatTTL; }
171 
172  void setVertexFormatTotalTTL(bool bUse) { mVertexFormatTotalTTL = bUse; }
174 
177 
180 
184  virtual const String& getType(void) const override;
185  virtual void _updateRenderQueue(RenderQueue* queue, Ogre::list<Particle*>::type& currentParticles, bool cullIndividually) override;
186  virtual void visitRenderables(Renderable::Visitor* visitor, bool debugRenderables = false) override;
187  virtual void _setMaterial(MaterialPtr& mat) override;
188  virtual void _notifyCurrentCamera(Camera* cam) override;
189  virtual void _notifyParticleRotated(void) override;
190  virtual void _notifyParticleResized(void) override;
191  virtual void _notifyParticleQuota(size_t quota) override;
192  virtual void _notifyAttached(Node* parent, bool isTagPoint = false) override;
193  virtual void _notifyDefaultDimensions(Real width, Real height) override;
194  virtual ParticleVisualData* _createVisualData(void) override;
195  virtual void _destroyVisualData(ParticleVisualData* vis) override;
196  virtual void setRenderQueueGroup(uint8 queueID) override;
197  virtual void setKeepParticlesInLocalSpace(bool keepLocal) override;
198  virtual SortMode _getSortMode(void) const override;
200 
204  virtual const MaterialPtr& getMaterial(void) const override;
205  virtual void getRenderOperation(RenderOperation& op) override;
206  virtual void getWorldTransforms(Matrix4* xform) const override;
207  virtual Real getSquaredViewDepth(const Camera* cam) const override;
208  virtual const LightList& getLights(void) const override;
210 
211  private:
212  const String rendererTypeName = "shader";
213 
215  bool allocateBuffers(size_t iNumParticles);
216 
218  void addParticle(uint8* pDataVB, const Particle& particle) const;
219  void setRenderQueueGroupAndPriority(Ogre::uint8,Ogre::ushort);
220  protected:
231  };
232 
234  class ShaderParticleRendererFactory : public ParticleSystemRendererFactory
235  {
236  public:
237  const String& getType() const override;
238  ParticleSystemRenderer* createInstance( const String& name ) override;
239  void destroyInstance( ParticleSystemRenderer* inst) override;
240  private:
241  const String rendererTypeName = "shader";
242  };
243 
246 
247 } // namespace Ogre
248 
249 #endif // __OGRE_SHADER_PARTICLE_RENDERER_H__
Ogre::ShaderParticleRenderer::getLights
virtual const LightList & getLights(void) const override
Definition: OgreShaderParticleRenderer.cpp:298
Ogre::ShaderParticleRenderer::mVertexSize
size_t mVertexSize
Definition: OgreShaderParticleRenderer.h:50
Ogre::ShaderParticleRenderer::mRadius
Real mRadius
maximum distance between particles and parent node
Definition: OgreShaderParticleRenderer.h:59
Ogre::ShaderParticleRenderer::setVertexFormatTotalTTL
void setVertexFormatTotalTTL(bool bUse)
Definition: OgreShaderParticleRenderer.h:172
Ogre::ShaderParticleRenderer::msVertexFmtTimeFrag
static CmdVertexFormatTimeFrag msVertexFmtTimeFrag
Definition: OgreShaderParticleRenderer.h:229
Ogre::ShaderParticleRenderer::mVertexFormatSize
bool mVertexFormatSize
particle size (width and height - float2)
Definition: OgreShaderParticleRenderer.h:42
Ogre::ShaderParticleRenderer::mParentNode
Node * mParentNode
parent node for particle system - used for world transformation
Definition: OgreShaderParticleRenderer.h:55
Ogre::ShaderParticleRenderer::_notifyAttached
virtual void _notifyAttached(Node *parent, bool isTagPoint=false) override
Definition: OgreShaderParticleRenderer.cpp:201
Ogre::ShaderParticleRenderer::CmdVertexFormatColour
Command objects for defining vertex format (see ParamCommand).
Definition: OgreShaderParticleRenderer.h:70
Ogre::ShaderParticleRenderer::getVertexFormatTotalTTL
bool getVertexFormatTotalTTL() const
Definition: OgreShaderParticleRenderer.h:173
Ogre::ShaderParticleRenderer::mDefaultParticleSize
Vector2 mDefaultParticleSize
other informations
Definition: OgreShaderParticleRenderer.h:54
Ogre::ShaderParticleRenderer::mTexCoordTable
Vector2 mTexCoordTable[4]
default texture coordinates
Definition: OgreShaderParticleRenderer.h:51
Ogre::ShaderParticleRenderer::msVertexFmtTotalTTL
static CmdVertexFormatTotalTTL msVertexFmtTotalTTL
Definition: OgreShaderParticleRenderer.h:228
Ogre::ShaderParticleRenderer::_notifyParticleResized
virtual void _notifyParticleResized(void) override
Definition: OgreShaderParticleRenderer.cpp:189
Ogre::ShaderParticleRenderer::setVertexFormatTimeFragment
void setVertexFormatTimeFragment(bool bUse)
Definition: OgreShaderParticleRenderer.h:175
Ogre::ShaderParticleRenderer::mKeepInLocalSpace
bool mKeepInLocalSpace
control transformation matrix for particles
Definition: OgreShaderParticleRenderer.h:61
Ogre::ShaderParticleRenderer::_notifyCurrentCamera
virtual void _notifyCurrentCamera(Camera *cam) override
Definition: OgreShaderParticleRenderer.cpp:178
Ogre::ShaderParticleRendererFactory::destroyInstance
void destroyInstance(ParticleSystemRenderer *inst) override
Definition: OgreShaderParticleRenderer.cpp:583
Ogre::ShaderParticleRenderer::setVertexFormatTimeFragmentInv
void setVertexFormatTimeFragmentInv(bool bUse)
Definition: OgreShaderParticleRenderer.h:178
Ogre::ShaderParticleRenderer::msVertexFmtRotation
static CmdVertexFormatRotation msVertexFmtRotation
Definition: OgreShaderParticleRenderer.h:224
Ogre::ShaderParticleRenderer::mMaterial
MaterialPtr mMaterial
rendering data
Definition: OgreShaderParticleRenderer.h:28
Ogre::ShaderParticleRenderer::_notifyParticleQuota
virtual void _notifyParticleQuota(size_t quota) override
Definition: OgreShaderParticleRenderer.cpp:195
Ogre::ShaderParticleRenderer::getWorldTransforms
virtual void getWorldTransforms(Matrix4 *xform) const override
Definition: OgreShaderParticleRenderer.cpp:275
Ogre::ShaderParticleRenderer::getVertexFormatSize
bool getVertexFormatSize() const
Definition: OgreShaderParticleRenderer.h:158
Ogre::ShaderParticleRenderer::getSquaredViewDepth
virtual Real getSquaredViewDepth(const Camera *cam) const override
Definition: OgreShaderParticleRenderer.cpp:288
Ogre::ShaderParticleRenderer::msVertexFmtColour
static CmdVertexFormatColour msVertexFmtColour
Definition: OgreShaderParticleRenderer.h:221
Ogre::ShaderParticleRenderer::CmdVertexFormatTimeFragInv
1.0f - TTL / total_TTL
Definition: OgreShaderParticleRenderer.h:142
Ogre::ShaderParticleRenderer::CmdVertexFormatDirection
direction
Definition: OgreShaderParticleRenderer.h:110
Ogre::ShaderParticleRenderer::mVertexFormatRotationSpeed
bool mVertexFormatRotationSpeed
particle rotation speed (radians/s - float1)
Definition: OgreShaderParticleRenderer.h:44
Ogre::ShaderParticleRenderer::_getSortMode
virtual SortMode _getSortMode(void) const override
Definition: OgreShaderParticleRenderer.cpp:239
Ogre::ShaderParticleRenderer::_updateRenderQueue
virtual void _updateRenderQueue(RenderQueue *queue, Ogre::list< Particle * >::type &currentParticles, bool cullIndividually) override
Definition: OgreShaderParticleRenderer.cpp:132
Ogre::ShaderParticleRenderer::getVertexFormatTexture
bool getVertexFormatTexture() const
Definition: OgreShaderParticleRenderer.h:155
Ogre::ShaderParticleRenderer::~ShaderParticleRenderer
virtual ~ShaderParticleRenderer()
Definition: OgreShaderParticleRenderer.cpp:119
Ogre::ShaderParticleRenderer::getRenderOperation
virtual void getRenderOperation(RenderOperation &op) override
Definition: OgreShaderParticleRenderer.cpp:251
Ogre::ShaderParticleRenderer::setVertexFormatRotationSpeed
void setVertexFormatRotationSpeed(bool bUse)
Definition: OgreShaderParticleRenderer.h:163
Ogre::ShaderParticleRenderer::_createVisualData
virtual ParticleVisualData * _createVisualData(void) override
Definition: OgreShaderParticleRenderer.cpp:215
Ogre::ShaderParticleRenderer::mParentIsTagPoint
bool mParentIsTagPoint
true if parent node is tag point
Definition: OgreShaderParticleRenderer.h:60
Ogre::ShaderParticleRenderer::getMaterial
virtual const MaterialPtr & getMaterial(void) const override
Definition: OgreShaderParticleRenderer.cpp:245
Ogre::ShaderParticleRendererFactory
Factory class for ShaderParticleRenderer.
Definition: OgreShaderParticleRenderer.h:234
Ogre::ShaderParticleRenderer::mVertexData
VertexData * mVertexData
Definition: OgreShaderParticleRenderer.h:29
Ogre::ShaderParticleRenderer::mLightList
LightList mLightList
light list for renderable
Definition: OgreShaderParticleRenderer.h:57
Ogre::ShaderParticleRenderer::ShaderParticleRenderer
ShaderParticleRenderer()
Definition: OgreShaderParticleRenderer.cpp:27
Ogre::ShaderParticleRenderer::setRenderQueueGroup
virtual void setRenderQueueGroup(uint8 queueID) override
Definition: OgreShaderParticleRenderer.cpp:227
Ogre::ShaderParticleRenderer::getVertexFormatTimeFragmentInv
bool getVertexFormatTimeFragmentInv() const
Definition: OgreShaderParticleRenderer.h:179
Ogre::ShaderParticleRenderer::msVertexFmtDirection
static CmdVertexFormatDirection msVertexFmtDirection
Definition: OgreShaderParticleRenderer.h:226
Ogre::ShaderParticleRenderer::setVertexFormatTTL
void setVertexFormatTTL(bool bUse)
Definition: OgreShaderParticleRenderer.h:169
Ogre::ShaderParticleRenderer::allocateBuffers
bool allocateBuffers(size_t iNumParticles)
allocate hardware buffers and prepare them for filling particles
Definition: OgreShaderParticleRenderer.cpp:334
Ogre::ShaderParticleRenderer::CmdVertexFormatTotalTTL
total time-to-live
Definition: OgreShaderParticleRenderer.h:126
Ogre::ShaderParticleRenderer
Specialisation of ParticleSystemRenderer to render particles using a custom shaders.
Definition: OgreShaderParticleRenderer.h:24
Ogre::ShaderParticleRenderer::mVertexFormatTotalTTL
bool mVertexFormatTotalTTL
particle total ttl (float1)
Definition: OgreShaderParticleRenderer.h:47
Ogre::ShaderParticleRenderer::getVertexFormatTimeFragment
bool getVertexFormatTimeFragment() const
Definition: OgreShaderParticleRenderer.h:176
Ogre::ShaderParticleRenderer::getVertexFormatDirection
bool getVertexFormatDirection() const
Definition: OgreShaderParticleRenderer.h:167
Ogre::ShaderParticleRenderer::getVertexFormatRotationSpeed
bool getVertexFormatRotationSpeed() const
Definition: OgreShaderParticleRenderer.h:164
Ogre::ShaderParticleRenderer::_notifyParticleRotated
virtual void _notifyParticleRotated(void) override
Definition: OgreShaderParticleRenderer.cpp:183
Ogre::ShaderParticleRenderer::mVertexFormatRotation
bool mVertexFormatRotation
particle rotation (radians - float1)
Definition: OgreShaderParticleRenderer.h:43
Ogre::ShaderParticleRenderer::getType
virtual const String & getType(void) const override
Definition: OgreShaderParticleRenderer.cpp:126
Ogre::ShaderParticleRenderer::mVertexFormatTexture
bool mVertexFormatTexture
true if particles use texture (float2)
Definition: OgreShaderParticleRenderer.h:41
Ogre::ShaderParticleRenderer::msVertexFmtTimeFragInv
static CmdVertexFormatTimeFragInv msVertexFmtTimeFragInv
Definition: OgreShaderParticleRenderer.h:230
Ogre::ShaderParticleRenderer::setRenderQueueGroupAndPriority
void setRenderQueueGroupAndPriority(Ogre::uint8, Ogre::ushort)
Definition: OgreShaderParticleRenderer.cpp:601
Ogre::ShaderParticleRendererFactory::createInstance
ParticleSystemRenderer * createInstance(const String &name) override
Definition: OgreShaderParticleRenderer.cpp:577
Ogre::ShaderParticleRenderer::mVertexFormatTTL
bool mVertexFormatTTL
particle ttl (float1)
Definition: OgreShaderParticleRenderer.h:46
Ogre::ShaderParticleRenderer::CmdVertexFormatSize
particle size
Definition: OgreShaderParticleRenderer.h:86
Ogre::ShaderParticleRenderer::setVertexFormatTexture
void setVertexFormatTexture(bool bUse)
Definition: OgreShaderParticleRenderer.h:154
Ogre::ShaderParticleRenderer::getVertexFormatRotation
bool getVertexFormatRotation() const
Definition: OgreShaderParticleRenderer.h:161
Ogre::ShaderParticleRenderer::_destroyVisualData
virtual void _destroyVisualData(ParticleVisualData *vis) override
Definition: OgreShaderParticleRenderer.cpp:221
Ogre::ShaderParticleRenderer::CmdVertexFormatTimeFrag
TTL / total_TTL.
Definition: OgreShaderParticleRenderer.h:134
Ogre::ShaderParticleRenderer::setVertexFormatSize
void setVertexFormatSize(bool bUse)
Definition: OgreShaderParticleRenderer.h:157
Ogre::ShaderParticleRenderer::getVertexFormatTTL
bool getVertexFormatTTL() const
Definition: OgreShaderParticleRenderer.h:170
Ogre::ShaderParticleRenderer::mSortMode
SortMode mSortMode
particle sorting
Definition: OgreShaderParticleRenderer.h:56
Ogre::ShaderParticleRenderer::addParticle
void addParticle(uint8 *pDataVB, const Particle &particle) const
add particle to vertex buffer
Definition: OgreShaderParticleRenderer.cpp:433
Ogre::ShaderParticleRenderer::setVertexFormatDirection
void setVertexFormatDirection(bool bUse)
Definition: OgreShaderParticleRenderer.h:166
Ogre::ShaderParticleRenderer::setVertexFormatColour
void setVertexFormatColour(bool bUse)
Definition: OgreShaderParticleRenderer.h:151
Ogre::ShaderParticleRenderer::_notifyDefaultDimensions
virtual void _notifyDefaultDimensions(Real width, Real height) override
Definition: OgreShaderParticleRenderer.cpp:208
Ogre::ShaderParticleRenderer::mVertexFormatDirection
bool mVertexFormatDirection
particle direction (float3)
Definition: OgreShaderParticleRenderer.h:45
Ogre::ShaderParticleRenderer::msVertexFmtSize
static CmdVertexFormatSize msVertexFmtSize
Definition: OgreShaderParticleRenderer.h:223
Ogre::ShaderParticleRenderer::mRenderQueueID
uint8 mRenderQueueID
Definition: OgreShaderParticleRenderer.h:31
Ogre::ShaderParticleRendererFactory::rendererTypeName
const String rendererTypeName
Definition: OgreShaderParticleRenderer.h:241
Ogre::ShaderParticleRenderer::msVertexFmtTexture
static CmdVertexFormatTexture msVertexFmtTexture
Definition: OgreShaderParticleRenderer.h:222
Ogre::ShaderParticleRenderer::msVertexFmtTTL
static CmdVertexFormatTTL msVertexFmtTTL
Definition: OgreShaderParticleRenderer.h:227
Ogre
Definition: ExtinguishableFireAffector.cpp:35
Ogre::ShaderParticleRenderer::mVertexFormatTimeFragmentInv
bool mVertexFormatTimeFragmentInv
particle inverse time fragment (1.0f - ttl / total ttl) (float1) (value 0.0f - 1.0f)
Definition: OgreShaderParticleRenderer.h:49
Ogre::ShaderParticleRenderer::CmdVertexFormatRotation
rotation
Definition: OgreShaderParticleRenderer.h:94
Ogre::ShaderParticleRenderer::rendererTypeName
const String rendererTypeName
Definition: OgreShaderParticleRenderer.h:212
Ogre::ShaderParticleRenderer::CmdVertexFormatTexture
general texture coord
Definition: OgreShaderParticleRenderer.h:78
Ogre::ShaderParticleRenderer::CmdVertexFormatTTL
time-to-live
Definition: OgreShaderParticleRenderer.h:118
Ogre::ShaderParticleRenderer::mIndexData
IndexData * mIndexData
Definition: OgreShaderParticleRenderer.h:30
Ogre::ShaderParticleRenderer::visitRenderables
virtual void visitRenderables(Renderable::Visitor *visitor, bool debugRenderables=false) override
Definition: OgreShaderParticleRenderer.cpp:166
Ogre::ShaderParticleRendererFactory::getType
const String & getType() const override
Definition: OgreShaderParticleRenderer.cpp:571
Ogre::ShaderParticleRenderer::setVertexFormatRotation
void setVertexFormatRotation(bool bUse)
Definition: OgreShaderParticleRenderer.h:160
Ogre::ShaderParticleRenderer::_setMaterial
virtual void _setMaterial(MaterialPtr &mat) override
Definition: OgreShaderParticleRenderer.cpp:172
Ogre::ShaderParticleRenderer::mLightListUpdated
ulong mLightListUpdated
indicator if we need update light list
Definition: OgreShaderParticleRenderer.h:58
Ogre::ShaderParticleRenderer::msVertexFmtRotationSpeed
static CmdVertexFormatRotationSpeed msVertexFmtRotationSpeed
Definition: OgreShaderParticleRenderer.h:225
Ogre::ShaderParticleRenderer::mVertexFormatTimeFragment
bool mVertexFormatTimeFragment
particle time fragment (ttl / total ttl) (float1) (value 0.0f - 1.0f)
Definition: OgreShaderParticleRenderer.h:48
Ogre::ShaderParticleRenderer::getVertexFormatColour
bool getVertexFormatColour() const
Definition: OgreShaderParticleRenderer.h:152
Ogre::ShaderParticleRenderer::setKeepParticlesInLocalSpace
virtual void setKeepParticlesInLocalSpace(bool keepLocal) override
Definition: OgreShaderParticleRenderer.cpp:233
Ogre::ShaderParticleRenderer::CmdVertexFormatRotationSpeed
rotation speed (rad/s)
Definition: OgreShaderParticleRenderer.h:102
Ogre::ShaderParticleRenderer::mVertexFormatColour
bool mVertexFormatColour
vertex format for particles
Definition: OgreShaderParticleRenderer.h:40