cgv
arrow_renderer.h
1 #pragma once
2 
3 #include "surface_renderer.h"
4 
5 #include "gl/lib_begin.h"
6 
7 namespace 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 
18  struct CGV_API arrow_render_style : public surface_render_style
19  {
20  /*@name arrow rendering attributes*/
22  float radius_lower_bound;
25  float radius_relative_to_length;
29  float head_length_relative_to_radius;
31  float head_length_relative_to_length;
33  float length_scale;
35  float color_scale;
37  bool normalize_length;
39  float relative_location_of_position;
41  float length_eps;
43  float inner_outer_lambda;
45  int nr_subdivisions;
49  };
50 
52  class CGV_API arrow_renderer : public surface_renderer
53  {
54  protected:
55  bool has_directions;
56  bool position_is_center;
57  bool direction_is_end_point;
59  render_style* create_render_style() const;
60  public:
64  void enable_attribute_array_manager(const context& ctx, attribute_array_manager& aam);
66  void disable_attribute_array_manager(const context& ctx, attribute_array_manager& aam);
68  template <typename T>
69  void set_direction_array(const context& ctx, const std::vector<T>& directions) { has_directions = true; direction_is_end_point = false; set_attribute_array(ctx, ref_prog().get_attribute_location(ctx, "direction"), directions); }
71  template <typename T>
72  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, ref_prog().get_attribute_location(ctx, "direction"), directions, nr_elements, stride_in_bytes); }
74  template <typename T>
75  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, ref_prog().get_attribute_location(ctx, "direction"), end_points); }
77  template <typename T>
78  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, ref_prog().get_attribute_location(ctx, "direction"), end_points, nr_elements, stride_in_bytes); }
80  bool init(context& ctx);
82  bool validate_attributes(const context& ctx) const;
84  bool enable(context& ctx);
86  bool disable(context& ctx);
88  void draw(context& ctx, size_t start, size_t count,
89  bool use_strips = false, bool use_adjacency = false, uint32_t strip_restart_index = -1);
90  };
91  struct CGV_API arrow_render_style_reflect : public arrow_render_style
92  {
93  bool self_reflect(cgv::reflect::reflection_handler& rh);
94  };
95  extern CGV_API cgv::reflect::extern_reflection_traits<arrow_render_style, arrow_render_style_reflect> get_reflection_traits(const arrow_render_style&);
96  }
97 }
98 
99 #include <cgv/config/lib_end.h>
cgv::render::render_style
base class for all render styles
Definition: renderer.h:16
cgv::render::arrow_render_style::head_radius_scale
float head_radius_scale
scaling factor of head radius with respect to tail radius
Definition: arrow_renderer.h:27
cgv::render::arrow_renderer::set_end_point_array
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,...
Definition: arrow_renderer.h:78
cgv::render::arrow_renderer::set_end_point_array
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,...
Definition: arrow_renderer.h:75
cgv::render::surface_render_style
Definition: surface_renderer.h:26
cgv::render::attribute_array_manager
attribute array manager used to upload arrays to gpu
Definition: renderer.h:21
cgv::reflect::reflection_handler
Definition: reflection_handler.h:63
cgv::render::arrow_renderer::set_direction_array
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,...
Definition: arrow_renderer.h:72
cgv::render::arrow_renderer::set_direction_array
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,...
Definition: arrow_renderer.h:69
cgv::render::ref_arrow_renderer
arrow_renderer & ref_arrow_renderer(context &ctx, int ref_count_change)
reference to a singleton surfel renderer that can be shared among drawables
Definition: arrow_renderer.cxx:7
cgv::render::arrow_renderer
renderer that supports point splatting
Definition: arrow_renderer.h:53
cgv::render::surface_renderer
base classes for renderers that support surface rendering
Definition: surface_renderer.h:43
cgv::reflect::extern_reflection_traits
this reflection traits implementation is used for external self_reflect implementations of instances ...
Definition: reflect_extern.h:28
cgv
the cgv namespace
Definition: vr_calib.cxx:9
cgv::render::context
Definition: context.h:525
cgv::render::arrow_render_style
Definition: arrow_renderer.h:19