RigsofRods
Soft-body Physics Simulation
GeometryBlock.cpp
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 #include "GeometryBlock.h"
25 
26 #include "VClouds.h"
27 
28 namespace SkyX { namespace VClouds
29 {
31  const float& Height, const Ogre::Radian& Alpha, const Ogre::Radian& Beta,
32  const float& Radius, const Ogre::Radian& Phi, const int& Na,
33  const int& Nb, const int& Nc, const int& A,
34  const int& B, const int& C, const int& Position)
35  : mVClouds(vc)
36  , mCreated(false)
37  , mSubMesh(0)
38  , mEntity(0)
39  , mVertices(0)
40  , mNumberOfTriangles(0)
41  , mVertexCount(0)
42  , mHeight(Height)
43  , mAlpha(Alpha)
44  , mBeta(Beta)
45  , mRadius(Radius)
46  , mPhi(Phi)
47  , mNa(Na) , mNb(Nb) , mNc(Nc)
48  , mA(A) , mB(B) , mC(C)
49  , mPosition(Position)
50  , mDisplacement(Ogre::Vector3(0,0,0))
51  , mWorldOffset(Ogre::Vector2(0,0))
52  , mCamera(0)
53  , mDistance(Ogre::Vector3(0,0,0))
54  , mLastFallingDistance(0)
55  {
57  }
58 
60  {
61  remove();
62  }
63 
65  {
66  remove();
67 
68  // Create mesh and submesh
69  mMesh = Ogre::MeshManager::getSingleton().createManual("_SkyX_VClouds_Block" + Ogre::StringConverter::toString(mPosition),
70  Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
71  mSubMesh = mMesh->createSubMesh();
72  mSubMesh->useSharedVertices = false;
73 
74  // Create mesh geometry
76 
77  // Build edge list
78  mMesh->buildEdgeList();
79 
80  // End mesh creation
81  mMesh->load();
82  mMesh->touch();
83 
84  // Create entity
85  mEntity = mVClouds->getSceneManager()->createEntity("_SkyX_VClouds_BlockEnt" + Ogre::StringConverter::toString(mPosition), "_SkyX_VClouds_Block" + Ogre::StringConverter::toString(mPosition));
86  mEntity->setMaterialName("SkyX_VolClouds");
87  mEntity->setCastShadows(false);
88  mEntity->setRenderQueueGroup(mVClouds->getRenderQueueGroups().vclouds);
89 
90  // Set bounds
92 
93  mCreated = true;
94  }
95 
97  {
98  if (!mCreated)
99  {
100  return;
101  }
102 
103  Ogre::MeshManager::getSingleton().remove(mMesh->getName());
104  mVClouds->getSceneManager()->destroyEntity(mEntity);
105 
106  mMesh.setNull();
107  mSubMesh = 0;
108  mEntity = 0;
109  mVertexBuffer.setNull();
110  mIndexBuffer.setNull();
111 
112  delete [] mVertices;
113 
114  mCreated = false;
115  }
116 
117  const Ogre::AxisAlignedBox GeometryBlock::_buildAABox(const float& fd) const
118  {
119  Ogre::Vector2 Center = Ogre::Vector2(0,0);
120  Ogre::Vector2 V1 = mRadius*Ogre::Vector2(Ogre::Math::Cos(mPhi*mPosition), Ogre::Math::Sin(mPhi*mPosition));
121  Ogre::Vector2 V2 = mRadius*Ogre::Vector2(Ogre::Math::Cos(mPhi*(mPosition+1)), Ogre::Math::Sin(mPhi*(mPosition+1)));
122 
123  Ogre::Vector2 Max = Ogre::Vector2(std::max<float>(std::max<float>(V1.x, V2.x), Center.x), std::max<float>(std::max<float>(V1.y, V2.y), Center.y) );
124  Ogre::Vector2 Min = Ogre::Vector2(std::min<float>(std::min<float>(V1.x, V2.x), Center.x), std::min<float>(std::min<float>(V1.y, V2.y), Center.y) );
125 
126  return Ogre::AxisAlignedBox(
127  // Min x,y,z
128  Min.x, -std::max<float>(fd,0), Min.y,
129  // Max x,y,z
130  Max.x, mHeight - std::min<float>(fd,0), Max.y);
131  }
132 
134  {
135  mVertexCount = 7*mNa + 6*mNb + 4*mNc;
136  mNumberOfTriangles = 5*mNa + 4*mNb + 2*mNc;
137 
138  mV2Cos = Ogre::Vector2(Ogre::Math::Cos(mPosition*mPhi), Ogre::Math::Cos((mPosition+1)*mPhi));
139  mV2Sin = Ogre::Vector2(Ogre::Math::Sin(mPosition*mPhi), Ogre::Math::Sin((mPosition+1)*mPhi));
140 
141  mBetaSin = Ogre::Math::Sin(Ogre::Math::PI-mBeta.valueRadians());
142  mAlphaSin = Ogre::Math::Sin(Ogre::Math::PI-mAlpha.valueRadians());
143  }
144 
146  {
147  // Vertex buffers
148  mSubMesh->vertexData = new Ogre::VertexData();
149  mSubMesh->vertexData->vertexStart = 0;
150  mSubMesh->vertexData->vertexCount = mVertexCount;
151 
152  Ogre::VertexDeclaration* vdecl = mSubMesh->vertexData->vertexDeclaration;
153  Ogre::VertexBufferBinding* vbind = mSubMesh->vertexData->vertexBufferBinding;
154 
155  size_t offset = 0;
156  // Position
157  vdecl->addElement(0, offset, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
158  offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
159  // 3D coords
160  vdecl->addElement(0, offset, Ogre::VET_FLOAT3, Ogre::VES_TEXTURE_COORDINATES, 0);
161  offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
162  // Noise coords
163  vdecl->addElement(0, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES, 1);
164  offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT2);
165  // Opacity
166  vdecl->addElement(0, offset, Ogre::VET_FLOAT1, Ogre::VES_TEXTURE_COORDINATES, 2);
167 
168  mVertexBuffer = Ogre::HardwareBufferManager::getSingleton().
169  createVertexBuffer(sizeof(VERTEX),
170  mVertexCount,
171  Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY);
172 
173  vbind->setBinding(0, mVertexBuffer);
174 
175  unsigned short *indexbuffer = new unsigned short[mNumberOfTriangles*3];
176 
177  int IndexOffset = 0;
178  int VertexOffset = 0;
179 
180  // C
181  for (int k = 0; k < mNc; k++)
182  {
183  // First triangle
184  indexbuffer[IndexOffset] = VertexOffset;
185  indexbuffer[IndexOffset+1] = VertexOffset+1;
186  indexbuffer[IndexOffset+2] = VertexOffset+3;
187 
188  // Second triangle
189  indexbuffer[IndexOffset+3] = VertexOffset;
190  indexbuffer[IndexOffset+4] = VertexOffset+3;
191  indexbuffer[IndexOffset+5] = VertexOffset+2;
192 
193  IndexOffset += 6;
194  VertexOffset += 4;
195  }
196 
197  // B
198  for (int k = 0; k < mNb; k++)
199  {
200  // First triangle
201  indexbuffer[IndexOffset] = VertexOffset;
202  indexbuffer[IndexOffset+1] = VertexOffset+1;
203  indexbuffer[IndexOffset+2] = VertexOffset+3;
204 
205  // Second triangle
206  indexbuffer[IndexOffset+3] = VertexOffset;
207  indexbuffer[IndexOffset+4] = VertexOffset+3;
208  indexbuffer[IndexOffset+5] = VertexOffset+2;
209 
210  // Third triangle
211  indexbuffer[IndexOffset+6] = VertexOffset+2;
212  indexbuffer[IndexOffset+7] = VertexOffset+3;
213  indexbuffer[IndexOffset+8] = VertexOffset+5;
214 
215  // Fourth triangle
216  indexbuffer[IndexOffset+9] = VertexOffset+2;
217  indexbuffer[IndexOffset+10] = VertexOffset+5;
218  indexbuffer[IndexOffset+11] = VertexOffset+4;
219 
220  IndexOffset += 12;
221  VertexOffset += 6;
222  }
223 
224  // A
225  for (int k = 0; k < mNa; k++)
226  {
227  // First triangle
228  indexbuffer[IndexOffset] = VertexOffset;
229  indexbuffer[IndexOffset+1] = VertexOffset+1;
230  indexbuffer[IndexOffset+2] = VertexOffset+3;
231 
232  // Second triangle
233  indexbuffer[IndexOffset+3] = VertexOffset;
234  indexbuffer[IndexOffset+4] = VertexOffset+3;
235  indexbuffer[IndexOffset+5] = VertexOffset+2;
236 
237  // Third triangle
238  indexbuffer[IndexOffset+6] = VertexOffset+2;
239  indexbuffer[IndexOffset+7] = VertexOffset+3;
240  indexbuffer[IndexOffset+8] = VertexOffset+5;
241 
242  // Fourth triangle
243  indexbuffer[IndexOffset+9] = VertexOffset+2;
244  indexbuffer[IndexOffset+10] = VertexOffset+5;
245  indexbuffer[IndexOffset+11] = VertexOffset+4;
246 
247  // Fifth triangle
248  indexbuffer[IndexOffset+12] = VertexOffset+4;
249  indexbuffer[IndexOffset+13] = VertexOffset+5;
250  indexbuffer[IndexOffset+14] = VertexOffset+6;
251 
252  IndexOffset += 15;
253  VertexOffset += 7;
254  }
255 
256  // Prepare buffer for indices
257  mIndexBuffer =
258  Ogre::HardwareBufferManager::getSingleton().createIndexBuffer(
259  Ogre::HardwareIndexBuffer::IT_16BIT,
261  Ogre::HardwareBuffer::HBU_STATIC, true);
262 
263  mIndexBuffer->
264  writeData(0,
265  mIndexBuffer->getSizeInBytes(),
266  indexbuffer,
267  true);
268 
269  delete []indexbuffer;
270 
271  // Set index buffer for this submesh
272  mSubMesh->indexData->indexBuffer = mIndexBuffer;
273  mSubMesh->indexData->indexStart = 0;
274  mSubMesh->indexData->indexCount = mNumberOfTriangles*3;
275 
276  // Create our internal buffer for manipulations
278  }
279 
280  void GeometryBlock::updateGeometry(Ogre::Camera* c, const Ogre::Vector3& displacement, const Ogre::Vector3& distance)
281  {
282  if (!mCreated)
283  {
284  return;
285  }
286 
287  mDisplacement = displacement;
288 
289  float fallingDistance = mVClouds->getDistanceFallingParams().x*(mEntity->getParentSceneNode()->_getDerivedPosition().y-c->getDerivedPosition().y);
290 
291  if (mVClouds->getDistanceFallingParams().y > 0) // -1 means no max falling
292  {
293  if (fallingDistance > 0)
294  {
295  if (fallingDistance > mVClouds->getDistanceFallingParams().y)
296  {
297  fallingDistance = mVClouds->getDistanceFallingParams().y;
298  }
299  }
300  else
301  {
302  if (-fallingDistance > mVClouds->getDistanceFallingParams().y)
303  {
304  fallingDistance = -mVClouds->getDistanceFallingParams().y;
305  }
306  }
307  }
308 
309  if (fallingDistance != mLastFallingDistance)
310  {
311  mLastFallingDistance = fallingDistance;
312  mMesh->_setBounds(_buildAABox(mLastFallingDistance));
313  }
314 
315  if (isInFrustum(c))
316  {
317  mCamera = c;
318  mDistance = distance;
319  _updateGeometry();
320  }
321  }
322 
324  {
325  // Update zone C
326  for (int k = 0; k < mNc; k++)
327  {
329  }
330 
331  // Update zone B
332  for (int k = 0; k < mNb; k++)
333  {
335  }
336 
337  // Update zone A
338  for (int k = 0; k < mNa; k++)
339  {
341  }
342 
343  // Upload changes
344  mVertexBuffer->
345  writeData(0,
346  mVertexBuffer->getSizeInBytes(),
347  mVertices,
348  true);
349  }
350 
352  {
353  int VertexOffset = n*4;
354 
355  // TODO, calculate constants by zone, not by slice
356  float Radius = mB+((mC-mB)/mNc)*(mNc-n);
357 
358  Radius += mDisplacement.z;
359 
360  float opacity = 1;
361 
362  if (n == 0)
363  {
364  opacity = 1 - mDisplacement.z/((mC-mB)/mNc);
365  }
366  else if (n == mNc-1)
367  {
368  opacity = mDisplacement.z/((mC-mB)/mNc);
369  }
370 
371  Ogre::Vector2 x1 = Radius*mV2Cos,
372  x2 = Radius*mBetaSin*mV2Cos,
373  z1 = Radius*mV2Sin,
374  z2 = Radius*mBetaSin*mV2Sin;
375 
376  Ogre::Vector3 or0 = Ogre::Vector3(x1.x, 0, z1.x),
377  or1 = Ogre::Vector3(x1.y, 0, z1.y);
378 
379  float y0 = Radius*Ogre::Math::Sin(mAlpha),
380  d = Ogre::Vector2(x1.x - x2.x, z1.x - z2.x).length(),
381  ang = Ogre::Math::ATan(y0/d).valueRadians(),
382  hip = mHeight / Ogre::Math::Sin(ang);
383 
384  // Vertex 0
385  _setVertexData(VertexOffset, or0, opacity);
386  // Vertex 1
387  _setVertexData(VertexOffset+1, or1, opacity);
388  // Vertex 2
389  _setVertexData(VertexOffset+2, or0+(Ogre::Vector3(x2.x, y0, z2.x)-or0).normalisedCopy()*hip, opacity);
390  // Vertex 3
391  _setVertexData(VertexOffset+3, or1+(Ogre::Vector3(x2.y, y0, z2.y)-or1).normalisedCopy()*hip, opacity);
392  }
393 
395  {
396  int VertexOffset = mNc*4 + n*6;
397 
398  // TODO
399  float Radius = mA+((mB-mA)/mNb)*(mNb-n);
400 
401  Radius += mDisplacement.y;
402 
403  float opacity = 1;
404 
405  if (n == 0)
406  {
407  opacity = 1-mDisplacement.y/((mB-mA)/mNb);
408  }
409  else if (n == mNb-1)
410  {
411  opacity = mDisplacement.y/((mB-mA)/mNb);
412  }
413 
414  Ogre::Vector2 x1 = Radius*mV2Cos,
415  x2 = Radius*mBetaSin*mV2Cos,
416  z1 = Radius*mV2Sin,
417  z2 = Radius*mBetaSin*mV2Sin;
418 
419  float y0 = Radius*Ogre::Math::Sin(mAlpha);
420 
421  // Vertex 0
422  _setVertexData(VertexOffset, Ogre::Vector3(x1.x, 0, z1.x), opacity);
423  // Vertex 1
424  _setVertexData(VertexOffset+1, Ogre::Vector3(x1.y, 0, z1.y), opacity);
425  // Vertex 2
426  _setVertexData(VertexOffset+2, Ogre::Vector3(x2.x, y0, z2.x), opacity);
427  // Vertex 3
428  _setVertexData(VertexOffset+3, Ogre::Vector3(x2.y, y0, z2.y), opacity);
429 
430  Ogre::Vector2 x3 = Radius*mAlphaSin*mV2Cos,
431  z3 = Radius*mAlphaSin*mV2Sin;
432 
433  Ogre::Vector3 or0 = Ogre::Vector3(x2.x, y0, z2.x),
434  or1 = Ogre::Vector3(x2.y, y0, z2.y);
435 
436  float y1 = Radius*Ogre::Math::Sin(mBeta),
437  y3 = y1-y0,
438  d = Ogre::Vector2(x3.x - x2.x, z3.x - z2.x).length(),
439  ang = Ogre::Math::ATan(y3/d).valueRadians(),
440  hip = (mHeight-y0) / Ogre::Math::Sin(ang);
441 
442  // Vertex 4
443  _setVertexData(VertexOffset+4, or0 + (Ogre::Vector3(x3.x, y1, z3.x)-or0).normalisedCopy()*hip, opacity);
444  // Vertex 5
445  _setVertexData(VertexOffset+5, or1 + (Ogre::Vector3(x3.y, y1, z3.y)-or1).normalisedCopy()*hip, opacity);
446  }
447 
449  {
450  int VertexOffset = mNc*4 + mNb*6 +n*7;
451 
452  // TODO
453  float Radius = (mA/mNa)*(mNa-n);
454 
455  Radius += mDisplacement.x;
456 
457  float opacity = (n == 0) ? (1-mDisplacement.x/(mA/mNa)) : 1.0f;
458 
459  Ogre::Vector2 x1 = Radius*mV2Cos,
460  x2 = Radius*mBetaSin*mV2Cos,
461  z1 = Radius*mV2Sin,
462  z2 = Radius*mBetaSin*mV2Sin;
463 
464  float y0 = Radius*Ogre::Math::Sin(mAlpha);
465 
466  // Vertex 0
467  _setVertexData(VertexOffset, Ogre::Vector3(x1.x, 0, z1.x), opacity);
468  // Vertex 1
469  _setVertexData(VertexOffset+1, Ogre::Vector3(x1.y, 0, z1.y), opacity);
470  // Vertex 2
471  _setVertexData(VertexOffset+2, Ogre::Vector3(x2.x, y0, z2.x), opacity);
472  // Vertex 3
473  _setVertexData(VertexOffset+3, Ogre::Vector3(x2.y, y0, z2.y), opacity);
474 
475  Ogre::Vector2 x3 = Radius*mAlphaSin*mV2Cos,
476  z3 = Radius*mAlphaSin*mV2Sin;
477 
478  float y1 = Radius*Ogre::Math::Sin(mBeta);
479 
480  // Vertex 4
481  _setVertexData(VertexOffset+4, Ogre::Vector3(x3.x, y1, z3.x), opacity);
482  // Vertex 5
483  _setVertexData(VertexOffset+5, Ogre::Vector3(x3.y, y1, z3.y), opacity);
484 
485  // Vertex 6
486  _setVertexData(VertexOffset+6, Ogre::Vector3(0, Radius, 0), opacity);
487  }
488 
489  void GeometryBlock::_setVertexData(const int& index, const Ogre::Vector3& p, const float& o)
490  {
491  float yDist = -mDistance.y;
492  float fallingDistance = mVClouds->getDistanceFallingParams().x*yDist*(Ogre::Vector2(p.x,p.z).length()/mRadius);
493 
494  if (mVClouds->getDistanceFallingParams().y > 0) // -1 means no max falling
495  {
496  if (fallingDistance > 0)
497  {
498  if (fallingDistance > mVClouds->getDistanceFallingParams().y)
499  {
500  fallingDistance = mVClouds->getDistanceFallingParams().y;
501  }
502  }
503  else
504  {
505  if (-fallingDistance > mVClouds->getDistanceFallingParams().y)
506  {
507  fallingDistance = -mVClouds->getDistanceFallingParams().y;
508  }
509  }
510  }
511 
512  fallingDistance *= Ogre::Math::Sign(yDist);
513 
514  // Position
515  mVertices[index].x = p.x;
516  if (yDist < -mHeight/2)
517  {
518  // Over-cloud
519  mVertices[index].y = mHeight - p.y;
520  }
521  else // Under-cloud
522  {
523  mVertices[index].y = p.y - fallingDistance;
524  }
525  mVertices[index].z = p.z;
526 
527  // 3D coords (Z-UP)
528  float scale = mVClouds->getCloudFieldScale()/mRadius;
529  mVertices[index].xc = (p.x+mWorldOffset.x)*scale;
530  mVertices[index].yc = (p.z+mWorldOffset.y)*scale;
531  mVertices[index].zc = Ogre::Math::Clamp<Ogre::Real>(p.y/mHeight, 0, 1);
532  if (yDist < -mHeight/2)
533  {
534  // Over-cloud
535  mVertices[index].zc = 1.0f - mVertices[index].zc;
536  }
537 
538  // Noise coords
539  float noise_scale = mVClouds->getNoiseScale()/mRadius;
540  float xz_length_radius = Ogre::Vector2(p.x,p.z).length() / mRadius;
541  Ogre::Vector3 origin = Ogre::Vector3(0,-(mEntity->getParentSceneNode()->_getDerivedPosition().y-mCamera->getDerivedPosition().y) -mRadius*(0.5f+0.5f*Ogre::Vector2(p.x,p.z).length()/mRadius),0);
542  Ogre::Vector3 dir = (p-origin).normalisedCopy();
543  float hip = Ogre::Math::Sqrt(Ogre::Math::Pow(xz_length_radius * mRadius, 2) + Ogre::Math::Pow(origin.y, 2));
544  Ogre::Vector3 uv = dir*hip; // Only x/z, += origin doesn't need
545  mVertices[index].u = (uv.x+mWorldOffset.x)*noise_scale;
546  mVertices[index].v = (uv.z+mWorldOffset.y)*noise_scale;
547 
548  // Opacity
549  float dist = (mDistance - Ogre::Vector3(p.x, p.y - fallingDistance, p.z)).length();
550  float att = Ogre::Math::Clamp((dist-mA/3.25f)/(mA/3.25f),0.0f,1.0f);
551  mVertices[index].o = o * att * mVClouds->getGlobalOpacity();
552  }
553 
554  const bool GeometryBlock::isInFrustum(Ogre::Camera *c) const
555  {
556  if (!mCreated)
557  {
558  return false;
559  }
560 
561  // TODO: Use a world bounding box for each geometry zone, this way the
562  // culling is going to be more acurrated and the geometry falling is going to be culled
563  // when the falling factor is bigger than 1.
564  return c->isVisible(mEntity->getParentSceneNode()->_getWorldAABB());
565  }
566 }}
SkyX::VClouds::VClouds::getNoiseScale
const Ogre::Real & getNoiseScale() const
Get noise scale.
Definition: VClouds.h:420
SkyX::VClouds::GeometryBlock::VERTEX::v
float v
Definition: GeometryBlock.h:44
SkyX::VClouds::GeometryBlock::mNc
int mNc
Definition: GeometryBlock.h:222
VClouds.h
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::VClouds::getRenderQueueGroups
const RenderQueueGroups & getRenderQueueGroups() const
Get render queue groups.
Definition: VClouds.h:260
SkyX::VClouds::VClouds::RenderQueueGroups::vclouds
Ogre::uint8 vclouds
VClouds render queue group.
Definition: VClouds.h:53
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::VClouds::getCloudFieldScale
const Ogre::Real & getCloudFieldScale() const
Get cloud field scale.
Definition: VClouds.h:404
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::_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::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::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::_updateGeometry
void _updateGeometry()
Update geometry.
Definition: GeometryBlock.cpp:323
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::VClouds::getDistanceFallingParams
const Ogre::Vector2 & getDistanceFallingParams() const
Get distance falling params.
Definition: VClouds.h:247
SkyX::VClouds::VClouds::getGlobalOpacity
const Ogre::Real & getGlobalOpacity() const
Get global opacity.
Definition: VClouds.h:388
SkyX::VClouds::GeometryBlock::remove
void remove()
Remove.
Definition: GeometryBlock.cpp:96
SkyX::VClouds::GeometryBlock::mBeta
Ogre::Radian mBeta
Definition: GeometryBlock.h:216
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
GeometryBlock.h
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
Ogre
Definition: ExtinguishableFireAffector.cpp:35
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::_calculateDataSize
void _calculateDataSize()
Calculate data size.
Definition: GeometryBlock.cpp:133
SkyX::VClouds::GeometryBlock::mVertices
VERTEX * mVertices
Vertices pointer.
Definition: GeometryBlock.h:206
SkyX::VClouds::VClouds::getSceneManager
Ogre::SceneManager * getSceneManager()
Get scene manager.
Definition: VClouds.h:459
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::mEntity
Ogre::Entity * mEntity
Ogre::Entity pointer.
Definition: GeometryBlock.h:198