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)
21 mesh_info.destruct(ctx);
22 mesh_info.construct(ctx, mesh);
23 mesh_info.bind(ctx, ctx.ref_surface_shader_program(
true),
true);
29 mesh_info.destruct(ctx);
34 mesh_info.draw_primitive(ctx, pi, !opaque, opaque, use_materials);
39 mesh_info.draw_all(ctx, !opaque, opaque);
56 std::cerr <<
"mesh file " <<
file_name <<
" not found" << std::endl;
62 box = mesh.compute_box();
63 rebuild_mesh_info =
true;
66 std::cerr <<
"could not read mesh " <<
file_name << std::endl;
75 view_ptr->set_focus(
box.get_center());
76 view_ptr->set_y_extent_at_focus(1.3*
box.get_extent()(
box.get_max_extent_coord_index()));
base class for all drawables, which is independent of the used rendering API.
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
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.
namespace for opengl specific GPU programming
namespace for api independent GPU programming
this header is dependency free
cgv::media::axis_aligned_box< float, 3 > box3
declare type of 3d single precision floating point axis-aligned boxes