GlobeEngine
Streamlines.h
Go to the documentation of this file.
1 #ifndef GlobeEngine_Streamlines_h
2 #define GlobeEngine_Streamlines_h
3 
4 #include "Composition.h"
5 #include "Texture.h"
6 #include <vmmlib/vmmlib.hpp>
8 #include "MultiLineObject.h"
9 #include "Polyline.h"
10 
11 namespace ge {
12 
14  {
15 
16  public:
17  Streamlines();
19 
20  void loadTextures(std::vector<std::vector<std::string>> _fileList, vmml::Vector3s _dim);
21 
22  std::vector<std::vector<std::shared_ptr<Texture3Drgb>>> getStreamlinesTextures() {
23  return this->streamlineTextures;
24  }
25 
26  void setTextureHandle(int _i, int _j) {
27  this->Composition::setTextureHandle(0, this->streamlineTextures[_i][_j]);
28  }
29 
31  this->streamlineInteractionInfo = _info;
32  }
33 
34  std::shared_ptr<geData::MultiLineObject> getMultilineGeometry() {
35  return this->multilineGeometry;
36  }
37 
38  void updatePolylines();
39 
40  protected:
41  void drawFrame(std::shared_ptr<ge::Camera> _cam);
42 
43  private:
44 
45  float* dataU;
46  float* dataV;
47  float* dataW;
48 
49  std::vector<std::vector<std::shared_ptr<Texture3Drgb>>> streamlineTextures;
50 
51  std::shared_ptr<geData::MultiLineObject> multilineGeometry;
52  std::shared_ptr<ge::Shader> programForMultiLineObject;
53 
54  bool cmpf(float A, float B, float epsilon = 0.005f)
55  {
56  return (fabs(A - B) < epsilon);
57  }
58 
59  int round(float f)
60  {
61  return floor(f + 0.5);
62  }
63 
64  int getIndex(vmml::Vector3f pos)
65  {
66  int dim_x = this->dimensions.x();
67  int dim_y = this->dimensions.y();
68  int dim_z = this->dimensions.z();
69 
70  int x = round(pos.x());
71  int y = round(pos.y());
72  int z = round(pos.z());
73 
74  int index;
75  if (x < 0 || x > dim_x - 1 || y < 0 || y > dim_y - 1 || z < 0 || z > dim_z - 1)
76  {
77  index = -1;
78  }
79  else
80  {
81  index = x + dim_x * (y + dim_y * z);
82  }
83 
84  return index;
85  }
86 
87  vmml::Vector3f map (vmml::Vector3f val)
88  {
89  float x = -18.0 + (val.x() * 36.0) / float(this->dimensions.x() - 1);
90  float y = -18.0 + (val.y() * 36.0) / float(this->dimensions.y() - 1);
91  float z = 4.0 - (val.z() * 8.0) / float(this->dimensions.z() - 1);
92  return vmml::Vector3f(x, z, y);
93  }
94 
95  float euclideanDistance(vmml::Vector3f _point1, vmml::Vector3f _point2)
96  {
97  float x = std::pow(_point1.x() - _point2.x(), 2);
98  float y = std::pow(_point1.y() - _point2.y(), 2);
99  float z = std::pow(_point1.z() - _point2.z(), 2);
100  return std::sqrt(x + y + z);
101  }
102 
103  gePlanetaryViewer::StreamlinesInteractionInfo streamlineInteractionInfo;
104 
105  vmml::Vector3s dimensions;
106  };
107 }
108 #endif
Streamlines()
Definition: Streamlines.cpp:5
void updatePolylines()
Definition: Streamlines.cpp:111
~Streamlines()
Definition: Streamlines.h:18
expr pow(half base, half exp)
Definition: Half.h:2231
std::vector< std::vector< std::shared_ptr< Texture3Drgb > > > getStreamlinesTextures()
Definition: Streamlines.h:22
void setTextureHandle(int _i, int _j)
Definition: Streamlines.h:26
void setInteractionInfo(gePlanetaryViewer::StreamlinesInteractionInfo _info)
Definition: Streamlines.h:30
half fabs(half arg)
Definition: Half.h:2061
void setTextureHandle(GLint _unit, const std::shared_ptr< ge::TextureHandle > _handle)
Definition: Composition.cpp:79
void loadTextures(std::vector< std::vector< std::string >> _fileList, vmml::Vector3s _dim)
Definition: Streamlines.cpp:16
Definition: PlanetaryViewerSceneBlueprint.h:47
std::shared_ptr< geData::MultiLineObject > getMultilineGeometry()
Definition: Streamlines.h:34
void drawFrame(std::shared_ptr< ge::Camera > _cam)
Definition: Streamlines.cpp:10
Definition: AvalancheTrainingSimulationEngine.h:28
Definition: Composition.h:23
Definition: Streamlines.h:13
expr sqrt(half arg)
Definition: Half.h:2206
half floor(half arg)
Definition: Half.h:2385