-
Notifications
You must be signed in to change notification settings - Fork 158
/
MeshViewer.h
62 lines (46 loc) · 1.86 KB
/
MeshViewer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright 2011-2021 the Polygon Mesh Processing Library developers.
// Distributed under a MIT-style license, see LICENSE.txt for details.
#pragma once
#include "pmp/visualization/TrackballViewer.h"
#include "pmp/SurfaceMesh.h"
#include "pmp/visualization/Renderer.h"
namespace pmp {
//! Simple viewer for a SurfaceMesh
//! \ingroup visualization
class MeshViewer : public TrackballViewer
{
public:
//! constructor
MeshViewer(const char* title, int width, int height, bool showgui = true);
//! destructor
~MeshViewer() override = default;
//! load a mesh from file \p filename
virtual void load_mesh(const char* filename);
//! load a matcap texture from file \p filename
void load_matcap(const char* filename);
//! load a texture from file \p filename
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);
//! 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
virtual void update_mesh();
//! draw the scene in different draw modes
void draw(const std::string& draw_mode) override;
//! handle ImGUI interface
void process_imgui() override;
//! this function handles keyboard events
void keyboard(int key, int code, int action, int mod) override;
//! load mesh by dropping file onto the window
void drop(int count, const char** paths) override;
//! get vertex closest to 3D position under the mouse cursor
Vertex pick_vertex(int x, int y);
protected:
SurfaceMesh mesh_;
Renderer renderer_;
std::string filename_; //!< the current file
float crease_angle_;
};
} // namespace pmp