cgv
Loading...
Searching...
No Matches
box_render_data_base.h
1#pragma once
2
3#include "render_data_base.h"
4
5namespace cgv {
6namespace render {
7
12template <class RendererType, class RenderStyleType, typename ColorType = rgb>
13class box_render_data_base : public render_data_base<RendererType, RenderStyleType, ColorType> {
14private:
15 // Base class we're going to use virtual functions from
17
18protected:
20 bool transfer(context& ctx, RendererType& r) override {
21 if(super::transfer(ctx, r)) {
22 CGV_RDB_TRANSFER_ARRAY(extent, extents);
23 CGV_RDB_TRANSFER_ARRAY(translation, translations);
24 CGV_RDB_TRANSFER_ARRAY(rotation, rotations);
25 return true;
26 }
27 return false;
28 }
29
30public:
32 std::vector<vec3> extents;
34 std::vector<vec3> translations;
36 std::vector<quat> rotations;
37
38 void clear() {
40 extents.clear();
41 translations.clear();
42 rotations.clear();
43 }
44
45 void add_extent(const vec3& extent) {
46 extents.push_back(extent);
47 }
48
49 void add_translation(const vec3& translation) {
50 translations.push_back(translation);
51 }
52
53 void add_rotation(const quat& rotation) {
54 rotations.push_back(rotation);
55 }
56
57 // Explicitly use add from the base class since it is shadowed by the overloaded versions
58 using super::add;
59
60 void add(const vec3& position, const vec3& extent) {
61 super::add_position(position);
62 add_extent(extent);
63 }
64
65 void add(const vec3& position, const vec3& extent, const quat& rotation) {
66 super::add_position(position);
67 add_extent(extent);
68 add_rotation(rotation);
69 }
70
71 void add(const vec3& position, const vec3& extent, const ColorType& color) {
72 add(position, extent);
73 super::add_color(color);
74 }
75
76 void add(const vec3& translation, const quat& rotation) {
77 add_translation(translation);
78 add_rotation(rotation);
79 }
80
81 void fill_extents(const vec3& extent) {
82 super::fill(extents, extent);
83 }
84
85 void fill_translations(const vec3& translation) {
86 super::fill(translations, translation);
87 }
88
89 void fill_rotations(const quat& rotation) {
90 super::fill(rotations, rotation);
91 }
92};
93
94}
95}
A base class for storing render data usable with the box_renderer and box_wire_renderer.
std::vector< quat > rotations
array of rotations
std::vector< vec3 > translations
array of translations
std::vector< vec3 > extents
array of extents
bool transfer(context &ctx, RendererType &r) override
See render_data_base::transfer.
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.
the cgv namespace
Definition print.h:11
cgv::math::quaternion< float > quat
declare type of quaternion
Definition quaternion.h:370
cgv::math::fvec< float, 3 > vec3
declare type of 3d single precision floating point vectors
Definition fvec.h:669