3#include "surface_renderer.h"
5#include "gl/lib_begin.h"
9 class CGV_API box_renderer;
15 extern CGV_API box_renderer&
ref_box_renderer(context& ctx,
int ref_count_change = 0);
21 vec3 default_extent = { 1.0f };
23 vec3 relative_anchor = { 0.0f };
25 bool rounding =
false;
27 float default_radius = 0.01f;
35 bool has_extents =
false;
37 bool has_radii =
false;
39 bool has_secondary_colors =
false;
41 bool has_translations =
false;
43 bool has_rotations =
false;
45 bool position_is_center =
true;
59 void set_position_is_center(
bool _position_is_center);
61 bool enable(
context& ctx)
override;
64 void set_extent(
const context& ctx,
const T& extent) { has_extents =
true; ref_prog().set_attribute(ctx, get_prog_attribute_location(ctx,
"extent"), extent); }
67 void set_extent_array(
const context& ctx,
const std::vector<T>& extents) { has_extents =
true; set_attribute_array(ctx,
"extent", extents); }
70 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); }
72 void remove_extent_array(
const context& ctx);
74 template <
typename T =
float>
75 void set_radius(
const context& ctx,
const T& radius) { has_radii =
true; ref_prog().set_attribute(ctx, ref_prog().get_attribute_location(ctx,
"radius"), radius); }
77 template <
typename T =
float>
78 void set_radius_array(
const context& ctx,
const std::vector<T>& radii) { has_radii =
true; set_attribute_array(ctx,
"radius", radii); }
80 template <
typename T =
float>
81 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); }
83 void remove_radius_array(
const context& ctx);
86 void set_secondary_color(
const context& ctx,
const T& color) { has_secondary_colors =
true; ref_prog().set_attribute(ctx,
"secondary_color", color); }
92 void set_secondary_color_array(
const context& ctx,
const T* colors,
size_t nr_elements,
unsigned stride_in_bytes = 0) { has_secondary_colors =
true; set_attribute_array(ctx,
"secondary_color", colors, nr_elements, stride_in_bytes); }
97 void set_secondary_color_array(
const context& ctx,
const vertex_buffer& vbo,
size_t offset_in_bytes,
size_t nr_elements,
unsigned stride_in_bytes = 0) {
set_secondary_color_array(ctx,
type_descriptor(
element_descriptor_traits<T>::get_type_descriptor(T()),
true), vbo, offset_in_bytes, nr_elements, stride_in_bytes); }
99 void remove_secondary_color_array(
const context& ctx);
101 template <
typename T>
105 set_position_is_center(
false);
108 template <
typename T>
110 set_composed_attribute_array(ctx,
"position", &boxes.front(), boxes.size(), boxes[0].get_min_pnt());
111 ref_composed_attribute_array(ctx,
"extent",
"position", &boxes.front(), boxes.size(), boxes[0].get_max_pnt());
112 has_positions =
true;
114 set_position_is_center(
false);
117 template <
typename T>
119 set_composed_attribute_array(ctx,
"position", boxes, count, boxes[0].get_min_pnt());
120 ref_composed_attribute_array(ctx,
"extent",
"position", boxes, count, boxes[0].get_max_pnt());
121 has_positions =
true;
123 set_position_is_center(
false);
126 template <
typename T>
127 void set_translation_array(
const context& ctx,
const std::vector<T>& translations) { has_translations =
true; set_attribute_array(ctx,
"translation", translations); }
129 template <
typename T>
130 void set_translation_array(
const context& ctx,
const T* translations,
size_t nr_elements,
unsigned stride_in_bytes = 0) { has_translations =
true; set_attribute_array(ctx,
"translation", translations, nr_elements, stride_in_bytes); }
132 void remove_translation_array(
const context& ctx);
134 template <
typename T>
135 void set_rotation_array(
const context& ctx,
const std::vector<T>& rotations) { has_rotations =
true; set_attribute_array(ctx,
"rotation", rotations); }
137 template <
typename T>
138 void set_rotation_array(
const context& ctx,
const T* rotations,
size_t nr_elements,
unsigned stride_in_bytes = 0) { has_rotations =
true; set_attribute_array(ctx,
"rotation", rotations, nr_elements, stride_in_bytes); }
140 void remove_rotation_array(
const context& ctx);
142 bool disable(
context& ctx)
override;
144 void draw(
context& ctx,
size_t start,
size_t count,
145 bool use_strips =
false,
bool use_adjacency =
false, uint32_t strip_restart_index = -1)
override;
155#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 point splatting
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_extent_array(const context &ctx, const std::vector< T > &extents)
extent array specifies box extends in case of position_is_center=true, otherwise the maximum point of...
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...
void set_secondary_color_array(const context &ctx, const vertex_buffer &vbo, size_t offset_in_bytes, size_t nr_elements, unsigned stride_in_bytes=0)
template method to set the secondary color attribute from a vertex buffer object, the element type mu...
void set_box(const context &ctx, const cgv::media::axis_aligned_box< T, 3 > &box)
specify a single box. This sets position_is_center to false as well as position and extent attributes
void set_secondary_color_array(const context &ctx, const T *colors, size_t nr_elements, unsigned stride_in_bytes=0)
template method to set the secondary color attribute from a vector of colors of type T
void set_secondary_color_array(const context &ctx, type_descriptor element_type, const vertex_buffer &vbo, size_t offset_in_bytes, size_t nr_elements, unsigned stride_in_bytes=0)
method to set the secondary color attribute from a vertex buffer object, the element type must be giv...
void set_secondary_color(const context &ctx, const T &color)
templated method to set the secondary color attribute from a single color of type T
void set_rotation_array(const context &ctx, const T *rotations, size_t nr_elements, unsigned stride_in_bytes=0)
template method to set the rotation from a vector of quaternions of type T, which should have 4 compo...
void set_extent(const context &ctx, const T &extent)
specify a single extent for all boxes
void set_translation_array(const context &ctx, const T *translations, size_t nr_elements, unsigned stride_in_bytes=0)
template method to set the translations from a vector of vectors of type T, which should have 3 compo...
void set_secondary_color_array(const context &ctx, const std::vector< T > &colors)
template method to set the secondary color attribute from a vector of colors of type T
render_style * create_render_style() const override
create and return the default render style
std::string get_default_prog_name() const override
return the default shader program name
void set_extent_array(const context &ctx, const T *extents, size_t nr_elements, unsigned stride_in_bytes=0)
extent array specifies box extends in case of position_is_center=true, otherwise the maximum point of...
void set_box_array(const context &ctx, const std::vector< cgv::media::axis_aligned_box< T, 3 > > &boxes)
specify box array directly. This sets position_is_center to false as well as position and extent arra...
void set_box_array(const context &ctx, const cgv::media::axis_aligned_box< T, 3 > *boxes, size_t count)
specify box array directly. This sets position_is_center to false as well as position and extent arra...
base class for all drawables, which is independent of the used rendering API.
Stores preprocessor options used for conditionally compiling shader programs.
base classes for renderers that support surface rendering
a vertex buffer is an unstructured memory block on the GPU.
box_renderer & ref_box_renderer(context &ctx, int ref_count_change)
reference to a singleton box renderer that is shared among drawables
this reflection traits implementation is used for external self_reflect implementations of instances ...
boxes use surface render styles
base class for all render styles
compact type description of data that can be sent to the context; convertible to int