RigsofRods
Soft-body Physics Simulation
GeometryBlock.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_VClouds_GeometryBlock_H_
25 #define _SkyX_VClouds_GeometryBlock_H_
26 
27 #include "Prerequisites.h"
28 
29 namespace SkyX { namespace VClouds{
30 
31  class VClouds;
32 
34  {
35  public:
38  struct VERTEX
39  { // Position
40  float x,y,z,
41  // 3D Coords
42  xc, yc, zc,
43  // Noise coords
44  u, v,
45  // Opacity
46  o;
47  };
48 
64  const float& Height, const Ogre::Radian& Alpha, const Ogre::Radian& Beta,
65  const float& Radius, const Ogre::Radian& Phi, const int& Na,
66  const int& Nb, const int& Nc, const int& A,
67  const int& B, const int& C, const int& Position);
68 
72 
75  void create();
76 
79  void remove();
80 
86  void updateGeometry(Ogre::Camera* c, const Ogre::Vector3& displacement, const Ogre::Vector3& distance);
87 
91  inline const bool& isCreated() const
92  {
93  return mCreated;
94  }
95 
99  inline Ogre::MeshPtr getMesh()
100  {
101  return mMesh;
102  }
103 
107  inline Ogre::SubMesh* getSubMesh()
108  {
109  return mSubMesh;
110  }
111 
115  inline Ogre::Entity* getEntity()
116  {
117  return mEntity;
118  }
119 
123  inline Ogre::HardwareVertexBufferSharedPtr &getHardwareVertexBuffer()
124  {
125  return mVertexBuffer;
126  }
127 
131  inline Ogre::HardwareIndexBufferSharedPtr &getHardwareIndexBuffer()
132  {
133  return mIndexBuffer;
134  }
135 
139  inline void setWorldOffset(const Ogre::Vector2& WorldOffset)
140  {
141  mWorldOffset = WorldOffset;
142  }
143 
148  const bool isInFrustum(Ogre::Camera *c) const;
149 
150  private:
154  const Ogre::AxisAlignedBox _buildAABox(const float& fd) const;
155 
158  void _calculateDataSize();
159 
162  void _createGeometry();
163 
166  void _updateGeometry();
167 
171  void _updateZoneCSlice(const int& n);
172 
176  void _updateZoneBSlice(const int& n);
177 
181  void _updateZoneASlice(const int& n);
182 
188  void _setVertexData(const int& index, const Ogre::Vector3& p, const float& o);
189 
191  bool mCreated;
192 
194  Ogre::MeshPtr mMesh;
196  Ogre::SubMesh *mSubMesh;
198  Ogre::Entity *mEntity;
199 
201  Ogre::HardwareVertexBufferSharedPtr mVertexBuffer;
203  Ogre::HardwareIndexBufferSharedPtr mIndexBuffer;
204 
207 
212 
214  float mHeight;
216  Ogre::Radian mAlpha, mBeta;
218  float mRadius;
220  Ogre::Radian mPhi;
222  int mNa, mNb, mNc;
224  float mA, mB, mC;
227 
229  Ogre::Vector2 mV2Cos;
230  Ogre::Vector2 mV2Sin;
232  float mBetaSin;
233  float mAlphaSin;
234 
236  Ogre::Vector3 mDisplacement;
238  Ogre::Vector2 mWorldOffset;
239 
243  Ogre::Camera* mCamera;
244 
246  Ogre::Vector3 mDistance;
247 
250  };
251 
252 
253 }}
254 
255 #endif
SkyX::VClouds::GeometryBlock::VERTEX::v
float v
Definition: GeometryBlock.h:44
SkyX::VClouds::GeometryBlock::mNc
int mNc
Definition: GeometryBlock.h:222
SkyX::VClouds::GeometryBlock::mPosition
int mPosition
Number of block(Position)
Definition: GeometryBlock.h:226
SkyX::VClouds::GeometryBlock::mAlpha
Ogre::Radian mAlpha
Angles.
Definition: GeometryBlock.h:216
SkyX::VClouds::GeometryBlock::mV2Cos
Ogre::Vector2 mV2Cos
Precomputed Cos/Sin vectors.
Definition: GeometryBlock.h:229
SkyX::VClouds::GeometryBlock::mDisplacement
Ogre::Vector3 mDisplacement
Displacement.
Definition: GeometryBlock.h:236
SkyX::VClouds::GeometryBlock::mWorldOffset
Ogre::Vector2 mWorldOffset
World coords offset.
Definition: GeometryBlock.h:238
SkyX::VClouds::GeometryBlock::isInFrustum
const bool isInFrustum(Ogre::Camera *c) const
Is the geometry block inside the camera frustum?
Definition: GeometryBlock.cpp:554
SkyX::VClouds::GeometryBlock::mDistance
Ogre::Vector3 mDistance
Current distance.
Definition: GeometryBlock.h:246
SkyX::VClouds::GeometryBlock::mAlphaSin
float mAlphaSin
Definition: GeometryBlock.h:233
SkyX
Definition: AtmosphereManager.cpp:30
SkyX::VClouds::GeometryBlock::VERTEX::z
float z
Definition: GeometryBlock.h:40
SkyX::VClouds::GeometryBlock::mVertexBuffer
Ogre::HardwareVertexBufferSharedPtr mVertexBuffer
Vertex buffer.
Definition: GeometryBlock.h:201
SkyX::VClouds::GeometryBlock::getSubMesh
Ogre::SubMesh * getSubMesh()
Get sub mesh.
Definition: GeometryBlock.h:107
SkyX::VClouds::GeometryBlock::_updateZoneCSlice
void _updateZoneCSlice(const int &n)
Update zone C slice.
Definition: GeometryBlock.cpp:351
SkyX::VClouds::GeometryBlock::_buildAABox
const Ogre::AxisAlignedBox _buildAABox(const float &fd) const
Build axis aligned box.
Definition: GeometryBlock.cpp:117
SkyX::VClouds::GeometryBlock::isCreated
const bool & isCreated() const
Has been create() already called?
Definition: GeometryBlock.h:91
SkyX::VClouds::GeometryBlock::mNumberOfTriangles
int mNumberOfTriangles
Current number of triangles.
Definition: GeometryBlock.h:209
SkyX::VClouds::GeometryBlock::mPhi
Ogre::Radian mPhi
Acimutal angle.
Definition: GeometryBlock.h:220
SkyX::VClouds::GeometryBlock::mA
float mA
A, B and C radius.
Definition: GeometryBlock.h:224
SkyX::VClouds::GeometryBlock::VERTEX::yc
float yc
Definition: GeometryBlock.h:42
SkyX::VClouds::GeometryBlock::mVClouds
VClouds * mVClouds
VClouds pointer.
Definition: GeometryBlock.h:241
SkyX::VClouds::GeometryBlock::mLastFallingDistance
float mLastFallingDistance
Last falling distance.
Definition: GeometryBlock.h:249
SkyX::VClouds::GeometryBlock::VERTEX
Vertex struct.
Definition: GeometryBlock.h:38
SkyX::VClouds::GeometryBlock::getMesh
Ogre::MeshPtr getMesh()
Get mesh.
Definition: GeometryBlock.h:99
SkyX::VClouds::GeometryBlock::updateGeometry
void updateGeometry(Ogre::Camera *c, const Ogre::Vector3 &displacement, const Ogre::Vector3 &distance)
Update geometry.
Definition: GeometryBlock.cpp:280
SkyX::VClouds::GeometryBlock::mIndexBuffer
Ogre::HardwareIndexBufferSharedPtr mIndexBuffer
Index buffer.
Definition: GeometryBlock.h:203
SkyX::VClouds::GeometryBlock::VERTEX::x
float x
Definition: GeometryBlock.h:40
SkyX::VClouds::GeometryBlock::VERTEX::u
float u
Definition: GeometryBlock.h:44
SkyX::VClouds::GeometryBlock::mB
float mB
Definition: GeometryBlock.h:224
SkyX::VClouds::GeometryBlock::VERTEX::o
float o
Definition: GeometryBlock.h:46
SkyX::VClouds::GeometryBlock::GeometryBlock
GeometryBlock(VClouds *vc, const float &Height, const Ogre::Radian &Alpha, const Ogre::Radian &Beta, const float &Radius, const Ogre::Radian &Phi, const int &Na, const int &Nb, const int &Nc, const int &A, const int &B, const int &C, const int &Position)
Constructor.
Definition: GeometryBlock.cpp:30
SkyX::VClouds::GeometryBlock::getHardwareIndexBuffer
Ogre::HardwareIndexBufferSharedPtr & getHardwareIndexBuffer()
Get hardware index buffer reference.
Definition: GeometryBlock.h:131
SkyX::VClouds::GeometryBlock::_updateGeometry
void _updateGeometry()
Update geometry.
Definition: GeometryBlock.cpp:323
SkyX::VClouds::GeometryBlock::getEntity
Ogre::Entity * getEntity()
Get entity.
Definition: GeometryBlock.h:115
SkyX::VClouds::GeometryBlock::mRadius
float mRadius
Radius.
Definition: GeometryBlock.h:218
SkyX::VClouds::GeometryBlock::mSubMesh
Ogre::SubMesh * mSubMesh
Ogre::Submesh pointer.
Definition: GeometryBlock.h:196
SkyX::VClouds::GeometryBlock::VERTEX::y
float y
Definition: GeometryBlock.h:40
SkyX::VClouds::GeometryBlock::mBetaSin
float mBetaSin
PI - Beta, PI - Alpha Sin.
Definition: GeometryBlock.h:232
SkyX::VClouds::GeometryBlock::remove
void remove()
Remove.
Definition: GeometryBlock.cpp:96
SkyX::VClouds::GeometryBlock::mBeta
Ogre::Radian mBeta
Definition: GeometryBlock.h:216
SkyX::VClouds::GeometryBlock::setWorldOffset
void setWorldOffset(const Ogre::Vector2 &WorldOffset)
Set world offset.
Definition: GeometryBlock.h:139
SkyX::VClouds::VClouds
Definition: VClouds.h:35
SkyX::VClouds::GeometryBlock::mNb
int mNb
Definition: GeometryBlock.h:222
SkyX::VClouds::GeometryBlock::mHeight
float mHeight
Height.
Definition: GeometryBlock.h:214
SkyX::VClouds::GeometryBlock::_setVertexData
void _setVertexData(const int &index, const Ogre::Vector3 &p, const float &o)
Set vertex data.
Definition: GeometryBlock.cpp:489
SkyX::VClouds::GeometryBlock::mCreated
bool mCreated
Has been create() already called?
Definition: GeometryBlock.h:191
SkyX::VClouds::GeometryBlock::_createGeometry
void _createGeometry()
Create geometry.
Definition: GeometryBlock.cpp:145
SkyX::VClouds::GeometryBlock::~GeometryBlock
~GeometryBlock()
Destructor.
Definition: GeometryBlock.cpp:59
SkyX::VClouds::GeometryBlock::mMesh
Ogre::MeshPtr mMesh
Ogre::MeshPtr.
Definition: GeometryBlock.h:194
SkyX::VClouds::GeometryBlock::mV2Sin
Ogre::Vector2 mV2Sin
Definition: GeometryBlock.h:230
SkyX::VClouds::GeometryBlock::mCamera
Ogre::Camera * mCamera
Current rendering camera.
Definition: GeometryBlock.h:243
SkyX::VClouds::GeometryBlock::mNa
int mNa
Number of slices per geometry zone.
Definition: GeometryBlock.h:222
SkyX::VClouds::GeometryBlock::_updateZoneBSlice
void _updateZoneBSlice(const int &n)
Update zone B slice.
Definition: GeometryBlock.cpp:394
SkyX::VClouds::GeometryBlock::VERTEX::zc
float zc
Definition: GeometryBlock.h:42
SkyX::VClouds::GeometryBlock::mC
float mC
Definition: GeometryBlock.h:224
SkyX::VClouds::GeometryBlock::_updateZoneASlice
void _updateZoneASlice(const int &n)
Update zone A slice.
Definition: GeometryBlock.cpp:448
SkyX::VClouds::GeometryBlock::create
void create()
Create.
Definition: GeometryBlock.cpp:64
SkyX::VClouds::GeometryBlock
Definition: GeometryBlock.h:33
SkyX::VClouds::GeometryBlock::_calculateDataSize
void _calculateDataSize()
Calculate data size.
Definition: GeometryBlock.cpp:133
SkyX::VClouds::GeometryBlock::mVertices
VERTEX * mVertices
Vertices pointer.
Definition: GeometryBlock.h:206
SkyX::VClouds::GeometryBlock::mVertexCount
int mVertexCount
Vertex count.
Definition: GeometryBlock.h:211
SkyX::VClouds::GeometryBlock::VERTEX::xc
float xc
Definition: GeometryBlock.h:42
SkyX::VClouds::GeometryBlock::getHardwareVertexBuffer
Ogre::HardwareVertexBufferSharedPtr & getHardwareVertexBuffer()
Get hardware vertex buffer reference.
Definition: GeometryBlock.h:123
SkyX::VClouds::GeometryBlock::mEntity
Ogre::Entity * mEntity
Ogre::Entity pointer.
Definition: GeometryBlock.h:198