cgv
Loading...
Searching...
No Matches
sphere_render_data.h
1#pragma once
2
3#include "sphere_renderer.h"
4#include "render_data_base.h"
5
6namespace cgv {
7namespace render {
8
11template <typename ColorType = rgb>
12class sphere_render_data : public render_data_base<sphere_renderer, sphere_render_style, ColorType> {
13private:
14 // Base class we're going to use virtual functions from
16
17 sphere_renderer& ref_renderer_singleton(context& ctx, int ref_count_change = 0) override {
18 return ref_sphere_renderer(ctx, ref_count_change);
19 }
20
21protected:
23 bool transfer(context& ctx, sphere_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 // Explicitly use add from the base class since it is shadowed by the overloaded versions
45 using super::add;
46
47 void add(const vec3& position, const float radius) {
48 super::add_position(position);
49 add_radius(radius);
50 }
51
52 void add(const vec3& position, const ColorType& color, const float radius) {
53 super::add(position, color);
54 add_radius(radius);
55 }
56
57 void fill_radii(const float radius) {
58 super::fill(radii, radius);
59 }
60};
61
62}
63}
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.
Render data for sphere geometry with support for the sphere_renderer.
bool transfer(context &ctx, sphere_renderer &r) override
See render_data_base::transfer.
std::vector< float > radii
array of radii
renderer that supports splatting of spheres
sphere_renderer & ref_sphere_renderer(context &ctx, int ref_count_change)
reference to a singleton sphere 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