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);
25 bool rounding =
false;
27 float default_radius = 0.01f;
62 void set_position_is_center(
bool _position_is_center);
67 void set_extent(
const context& ctx,
const T& extent) { has_extents =
true; ref_prog().set_attribute(ctx, get_prog_attribute_location(ctx,
"extent"), extent); }
70 void set_extent_array(
const context& ctx,
const std::vector<T>& extents) { has_extents =
true; set_attribute_array(ctx,
"extent", extents); }
73 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); }
75 void remove_extent_array(
const context& ctx);
77 template <
typename T =
float>
78 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); }
80 template <
typename T =
float>
81 void set_radius_array(
const context& ctx,
const std::vector<T>& radii) { has_radii =
true; set_attribute_array(ctx,
"radius", radii); }
83 template <
typename T =
float>
84 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); }
86 void remove_radius_array(
const context& ctx);
89 void set_secondary_color(
const context& ctx,
const T& color) { has_secondary_colors =
true; ref_prog().set_attribute(ctx,
"secondary_color", color); }
95 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); }
100 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); }
102 void remove_secondary_color_array(
const context& ctx);
104 template <
typename T>
108 set_position_is_center(
false);
111 template <
typename T>
113 set_composed_attribute_array(ctx,
"position", &boxes.front(), boxes.size(), boxes[0].get_min_pnt());
114 ref_composed_attribute_array(ctx,
"extent",
"position", &boxes.front(), boxes.size(), boxes[0].get_max_pnt());
115 has_positions =
true;
117 set_position_is_center(
false);
120 template <
typename T>
122 set_composed_attribute_array(ctx,
"position", boxes, count, boxes[0].get_min_pnt());
123 ref_composed_attribute_array(ctx,
"extent",
"position", boxes, count, boxes[0].get_max_pnt());
124 has_positions =
true;
126 set_position_is_center(
false);
129 template <
typename T>
130 void set_translation_array(
const context& ctx,
const std::vector<T>& translations) { has_translations =
true; set_attribute_array(ctx,
"translation", translations); }
132 template <
typename T>
133 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); }
135 void remove_translation_array(
const context& ctx);
137 template <
typename T>
138 void set_rotation_array(
const context& ctx,
const std::vector<T>& rotations) { has_rotations =
true; set_attribute_array(ctx,
"rotation", rotations); }
140 template <
typename T>
141 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); }
143 void remove_rotation_array(
const context& ctx);
147 void draw(
context& ctx,
size_t start,
size_t count,
148 bool use_strips =
false,
bool use_adjacency =
false, uint32_t strip_restart_index = -1);
158#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...
bool has_translations
whether array with per box translations has been specified
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
bool has_rotations
whether array with per box rotations has been specified
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
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...
bool has_radii
store whether extent array has been specified
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...
bool has_secondary_colors
whether secondary color or color array was set
bool position_is_center
whether position is box center, if not it is lower left bottom corner
bool has_extents
store whether extent array has been specified
base class for all drawables, which is independent of the used rendering API.
a shader program combines several shader code fragments to a complete definition of the shading pipel...
base classes for renderers that support surface rendering
a vertex buffer is an unstructured memory block on the GPU.
std::map< std::string, std::string > shader_define_map
typedef for shader define map data structure
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
vec3 default_extent
extent used in case extent array is not specified
vec3 relative_anchor
box anchor position relative to center that corresponds to the position attribute
base class for all render styles
compact type description of data that can be sent to the context; convertible to int