FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
FlowPlane.h
1#pragma once
2#ifdef FH_VISUALIZATION
3
4# include <OgreManualObject.h>
5# include <OgreMaterial.h>
6# include <OgreMesh.h>
7# include <OgreRoot.h>
8# include <OgreSceneNode.h>
9# include <OgreSubMesh.h>
10# include <array>
11# include <fhsim_environment/EnvironmentProvider.h>
12# include <functional>
13# include <vector>
14
15namespace visual
16{
17
19struct FlowPlaneSettings
20{
22 double position[3] = {0.0, 0.0, 0.0};
24 double localX[3] = {1.0, 0.0, 0.0};
26 double localY[3] = {0.0, 1.0, 0.0};
28 double size[2] = {50.0, 50.0};
30 int vertexCounts[2] = {50, 50};
32 double visibleRange[2] = {0.0, 1.0};
34 double colorRange[2] = {0.0, 1.0};
36 double alphaRange[2] = {0.3, 0.6};
37};
38
40using ComputeFunction = std::function<double(double T, const double pos[3])>;
41
48class FlowPlane
49{
50public:
58 FlowPlane(Ogre::Root* ogreRoot,
59 environment::EnvironmentProvider* provider,
60 const FlowPlaneSettings& settings,
61 ComputeFunction computeFunc = nullptr);
62
68 ~FlowPlane();
69
70 FlowPlane(const FlowPlane&) = delete;
71 FlowPlane& operator=(const FlowPlane&) = delete;
72
77 void Update(double T);
78
85 void SetTransform(const double position[3], const double localX[3], const double localY[3]);
86
94 void SetComputeFunction(ComputeFunction func);
95
96private:
102 void Release();
103
108 void UpdateVertexPositions();
109
114 void UpdateOgreNodeOrientation();
115
117 environment::EnvironmentProvider* m_provider;
119 Ogre::SceneManager* m_sceneMgr;
121 Ogre::SceneNode* m_node;
123 Ogre::MeshPtr m_mesh;
125 Ogre::SubMesh* m_subMesh;
127 int m_vertexCounts[2];
129 double m_size[2];
131 double m_position[3];
133 double m_localX[3];
135 double m_localY[3];
137 std::vector<std::array<double, 3>> m_vertexWorldPos;
139 ComputeFunction m_computeFunction;
141 Ogre::Entity* m_entity;
148 Ogre::MaterialPtr m_material;
149};
150
151} // namespace visual
152#endif // FH_VISUALIZATION
Visualization utilities.
Definition EnvironmentSettings.h:15