MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
PathOperator.hpp
Go to the documentation of this file.
1#pragma once
4
6
7class MAYAFLUX_API PathOperator : public GraphicsOperator {
8public:
9 explicit PathOperator(
10 Kinesis::InterpolationMode mode = Kinesis::InterpolationMode::CATMULL_ROM,
11 Eigen::Index samples_per_segment = 32);
12
13 /**
14 * @brief Initialize a single path with given control points and properties.
15 */
16 void initialize(const std::vector<LineVertex>& vertices);
17
18 /**
19 * @brief Initialize multiple paths with given control points and properties.
20 * @param paths Vector of control point vectors, one per path.
21 * @param mode Interpolation mode for all paths.
22 */
23 void initialize_paths(
24 const std::vector<std::vector<LineVertex>>& paths,
26
27 /**
28 * @brief Add a new path with given control points and properties.
29 * @param control_points Vector of control points for the path.
30 * @param mode Interpolation mode for the path.
31 */
32 void add_path(
33 const std::vector<LineVertex>& control_vertices,
35
36 void process(float dt) override;
37
38 [[nodiscard]] std::span<const uint8_t> get_vertex_data() const override;
39 [[nodiscard]] std::span<const uint8_t> get_vertex_data_for_collection(uint32_t idx) const override;
40 [[nodiscard]] Kakshya::VertexLayout get_vertex_layout() const override;
41 [[nodiscard]] size_t get_vertex_count() const override;
42 [[nodiscard]] bool is_vertex_data_dirty() const override;
43 void mark_vertex_data_clean() override;
44
45 /**
46 * @brief Extract current vertex data as LineVertex array
47 * @return Vector of LineVertex with current positions, colors, thicknesses
48 */
49 [[nodiscard]] std::vector<LineVertex> extract_vertices() const;
50
51 void set_parameter(std::string_view param, double value) override;
52 [[nodiscard]] std::optional<double> query_state(std::string_view query) const override;
53 [[nodiscard]] std::string_view get_type_name() const override { return "Path"; }
54 [[nodiscard]] size_t get_point_count() const override;
55
56 /**
57 * @brief Set the number of samples per segment for all paths.
58 * @param samples Number of samples to generate per segment between control points.
59 */
60 void set_samples_per_segment(Eigen::Index samples);
61
62 /**
63 * @brief Set the tension parameter for all paths (if supported by mode).
64 * @param tension Tension value (e.g., for cubic Hermite interpolation).
65 */
66 void set_tension(double tension);
67
68 /**
69 * @brief Set the global thickness for all paths.
70 * @param thickness Thickness value to apply to all paths.
71 */
72 void set_global_thickness(float thickness);
73
74 /**
75 * @brief Set the global color tint for all paths.
76 * @param color Color tint to apply to all paths (multiplied with individual tints).
77 */
78 void set_global_color(const glm::vec3& color);
79
80 /**
81 * @brief Get the number of paths currently managed by this operator.
82 * @return Number of path collections.
83 */
84 [[nodiscard]] size_t get_path_count() const { return m_paths.size(); }
85
86 const char* get_vertex_type_name() const override { return "PathVertex"; }
87
88protected:
89 void* get_data_at(size_t global_index) override;
90
91private:
92 std::vector<std::shared_ptr<GpuSync::PathGeneratorNode>> m_paths;
93
94 mutable std::vector<uint8_t> m_vertex_data_aggregate;
95
98 float m_default_thickness { 2.0F };
99};
100
101} // namespace MayaFlux::Nodes::Network
Operator that produces GPU-renderable geometry.
const char * get_vertex_type_name() const override
Get human-readable vertex type name (for validation/debugging)
std::vector< uint8_t > m_vertex_data_aggregate
Kinesis::InterpolationMode m_default_mode
std::vector< std::shared_ptr< GpuSync::PathGeneratorNode > > m_paths
size_t get_path_count() const
Get the number of paths currently managed by this operator.
std::string_view get_type_name() const override
Type name for introspection.
void initialize()
Definition main.cpp:11
InterpolationMode
Mathematical interpolation methods.
Complete description of vertex data layout in a buffer.