cgv
cgv::render::gl::mesh_drawable Class Reference

simple implementation of a drawable for a polygonal mesh with support for materials More...

#include <mesh_drawable.h>

Inheritance diagram for cgv::render::gl::mesh_drawable:
cgv::render::drawable cgv::base::traverse_policy

Public Types

typedef cgv::media::mesh::simple_mesh< float > mesh_type
 type of mesh
 
typedef cgv::media::color< float, cgv::media::RGB > rgb
 declare rgb color type
 
typedef cgv::media::color< float, cgv::media::RGB, cgv::media::OPACITY > rgba
 declare rgba color type
 
typedef cgv::media::color< cgv::type::uint8_type, cgv::media::RGB > rgb8
 declare rgb color type
 
typedef cgv::media::color< cgv::type::uint8_type, cgv::media::RGB, cgv::media::OPACITY > rgba8
 declare rgba color type
 
typedef cgv::math::fvec< float, 2 > vec2
 declare type of 2d vectors
 
typedef cgv::math::fvec< float, 3 > vec3
 declare type of 3d vectors
 
typedef cgv::math::fvec< float, 4 > vec4
 declare type of homogeneous vectors
 
typedef cgv::math::vec< float > vecn
 declare type of vector with varying dimension
 
typedef cgv::math::fmat< float, 2, 2 > mat2
 declare type of 2x2 matrices
 
typedef cgv::math::fmat< float, 3, 3 > mat3
 declare type of 3x3 matrices
 
typedef cgv::math::fmat< float, 4, 4 > mat4
 declare type of 4x4 matrices
 
typedef cgv::math::fmat< float, 3, 4 > mat34
 declare type of 3x4 matrices which are often used to store a pose
 
typedef cgv::math::mat< float > matn
 declare type of matrices of varying dimensions
 
typedef cgv::math::fvec< double, 2 > dvec2
 declare type of 2d vectors
 
typedef cgv::math::fvec< double, 3 > dvec3
 declare type of 3d vectors
 
typedef cgv::math::fvec< double, 4 > dvec4
 declare type of homogeneous vectors
 
typedef cgv::math::vec< double > dvecn
 declare type of vector with varying dimension
 
typedef cgv::math::fmat< double, 2, 2 > dmat2
 declare type of 2x2 matrices
 
typedef cgv::math::fmat< double, 3, 3 > dmat3
 declare type of 3x3 matrices
 
typedef cgv::math::fmat< double, 4, 4 > dmat4
 declare type of 4x4 matrices
 
typedef cgv::math::fmat< double, 3, 4 > dmat34
 declare type of 3x4 matrices which are often used to store a pose
 
typedef cgv::math::mat< double > dmatn
 declare type of matrices of varying dimensions
 
typedef cgv::media::axis_aligned_box< float, 2 > box2
 declare type of 2d boxes
 
typedef cgv::media::axis_aligned_box< float, 3 > box3
 declare type of 3d boxes
 
typedef cgv::media::axis_aligned_box< float, 4 > box4
 declare type of 4d boxes
 
typedef cgv::media::axis_aligned_box< double, 2 > dbox2
 declare type of 2d boxes
 
typedef cgv::media::axis_aligned_box< double, 3 > dbox3
 declare type of 3d boxes
 
typedef cgv::media::axis_aligned_box< double, 4 > dbox4
 declare type of 4d boxes
 
typedef cgv::math::quaternion< float > quat
 declare type of quaternion
 
typedef cgv::math::quaternion< double > dquat
 declare type of double quaternion
 
typedef cgv::math::fvec< int32_t, 2 > ivec2
 declare type of 2d integer vectors
 
typedef cgv::math::fvec< int32_t, 3 > ivec3
 declare type of 3d integer vectors
 
typedef cgv::math::fvec< int32_t, 4 > ivec4
 declare type of 4d integer vectors
 
typedef cgv::math::fvec< uint32_t, 2 > uvec2
 declare type of 2d unsigned integer vectors
 
typedef cgv::math::fvec< uint32_t, 3 > uvec3
 declare type of 3d unsigned integer vectors
 
typedef cgv::math::fvec< uint32_t, 4 > uvec4
 declare type of 4d unsigned integer vectors
 

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 More...
 
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 box3get_box () const
 return the axis aligned bounding box
 
void hide ()
 hide the drawable
 
void show ()
 show the drawable
 
bool is_visible () const
 check whether the drawable is visible
 
contextget_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
 
cgv::render::viewfind_view_as_node (size_t view_idx=0) const
 convenience function to find the view control in the current hierarchy More...
 
bool get_world_location (int x, int y, const cgv::render::view &V, cgv::math::fvec< double, 3 > &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) More...
 
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 More...
 
virtual void finish_frame (context &)
 this method is called in one pass over all drawables after drawing
 
virtual void after_finish (cgv::render::context &)
 this method is called in one pass over all drawables after finish frame
 
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. More...
 

Protected Attributes

std::string model_path
 default path to file names
 
std::string file_name
 currently loaded file name
 
box3 box
 the bounding box of the mesh is computed in the read_mesh method
 

Detailed Description

simple implementation of a drawable for a polygonal mesh with support for materials

Member Function Documentation

◆ center_view()

void cgv::render::gl::mesh_drawable::center_view ( )
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

◆ find_view_as_node()

cgv::render::view * cgv::render::drawable::find_view_as_node ( size_t  view_idx = 0) const
inherited

convenience function to find the view control in the current hierarchy

this only works if your class inherits from the cgv::base::node class.

◆ get_world_location()

bool cgv::render::drawable::get_world_location ( int  x,
int  y,
const cgv::render::view V,
cgv::math::fvec< double, 3 > &  world_location,
double *  window_z_ptr = 0 
) const
inherited

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)

returns true if a world location could be computed which is the case when the context pointer of the drawable has been set and when the mouse location points inside a valid view panel.

◆ init_frame()

void cgv::render::gl::mesh_drawable::init_frame ( cgv::render::context ctx)
virtual

init textures if the mesh has been newly loaded

init textures

Reimplemented from cgv::render::drawable.

◆ resize()

void cgv::render::drawable::resize ( unsigned int  w,
unsigned int  h 
)
virtualinherited

callback to announce resizing of the output window

callback to anounce resizing of the output window


The documentation for this class was generated from the following files: