MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ apply_one_to_one()

void MayaFlux::Nodes::Network::GraphicsOperator::apply_one_to_one ( std::string_view  param,
const std::shared_ptr< NodeNetwork > &  source 
)
overridevirtual

Apply ONE_TO_ONE parameter mapping.

Default implementation handles common graphics properties:

  • "color": Per-point color
  • "size": Per-point size (for point rendering)

Reimplemented from MayaFlux::Nodes::Network::NetworkOperator.

Reimplemented in MayaFlux::Nodes::Network::PhysicsOperator.

Definition at line 17 of file GraphicsOperator.cpp.

20{
21 size_t point_count = get_point_count();
22
23 if (source->get_node_count() != point_count) {
24 return;
25 }
26
27 if (param == "color") {
28 for (size_t i = 0; i < point_count; ++i) {
29 auto val = source->get_node_output(i);
30 if (!val)
31 continue;
32
33 auto* point = static_cast<PointVertex*>(get_data_at(i));
34 if (point) {
35 float normalized = glm::clamp(static_cast<float>(*val), 0.0F, 1.0F);
36 point->color = glm::vec3(normalized, 0.5F, 1.0F - normalized);
37 }
38 }
39 } else if (param == "size") {
40 for (size_t i = 0; i < point_count; ++i) {
41 auto val = source->get_node_output(i);
42 if (!val)
43 continue;
44
45 auto* point = static_cast<PointVertex*>(get_data_at(i));
46 if (point) {
47 point->size = glm::clamp(static_cast<float>(*val) * 10.0F, 1.0F, 50.0F);
48 }
49 }
50 }
51}
virtual void * get_data_at(size_t global_index)=0
Get mutable access to point at global index.
virtual size_t get_point_count() const =0
Get source point count (before topology expansion)
Kakshya::PointVertex PointVertex
Definition VertexSpec.hpp:8
Form< glm::vec2 > point(glm::vec3 color, float size, float hit_radius)
Geometry function for a positioned point in NDC space.
Source source()
Begin a Source chain.
Definition Plot.hpp:127

References get_data_at(), and get_point_count().

Referenced by MayaFlux::Nodes::Network::FieldOperator::apply_one_to_one(), and MayaFlux::Nodes::Network::PhysicsOperator::apply_one_to_one().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: