cgv
Loading...
Searching...
No Matches
slab_renderer.h
1#pragma once
2
3#include "group_renderer.h"
4
5#include "gl/lib_begin.h"
6
7namespace cgv { // @<
8 namespace render { // @<
9 class CGV_API slab_renderer;
10
12
15 extern CGV_API slab_renderer& ref_slab_renderer(context& ctx, int ref_count_change = 0);
16
24 struct CGV_API slab_render_style : public group_render_style
25 {
35 int tf_source_channel;
41 float step_size;
43 float opacity;
49 float scale;
52 };
53
55 class CGV_API slab_renderer : public group_renderer
56 {
57 protected:
69 render_style* create_render_style() const;
71 bool build_shader_program(context& ctx, shader_program& prog, const shader_define_map& defines);
72 public:
76 void enable_attribute_array_manager(const context& ctx, attribute_array_manager& aam);
78 void disable_attribute_array_manager(const context& ctx, attribute_array_manager& aam);
80 void set_position_is_center(bool _position_is_center);
82 bool enable(context& ctx);
84 template <typename T>
85 void set_extent(const context& ctx, const T& extent) { has_extents = true; ref_prog().set_attribute(ctx, get_prog_attribute_location(ctx, "extent"), extent); }
87 template <typename T>
88 void set_extent_array(const context& ctx, const std::vector<T>& extents) { has_extents = true; set_attribute_array(ctx, "extent", extents); }
90 template <typename T>
91 void set_extent_array(const context& ctx, const T* extents, size_t nr_elements, unsigned stride_in_bytes = 0) { has_extents = true; set_attribute_array(ctx, "extent", extents, nr_elements, stride_in_bytes); }
93 template <typename T>
94 void set_box_array(const context& ctx, const std::vector<cgv::media::axis_aligned_box<T, 3> >& box) {
95 set_composed_attribute_array(ctx, "position", &box.front(), box.size(), box[0].get_min_pnt());
96 ref_composed_attribute_array(ctx, "extent", "position", &box.front(), box.size(), box[0].get_max_pnt());
97 has_positions = true;
98 has_extents = true;
99 set_position_is_center(false);
100 }
102 template <typename T>
103 void set_box_array(const context& ctx, const cgv::media::axis_aligned_box<T, 3>* box, size_t count) {
104 set_composed_attribute_array(ctx, "position", box, count, box[0].get_min_pnt());
105 ref_composed_attribute_array(ctx, "extent", "position", box, count, box[0].get_max_pnt());
106 has_positions = true;
107 has_extents = true;
108 set_position_is_center(false);
109 }
111 template <typename T>
112 void set_translation_array(const context& ctx, const std::vector<T>& translations) { has_translations = true; set_attribute_array(ctx, "translation", translations); }
114 template <typename T>
115 void set_translation_array(const context& ctx, const T* translations, size_t nr_elements, unsigned stride) { has_translations = true; set_attribute_array(ctx, "translation", translations, nr_elements, stride); }
117 template <typename T>
118 void set_rotation_array(const context& ctx, const std::vector<T>& rotations) { has_rotations = true; set_attribute_array(ctx, "rotation", rotations); }
120 template <typename T>
121 void set_rotation_array(const context& ctx, const T* rotations, size_t nr_elements, unsigned stride) { has_rotations = true; set_attribute_array(ctx, "rotation", rotations, nr_elements, stride); }
123 template <typename T>
124 void set_texture_index_array(const context& ctx, const std::vector<T>& texture_indices) { has_texture_indices = true; set_attribute_array(ctx, "texture_index", texture_indices); }
126 template <typename T>
127 void set_texture_index_array(const context& ctx, const T* texture_indices, size_t nr_elements, unsigned stride_in_bytes = 0) { has_texture_indices = true; set_attribute_array(ctx, "texture_index", texture_indices, nr_elements, stride_in_bytes); }
129 bool validate_attributes(const context& ctx) const;
131 bool disable(context& ctx);
133 void draw(context& ctx, size_t start, size_t count,
134 bool use_strips = false, bool use_adjacency = false, uint32_t strip_restart_index = -1);
135 };
136
138 {
139 bool self_reflect(cgv::reflect::reflection_handler& rh);
140 };
142 }
143}
144
145#include <cgv/config/lib_end.h>
An axis aligned box, defined by to points: min and max.
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
abstract renderer class that provides functionality for grouping primitives
a shader program combines several shader code fragments to a complete definition of the shading pipel...
renderer that supports point splatting
void set_translation_array(const context &ctx, const T *translations, size_t nr_elements, unsigned stride)
template method to set the translations from a vector of vectors of type T, which should have 3 compo...
bool has_extents
store whether extent array has been specified
void set_texture_index_array(const context &ctx, const std::vector< T > &texture_indices)
extent array specifies slab extends in case of position_is_center=true, otherwise the maximum point o...
bool has_texture_indices
whether array with per slab texture index has been specified
void set_box_array(const context &ctx, const std::vector< cgv::media::axis_aligned_box< T, 3 > > &box)
specify box array directly. This sets position_is_center to false as well as position and extent arra...
void set_translation_array(const context &ctx, const std::vector< T > &translations)
template method to set the translations from a vector of vectors of type T, which should have 3 compo...
void set_rotation_array(const context &ctx, const std::vector< T > &rotations)
template method to set the rotation from a vector of quaternions of type T, which should have 4 compo...
bool has_translations
whether array with per slab translations has been specified
void set_extent(const context &ctx, const T &extent)
specify a single extent for all slabs
bool position_is_center
whether position is slab center, if not it is lower left bottom corner
void set_box_array(const context &ctx, const cgv::media::axis_aligned_box< T, 3 > *box, size_t count)
specify box array directly. This sets position_is_center to false as well as position and extent arra...
void set_extent_array(const context &ctx, const std::vector< T > &extents)
extent array specifies slab extends in case of position_is_center=true, otherwise the maximum point o...
void set_texture_index_array(const context &ctx, const T *texture_indices, size_t nr_elements, unsigned stride_in_bytes=0)
extent array specifies slab extends in case of position_is_center=true, otherwise the maximum point o...
void set_extent_array(const context &ctx, const T *extents, size_t nr_elements, unsigned stride_in_bytes=0)
extent array specifies slab extends in case of position_is_center=true, otherwise the maximum point o...
bool has_rotations
whether array with per slab rotations has been specified
void set_rotation_array(const context &ctx, const T *rotations, size_t nr_elements, unsigned stride)
template method to set the rotation from a vector of quaternions of type T, which should have 4 compo...
std::map< std::string, std::string > shader_define_map
typedef for shader define map data structure
Definition shader_code.h:52
slab_renderer & ref_slab_renderer(context &ctx, int ref_count_change)
reference to a singleton slab 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 ...
render style used for group information
base class for all render styles
Definition renderer.h:16
float falloff_mix
overall influence of the falloff
float opacity
multiplied to the input opacity value during rendering to change the overall opacity of the slabs
float falloff_strength
strength of the opacity falloff in the slabs normal direction
int tf_tex_unit
unit used to access the volume transfer function texture, initialized to 1, must be a 1d texture
float step_size
constant step size for volume ray integration over all slabs
int tex_idx_offset
used to offset the texture index of each slab when specified
float scale
compensates for the overall slab scale
int tex_unit
unit used to access the slab texture values, initialized to 0, must point to a 2d texture array
bool use_transfer_function
whether to use a transfer function or interpret the luminance as alpha, initialized to false
float thickness_scale
multiplied to the thickness, initialized to 1
int tex_idx_stride
multiplied to the texture index of each slab