| 
    cgv
    
   | 
 
the mesh_render_info structure manages vertex buffer objects for attribute and element buffers as well as an attribute array binding object. More...
#include <mesh_render_info.h>
  
Classes | |
| struct | attribute_configuration | 
| information needed per mesh attribute to know where it is stored in vbos  More... | |
| struct | vbo_configuration | 
| information stored per vbo  More... | |
Public Types | |
| typedef cgv::media::mesh::simple_mesh_base::attribute_type | attribute_type | 
| redeclare attribute type for shorter name   | |
| typedef cgv::math::fvec< idx_type, 3 > | idx3_type | 
| index triple type   | |
| typedef cgv::math::fvec< idx_type, 4 > | idx4_type | 
| index quadruple type   | |
| typedef std::map< attribute_type, uint32_t > | attribute_map | 
| type of map from mesh attribute to vbo index   | |
  Public Types inherited from cgv::render::render_info | |
| typedef cgv::type::uint32_type | idx_type | 
| define index type   | |
Public Member Functions | |
| mesh_render_info () | |
| set vbo and vbe types   | |
| bool | is_constructed () const | 
| check whether vbos are constructed   | |
| bool | is_bound () const | 
| check whether attribute array binding is bound   | |
| template<typename T > | |
| 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 one vertex buffer object that does not allow dynamic updates.   | |
| template<typename T > | |
| 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 vertex buffer objects which allow for dynamic updates.   | |
| template<typename T > | |
| 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   | |
| void | set_nr_instances (unsigned nr) | 
| set the number of to be drawn instances - in case of 0, instanced drawing is turned off   | |
| size_t | get_nr_primitives () const | 
| return number of mesh primitives   | |
| const std::string & | get_primitive_name (size_t i) const | 
| return name of i-th mesh primitive   | |
| size_t | get_nr_fragments () const | 
| return number of mesh fragments that are of distinct primitive and material   | |
| size_t | get_material_index (size_t i) const | 
| return material index of i-th fragment   | |
| size_t | get_primitive_index (size_t i) const | 
| return group index of i-th fragment   | |
| size_t | get_nr_vertices () const | 
| Returns how many vertices the mesh has.   | |
| size_t | get_nr_edge_elements () const | 
| Returns how many edge-indices are recorded in the element buffer.   | |
| size_t | get_nr_triangle_elements () const | 
| Returns how many triangle-indices are recorded in the element buffer.   | |
| size_t | get_element_size () const | 
| Returns how many bytes on index value takes up in the element buffer.   | |
| void | draw_primitive (cgv::render::context &ctx, size_t primitive_index, bool skip_opaque=false, bool skip_blended=false, bool use_materials=true) | 
| draw triangles of given mesh part or whole mesh in case part_index is not given (=-1)   | |
| bool | bind (context &ctx, shader_program &prog, bool force_success, int aa_index=-1) | 
| override to restrict bind function to first aa as second is used for wireframe rendering   | |
| bool | bind_wireframe (context &ctx, shader_program &prog, bool force_success) | 
| bind all or specific aa to the passed shader program   | |
| void | draw_wireframe (cgv::render::context &ctx) | 
| draw array elements forming the edges of the wireframe   | |
| void | destruct (cgv::render::context &ctx) | 
| destruct render mesh info and free vertex buffer objects   | |
  Public Member Functions inherited from cgv::render::render_info | |
| render_info () | |
| set vbo and vbe types   | |
| const std::vector< textured_material * > & | get_materials () const | 
| give read access to materials   | |
| const std::vector< vertex_buffer * > & | get_vbos () const | 
| give read access to vbos   | |
| const std::vector< attribute_array > & | get_aas () const | 
| give read access to aabs   | |
| const std::vector< texture * > & | get_textures () const | 
| give read access to texture   | |
| const std::vector< draw_call > & | get_draw_calls () const | 
| give read access to draw calls   | |
| std::vector< textured_material * > & | ref_materials () | 
| give write access to materials   | |
| std::vector< vertex_buffer * > & | ref_vbos () | 
| give write access to vbos   | |
| std::vector< attribute_array > & | ref_aas () | 
| give write access to aabs   | |
| std::vector< texture * > & | ref_textures () | 
| give write access to texture   | |
| std::vector< draw_call > & | ref_draw_calls () | 
| give write access to draw calls   | |
| void | draw_all (context &ctx, bool skip_opaque=false, bool skip_blended=false, bool use_materials=true) | 
| execute all draw calls   | |
| void | destruct (cgv::render::context &ctx) | 
| destruct render mesh info and free vertex buffer objects   | |
Protected Member Functions | |
| bool | attribute_is_used (attribute_type at) const | 
| check whether a mesh attribute is used   | |
| 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 dynamic updates   | |
| 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.   | |
| 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.   | |
| 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   | |
  Protected Member Functions inherited from cgv::render::render_info | |
| void | draw (context &ctx, const draw_call &dc, const draw_call *prev_dc=0, const draw_call *next_dc=0, bool use_materials=true) | 
| perform a single render call   | |
Protected Attributes | |
| std::vector< std::string > | primitive_names | 
| store list of primitive names   | |
| std::vector< idx3_type > | material_primitive_start | 
| index triple storing the material index, the primitive index and the offset (element index) in the triangle element buffer   | |
| bool | include_tex_coords | 
| store whether tex coords are in vbo   | |
| bool | include_normals | 
| store whether normals are in vbo   | |
| bool | include_tangents | 
| store whether tangents are in vbo   | |
| bool | include_colors | 
| store whether colors are in vbo   | |
| size_t | nr_vertices | 
| number of vertices   | |
| size_t | nr_edge_elements | 
| number of edges in the wireframe representation   | |
| size_t | nr_triangle_elements | 
| number of triangles in the triangulation   | |
| size_t | element_size | 
| size of single coordinate   | |
| draw_call | wire_draw_call | 
| draw call for wireframe rendering   | |
| cgv::render::type_descriptor | position_descr | 
| type description of position attribute   | |
| cgv::render::type_descriptor | tex_coords_descr | 
| type description of tex coordinate attribute   | |
| size_t | color_increment | 
| color type size in bytes   | |
| cgv::media::ColorType | ct | 
| color type   | |
| std::vector< vbo_configuration > | vbo_config | 
| store for each vbo its configuration   | |
| 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< idx4_type > | unique_quadruples | 
| in case that at least one vbo is replaceable, store per vertex the unique quadruple of attribute indices   | |
  Protected Attributes inherited from cgv::render::render_info | |
| std::vector< textured_material * > | materials | 
| store materials   | |
| std::vector< texture * > | textures | 
| store textures   | |
| std::vector< vertex_buffer * > | vbos | 
| store buffers   | |
| std::vector< attribute_array > | aas | 
| store attribute bindings   | |
| std::vector< draw_call > | draw_calls | 
| store vector of render calls   | |
the mesh_render_info structure manages vertex buffer objects for attribute and element buffers as well as an attribute array binding object.
The vertex buffer can be constructed from a simple mesh and the attribute array binding is bound to a specific shader program which defines the attribute locations. 
 
Definition at line 15 of file mesh_render_info.h.
| typedef std::map<attribute_type, uint32_t> cgv::render::mesh_render_info::attribute_map | 
type of map from mesh attribute to vbo index
Definition at line 25 of file mesh_render_info.h.
| typedef cgv::media::mesh::simple_mesh_base::attribute_type cgv::render::mesh_render_info::attribute_type | 
redeclare attribute type for shorter name
Definition at line 19 of file mesh_render_info.h.
index triple type
Definition at line 21 of file mesh_render_info.h.
index quadruple type
Definition at line 23 of file mesh_render_info.h.
| cgv::render::mesh_render_info::mesh_render_info | ( | ) | 
set vbo and vbe types
Definition at line 6 of file mesh_render_info.cxx.
References nr_edge_elements, and nr_triangle_elements.
      
  | 
  protected | 
check whether a mesh attribute is used
Definition at line 62 of file mesh_render_info.cxx.
References per_attribute_vbo_config.
Referenced by construct_draw_calls(), and construct_index_buffers().
      
  | 
  virtual | 
override to restrict bind function to first aa as second is used for wireframe rendering
Reimplemented from cgv::render::render_info.
Definition at line 98 of file mesh_render_info.cxx.
References cgv::render::render_info::bind().
Referenced by cgv::render::gl::gl_implicit_surface_drawable_base::draw(), vr_test::init(), and cgv::render::gl::mesh_drawable::init_frame().
| bool cgv::render::mesh_render_info::bind_wireframe | ( | context & | ctx, | 
| shader_program & | prog, | ||
| bool | force_success | ||
| ) | 
bind all or specific aa to the passed shader program
Definition at line 102 of file mesh_render_info.cxx.
References cgv::render::render_info::bind(), and wire_draw_call.
Referenced by cgv::render::gl::gl_implicit_surface_drawable_base::draw().
      
  | 
  protected | 
configure which attributes should be stored, in which vbos they go and which vbos should support dynamic updates
Definition at line 66 of file mesh_render_info.cxx.
References cgv::render::context::error(), per_attribute_vbo_config, cgv::utils::to_string(), and vbo_config.
      
  | 
  inline | 
Construct mesh render info from a given simple mesh and store all vertex attributes in interleaved in one vertex buffer object that does not allow dynamic updates.
| T | The coordinate type which is used in the cgv::media::mesh::simple_mesh | 
| ctx | The CGV rendering context. | 
| mesh | The general mesh which will be translated into appropriately formatted GPU buffers. | 
| tuple_pos_indices | If not nullptr, will be filled the mapping from unique vertex attribute tuples to the original position buffers of the mesh. | 
| tuple_normal_indices | If not nullptr, will be filled the mapping from unique vertex attribute tuples to the original normal buffers of the mesh. | 
| num_floats_in_vertex | If not nullptr will be set to the number of floats which make up one vertex with all its attributes. | 
Definition at line 131 of file mesh_render_info.h.
References cgv::media::mesh::simple_mesh_base::extract_vertex_attribute_buffer_base(), cgv::media::colored_model::has_colors(), cgv::media::mesh::simple_mesh< T >::has_normals(), cgv::media::mesh::simple_mesh< T >::has_tangents(), cgv::media::mesh::simple_mesh< T >::has_tex_coords(), and cgv::render::VBT_VERTICES.
Referenced by cgv::render::gl::gl_implicit_surface_drawable_base::draw(), vr_test::init(), and cgv::render::gl::mesh_drawable::init_frame().
      
  | 
  protected | 
for each combination of primitive (face group of mesh) and material create and store one draw call
Definition at line 107 of file mesh_render_info.cxx.
References attribute_is_used(), ct, material_primitive_start, nr_edge_elements, nr_triangle_elements, nr_vertices, per_attribute_vbo_config, position_descr, cgv::render::render_info::ref_aas(), cgv::render::render_info::ref_draw_calls(), cgv::render::render_info::ref_materials(), cgv::render::render_info::ref_vbos(), tex_coords_descr, cgv::type::info::TI_FLT32, cgv::type::info::TI_UINT32, cgv::type::info::TI_UINT8, vbo_config, and wire_draw_call.
      
  | 
  inline | 
Construct mesh render info from a given simple mesh and store vertex attributes flexibly in multiple vertex buffer objects which allow for dynamic updates.
Definition at line 171 of file mesh_render_info.h.
References cgv::media::mesh::simple_mesh_base::extract_vertex_attribute_buffer_base(), and cgv::render::VBT_VERTICES.
      
  | 
  protected | 
Uploads the given element buffers into EBOs on the GPU.
| [in] | ctx | The CGV drawing context. | 
| [in] | edge_element_buffer | The vector of indices which make up the edges of faces. | 
| [in] | triangle_element_buffer | The vector of indices which make up triangles. | 
Definition at line 54 of file mesh_render_info.cxx.
References cgv::render::vertex_buffer::create(), nr_edge_elements, nr_triangle_elements, cgv::render::render_info::ref_vbos(), cgv::render::vertex_buffer::replace(), and cgv::render::VBT_INDICES.
      
  | 
  protected | 
Prepare vertex attribute data creation by extraction of unique combinations of attribute indices.
| [in] | ctx | The render context. | 
| [in] | mesh | The mesh which shall be transformed. | 
| [out] | vertex_indices | per face corner the vertex index or index of attribute index tuple | 
| [out] | unique_quadruples | the list of attribute index tuples which aggregate unique combinations of vertex attribute indices | 
| [out] | triangle_element_buffer | the buffer with successive vertex index triples, which make up mesh triangles. | 
| [out] | edge_element_buffer | the buffer with successive vertex index pairs, which make up the mesh edges | 
Definition at line 24 of file mesh_render_info.cxx.
References attribute_is_used(), ct, cgv::media::mesh::simple_mesh_base::extract_triangle_element_buffer(), cgv::media::mesh::simple_mesh_base::extract_wireframe_element_buffer(), cgv::media::colored_model::get_color_storage_type(), cgv::media::mesh::simple_mesh_base::get_material(), cgv::media::mesh::simple_mesh_base::get_nr_groups(), cgv::media::mesh::simple_mesh_base::get_nr_materials(), include_colors, include_normals, include_tangents, include_tex_coords, material_primitive_start, cgv::media::mesh::simple_mesh_base::merge_indices(), nr_edge_elements, nr_triangle_elements, nr_vertices, cgv::render::render_info::ref_materials(), and cgv::media::mesh::simple_mesh_base::sort_faces().
| void cgv::render::mesh_render_info::destruct | ( | cgv::render::context & | ctx | ) | 
destruct render mesh info and free vertex buffer objects
Definition at line 13 of file mesh_render_info.cxx.
References cgv::render::render_info::destruct(), element_size, material_primitive_start, nr_edge_elements, nr_triangle_elements, nr_vertices, per_attribute_vbo_config, and vbo_config.
Referenced by cgv::render::gl::mesh_drawable::clear(), cgv::render::gl::gl_implicit_surface_drawable_base::draw(), vr::get_vrmesh_render_info(), and cgv::render::gl::mesh_drawable::init_frame().
| void cgv::render::mesh_render_info::draw_primitive | ( | cgv::render::context & | ctx, | 
| size_t | primitive_index, | ||
| bool | skip_opaque = false,  | 
        ||
| bool | skip_blended = false,  | 
        ||
| bool | use_materials = true  | 
        ||
| ) | 
draw triangles of given mesh part or whole mesh in case part_index is not given (=-1)
Definition at line 232 of file mesh_render_info.cxx.
References cgv::render::render_info::draw(), cgv::render::render_info::draw_calls, and material_primitive_start.
Referenced by cgv::render::gl::mesh_drawable::draw_mesh_primitive().
| void cgv::render::mesh_render_info::draw_wireframe | ( | cgv::render::context & | ctx | ) | 
draw array elements forming the edges of the wireframe
Definition at line 260 of file mesh_render_info.cxx.
References cgv::render::render_info::draw(), and wire_draw_call.
Referenced by cgv::render::gl::gl_implicit_surface_drawable_base::draw_implicit_surface().
      
  | 
  inline | 
Returns how many bytes on index value takes up in the element buffer.
Definition at line 228 of file mesh_render_info.h.
      
  | 
  inline | 
return material index of i-th fragment
Definition at line 217 of file mesh_render_info.h.
      
  | 
  inline | 
Returns how many edge-indices are recorded in the element buffer.
Definition at line 224 of file mesh_render_info.h.
      
  | 
  inline | 
return number of mesh fragments that are of distinct primitive and material
Definition at line 215 of file mesh_render_info.h.
      
  | 
  inline | 
return number of mesh primitives
Definition at line 211 of file mesh_render_info.h.
      
  | 
  inline | 
Returns how many triangle-indices are recorded in the element buffer.
Definition at line 226 of file mesh_render_info.h.
      
  | 
  inline | 
Returns how many vertices the mesh has.
Definition at line 222 of file mesh_render_info.h.
      
  | 
  inline | 
return group index of i-th fragment
Definition at line 219 of file mesh_render_info.h.
      
  | 
  inline | 
return name of i-th mesh primitive
Definition at line 213 of file mesh_render_info.h.
      
  | 
  inline | 
check whether attribute array binding is bound
Definition at line 119 of file mesh_render_info.h.
      
  | 
  inline | 
check whether vbos are constructed
Definition at line 117 of file mesh_render_info.h.
Referenced by vr_test::draw().
| void cgv::render::mesh_render_info::set_nr_instances | ( | unsigned | nr | ) | 
set the number of to be drawn instances - in case of 0, instanced drawing is turned off
Definition at line 208 of file mesh_render_info.cxx.
References cgv::render::render_info::ref_draw_calls().
      
  | 
  inline | 
replace the content of one vbo from a mesh
Definition at line 200 of file mesh_render_info.h.
References cgv::media::mesh::simple_mesh_base::extract_vertex_attribute_buffer_base().
      
  | 
  protected | 
color type size in bytes
Definition at line 54 of file mesh_render_info.h.
      
  | 
  protected | 
color type
Definition at line 56 of file mesh_render_info.h.
Referenced by construct_draw_calls(), and construct_index_buffers().
      
  | 
  protected | 
size of single coordinate
Definition at line 46 of file mesh_render_info.h.
Referenced by destruct().
      
  | 
  protected | 
store whether colors are in vbo
Definition at line 38 of file mesh_render_info.h.
Referenced by construct_index_buffers().
      
  | 
  protected | 
store whether normals are in vbo
Definition at line 34 of file mesh_render_info.h.
Referenced by construct_index_buffers().
      
  | 
  protected | 
store whether tangents are in vbo
Definition at line 36 of file mesh_render_info.h.
Referenced by construct_index_buffers().
      
  | 
  protected | 
store whether tex coords are in vbo
Definition at line 32 of file mesh_render_info.h.
Referenced by construct_index_buffers().
      
  | 
  protected | 
index triple storing the material index, the primitive index and the offset (element index) in the triangle element buffer
Definition at line 30 of file mesh_render_info.h.
Referenced by construct_draw_calls(), construct_index_buffers(), destruct(), and draw_primitive().
      
  | 
  protected | 
number of edges in the wireframe representation
Definition at line 42 of file mesh_render_info.h.
Referenced by construct_draw_calls(), construct_element_vbo(), construct_index_buffers(), destruct(), and mesh_render_info().
      
  | 
  protected | 
number of triangles in the triangulation
Definition at line 44 of file mesh_render_info.h.
Referenced by construct_draw_calls(), construct_element_vbo(), construct_index_buffers(), destruct(), and mesh_render_info().
      
  | 
  protected | 
number of vertices
Definition at line 40 of file mesh_render_info.h.
Referenced by construct_draw_calls(), construct_index_buffers(), and destruct().
      
  | 
  protected | 
for each mesh attribute that is used, map attribute type to the vbo index
Definition at line 76 of file mesh_render_info.h.
Referenced by attribute_is_used(), configure_vbos(), construct_draw_calls(), and destruct().
      
  | 
  protected | 
type description of position attribute
Definition at line 50 of file mesh_render_info.h.
Referenced by construct_draw_calls().
      
  | 
  protected | 
store list of primitive names
Definition at line 28 of file mesh_render_info.h.
      
  | 
  protected | 
type description of tex coordinate attribute
Definition at line 52 of file mesh_render_info.h.
Referenced by construct_draw_calls().
      
  | 
  protected | 
in case that at least one vbo is replaceable, store per vertex the unique quadruple of attribute indices
Definition at line 78 of file mesh_render_info.h.
      
  | 
  protected | 
store for each vbo its configuration
Definition at line 68 of file mesh_render_info.h.
Referenced by configure_vbos(), construct_draw_calls(), and destruct().
      
  | 
  protected | 
draw call for wireframe rendering
Definition at line 48 of file mesh_render_info.h.
Referenced by bind_wireframe(), construct_draw_calls(), and draw_wireframe().