cgv
Loading...
Searching...
No Matches
arrow_render_data.h
1#pragma once
2
3#include "arrow_renderer.h"
4#include "render_data_base.h"
5
6namespace cgv {
7namespace render {
8
9template <typename ColorType = rgb>
10class arrow_render_data : public render_data_base<arrow_renderer, arrow_render_style, ColorType> {
11private:
12 // Base class we're going to use virtual functions from
14
15 arrow_renderer& ref_renderer_singleton(context& ctx, int ref_count_change = 0) override {
16 return ref_arrow_renderer(ctx, ref_count_change);
17 }
18
19protected:
21 bool transfer(context& ctx, arrow_renderer& r) override {
22 if(super::transfer(ctx, r)) {
24 CGV_RDB_TRANSFER_ARRAY(end_point, directions);
25 } else {
26 CGV_RDB_TRANSFER_ARRAY(direction, directions);
27 }
28 return true;
29 }
30 return false;
31 }
32
33public:
35 std::vector<vec3> directions;
38
39 void clear() {
41 directions.clear();
42 }
43
44 void add_direction(const vec3& direction) {
45 directions.push_back(direction);
46 }
47
48 // Explicitly use add from the base class since it is shadowed by the overloaded versions
49 using super::add;
50
51 void add(const vec3& position, const vec3& direction) {
52 super::add_position(position);
53 add_direction(direction);
54 }
55
56 void add(const vec3& position, const ColorType& color, const vec3& direction) {
57 super::add(position, color);
58 add_direction(direction);
59 }
60
61 void fill_directions(const vec3& direction) {
62 super::fill(directions, direction);
63 }
64};
65
66}
67}
bool transfer(context &ctx, arrow_renderer &r) override
See render_data_base::transfer.
bool direction_is_end_point
whether to interpret the direction attribute as the arrow end point position
std::vector< vec3 > directions
array of directions
renderer that supports point splatting
base class for all drawables, which is independent of the used rendering API.
Definition context.h:621
A base class for storing render data and style usable with the default renderers provided in the cgv:...
virtual bool transfer(context &ctx, RendererType &r)
Transfers the data stored in members to the attribute array.
void clear()
Clear the stored data and set state out of date.
void fill(std::vector< T > &vector, const T &value)
Template for filling a member array to the size of the render data.
arrow_renderer & ref_arrow_renderer(context &ctx, int ref_count_change)
reference to a singleton surfel renderer that can be shared among drawables
the cgv namespace
Definition print.h:11
cgv::math::fvec< float, 3 > vec3
declare type of 3d single precision floating point vectors
Definition fvec.h:669