pmp-library  1.0

Simple viewer for a SurfaceMesh. More...

#include <pmp/visualization/MeshViewer.h>

Inheritance diagram for MeshViewer:
TrackballViewer Window

Public Member Functions

 MeshViewer (const char *title, int width, int height, bool showgui=true)
 constructor
 
virtual ~MeshViewer ()
 destructor
 
virtual bool load_mesh (const char *filename)
 load a mesh from file filename
 
bool load_texture (const char *filename, GLint format=GL_RGB, GLint min_filter=GL_LINEAR_MIPMAP_LINEAR, GLint mag_filter=GL_LINEAR, GLint wrap=GL_CLAMP_TO_EDGE)
 load a texture from file filename
 
virtual void update_mesh ()
 update mesh normals and all buffers for OpenGL rendering. More...
 
virtual void draw (const std::string &draw_mode) override
 draw the scene in different draw modes
 
virtual void process_imgui () override
 handle ImGUI interface
 
virtual void keyboard (int key, int code, int action, int mod) override
 this function handles keyboard events
 
Vertex pick_vertex (int x, int y)
 get vertex closest to 3D position Distributed under the mouse cursor
 
- Public Member Functions inherited from TrackballViewer
 TrackballViewer (const char *title, int width, int height, bool showgui=true)
 constructor
 
virtual ~TrackballViewer ()
 destructor
 
void set_scene (const vec3 &center, float radius)
 define the center and radius of the scene/ used for trackball rotation
 
void view_all ()
 adjust camera such that the whole scene (defined by set_scene()) is visible
 
- Public Member Functions inherited from Window
 Window (const char *title, int width, int height, bool showgui=true)
 constructor
 
virtual ~Window ()
 destructor
 
int run ()
 main window loop
 

Protected Attributes

SurfaceMeshGL mesh_
 the mesh
 
std::string filename_
 the current file
 
- Protected Attributes inherited from TrackballViewer
unsigned int draw_mode_
 draw modes
 
vec3 center_
 scene position and dimension
 
float near_
 projection parameters
 
mat4 projection_matrix_
 OpenGL matrices.
 
ivec2 last_point_2d_
 trackball helpers
 

Additional Inherited Members

- Protected Member Functions inherited from TrackballViewer
virtual void display (void) override
 this function is called when the scene has to be rendered. More...
 
virtual void mouse (int button, int action, int mods) override
 this function handles mouse button events
 
virtual void motion (double xpos, double ypos) override
 this function handles mouse motion (passive/active position)
 
virtual void scroll (double xoffset, double yoffset) override
 this function handles mouse scroll events
 
virtual void resize (int width, int height) override
 this function is called if the window is resized
 
void clear_draw_modes ()
 reset the list of draw modes
 
unsigned int add_draw_mode (const std::string &drawMode)
 add a draw mode
 
void set_draw_mode (const std::string &drawMode)
 activate a draw mode
 
virtual void init ()
 initialize all OpenGL states
 
void rotation (int x, int y)
 turn a mouse event into a rotation around the scene center. calls rotate().
 
void translation (int x, int y)
 turn a mouse event into a translation in the view plane. calls translate().
 
void zoom (int x, int y)
 turn a mouse event into a zoom, i.e., translation in z-direction. calls translate().
 
bool pick (vec3 &result)
 get 3D position under the mouse cursor
 
bool pick (int x, int y, vec3 &result)
 get 3D position of 2D position (x,y)
 
void fly_to (int x, int y)
 fly toward the position Distributed under the mouse cursor and set rotation center to it
 
void translate (const vec3 &trans)
 translate the scene and update modelview matrix
 
void rotate (const vec3 &axis, float angle)
 rotate the scene (around its center) and update modelview matrix
 
bool map_to_sphere (const ivec2 &point, vec3 &result)
 virtual trackball: map 2D screen point to unit sphere. used by rotate().
 
- Protected Member Functions inherited from Window
virtual void character (unsigned int)
 this function handles unicode character events
 
virtual void do_processing ()
 this function is called just before rendering
 
void init_imgui ()
 setup ImGUI user interface
 
void scale_imgui (float scale)
 scale ImGUI elements and font
 
bool show_imgui () const
 is ImGUI visible or hidden?
 
void show_imgui (bool b)
 show or hide ImGUI
 
void clear_help_items ()
 clear help items
 
void add_help_item (std::string key, std::string description, int position=-1)
 add key binding (or general action description)
 
void show_help ()
 show ImGUI help dialog
 
int width () const
 width of window
 
int height () const
 height of window
 
float high_dpi_scaling () const
 highDPI scaling
 
void cursor_pos (double &x, double &y) const
 get position of mouse cursor
 
bool left_mouse_pressed () const
 is left mouse button pressed down?
 
bool right_mouse_pressed () const
 is right mouse button pressed down?
 
bool middle_mouse_pressed () const
 is middle mouse button pressed down?
 
bool ctrl_pressed () const
 is CTRL modifier key pressed down?
 
bool alt_pressed () const
 is ALT modifier key pressed down?
 
bool shift_pressed () const
 is SHIFT modifier key pressed down?
 

Detailed Description

Simple viewer for a SurfaceMesh.

Member Function Documentation

void update_mesh ( )
virtual

update mesh normals and all buffers for OpenGL rendering.

call this function whenever you change either the vertex positions or the triangulation of the mesh