OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ripplesimulation.hpp
Go to the documentation of this file.
1 #ifndef OPENMW_MWRENDER_RIPPLESIMULATION_H
2 #define OPENMW_MWRENDER_RIPPLESIMULATION_H
3 
4 #include <osg/ref_ptr>
5 
6 #include "../mwworld/ptr.hpp"
7 
8 namespace osg
9 {
10  class Group;
11  class PositionAttitudeTransform;
12 }
13 
14 namespace osgParticle
15 {
16  class ParticleSystem;
17 }
18 
19 namespace Resource
20 {
21  class ResourceSystem;
22 }
23 
24 namespace Fallback
25 {
26  class Map;
27 }
28 
29 namespace MWRender
30 {
31 
32  struct Emitter
33  {
35  osg::Vec3f mLastEmitPosition;
36  float mScale;
37  float mForce;
38  };
39 
41  {
42  public:
43  RippleSimulation(osg::Group* parent, Resource::ResourceSystem* resourceSystem, const Fallback::Map* fallback);
45 
47  void update(float dt);
48 
50  void addEmitter (const MWWorld::ConstPtr& ptr, float scale = 1.f, float force = 1.f);
51  void removeEmitter (const MWWorld::ConstPtr& ptr);
52  void updateEmitterPtr (const MWWorld::ConstPtr& old, const MWWorld::ConstPtr& ptr);
53  void removeCell(const MWWorld::CellStore* store);
54 
55  void emitRipple(const osg::Vec3f& pos);
56 
58  void setWaterHeight(float height);
59 
61  void clear();
62 
63  private:
64  osg::ref_ptr<osg::Group> mParent;
65 
66  osg::ref_ptr<osgParticle::ParticleSystem> mParticleSystem;
67  osg::ref_ptr<osg::PositionAttitudeTransform> mParticleNode;
68 
69  std::vector<Emitter> mEmitters;
70  };
71 
72 }
73 
74 #endif
Wrapper class that constructs and provides access to the most commonly used resource subsystems...
Definition: resourcesystem.hpp:24
Definition: ripplesimulation.hpp:40
contains settings imported from the Morrowind INI file.
Definition: fallback.hpp:12
float mScale
Definition: ripplesimulation.hpp:36
void clear()
Remove all active ripples.
Definition: ripplesimulation.cpp:210
Definition: ripplesimulation.hpp:32
~RippleSimulation()
Definition: ripplesimulation.cpp:113
void updateEmitterPtr(const MWWorld::ConstPtr &old, const MWWorld::ConstPtr &ptr)
Definition: ripplesimulation.cpp:170
void emitRipple(const osg::Vec3f &pos)
Definition: ripplesimulation.cpp:195
osg::ref_ptr< osg::PositionAttitudeTransform > mParticleNode
Definition: ripplesimulation.hpp:67
osg::Vec3f mLastEmitPosition
Definition: ripplesimulation.hpp:35
void update(float dt)
Definition: ripplesimulation.cpp:118
Mutable state of a cell.
Definition: cellstore.hpp:53
RippleSimulation(osg::Group *parent, Resource::ResourceSystem *resourceSystem, const Fallback::Map *fallback)
Definition: ripplesimulation.cpp:84
void addEmitter(const MWWorld::ConstPtr &ptr, float scale=1.f, float force=1.f)
adds an emitter, position will be tracked automatically
Definition: ripplesimulation.cpp:148
Pointer to a const LiveCellRef.
Definition: ptr.hpp:90
osg::ref_ptr< osgParticle::ParticleSystem > mParticleSystem
Definition: ripplesimulation.hpp:66
osg::ref_ptr< osg::Group > mParent
Definition: ripplesimulation.hpp:64
float mForce
Definition: ripplesimulation.hpp:37
MWWorld::ConstPtr mPtr
Definition: ripplesimulation.hpp:34
void removeCell(const MWWorld::CellStore *store)
Definition: ripplesimulation.cpp:182
void setWaterHeight(float height)
Change the height of the water surface, thus moving all ripples with it.
Definition: ripplesimulation.cpp:205
std::vector< Emitter > mEmitters
Definition: ripplesimulation.hpp:69
void removeEmitter(const MWWorld::ConstPtr &ptr)
Definition: ripplesimulation.cpp:158