RigsofRods
Soft-body Physics Simulation
DecalsManager.h
Go to the documentation of this file.
1 /*
2 --------------------------------------------------------------------------------
3 This source file is part of Hydrax.
4 Visit ---
5 
6 Copyright (C) 2008 Xavier Verguín González <xavierverguin@hotmail.com>
7  <xavyiy@gmail.com>
8 
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU Lesser General Public License as published by the Free Software
11 Foundation; either version 2 of the License, or (at your option) any later
12 version.
13 
14 This program is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public License along with
19 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21 http://www.gnu.org/copyleft/lesser.txt.
22 --------------------------------------------------------------------------------
23 */
24 
25 #ifndef _Hydrax_DecalsManager_H_
26 #define _Hydrax_DecalsManager_H_
27 
28 #include "Prerequisites.h"
29 
32 
35 
36 namespace Hydrax
37 {
38  class Hydrax;
39 
42  class Decal
43  {
44  public:
50  Decal(Hydrax *h, const Ogre::String &TextureName, const int& Id);
51 
54  ~Decal();
55 
59  void registerPass(Ogre::Pass* _Pass);
60 
63  void unregister();
64 
68  inline const Ogre::String& getTextureName() const
69  {
70  return mTextureName;
71  }
72 
76  inline const int& getId() const
77  {
78  return mId;
79  }
80 
84  inline Ogre::Frustum* getProjector()
85  {
86  return mProjector;
87  }
88 
92  inline Ogre::SceneNode* getSceneNode()
93  {
94  return mSceneNode;
95  }
96 
101  inline Ogre::Pass *getRegisteredPass()
102  {
103  return mRegisteredPass;
104  }
105 
109  inline const Ogre::Vector2& getPosition() const
110  {
111  return mPosition;
112  }
113 
117  inline const Ogre::Vector2& getSize() const
118  {
119  return mSize;
120  }
121 
125  inline const Ogre::Radian& getOrientation() const
126  {
127  return mOrientation;
128  }
129 
133  inline const Ogre::Real& getTransparency() const
134  {
135  return mTransparency;
136  }
137 
141  inline const bool& isVisible() const
142  {
143  return mVisible;
144  }
145 
149  void setPosition(const Ogre::Vector2& Position);
150 
154  void setSize(const Ogre::Vector2& Size);
155 
159  void setOrientation(const Ogre::Radian& Orientation);
160 
165  void setTransparency(const Ogre::Real& Transparency);
166 
170  void setVisible(const bool& Visible);
171 
172  private:
174  Ogre::String mTextureName;
176  int mId;
178  Ogre::Frustum *mProjector;
180  Ogre::SceneNode *mSceneNode;
182  Ogre::Pass *mRegisteredPass;
183 
185  Ogre::Vector2 mPosition;
187  Ogre::Vector2 mSize;
189  Ogre::Radian mOrientation;
191  Ogre::Real mTransparency;
193  bool mVisible;
194 
197  };
198 
203  {
204  public:
208  DecalsManager(Hydrax *h);
209 
212  ~DecalsManager();
213 
217  void update();
218 
223  Decal* add(const Ogre::String& TextureName);
224 
229  Decal* get(const int& Id);
230 
234  void remove(const int& Id);
235 
238  void removeAll();
239 
243  void registerAll();
244 
248  inline std::vector<Decal*> getDecals()
249  {
250  return mDecals;
251  }
252 
256  inline const Ogre::Real _getWaterStrength() const
257  {
258  return mWaterStrength;
259  }
260 
264  inline void _setWaterStrength(const Ogre::Real &WaterStrength)
265  {
266  mWaterStrength = WaterStrength;
267  }
268 
271  inline void _forceToUpdate()
272  {
273  mForceToUpdate = true;
274  }
275 
276  private:
278  std::vector<Decal*> mDecals;
280  std::vector<Decal*>::iterator DecalIt;
282  int mNextId;
283 
285  Ogre::Real mWaterStrength;
286 
288  Ogre::Vector3 mLastPosition;
289  Ogre::Quaternion mLastOrientation;
292 
295  };
296 };
297 
300 
301 #endif
Hydrax::DecalsManager::update
void update()
Update decal manager.
Definition: DecalsManager.cpp:157
Hydrax::DecalsManager::DecalsManager
DecalsManager(Hydrax *h)
Constructor.
Definition: DecalsManager.cpp:138
Hydrax::DecalsManager::mLastPosition
Ogre::Vector3 mLastPosition
Last camera position, orientation, underwater.
Definition: DecalsManager.h:288
Hydrax::Decal::mTransparency
Ogre::Real mTransparency
Transparency.
Definition: DecalsManager.h:191
Hydrax::Decal::isVisible
const bool & isVisible() const
Is decal visile?
Definition: DecalsManager.h:141
Hydrax::Decal::getProjector
Ogre::Frustum * getProjector()
Get the decal projector.
Definition: DecalsManager.h:84
Hydrax::DecalsManager::mHydrax
Hydrax * mHydrax
Hydrax parent pointer.
Definition: DecalsManager.h:294
Hydrax
Definition: CfgFileManager.cpp:28
Hydrax::DecalsManager
Decals manager class.
Definition: DecalsManager.h:202
Hydrax::Decal::mTextureName
Ogre::String mTextureName
Decal texture name.
Definition: DecalsManager.h:174
Hydrax::DecalsManager::_setWaterStrength
void _setWaterStrength(const Ogre::Real &WaterStrength)
Set water strength (used for decals culling)
Definition: DecalsManager.h:264
Hydrax::Decal::getSceneNode
Ogre::SceneNode * getSceneNode()
Get the decal scene node.
Definition: DecalsManager.h:92
Hydrax::Size
Struct wich contains an especific width and height value.
Definition: Help.h:40
Hydrax::DecalsManager::mLastOrientation
Ogre::Quaternion mLastOrientation
Definition: DecalsManager.h:289
Hydrax::Decal::mSize
Ogre::Vector2 mSize
Size.
Definition: DecalsManager.h:187
Hydrax::DecalsManager::get
Decal * get(const int &Id)
Get decal.
Definition: DecalsManager.cpp:266
Hydrax::DecalsManager::_forceToUpdate
void _forceToUpdate()
Call to force to update decals.
Definition: DecalsManager.h:271
Hydrax::Decal::mPosition
Ogre::Vector2 mPosition
Position.
Definition: DecalsManager.h:185
Hydrax::Decal::mId
int mId
Decal Id.
Definition: DecalsManager.h:176
Hydrax::Decal::getPosition
const Ogre::Vector2 & getPosition() const
Get decal position.
Definition: DecalsManager.h:109
Hydrax::Decal::setTransparency
void setTransparency(const Ogre::Real &Transparency)
Set decal transparency.
Definition: DecalsManager.cpp:116
Hydrax::DecalsManager::~DecalsManager
~DecalsManager()
Destructor.
Definition: DecalsManager.cpp:147
Hydrax::Decal
Decal class.
Definition: DecalsManager.h:42
Hydrax::Decal::getTransparency
const Ogre::Real & getTransparency() const
Get decal transparency.
Definition: DecalsManager.h:133
Hydrax::Decal::setOrientation
void setOrientation(const Ogre::Radian &Orientation)
Set decal orientation.
Definition: DecalsManager.cpp:109
Hydrax::Decal::~Decal
~Decal()
Destructor.
Definition: DecalsManager.cpp:55
Hydrax::DecalsManager::removeAll
void removeAll()
Remove all decals.
Definition: DecalsManager.cpp:293
Hydrax::Decal::getOrientation
const Ogre::Radian & getOrientation() const
Get decal orientation.
Definition: DecalsManager.h:125
Hydrax::Decal::setVisible
void setVisible(const bool &Visible)
Set decal visibile or not.
Definition: DecalsManager.cpp:127
Hydrax::DecalsManager::mForceToUpdate
bool mForceToUpdate
Definition: DecalsManager.h:291
Hydrax::Decal::getTextureName
const Ogre::String & getTextureName() const
Get decal texture name.
Definition: DecalsManager.h:68
Hydrax::DecalsManager::_getWaterStrength
const Ogre::Real _getWaterStrength() const
Get water strength (used for decals culling)
Definition: DecalsManager.h:256
Hydrax::Decal::getSize
const Ogre::Vector2 & getSize() const
Get decal size.
Definition: DecalsManager.h:117
Hydrax::Decal::mProjector
Ogre::Frustum * mProjector
Decal projector.
Definition: DecalsManager.h:178
Hydrax::Decal::getRegisteredPass
Ogre::Pass * getRegisteredPass()
Get the pass the decal is in.
Definition: DecalsManager.h:101
Hydrax::Decal::setSize
void setSize(const Ogre::Vector2 &Size)
Set decal size.
Definition: DecalsManager.cpp:99
Hydrax::Decal::unregister
void unregister()
Unregister from current technique.
Definition: DecalsManager.cpp:83
Hydrax::Decal::mVisible
bool mVisible
Is decal visible?
Definition: DecalsManager.h:193
Hydrax::DecalsManager::getDecals
std::vector< Decal * > getDecals()
Get decals std::vector.
Definition: DecalsManager.h:248
Hydrax::DecalsManager::DecalIt
std::vector< Decal * >::iterator DecalIt
Decal iterator.
Definition: DecalsManager.h:280
Prerequisites.h
Hydrax::Decal::getId
const int & getId() const
Get the decal Id.
Definition: DecalsManager.h:76
Hydrax::DecalsManager::mLastUnderwater
bool mLastUnderwater
Definition: DecalsManager.h:290
Hydrax::DecalsManager::mWaterStrength
Ogre::Real mWaterStrength
Water strength (For decals culling)
Definition: DecalsManager.h:285
Hydrax::Decal::mHydrax
Hydrax * mHydrax
Hydrax parent pointer.
Definition: DecalsManager.h:196
Hydrax::Decal::registerPass
void registerPass(Ogre::Pass *_Pass)
Register the decal int the specified pass.
Definition: DecalsManager.cpp:64
Hydrax::DecalsManager::remove
void remove(const int &Id)
Remove decal.
Definition: DecalsManager.cpp:279
Hydrax::DecalsManager::add
Decal * add(const Ogre::String &TextureName)
Add decal.
Definition: DecalsManager.cpp:248
Hydrax::DecalsManager::registerAll
void registerAll()
Register all decals.
Definition: DecalsManager.cpp:305
Hydrax::Decal::Decal
Decal(Hydrax *h, const Ogre::String &TextureName, const int &Id)
Constructor.
Definition: DecalsManager.cpp:31
Hydrax::Decal::mOrientation
Ogre::Radian mOrientation
Orientation.
Definition: DecalsManager.h:189
Hydrax::DecalsManager::mNextId
int mNextId
Next Id.
Definition: DecalsManager.h:282
Hydrax::Decal::mSceneNode
Ogre::SceneNode * mSceneNode
Decal scene node.
Definition: DecalsManager.h:180
Hydrax::Decal::setPosition
void setPosition(const Ogre::Vector2 &Position)
Set decal position.
Definition: DecalsManager.cpp:92
Hydrax::Decal::mRegisteredPass
Ogre::Pass * mRegisteredPass
Registered pass.
Definition: DecalsManager.h:182
Hydrax::DecalsManager::mDecals
std::vector< Decal * > mDecals
Decals std::vector.
Definition: DecalsManager.h:278