GitHub link
Polygon Mesh Processing Library
MeshViewer Class Reference

Simple viewer for a SurfaceMesh. More...

#include <pmp/visualization/MeshViewer.h>

Inherits TrackballViewer.

Inherited by MeshProcessingViewer, Viewer, Viewer, Viewer, Viewer, Viewer, Viewer, and Viewer.

Public Member Functions

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

Protected Attributes

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

Additional Inherited Members

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

Detailed Description

Simple viewer for a SurfaceMesh.

Constructor & Destructor Documentation

◆ MeshViewer()

MeshViewer ( const char *  title,
int  width,
int  height,
bool  showgui = true 
)

constructor

◆ ~MeshViewer()

~MeshViewer ( )
overridedefault

destructor

Member Function Documentation

◆ draw()

void draw ( const std::string &  draw_mode)
overridevirtual

draw the scene in different draw modes

Implements TrackballViewer.

◆ keyboard()

void keyboard ( int  key,
int  code,
int  action,
int  mod 
)
overridevirtual

this function handles keyboard events

Reimplemented from Window.

◆ load_matcap()

void load_matcap ( const char *  filename)

load a matcap texture from file filename

◆ load_mesh()

void load_mesh ( const char *  filename)
virtual

load a mesh from file filename

◆ load_texture()

void 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

◆ pick_vertex()

Vertex pick_vertex ( int  x,
int  y 
)

get vertex closest to 3D position Distributed under the mouse cursor

◆ process_imgui()

void process_imgui ( )
overridevirtual

handle ImGUI interface

Reimplemented from Window.

◆ update_mesh()

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

Member Data Documentation

◆ filename_

std::string filename_
protected

the current file

◆ mesh_

SurfaceMeshGL mesh_
protected

the mesh