CloudyDay
 All Classes Functions Variables Enumerations
CelluarAutomataGenerator.h
1 #pragma once
2 #include "Scene.h"
3 #include "CloudGenerator.h"
4 #include "CloudScene.h"
5 
6 #include <stdlib.h>
7 #include <string>
8 #include <stdio.h>
9 #include <iostream>
10 #include <cstdlib>
11 #include <math.h>
12 
13 namespace osgCloudyDay
14 {
16  {
17  public:
26  CelluarAutomataGenerator(unsigned int width, unsigned int depth, unsigned int height, int type, osg::Vec4 color);
31 
35  void Perform(void);
39  void Update(void);
40 
41  protected:
45  void Initialize();
46 
47  int m_type;
48 
55  void AddEllipsoide(osg::Vec3 radius, osg::Vec3 position, float lifetime);
56 
64  float GetCellDensity( int i, int j, int k );
70  float GetPointDensity(osg::Vec3 Point);
71 
72  private:
76  void DefineInitValues();
81  void Interpolate(float& t);
82 
90  inline int Index(int i, int j, int k);
95  inline bool IsCellInSpace(int x, int y, int z);
96 
100  void UpdateEllisoides();
105  bool IsOutside(osg::Vec3 pos);
109  void Grow();
113  void Extrinction();
121  void InitCell( int x, int y, int z, float fProbSeed );
125  void ShapeVolume();
129  void SetupArrays();
133  void CalcDensity();
137  void SupplyVapor();
141  void AdvectionWind();
142 
143  float* m_current_density;
144  float** m_density2;
145 
146  unsigned int** m_hum;
147  unsigned int** m_act;
148  unsigned int** m_cld;
149  unsigned int* m_fact;
150 
151  float* m_phum;
152  float* m_pext;
153  float* m_pact;
154 
155  int m_depth;
156  int m_width;
157  int m_height;
158  float f_depth;
159  float f_width;
160  float f_height;
161 
162  unsigned int t;
163  unsigned int tdens;
164 
165  unsigned int m_elapsedSteps;
166 
167  osg::Vec3 bb_min;
168  osg::Vec3 bb_max;
169 
170  osg::Vec3 windVector;
171 
172 
173  osg::ref_ptr<osg::Vec3Array> m_positions;
174  osg::ref_ptr<osg::Vec3Array> m_radius;
175  osg::ref_ptr<osg::UIntArray> m_lifetimes;
176 
177  float m_time;
178 
179  osg::Vec3* randomPos;
180  osg::Vec3 windDirection;
181  };
182 }