cgv
Loading...
Searching...
No Matches
cone_render_data.h
1#pragma once
2
3#include "cone_renderer.h"
4#include "render_data_base.h"
5
6namespace cgv {
7namespace render {
8
11template <typename ColorType = rgb>
12class cone_render_data : public render_data_base<cone_renderer, cone_render_style, ColorType> {
13private:
14 // Base class we're going to use virtual functions from
16
17 cone_renderer& ref_renderer_singleton(context& ctx, int ref_count_change = 0) override {
18 return ref_cone_renderer(ctx, ref_count_change);
19 }
20
21protected:
23 bool transfer(context& ctx, cone_renderer& r) override {
24 if(super::transfer(ctx, r)) {
25 CGV_RDB_TRANSFER_ARRAY(radius, radii);
26 return true;
27 }
28 return false;
29 }
30
31public:
33 std::vector<float> radii;
34
35 void clear() {
37 radii.clear();
38 }
39
40 void add_radius(const float radius) {
41 radii.push_back(radius);
42 }
43
44 void add_segment_radius(const float radius) {
45 add_radius(radius);
46 add_radius(radius);
47 }
48
49 void add_segment_color(const ColorType& color) {
50 super::add_color(color);
51 super::add_color(color);
52 }
53
54 // Explicitly use add from the base class since it is shadowed by the overloaded versions
55 using super::add;
56
57 void add(const vec3& start_position, const vec3& end_position) {
58 super::add_position(start_position);
59 super::add_position(end_position);
60 }
61
62 void add(const vec3& start_position, const vec3& end_position, const ColorType& color) {
63 add(start_position, end_position);
64 add_segment_color(color);
65 }
66
67 void add(const vec3& start_position, const vec3& end_position, const float radius) {
68 add(start_position, end_position);
69 add_segment_radius(radius);
70 }
71
72 void add(const vec3& start_position, const vec3& end_position, const ColorType& color, const float radius) {
73 add(start_position, end_position);
74 add_segment_color(color);
75 add_segment_radius(radius);
76 }
77
78 void add(const float start_radius, const float end_radius) {
79 add_radius(start_radius);
80 add_radius(end_radius);
81 }
82
83 void add(const ColorType& start_color, const ColorType& end_color) {
84 super::add_color(start_color);
85 super::add_color(end_color);
86 }
87
88 void fill_radii(const float radius) {
89 super::fill(radii, radius);
90 }
91};
92
93}
94}
Render data for cone geometry with support for the cone_renderer.
std::vector< float > radii
array of radii
bool transfer(context &ctx, cone_renderer &r) override
See render_data_base::transfer.
renderer that supports raycasting of cones
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.
cone_renderer & ref_cone_renderer(context &ctx, int ref_count_change)
reference to a singleton cone renderer that is 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