1#ifndef TATOOINE_FLOWEXPLORER_NODES_POSITION_H
2#define TATOOINE_FLOWEXPLORER_NODES_POSITION_H
4#include <tatooine/flowexplorer/point_shader.h>
22 std::array<GLfloat, 4>
m_color{0.0f, 0.0f, 0.0f, 1.0f};
43 for (
size_t i = 0; i < N; ++i) {
45 this->
template insert_input_pin<real_type>(
""),
at(i));
52 point_shader::get().bind();
54 point_shader::get().set_projection_matrix(P);
55 point_shader::get().set_modelview_matrix(V);
62 vbomap[0] = [
this]() ->
gpu_vec {
63 if constexpr (N == 3) {
64 return {
static_cast<GLfloat
>(this->
at(0)),
65 static_cast<GLfloat
>(this->
at(1)),
66 static_cast<GLfloat
>(this->
at(2))};
67 }
else if constexpr (N == 2) {
68 return {
static_cast<GLfloat
>(this->
at(0)),
69 static_cast<GLfloat
>(this->
at(1)),
87 auto const P = this->
scene().camera_controller().projection_matrix();
88 auto const V = this->
scene().camera_controller().view_matrix();
90 auto x = [
this]() ->
vec4 {
91 if constexpr (N == 2) {
92 return {
at(0),
at(1), 0, 1};
93 }
else if constexpr (N == 3) {
94 return {
at(0),
at(1),
at(2), 1};
99 x(0) = (
x(0) * 0.5 + 0.5) * (this->
scene().window().width() - 1) + offset_x;
100 x(1) = (
x(1) * 0.5 + 0.5) * (this->
scene().window().height() - 1) - offset_y;
102 x(0) =
x(0) / (this->
scene().window().width() - 1) * 2 - 1;
103 x(1) =
x(1) / (this->
scene().window().height() - 1) * 2 - 1;
109 if constexpr (N == 3) {
113 for (
auto l : this->
self_pin().links()) {
114 l->input().node().on_property_changed();
120 bool changed =
false;
121 constexpr auto label = [](
size_t const i) {
135 for (
size_t i = 0; i < N; ++i) {
138 changed |= ImGui::DragInt(
"point size", &
m_pointsize, 0, 20);
139 changed |= ImGui::ColorEdit3(
"color",
m_color.data());
144 -> std::optional<intersection<double, 3>>
override {
145 if constexpr (N == 3) {
148 }
else if constexpr (N == 2) {
162 TATOOINE_REFLECTION_INSERT_METHOD(position, pos()),
163 TATOOINE_REFLECTION_INSERT_GETTER(point_size),
164 TATOOINE_REFLECTION_INSERT_GETTER(color))
167 TATOOINE_REFLECTION_INSERT_METHOD(position, pos()),
168 TATOOINE_REFLECTION_INSERT_GETTER(point_size),
169 TATOOINE_REFLECTION_INSERT_GETTER(color))
Definition: indexeddata.h:13
auto vertexbuffer() -> auto &
Definition: indexeddata.h:148
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))
DLL_API auto DragDouble(const char *label, double *v, double v_speed=1.0, double v_min=0.0, double v_max=0.0, const char *format="%.3lf", float power=1.0) -> bool
DLL_API auto point_size(GLfloat size) -> void
constexpr auto inv(diag_static_tensor< Tensor, N, N > const &A) -> std::optional< diag_static_tensor< vec< tatooine::value_type< Tensor >, N >, N, N > >
Definition: diag_tensor.h:109
Definition: position.h:14
auto is_transparent() const -> bool override
Definition: position.h:82
auto pos() const -> vec< real_type, N > const &
Definition: position.h:26
auto color() -> auto &
Definition: position.h:31
std::array< GLfloat, 4 > m_color
Definition: position.h:22
auto create_indexed_data() -> void
Definition: position.h:75
std::array< ui::input_pin *, N > m_input_pins
Definition: position.h:23
auto on_mouse_drag(int offset_x, int offset_y) -> bool override
Definition: position.h:86
auto color() const -> auto const &
Definition: position.h:32
int m_pointsize
Definition: position.h:21
auto render(mat4f const &P, mat4f const &V) -> void override
Definition: position.h:49
constexpr position(position &&) noexcept=default
gl::indexeddata< gpu_vec > m_gpu_data
Definition: position.h:20
auto point_size() -> auto &
Definition: position.h:28
auto point_size() const -> auto const &
Definition: position.h:29
auto draw_properties() -> bool override
Definition: position.h:119
void set_vbo_data()
Definition: position.h:60
auto pos() -> vec< real_type, N > &
Definition: position.h:25
auto check_intersection(ray< float, 3 > const &r) const -> std::optional< intersection< double, 3 > > override
Definition: position.h:143
constexpr position(position const &)=default
Definition: renderable.h:42
auto scene() const -> auto const &
Definition: node.h:72
auto insert_input_pin_property_link(input_pin &pin, Prop &prop) -> auto &
Definition: node.h:56
auto self_pin() const -> auto const &
Definition: node.h:79
auto constexpr at(integral auto const ... is) -> decltype(auto)
Definition: tensor.h:38
type_list_at< this_type, I > at
Definition: type_list.h:269
auto constexpr x() const -> auto const &requires(N >=1)
Definition: vec.h:102