RigsofRods
Soft-body Physics Simulation
MeshManager.h
Go to the documentation of this file.
1 /*
2 --------------------------------------------------------------------------------
3 This source file is part of SkyX.
4 Visit http://www.paradise-studios.net/products/skyx/
5 
6 Copyright (C) 2009-2012 Xavier Verguín González <xavyiy@gmail.com>
7 
8 This program is free software; you can redistribute it and/or modify it under
9 the terms of the GNU Lesser General Public License as published by the Free Software
10 Foundation; either version 2 of the License, or (at your option) any later
11 version.
12 
13 This program is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public License along with
18 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20 http://www.gnu.org/copyleft/lesser.txt.
21 --------------------------------------------------------------------------------
22 */
23 
24 #ifndef _SkyX_MeshManager_H_
25 #define _SkyX_MeshManager_H_
26 
27 #include "Prerequisites.h"
28 
29 namespace SkyX
30 {
31  class SkyX;
32 
33  class MeshManager
34  {
35  public:
38  struct VERTEX
39  {
40  // Position
41  float x, y, z,
42  // Normalized position
43  nx, ny, nz,
44  // Texture coords
45  u, v,
46  // Opacity
47  o;
48  };
49 
53  MeshManager(SkyX *s);
54 
57  ~MeshManager();
58 
62  void create();
63 
66  void remove();
67 
71  void updateGeometry(Ogre::Camera* cam);
72 
76  inline Ogre::MeshPtr getMesh()
77  {
78  return mMesh;
79  }
80 
84  inline Ogre::SubMesh* getSubMesh()
85  {
86  return mSubMesh;
87  }
88 
92  inline Ogre::Entity* getEntity()
93  {
94  return mEntity;
95  }
96 
100  inline const Ogre::String& getMaterialName() const
101  {
102  return mMaterialName;
103  }
104 
108  void setMaterialName(const Ogre::String &MaterialName);
109 
113  inline Ogre::HardwareVertexBufferSharedPtr &getHardwareVertexBuffer()
114  {
115  return mVertexBuffer;
116  }
117 
121  inline Ogre::HardwareIndexBufferSharedPtr &getHardwareIndexBuffer()
122  {
123  return mIndexBuffer;
124  }
125 
129  inline Ogre::SceneNode* getSceneNode()
130  {
131  return mSceneNode;
132  }
133 
137  inline const bool& isCreated() const
138  {
139  return mCreated;
140  }
141 
146  void setGeometryParameters(const int& Steps, const int& Circles);
147 
151  inline const int& getSteps() const
152  {
153  return mSteps;
154  }
155 
159  inline const int& getCircles() const
160  {
161  return mCircles;
162  }
163 
175  void setUnderHorizonParams(const int& UnderHorizonCircles = 15, const bool& UnderHorizonFading = true, const Ogre::Real& UnderHorizonFadingExponent = 1, const Ogre::Real& UnderHorizonFadingMultiplier = 2);
176 
180  inline const int& getUnderHorizonCircles() const
181  {
182  return mUnderHorizonCircles;
183  }
184 
188  inline const bool& getUnderHorizonFading() const
189  {
190  return mUnderHorizonFading;
191  }
192 
196  inline const Ogre::Real& getUnderHorizonFadingExponent() const
197  {
199  }
200 
204  inline const Ogre::Real& getUnderHorizonFadingMultiplier() const
205  {
207  }
208 
214  inline void setRadiusMultiplier(const Ogre::Real& RadiusMultiplier)
215  {
216  mRadiusMultiplier = RadiusMultiplier;
217  }
218 
223  const float getSkydomeRadius(Ogre::Camera* c) const;
224 
225  private:
228  void _createGeometry();
229 
231  bool mCreated;
232 
234  Ogre::MeshPtr mMesh;
236  Ogre::SubMesh *mSubMesh;
238  Ogre::Entity *mEntity;
239 
241  Ogre::HardwareVertexBufferSharedPtr mVertexBuffer;
243  Ogre::HardwareIndexBufferSharedPtr mIndexBuffer;
244 
247 
249  int mCircles;
251  int mSteps;
252 
261 
263  Ogre::Real mRadiusMultiplier;
264 
266  Ogre::SceneNode* mSceneNode;
267 
269  Ogre::String mMaterialName;
270 
273  };
274 }
275 
276 #endif
SkyX::MeshManager::setMaterialName
void setMaterialName(const Ogre::String &MaterialName)
Set mesh material.
Definition: MeshManager.cpp:350
SkyX::MeshManager::VERTEX::nx
float nx
Definition: MeshManager.h:43
SkyX::MeshManager::_createGeometry
void _createGeometry()
Create geometry.
Definition: MeshManager.cpp:221
SkyX::MeshManager::setGeometryParameters
void setGeometryParameters(const int &Steps, const int &Circles)
Set geometry parameters.
Definition: MeshManager.cpp:322
SkyX::MeshManager::VERTEX::u
float u
Definition: MeshManager.h:45
SkyX::MeshManager::MeshManager
MeshManager(SkyX *s)
Constructor.
Definition: MeshManager.cpp:30
Prerequisites.h
SkyX::MeshManager::VERTEX::nz
float nz
Definition: MeshManager.h:43
SkyX::MeshManager::VERTEX::z
float z
Definition: MeshManager.h:41
SkyX::MeshManager::getEntity
Ogre::Entity * getEntity()
Get entity.
Definition: MeshManager.h:92
SkyX::MeshManager::mUnderHorizonCircles
int mUnderHorizonCircles
Under-horizon rendering.
Definition: MeshManager.h:254
SkyX::MeshManager::getCircles
const int & getCircles() const
Get number of circles.
Definition: MeshManager.h:159
SkyX
Definition: AtmosphereManager.cpp:30
SkyX::MeshManager::mEntity
Ogre::Entity * mEntity
Ogre::Entity pointer.
Definition: MeshManager.h:238
SkyX::MeshManager::getHardwareIndexBuffer
Ogre::HardwareIndexBufferSharedPtr & getHardwareIndexBuffer()
Get hardware index buffer reference.
Definition: MeshManager.h:121
SkyX::MeshManager::mMaterialName
Ogre::String mMaterialName
Material name.
Definition: MeshManager.h:269
SkyX::MeshManager::mVertices
VERTEX * mVertices
Vertices.
Definition: MeshManager.h:246
SkyX::MeshManager::getSubMesh
Ogre::SubMesh * getSubMesh()
Get sub mesh.
Definition: MeshManager.h:84
SkyX::MeshManager::getSkydomeRadius
const float getSkydomeRadius(Ogre::Camera *c) const
Get skydome radius.
Definition: MeshManager.cpp:360
SkyX::MeshManager::mRadiusMultiplier
Ogre::Real mRadiusMultiplier
Radius multiplier.
Definition: MeshManager.h:263
SkyX::MeshManager::VERTEX::ny
float ny
Definition: MeshManager.h:43
SkyX::MeshManager::mUnderHorizonFading
bool mUnderHorizonFading
Under-horizon fading.
Definition: MeshManager.h:256
SkyX::MeshManager::~MeshManager
~MeshManager()
Destructor.
Definition: MeshManager.cpp:51
SkyX::MeshManager::mUnderHorizonFadingExponent
Ogre::Real mUnderHorizonFadingExponent
Under-horizon exponent fading (1=linear fading)
Definition: MeshManager.h:258
SkyX::MeshManager::isCreated
const bool & isCreated() const
Is _createGeometry() called?
Definition: MeshManager.h:137
SkyX::MeshManager::VERTEX::v
float v
Definition: MeshManager.h:45
SkyX::MeshManager::mCircles
int mCircles
Circles.
Definition: MeshManager.h:249
SkyX::MeshManager::VERTEX::y
float y
Definition: MeshManager.h:41
SkyX::MeshManager::updateGeometry
void updateGeometry(Ogre::Camera *cam)
Update geometry.
Definition: MeshManager.cpp:117
SkyX::MeshManager::mSubMesh
Ogre::SubMesh * mSubMesh
Ogre::Submesh pointer.
Definition: MeshManager.h:236
SkyX::MeshManager::mSteps
int mSteps
Steps.
Definition: MeshManager.h:251
SkyX::MeshManager::getSteps
const int & getSteps() const
Get number of steps.
Definition: MeshManager.h:151
SkyX::MeshManager::VERTEX
Vertex struct.
Definition: MeshManager.h:38
SkyX::MeshManager::remove
void remove()
Remove all resources.
Definition: MeshManager.cpp:56
SkyX::MeshManager::setUnderHorizonParams
void setUnderHorizonParams(const int &UnderHorizonCircles=15, const bool &UnderHorizonFading=true, const Ogre::Real &UnderHorizonFadingExponent=1, const Ogre::Real &UnderHorizonFadingMultiplier=2)
Set under-horizon rendering params.
Definition: MeshManager.cpp:334
SkyX::MeshManager::mUnderHorizonFadingMultiplier
Ogre::Real mUnderHorizonFadingMultiplier
Under-horizon fading multiplier: opacity = saturate(pow(opacity,fading_exp)*fading_multiplier)
Definition: MeshManager.h:260
SkyX::MeshManager::getMaterialName
const Ogre::String & getMaterialName() const
Get material name.
Definition: MeshManager.h:100
SkyX::MeshManager::mSceneNode
Ogre::SceneNode * mSceneNode
Ogre::SceneNode pointer.
Definition: MeshManager.h:266
SkyX::MeshManager::getUnderHorizonFadingMultiplier
const Ogre::Real & getUnderHorizonFadingMultiplier() const
Get under-horizon fading multiplier.
Definition: MeshManager.h:204
SkyX::MeshManager::getUnderHorizonFadingExponent
const Ogre::Real & getUnderHorizonFadingExponent() const
Get under-horizon exponent fading.
Definition: MeshManager.h:196
SkyX::MeshManager::getSceneNode
Ogre::SceneNode * getSceneNode()
Get the Ogre::SceneNode pointer where Hydrax mesh is attached.
Definition: MeshManager.h:129
SkyX::MeshManager::getHardwareVertexBuffer
Ogre::HardwareVertexBufferSharedPtr & getHardwareVertexBuffer()
Get hardware vertex buffer reference.
Definition: MeshManager.h:113
SkyX::MeshManager::getMesh
Ogre::MeshPtr getMesh()
Get mesh.
Definition: MeshManager.h:76
SkyX::MeshManager::mVertexBuffer
Ogre::HardwareVertexBufferSharedPtr mVertexBuffer
Vertex buffer.
Definition: MeshManager.h:241
SkyX::MeshManager::mCreated
bool mCreated
Has been create() already called?
Definition: MeshManager.h:231
SkyX::MeshManager::mSkyX
SkyX * mSkyX
Main SkyX pointer.
Definition: MeshManager.h:272
SkyX::MeshManager::setRadiusMultiplier
void setRadiusMultiplier(const Ogre::Real &RadiusMultiplier)
Set radius multiplier.
Definition: MeshManager.h:214
SkyX::MeshManager::VERTEX::x
float x
Definition: MeshManager.h:41
SkyX::MeshManager::create
void create()
Create our water mesh, geometry, entity, etc...
Definition: MeshManager.cpp:82
SkyX::MeshManager
Definition: MeshManager.h:33
SkyX::MeshManager::mMesh
Ogre::MeshPtr mMesh
Ogre::MeshPtr.
Definition: MeshManager.h:234
SkyX::MeshManager::getUnderHorizonCircles
const int & getUnderHorizonCircles() const
Get under-horizon circles.
Definition: MeshManager.h:180
SkyX::MeshManager::getUnderHorizonFading
const bool & getUnderHorizonFading() const
Get under-horizon fading.
Definition: MeshManager.h:188
SkyX::MeshManager::mIndexBuffer
Ogre::HardwareIndexBufferSharedPtr mIndexBuffer
Index buffer.
Definition: MeshManager.h:243
SkyX::MeshManager::VERTEX::o
float o
Definition: MeshManager.h:47