cgv
|
simple implementation of a drawable for a polygonal mesh with support for materials More...
#include <mesh_drawable.h>
Public Types | |
typedef cgv::media::mesh::simple_mesh< float > | mesh_type |
type of mesh | |
Public Member Functions | |
mesh_drawable () | |
construct from name which is necessary construction argument to node | |
void | init_frame (cgv::render::context &ctx) |
init textures if the mesh has been newly loaded | |
void | draw (cgv::render::context &ctx) |
default drawing implementation calls draw_mesh(ctx, true) to render opaque part | |
void | finish_draw (context &ctx) |
default finish drawing implementation calls draw_mesh(ctx, false) to render transparent part | |
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 | clear (context &ctx) |
clear all objects living in the context like textures or display lists | |
const box3 & | get_box () const |
return the axis aligned bounding box | |
![]() | |
drawable () | |
default construction | |
void | hide () |
hide the drawable | |
void | show () |
show the drawable | |
bool | is_visible () const |
check whether the drawable is visible | |
context * | get_context () const |
access the current context. The context will be available latestly in the init method but not in the contructor. | |
void | set_context (context *_ctx) |
set the current focus context, this should only be called by the context itself | |
view * | find_view_as_node (size_t view_idx=0) const |
convenience function to find the view control in the current hierarchy | |
bool | get_world_location (int x, int y, const view &V, dvec3 &world_location, double *window_z_ptr=0) const |
use given view together with depth buffer of context in order to compute the world location of the point at mouse pointer location (x,y) | |
void | post_redraw () |
posts a redraw event to the current context if one is available | |
void | force_redraw () |
forces a redraw right now. This cannot be called from init, init_frame, draw, finish_draw, finish_frame and clear | |
virtual bool | init (context &) |
this method is called after creation or recreation of the context, return whether all necessary functionality is supported | |
virtual void | resize (unsigned int w, unsigned int h) |
callback to announce resizing of the output window | |
virtual void | finish_frame (context &) |
this method is called in one pass over all drawables after drawing | |
virtual void | after_finish (context &) |
this method is called in one pass over all drawables after finish frame | |
![]() | |
traverse_policy (int _policy=TP_ALL+TP_STOP_ON_SUCCESS, bool _active=true, int _focus=-1) | |
construct default traverse policy that visits everything | |
int | get_policy () const |
return the policy without the stop on success flag | |
bool | stop_on_success () const |
return whether to stop on success | |
bool | stop_on_failure () const |
return whether to stop on failure | |
void | set_policy (int _policy) |
set a new policy, always add stop on success flag if needed | |
int | get_focused_child () const |
return the focused child or -1 if none is focused | |
void | set_focused_child (int _focused_child) |
set the focused child | |
bool | get_active () const |
return whether the current node is active | |
void | set_active (bool _active) |
set the active flag of the current node | |
Protected Member Functions | |
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 | draw_mesh (cgv::render::context &ctx, bool opaque, bool use_materials=true) |
draw the complete mesh, optionally turn off the specification of materials | |
void | center_view () |
call this to center the view after loading the mesh. | |
Protected Attributes | |
std::string | model_path |
default path to file names | |
std::string | file_name |
currently loaded file name | |
mesh_type | mesh |
mesh_render_info | mesh_info |
bool | rebuild_mesh_info |
box3 | box |
the bounding box of the mesh is computed in the read_mesh method | |
![]() | |
TraversePolicy | policy |
bool | active |
int | focus |
simple implementation of a drawable for a polygonal mesh with support for materials
Definition at line 21 of file mesh_drawable.h.
type of mesh
Definition at line 25 of file mesh_drawable.h.
cgv::render::gl::mesh_drawable::mesh_drawable | ( | ) |
construct from name which is necessary construction argument to node
Definition at line 10 of file mesh_drawable.cxx.
|
protected |
call this to center the view after loading the mesh.
For this to work you need to derive from at least cgv::base::node and register an instance through the object registration mechanism defined in cgv/base/register.h
Definition at line 70 of file mesh_drawable.cxx.
References box, cgv::render::drawable::find_view_as_node(), cgv::media::axis_aligned_box< T, N >::get_center(), cgv::media::axis_aligned_box< T, N >::get_extent(), cgv::media::axis_aligned_box< T, N >::get_max_extent_coord_index(), and cgv::render::drawable::post_redraw().
|
virtual |
clear all objects living in the context like textures or display lists
Reimplemented from cgv::render::drawable.
Definition at line 27 of file mesh_drawable.cxx.
References cgv::render::mesh_render_info::destruct().
|
virtual |
default drawing implementation calls draw_mesh(ctx, true) to render opaque part
Reimplemented from cgv::render::drawable.
Definition at line 42 of file mesh_drawable.cxx.
References draw_mesh().
|
protected |
draw the complete mesh, optionally turn off the specification of materials
Definition at line 37 of file mesh_drawable.cxx.
References cgv::render::render_info::draw_all().
Referenced by draw(), and finish_draw().
|
protected |
draw all faces belonging to the given primitive, optionally turn off the specification of materials
Definition at line 32 of file mesh_drawable.cxx.
References cgv::render::mesh_render_info::draw_primitive().
|
virtual |
default finish drawing implementation calls draw_mesh(ctx, false) to render transparent part
Reimplemented from cgv::render::drawable.
Definition at line 47 of file mesh_drawable.cxx.
References draw_mesh().
const box3 & cgv::render::gl::mesh_drawable::get_box | ( | ) | const |
return the axis aligned bounding box
Definition at line 80 of file mesh_drawable.cxx.
References box.
|
virtual |
init textures if the mesh has been newly loaded
init textures
Reimplemented from cgv::render::drawable.
Definition at line 16 of file mesh_drawable.cxx.
References cgv::render::mesh_render_info::bind(), cgv::render::mesh_render_info::construct(), cgv::render::mesh_render_info::destruct(), and cgv::render::context::ref_surface_shader_program().
|
virtual |
read mesh from the given file_name which is extended by model path if it does not exist
Definition at line 52 of file mesh_drawable.cxx.
References box, cgv::media::mesh::simple_mesh< T >::clear(), cgv::media::mesh::simple_mesh< T >::compute_box(), file_name, cgv::base::find_data_file(), model_path, and cgv::media::mesh::simple_mesh< T >::read().
|
protected |
the bounding box of the mesh is computed in the read_mesh method
Definition at line 38 of file mesh_drawable.h.
Referenced by center_view(), get_box(), and read_mesh().
|
protected |
currently loaded file name
Definition at line 30 of file mesh_drawable.h.
Referenced by read_mesh().
|
protected |
Definition at line 32 of file mesh_drawable.h.
|
protected |
Definition at line 34 of file mesh_drawable.h.
|
protected |
default path to file names
Definition at line 28 of file mesh_drawable.h.
Referenced by read_mesh().
|
protected |
Definition at line 36 of file mesh_drawable.h.