cgv
Loading...
Searching...
No Matches
ellipsoid_render_data.h
1#pragma once
2
3#include "ellipsoid_renderer.h"
4#include "render_data_base.h"
5
6namespace cgv {
7namespace render {
8
11template <typename ColorType = rgb>
12class ellipsoid_render_data : public render_data_base<ellipsoid_renderer, ellipsoid_render_style, ColorType> {
13private:
14 // Base class we're going to use virtual functions from
16
17 ellipsoid_renderer& ref_renderer_singleton(context& ctx, int ref_count_change = 0) override {
18 return ref_ellipsoid_renderer(ctx, ref_count_change);
19 }
20
21protected:
23 bool transfer(context& ctx, ellipsoid_renderer& r) override {
24 if(super::transfer(ctx, r)) {
25 CGV_RDB_TRANSFER_ARRAY(size, sizes);
26 CGV_RDB_TRANSFER_ARRAY(orientation, orientations);
27 return true;
28 }
29 return false;
30 }
31
32public:
34 std::vector<cgv::vec3> sizes;
36 std::vector<cgv::quat> orientations;
37
38 void clear() {
40 sizes.clear();
41 orientations.clear();
42 }
43
44 void add_size(const cgv::vec3& size) {
45 sizes.push_back(size);
46 }
47
48 void add_orientation(const cgv::quat& orientation) {
49 orientations.push_back(orientation);
50 }
51
52 // Explicitly use add from the base class since it is shadowed by the overloaded versions
53 using super::add;
54
55 void add(const vec3& position, const cgv::vec3& size) {
56 super::add_position(position);
57 add_size(size);
58 }
59
60 void add(const vec3& position, const ColorType& color, const cgv::vec3& size) {
61 super::add(position, color);
62 add_size(size);
63 }
64
65 void add(const vec3& position, const cgv::vec3& size, const quat& rotation) {
66 add(position, size);
67 add_size(size);
68 add_orientation(orientation);
69 }
70
71 void add(const vec3& position, const ColorType& color, const cgv::vec3& size, const quat& rotation) {
72 super::add(position, color);
73 add_size(size);
74 add_orientation(orientation);
75 }
76
77 void fill_sizes(const cgv::vec3& size) {
79 }
80};
81
82}
83}
base class for all drawables, which is independent of the used rendering API.
Definition context.h:621
Render data for ellipsoid geometry with support for the ellipsoid_renderer.
bool transfer(context &ctx, ellipsoid_renderer &r) override
See render_data_base::transfer.
std::vector< cgv::quat > orientations
array of orientations
std::vector< cgv::vec3 > sizes
array of sizes
renderer that supports splatting of ellipsoids
A base class for storing render data and style usable with the default renderers provided in the cgv:...
size_t size()
Return the number of stored positions.
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.
ellipsoid_renderer & ref_ellipsoid_renderer(context &ctx, int ref_count_change)
reference to a singleton ellipsoid renderer that can be shared among drawables
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