Tatooine
lic.h
Go to the documentation of this file.
1#ifndef TATOOINE_FLOWEXPLORER_NODES_LIC_H
2#define TATOOINE_FLOWEXPLORER_NODES_LIC_H
3//==============================================================================
6#include <tatooine/gpu/lic.h>
7#include <tatooine/gpu/texture_shader.h>
10#include <tatooine/gl/texture.h>
11#include <tatooine/gl/indexdata.h>
12
13#include <mutex>
14//==============================================================================
16//==============================================================================
17struct lic : renderable<lic> {
18 //----------------------------------------------------------------------------
19 // typedefs
20 //----------------------------------------------------------------------------
23
24 //----------------------------------------------------------------------------
25 // attributes
26 //----------------------------------------------------------------------------
27 private:
28 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
29 // pins
30 vectorfield_t* m_v = nullptr;
31 bb_t* m_bb = nullptr;
32
33 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
34 // internal
35 bool m_calculating = false;
37 std::unique_ptr<gpu::texture_shader> m_shader;
38 std::unique_ptr<gl::tex2rgba<float>> m_lic_tex;
40 std::mutex m_mutex;
41
42 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
43 // user data
46 double m_stepsize;
47 float m_alpha;
48 std::string m_seed_str;
49
50 public:
51 //----------------------------------------------------------------------------
52 // ctors
53 //----------------------------------------------------------------------------
55
56 //----------------------------------------------------------------------------
57 // methods
58 //----------------------------------------------------------------------------
59 auto init() -> void;
60 auto write_png() -> void;
61 //----------------------------------------------------------------------------
62 auto setup_pins() -> void;
63 //----------------------------------------------------------------------------
64 auto setup_quad() -> void;
65 //----------------------------------------------------------------------------
66 auto render(mat4f const& projection_matrix, mat4f const& view_matrix)
67 -> void override;
68 //----------------------------------------------------------------------------
69 auto on_property_changed() -> void override;
70 //----------------------------------------------------------------------------
71 auto calculate_lic() -> void;
72 //----------------------------------------------------------------------------
73 auto update_shader(mat4f const& projection_matrix, mat4f const& view_matrix)
74 -> void;
75 //----------------------------------------------------------------------------
77 ui::output_pin& other_pin) override;
78 //----------------------------------------------------------------------------
79 void on_pin_disconnected(ui::input_pin& this_pin) override;
80 //----------------------------------------------------------------------------
81 auto is_transparent() const -> bool override;
82 //----------------------------------------------------------------------------
83 // setters / getters
84 //----------------------------------------------------------------------------
85 auto lic_res() -> auto& { return m_lic_res; }
86 auto lic_res() const -> auto const& { return m_lic_res; }
87 //----------------------------------------------------------------------------
88 auto num_samples() -> auto& { return m_num_samples; }
89 auto num_samples() const { return m_num_samples; }
90 //----------------------------------------------------------------------------
91 auto stepsize() -> auto& { return m_stepsize; }
92 auto stepsize() const { return m_stepsize; }
93 //----------------------------------------------------------------------------
94 auto alpha() -> auto& { return m_alpha; }
95 auto alpha() const { return m_alpha; }
96 //----------------------------------------------------------------------------
97 auto seed() -> auto& { return m_seed_str; }
98 auto seed() const -> auto const& { return m_seed_str; }
99 //----------------------------------------------------------------------------
100 auto update(std::chrono::duration<double> const& /*dt*/) -> void override;
101 //----------------------------------------------------------------------------
102 auto draw_properties() -> bool override {
103 auto const changed = renderable<lic>::draw_properties();
104
105 if (m_lic_tex) {
106 if (ImGui::Button("write png")) {
107 write_png();
108 }
109 }
110
111 return changed;
112 }
113};
114//==============================================================================
115} // namespace tatooine::flowexplorer::nodes
116//==============================================================================
119 TATOOINE_REFLECTION_INSERT_METHOD(resolution, lic_res()),
120 TATOOINE_REFLECTION_INSERT_GETTER(num_samples),
121 TATOOINE_REFLECTION_INSERT_GETTER(stepsize),
122 TATOOINE_REFLECTION_INSERT_GETTER(alpha),
123 TATOOINE_REFLECTION_INSERT_GETTER(seed))
124#endif
Definition: indexeddata.h:13
TATOOINE_FLOWEXPLORER_REGISTER_RENDERABLE(tatooine::flowexplorer::nodes::aabb2d, TATOOINE_REFLECTION_INSERT_GETTER(min), TATOOINE_REFLECTION_INSERT_GETTER(max), TATOOINE_REFLECTION_INSERT_GETTER(line_width), TATOOINE_REFLECTION_INSERT_GETTER(line_color))
Definition: abcflow.h:7
Definition: axis_aligned_bounding_box.h:15
auto lic_res() const -> auto const &
Definition: lic.h:86
auto lic_res() -> auto &
Definition: lic.h:85
auto stepsize() const
Definition: lic.h:92
auto is_transparent() const -> bool override
int m_num_samples
Definition: lic.h:45
std::mutex m_mutex
Definition: lic.h:40
std::unique_ptr< gl::tex2rgba< float > > m_lic_tex
Definition: lic.h:38
auto seed() -> auto &
Definition: lic.h:97
auto stepsize() -> auto &
Definition: lic.h:91
float m_alpha
Definition: lic.h:47
std::string m_seed_str
Definition: lic.h:48
vectorfield_t * m_v
Definition: lic.h:30
double m_stepsize
Definition: lic.h:46
void on_pin_connected(ui::input_pin &this_pin, ui::output_pin &other_pin) override
auto alpha() const
Definition: lic.h:95
auto draw_properties() -> bool override
Definition: lic.h:102
std::unique_ptr< gpu::texture_shader > m_shader
Definition: lic.h:37
lic(flowexplorer::scene &s)
bool m_calculating
Definition: lic.h:35
auto update(std::chrono::duration< double > const &) -> void override
gl::indexeddata< vec< float, 2 >, vec< float, 2 >, float > m_quad
Definition: lic.h:39
auto update_shader(mat4f const &projection_matrix, mat4f const &view_matrix) -> void
auto render(mat4f const &projection_matrix, mat4f const &view_matrix) -> void override
auto num_samples() -> auto &
Definition: lic.h:88
auto on_property_changed() -> void override
auto seed() const -> auto const &
Definition: lic.h:98
auto num_samples() const
Definition: lic.h:89
auto alpha() -> auto &
Definition: lic.h:94
void on_pin_disconnected(ui::input_pin &this_pin) override
vec< int, 2 > m_lic_res
Definition: lic.h:44
bool m_needs_another_update
Definition: lic.h:36
bb_t * m_bb
Definition: lic.h:31
Definition: vectorfield_to_gpu.h:11
Definition: renderable.h:42
auto draw_properties() -> bool override
Definition: renderable.h:55
Definition: scene.h:17
Definition: mat.h:14
Definition: vec.h:12