cgv
Loading...
Searching...
No Matches
cone_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
10 class CGV_API cone_renderer;
11
13
17 extern CGV_API cone_renderer& ref_cone_renderer(context& ctx, int ref_count_change = 0);
19 {
22
24 float radius;
25
26 bool show_caps;
27 bool rounded_caps;
28
29 bool enable_texturing;
30 enum TextureBlendMode {
31 TBM_MIX = 0,
32 TBM_TINT = 1,
33 TBM_MULTIPLY = 2,
34 TBM_INVERSE_MULTIPLY = 3,
35 TBM_ADD = 4,
36 } texture_blend_mode;
37 float texture_blend_factor;
38 bool texture_tile_from_center;
39 vec2 texture_offset;
40 vec2 texture_tiling;
41 bool texture_use_reference_length;
42 float texture_reference_length;
43
44 bool enable_ambient_occlusion;
45 float ao_offset;
46 float ao_distance;
47 float ao_strength;
48
49 vec3 tex_offset;
50 vec3 tex_scaling;
51 vec3 tex_coord_scaling;
52 float texel_size;
53 float cone_angle_factor;
54 std::vector<vec3> sample_dirs;
55
58 };
59
61 class CGV_API cone_renderer : public surface_renderer
62 {
63 protected:
64 bool has_radii;
68 render_style* create_render_style() const;
70 void update_defines(shader_define_map& defines);
72 bool build_shader_program(context& ctx, shader_program& prog, const shader_define_map& defines);
73
74 texture* albedo_texture;
75 texture* density_texture;
76
77 public:
81 void enable_attribute_array_manager(const context& ctx, attribute_array_manager& aam);
83 void disable_attribute_array_manager(const context& ctx, attribute_array_manager& aam);
84 bool set_albedo_texture(texture* tex);
85 bool set_density_texture(texture* tex);
87 bool enable(context& ctx);
89 template <typename T = float>
90
91 void set_radius_array(const context& ctx, const std::vector<T>& radii) { has_radii = true; set_attribute_array(ctx, "radius", radii); }
93 template <typename T = float>
94 void set_radius_array(const context& ctx, const T* radii, size_t nr_elements, unsigned stride_in_bytes = 0) { has_radii = true; set_attribute_array(ctx, "radius", radii, nr_elements, stride_in_bytes); }
96 void remove_radius_array(const context& ctx);
98 template <typename T = float>
99 void set_sphere_array(const context& ctx, const std::vector<cgv::math::fvec<T, 4> >& spheres) {
100 set_composed_attribute_array(ctx, "position", &spheres.front(), spheres.size(), reinterpret_cast<const cgv::math::fvec<T, 3>&>(spheres.front()));
101 ref_composed_attribute_array(ctx, "radius", "position", &spheres.front(), spheres.size(), spheres[0][3]);
102 has_positions = true;
103 has_radii = true;
104 }
106 bool validate_attributes(const context& ctx) const;
108 bool disable(context& ctx);
110 void draw(context& ctx, size_t start, size_t count,
111 bool use_strips = false, bool use_adjacency = false, uint32_t strip_restart_index = -1);
113 virtual void clear(const context& ctx);
114 };
115
117 {
118 bool self_reflect(cgv::reflect::reflection_handler& rh);
119 };
120
122 }
123}
124
125#include <cgv/config/lib_end.h>
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
renderer that supports raycasting of cones
void set_sphere_array(const context &ctx, const std::vector< cgv::math::fvec< T, 4 > > &spheres)
use this function if you store spheres in vec4 with the 4th component the radius
shader_define_map shader_defines
the shader defines used to build the shader, used to comapre against new defines to determine if the ...
base class for all drawables, which is independent of the used rendering API.
Definition context.h:621
a shader program combines several shader code fragments to a complete definition of the shading pipel...
base classes for renderers that support surface rendering
the texture class encapsulates all functionality independent of the rendering api.
Definition texture.h:15
std::map< std::string, std::string > shader_define_map
typedef for shader define map data structure
Definition shader_code.h:52
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
this reflection traits implementation is used for external self_reflect implementations of instances ...
float radius
default value assigned to radius attribute in enable method of cone renderer, set to 1 in constructor
float radius_scale
multiplied to the sphere radii, initialized to 1
base class for all render styles
Definition renderer.h:16