cgv
Loading...
Searching...
No Matches
arrow_renderer.h
1#pragma once
2
3#include "surface_renderer.h"
4
5#include "gl/lib_begin.h"
6
7namespace cgv {
8 namespace render {
9 class CGV_API arrow_renderer;
10
12
15 extern CGV_API arrow_renderer& ref_arrow_renderer(context& ctx, int ref_count_change = 0);
16
21 {
22 AHLM_RELATIVE_TO_RADIUS = 1,
23 AHLM_RELATIVE_TO_LENGTH = 2,
24 AHLM_MINIMUM_OF_RADIUS_AND_LENGTH = 3
25 };
26
29 {
30 /*@name arrow rendering attributes*/
32
35 float radius_relative_to_length;
39 ArrowHeadLengthMode head_length_mode;
41 float head_length_relative_to_radius;
43 float head_length_relative_to_length;
45 float length_scale;
47 float color_scale;
49 bool normalize_length;
51 float relative_location_of_position;
53 float length_eps;
55
57 };
58
60 class CGV_API arrow_renderer : public surface_renderer
61 {
62 protected:
63 bool has_directions;
64 bool position_is_center;
65 bool direction_is_end_point;
67 render_style* create_render_style() const;
69 bool build_shader_program(context& ctx, shader_program& prog, const shader_define_map& defines);
70 public:
74 void enable_attribute_array_manager(const context& ctx, attribute_array_manager& aam);
76 void disable_attribute_array_manager(const context& ctx, attribute_array_manager& aam);
78 template <typename T>
79 void set_direction_array(const context& ctx, const std::vector<T>& directions) { has_directions = true; direction_is_end_point = false; set_attribute_array(ctx, "direction", directions); }
81 template <typename T>
82 void set_direction_array(const context& ctx, const T* directions, size_t nr_elements, unsigned stride_in_bytes = 0) { has_directions = true; direction_is_end_point = false; set_attribute_array(ctx, "direction", directions, nr_elements, stride_in_bytes); }
84 void remove_direction_array(const context& ctx);
86 template <typename T>
87 void set_end_point_array(const context& ctx, const std::vector<T>& end_points) { has_directions = true; direction_is_end_point = true; set_attribute_array(ctx, "direction", end_points); }
89 template <typename T>
90 void set_end_point_array(const context& ctx, const T* end_points, size_t nr_elements, unsigned stride_in_bytes = 0) { has_directions = true; direction_is_end_point = true; set_attribute_array(ctx, "direction", end_points, nr_elements, stride_in_bytes); }
92 void remove_end_point_array(const context& ctx);
94 bool validate_attributes(const context& ctx) const;
96 bool enable(context& ctx);
98 bool disable(context& ctx);
100 void draw(context& ctx, size_t start, size_t count,
101 bool use_strips = false, bool use_adjacency = false, uint32_t strip_restart_index = -1);
102 };
104 {
105 bool self_reflect(cgv::reflect::reflection_handler& rh);
106 };
108 }
109}
110
111#include <cgv/config/lib_end.h>
the self reflection handler is passed to the virtual self_reflect() method of cgv::base::base.
renderer that supports point splatting
void set_direction_array(const context &ctx, const T *directions, size_t nr_elements, unsigned stride_in_bytes=0)
templated method to set the direction attribute from an array of directions of type T,...
void set_end_point_array(const context &ctx, const T *end_points, size_t nr_elements, unsigned stride_in_bytes=0)
templated method to set the end_point attribute from an array of end_points of type T,...
void set_direction_array(const context &ctx, const std::vector< T > &directions)
templated method to set the direction attribute from a vector of directions of type T,...
void set_end_point_array(const context &ctx, const std::vector< T > &end_points)
templated method to set the end_point attribute from a vector of end_points of type T,...
attribute array manager used to upload arrays to gpu
base class for all drawables, which is independent of the used rendering API.
Definition context.h:621
a shader program combines several shader code fragments to a complete definition of the shading pipel...
base classes for renderers that support surface rendering
std::map< std::string, std::string > shader_define_map
typedef for shader define map data structure
Definition shader_code.h:52
arrow_renderer & ref_arrow_renderer(context &ctx, int ref_count_change)
reference to a singleton surfel renderer that can be shared among drawables
ArrowHeadLengthMode
different modes to compute the head length of an arrow
the cgv namespace
Definition print.h:11
this reflection traits implementation is used for external self_reflect implementations of instances ...
float head_radius_scale
scaling factor of head radius with respect to tail radius
float radius_lower_bound
smallest value for the radius
base class for all render styles
Definition renderer.h:16