You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.1 KiB
56 lines
1.1 KiB
#include <igl/readOFF.h>
|
|
#include <igl/opengl/glfw/Viewer.h>
|
|
#include <igl/lscm.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[])
|
|
{
|
|
using namespace Eigen;
|
|
using namespace std;
|
|
|
|
// Load a mesh in OFF format
|
|
igl::readOFF(TUTORIAL_SHARED_PATH "/camelhead.off", V, F);
|
|
|
|
// LSCM parametrization
|
|
igl::lscm(V,F,V_uv);
|
|
|
|
// Plot the mesh
|
|
igl::opengl::glfw::Viewer viewer;
|
|
viewer.data().set_mesh(V, F);
|
|
viewer.data().set_uv(V_uv);
|
|
viewer.callback_key_down = &key_down;
|
|
|
|
// Disable wireframe
|
|
viewer.data().show_lines = false;
|
|
|
|
// Draw checkerboard texture
|
|
viewer.data().show_texture = true;
|
|
|
|
// Launch the viewer
|
|
viewer.launch();
|
|
}
|
|
|