3#include "render_info.h"
4#include <cgv/media/mesh/simple_mesh.h>
56 cgv::media::ColorType
ct;
63 bool is_dynamic =
false;
72 uint32_t vbo_index = 0;
83 const attribute_map& attribute_to_vbo_index_map,
const std::vector<int>& dynamic_vbo_idx);
99 std::vector<idx4_type>&
unique_quadruples, std::vector<idx_type>& per_corner_vertex_index,
100 std::vector<idx_type>& edges_element_buffer, std::vector<idx_type>& triangles_element_buffer);
130 template <
typename T>
132 std::vector<idx_type>* tuple_pos_indices =
nullptr,
133 std::vector<idx_type>* tuple_normal_indices =
nullptr,
134 int* num_floats_in_vertex =
nullptr)
141 attribute_map va_vbo_idx = { { attribute_type::position, 0 } };
143 va_vbo_idx[attribute_type::texcoords] = 0;
145 va_vbo_idx[attribute_type::normal] = 0;
147 va_vbo_idx[attribute_type::tangent] = 0;
149 va_vbo_idx[attribute_type::color] = 0;
152 std::vector<idx_type> vertex_indices, edge_element_buffer, triangle_element_buffer;
157 if (tuple_pos_indices)
158 tuple_pos_indices->push_back(tuple[0]);
159 if (tuple_normal_indices)
160 tuple_normal_indices->push_back(tuple[2]);
162 std::vector<uint8_t> attrib_buffer;
165 ref_vbos().back()->create(ctx, attrib_buffer);
170 template <
typename T>
172 const attribute_map& va_vbo_idx,
const std::vector<int>& dynamic_vbo_idx)
180 bool keep_unique_quadrupels = !dynamic_vbo_idx.empty();
183 std::vector<idx4_type> tmp_unique_quadruples;
184 std::vector<idx4_type>& unique_quadruples_ref = keep_unique_quadrupels ?
unique_quadruples : tmp_unique_quadruples;
185 std::vector<idx_type> per_corner_vertex_index, edge_element_buffer, triangle_element_buffer;
186 construct_index_buffers(ctx, mesh, unique_quadruples_ref, per_corner_vertex_index, edge_element_buffer, triangle_element_buffer);
189 std::vector<uint8_t> attrib_buffer;
190 auto vca = vc.attributes;
193 ref_vbos().back()->create(ctx, attrib_buffer);
199 template <
typename T>
203 std::vector<uint8_t> attrib_buffer;
204 auto vca = vc.attributes;
206 ref_vbos()[vbo_index]->replace(ctx, 0, &attrib_buffer[0], attrib_buffer.size());
209 void set_nr_instances(
unsigned nr);
231 void draw_primitive(
cgv::render::context& ctx,
size_t primitive_index,
bool skip_opaque =
false,
bool skip_blended =
false,
bool use_materials =
true);
244#include <cgv/config/lib_end.h>
A vector with zero based index.
base class for all drawables, which is independent of the used rendering API.
cgv::math::fvec< idx_type, 3 > idx3_type
index triple type
size_t get_nr_edge_elements() const
Returns how many edge-indices are recorded in the element buffer.
size_t get_material_index(size_t i) const
return material index of i-th fragment
std::vector< idx3_type > material_primitive_start
index triple storing the material index, the primitive index and the offset (element index) in the tr...
std::vector< idx4_type > unique_quadruples
in case that at least one vbo is replaceable, store per vertex the unique quadruple of attribute indi...
size_t get_nr_fragments() const
return number of mesh fragments that are of distinct primitive and material
void update_vbo(cgv::render::context &ctx, cgv::media::mesh::simple_mesh< T > &mesh, int vbo_index)
replace the content of one vbo from a mesh
bool is_bound() const
check whether attribute array binding is bound
std::map< attribute_type, attribute_configuration > per_attribute_vbo_config
for each mesh attribute that is used, map attribute type to the vbo index
std::vector< vbo_configuration > vbo_config
store for each vbo its configuration
size_t get_primitive_index(size_t i) const
return group index of i-th fragment
cgv::render::type_descriptor tex_coords_descr
type description of tex coordinate attribute
void construct_index_buffers(cgv::render::context &ctx, const cgv::media::mesh::simple_mesh_base &mesh, std::vector< idx4_type > &unique_quadruples, std::vector< idx_type > &per_corner_vertex_index, std::vector< idx_type > &edges_element_buffer, std::vector< idx_type > &triangles_element_buffer)
Prepare vertex attribute data creation by extraction of unique combinations of attribute indices.
bool include_tex_coords
store whether tex coords are in vbo
size_t color_increment
color type size in bytes
bool include_normals
store whether normals are in vbo
bool include_tangents
store whether tangents are in vbo
bool configure_vbos(cgv::render::context &ctx, const cgv::media::mesh::simple_mesh_base &mesh, const attribute_map &attribute_to_vbo_index_map, const std::vector< int > &dynamic_vbo_idx)
configure which attributes should be stored, in which vbos they go and which vbos should support dyna...
cgv::render::type_descriptor position_descr
type description of position attribute
void construct_element_vbo(cgv::render::context &ctx, const std::vector< idx_type > &edge_element_buffer, const std::vector< idx_type > &triangle_element_buffer)
Uploads the given element buffers into EBOs on the GPU.
size_t nr_vertices
number of vertices
size_t get_nr_vertices() const
Returns how many vertices the mesh has.
void construct_draw_calls(cgv::render::context &ctx)
for each combination of primitive (face group of mesh) and material create and store one draw call
cgv::media::mesh::simple_mesh_base::attribute_type attribute_type
redeclare attribute type for shorter name
cgv::media::ColorType ct
color type
const std::string & get_primitive_name(size_t i) const
return name of i-th mesh primitive
std::vector< std::string > primitive_names
store list of primitive names
bool attribute_is_used(attribute_type at) const
check whether a mesh attribute is used
mesh_render_info()
set vbo and vbe types
size_t get_nr_triangle_elements() const
Returns how many triangle-indices are recorded in the element buffer.
size_t nr_edge_elements
number of edges in the wireframe representation
size_t get_element_size() const
Returns how many bytes on index value takes up in the element buffer.
cgv::math::fvec< idx_type, 4 > idx4_type
index quadruple type
size_t element_size
size of single coordinate
size_t get_nr_primitives() const
return number of mesh primitives
draw_call wire_draw_call
draw call for wireframe rendering
bool include_colors
store whether colors are in vbo
std::map< attribute_type, uint32_t > attribute_map
type of map from mesh attribute to vbo index
void construct_dynamic(cgv::render::context &ctx, cgv::media::mesh::simple_mesh< T > &mesh, const attribute_map &va_vbo_idx, const std::vector< int > &dynamic_vbo_idx)
Construct mesh render info from a given simple mesh and store vertex attributes flexibly in multiple ...
void construct(cgv::render::context &ctx, cgv::media::mesh::simple_mesh< T > &mesh, std::vector< idx_type > *tuple_pos_indices=nullptr, std::vector< idx_type > *tuple_normal_indices=nullptr, int *num_floats_in_vertex=nullptr)
Construct mesh render info from a given simple mesh and store all vertex attributes in interleaved in...
size_t nr_triangle_elements
number of triangles in the triangulation
bool is_constructed() const
check whether vbos are constructed
std::vector< vertex_buffer * > & ref_vbos()
give write access to vbos
const std::vector< vertex_buffer * > & get_vbos() const
give read access to vbos
render_info()
set vbo and vbe types
const std::vector< attribute_array > & get_aas() const
give read access to aabs
a shader program combines several shader code fragments to a complete definition of the shading pipel...
a vertex buffer is an unstructured memory block on the GPU.
namespace for api independent GPU programming
@ VBT_VERTICES
The buffer contains vertices and will be bound to GL_ARRAY_BUFFER.
this header is dependency free
information needed per mesh attribute to know where it is stored in vbos
information stored per vbo
compact type description of data that can be sent to the context; convertible to int