1#include <cgv/base/base.h>
2#include "mesh_drawable.h"
3#include <cgv/base/import.h>
12 rebuild_mesh_info =
false;
18 if (!rebuild_mesh_info)
39 mesh_info.
draw_all(ctx, !opaque, opaque);
56 std::cerr <<
"mesh file " <<
file_name <<
" not found" << std::endl;
63 rebuild_mesh_info =
true;
66 std::cerr <<
"could not read mesh " <<
file_name << std::endl;
base class for all drawables, which is independent of the used rendering API.
virtual shader_program & ref_surface_shader_program(bool texture_support=false)=0
return a reference to the default shader program used to render surfaces
view * find_view_as_node(size_t view_idx=0) const
convenience function to find the view control in the current hierarchy
void post_redraw()
posts a redraw event to the current context if one is available
const box3 & get_box() const
return the axis aligned bounding box
void center_view()
call this to center the view after loading the mesh.
void draw_mesh_primitive(cgv::render::context &ctx, unsigned pi, bool opaque, bool use_materials=true)
draw all faces belonging to the given primitive, optionally turn off the specification of materials
void init_frame(cgv::render::context &ctx)
init textures if the mesh has been newly loaded
void clear(context &ctx)
clear all objects living in the context like textures or display lists
virtual bool read_mesh(const std::string &file_name)
read mesh from the given file_name which is extended by model path if it does not exist
void finish_draw(context &ctx)
default finish drawing implementation calls draw_mesh(ctx, false) to render transparent part
mesh_drawable()
construct from name which is necessary construction argument to node
std::string file_name
currently loaded file name
void draw_mesh(cgv::render::context &ctx, bool opaque, bool use_materials=true)
draw the complete mesh, optionally turn off the specification of materials
void draw(cgv::render::context &ctx)
default drawing implementation calls draw_mesh(ctx, true) to render opaque part
std::string model_path
default path to file names
box3 box
the bounding box of the mesh is computed in the read_mesh method
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
void destruct(cgv::render::context &ctx)
destruct render mesh info and free vertex buffer objects
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...
void draw_all(context &ctx, bool skip_opaque=false, bool skip_blended=false, bool use_materials=true)
execute all draw calls
defines a symmetric view with the following quantities:
std::string find_data_file(const std::string &file_name, const std::string &strategy, const std::string &sub_directory, const std::string &master_path)
Find a file with the given strategy and return the file name extended by the necessary path.