cgv
Loading...
Searching...
No Matches
ellipsoid_renderer.h
1#pragma once
2
3#include "surface_renderer.h"
4
5#include "gl/lib_begin.h"
6
7namespace cgv { // @<
8 namespace render { // @<
9 class CGV_API ellipsoid_renderer;
10
12
15 extern CGV_API ellipsoid_renderer& ref_ellipsoid_renderer(context& ctx, int ref_count_change = 0);
16
19 {
20 /*@name ellipsoid rendering attributes*/
22
27
30 };
31
33 class CGV_API ellipsoid_renderer : public surface_renderer
34 {
35 protected:
36 bool has_sizes;
37 bool has_orientations;
39 render_style* create_render_style() const;
41 bool build_shader_program(context& ctx, shader_program& prog, const shader_define_map& defines);
42 public:
46 void enable_attribute_array_manager(const context& ctx, attribute_array_manager& aam);
48 void disable_attribute_array_manager(const context& ctx, attribute_array_manager& aam);
50 template <typename T = float>
51 void set_size(const context& ctx, const T& size) {
52 has_sizes = true;
53 ref_prog().set_attribute(ctx, ref_prog().get_attribute_location(ctx, "size"), size);
54 }
56 template <typename T = float>
57 void set_size_array(const context& ctx, const std::vector<T>& sizes) {
58 has_sizes = true;
59 set_attribute_array(ctx, "size", sizes);
60 }
62 template <typename T>
63 void set_size_array(const context& ctx, const T* sizes, size_t nr_elements, unsigned stride_in_bytes = 0) {
64 has_sizes = true;
65 set_attribute_array(ctx, "size", sizes, nr_elements, stride_in_bytes);
66 }
68 void remove_size_array(const context& ctx);
70 template <typename T = float>
71 void set_orientation(const context& ctx, const cgv::math::quaternion<T>& orientation) {
72 has_orientations = true;
73 ref_prog().set_attribute(ctx, ref_prog().get_attribute_location(ctx, "orientation"), orientation);
74 }
76 template <typename T = float>
77 void set_orientation_array(const context& ctx, const std::vector<cgv::math::quaternion<T>>& orientations) {
78 has_orientations = true;
79 set_attribute_array(ctx, "orientation", orientations);
80 }
82 template <typename T>
83 void set_orientation_array(const context& ctx, const T* orientations, size_t nr_elements, unsigned stride_in_bytes = 0) {
84 has_orientations = true;
85 set_attribute_array(ctx, "orientation", orientations, nr_elements, stride_in_bytes);
86 }
88 void remove_orientation_array(const context& ctx);
90 bool validate_attributes(const context& ctx) const;
92 bool enable(context& ctx);
94 bool disable(context& ctx);
96 void draw(context& ctx, size_t start, size_t count,
97 bool use_strips = false, bool use_adjacency = false, uint32_t strip_restart_index = -1);
98 };
99
101 {
102 bool self_reflect(cgv::reflect::reflection_handler& rh);
103 };
105 }
106}
107
108
109#include <cgv/config/lib_end.h>
implements a quaternion.
Definition quaternion.h:21
the self reflection handler is passed to the virtual self_reflect() method of cgv::base::base.
attribute array manager used to upload arrays to gpu
base class for all drawables, which is independent of the used rendering API.
Definition context.h:621
renderer that supports splatting of ellipsoids
void set_orientation_array(const context &ctx, const std::vector< cgv::math::quaternion< T > > &orientations)
use this function if you store spheres in vec4 with the 4th component the radius
a shader program combines several shader code fragments to a complete definition of the shading pipel...
base classes for renderers that support surface rendering
std::map< std::string, std::string > shader_define_map
typedef for shader define map data structure
Definition shader_code.h:52
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
this reflection traits implementation is used for external self_reflect implementations of instances ...
render style for ellipsoid rendere
cgv::vec3 size
default value assigned to size attribute in enable method of ellipsoid renderer, set to 1 in construc...
float size_scale
multiplied to the ellipsoid sizes, initialized to 1
base class for all render styles
Definition renderer.h:16