All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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,
65  const Ogre::Radian& Beta,
66  const float& Radius, const Ogre::Radian& Phi, const int& Na,
67  const int& Nb, const int& Nc, const int& A,
68  const int& B, const int& C, const int& Position);
69 
72  ~GeometryBlock();
73 
76  void create();
77 
80  void remove();
81 
86  void updateGeometry(Ogre::Camera* c, const Ogre::Vector3& displacement);
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  bool isInFrustum(Ogre::Camera *c) const;
149 
150  private:
155  const Ogre::AxisAlignedBox _buildAABox(const float& fd) const;
156 
159  void _calculateDataSize();
160 
163  void _createGeometry();
164 
167  void _updateGeometry();
168 
172  void _updateZoneCSlice(const int& n);
173 
177  void _updateZoneBSlice(const int& n);
178 
182  void _updateZoneASlice(const int& n);
183 
189  void _setVertexData(const int& index, const Ogre::Vector3& p,
190  const float& o);
191 
193  VClouds *mVClouds;
194 
196  bool mCreated;
197 
199  Ogre::SubMesh *mSubMesh;
200 
202  Ogre::Entity *mEntity;
203 
205  VERTEX *mVertices;
206 
208  int mNumberOfTriangles;
210  int mVertexCount;
211 
213  float mHeight;
215  Ogre::Radian mAlpha, mBeta;
216 
218  float mRadius;
219 
221  Ogre::Radian mPhi;
223  int mNa, mNb, mNc;
225  float mA, mB, mC;
226 
228  int mPosition;
229 
231  Ogre::Vector3 mDisplacement;
233  Ogre::Vector2 mWorldOffset;
234 
236  Ogre::Camera* mCamera;
237 
239  float mLastFallingDistance;
240 
242  Ogre::MeshPtr mMesh;
244  Ogre::HardwareVertexBufferSharedPtr mVertexBuffer;
246  Ogre::HardwareIndexBufferSharedPtr mIndexBuffer;
247 
249  Ogre::Vector2 mV2Cos;
250  Ogre::Vector2 mV2Sin;
252  float mBetaSin;
253  float mAlphaSin;
254  };
255 }}
256 #endif
const bool & isCreated() const
Has been create() already called?
Definition: GeometryBlock.h:91
Ogre::MeshPtr getMesh()
Get mesh.
Definition: GeometryBlock.h:99
Vertex struct.
Definition: GeometryBlock.h:38
Ogre::HardwareVertexBufferSharedPtr & getHardwareVertexBuffer()
Get hardware vertex buffer reference.
Definition: GeometryBlock.h:123
Ogre::SubMesh * getSubMesh()
Get sub mesh.
Definition: GeometryBlock.h:107
Definition: VClouds.h:37
Ogre::HardwareIndexBufferSharedPtr & getHardwareIndexBuffer()
Get hardware index buffer reference.
Definition: GeometryBlock.h:131
void create()
Create SkyX.
Ogre::Entity * getEntity()
Get entity.
Definition: GeometryBlock.h:115
Ogre::Camera * mCamera
Current rendering camera.
Definition: SkyX.h:404
void setWorldOffset(const Ogre::Vector2 &WorldOffset)
Set world offset.
Definition: GeometryBlock.h:139
Definition: GeometryBlock.h:33
SkyX(Ogre::SceneManager *sm, Controller *c)
Contructor.
float zc
Definition: GeometryBlock.h:40
bool mCreated
Is SkyX created?
Definition: SkyX.h:422
#define DllExport
Include external headers.
Definition: Prerequisites.h:45