|
|
@@ -1,39 +1,18 @@
|
|
|
#include <igl/boundary_loop.h>
|
|
|
#include <igl/harmonic.h>
|
|
|
#include <igl/map_vertices_to_circle.h>
|
|
|
-#include <igl/readOFF.h>
|
|
|
+#include <igl/read_triangle_mesh.h>
|
|
|
#include <igl/opengl/glfw/Viewer.h>
|
|
|
|
|
|
#include "tutorial_shared_path.h"
|
|
|
|
|
|
-Eigen::MatrixXd V;
|
|
|
-Eigen::MatrixXi F;
|
|
|
-Eigen::MatrixXd V_uv;
|
|
|
-
|
|
|
-bool key_down(igl::opengl::glfw::Viewer& viewer, unsigned char key, int modifier)
|
|
|
-{
|
|
|
- if (key == '1')
|
|
|
- {
|
|
|
- // Plot the 3D mesh
|
|
|
- viewer.data().set_mesh(V,F);
|
|
|
- viewer.core().align_camera_center(V,F);
|
|
|
- }
|
|
|
- else if (key == '2')
|
|
|
- {
|
|
|
- // Plot the mesh in 2D using the UV coordinates as vertex coordinates
|
|
|
- viewer.data().set_mesh(V_uv,F);
|
|
|
- viewer.core().align_camera_center(V_uv,F);
|
|
|
- }
|
|
|
-
|
|
|
- viewer.data().compute_normals();
|
|
|
-
|
|
|
- return false;
|
|
|
-}
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
{
|
|
|
+ Eigen::MatrixXd V, V_uv;
|
|
|
+ Eigen::MatrixXi F;
|
|
|
// Load a mesh in OFF format
|
|
|
- igl::readOFF(TUTORIAL_SHARED_PATH "/camelhead.off", V, F);
|
|
|
+ igl::read_triangle_mesh(TUTORIAL_SHARED_PATH "/camelhead.off", V, F);
|
|
|
|
|
|
// Find the open boundary
|
|
|
Eigen::VectorXi bnd;
|
|
|
@@ -53,14 +32,34 @@ int main(int argc, char *argv[])
|
|
|
igl::opengl::glfw::Viewer viewer;
|
|
|
viewer.data().set_mesh(V, F);
|
|
|
viewer.data().set_uv(V_uv);
|
|
|
- viewer.callback_key_down = &key_down;
|
|
|
+ // Attach callback to allow toggling between 3D and 2D view
|
|
|
+ viewer.callback_key_pressed =
|
|
|
+ [&V,&V_uv,&F](igl::opengl::glfw::Viewer& viewer, unsigned int key, int /*mod*/)
|
|
|
+ {
|
|
|
+ if(key == '3' || key == '2')
|
|
|
+ {
|
|
|
+ // Plot the 3D mesh or 2D UV coordinates
|
|
|
+ viewer.data().set_vertices(key=='3'?V:V_uv);
|
|
|
+ viewer.data().compute_normals();
|
|
|
+ viewer.core().align_camera_center(key=='3'?V:V_uv,F);
|
|
|
+ // key press was used
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ // key press not used
|
|
|
+ return false;
|
|
|
+ };
|
|
|
|
|
|
// Disable wireframe
|
|
|
viewer.data().show_lines = false;
|
|
|
|
|
|
- // Draw checkerboard texture
|
|
|
+ // Draw default checkerboard texture
|
|
|
viewer.data().show_texture = true;
|
|
|
|
|
|
+ std::cout<<R"(
|
|
|
+3 Show 3D model
|
|
|
+2 Show 2D parametrization
|
|
|
+)";
|
|
|
+
|
|
|
// Launch the viewer
|
|
|
viewer.launch();
|
|
|
}
|