Files
igl/tutorial/104_Colors/main.cpp
T
Daniel Crispell a0eed05e8b Enable out of source tutorial build
Use CMake's "configure_file" functionality to store path to the tutorial
shared directory, enabling tutorial executables build out of source to
correctly find the data files.
2015-10-09 22:52:39 -04:00

31 lines
661 B
C++
Executable File

#include <igl/readOFF.h>
#include <igl/viewer/Viewer.h>
#include <igl/jet.h>
#include "tutorial_shared_path.h"
Eigen::MatrixXd V;
Eigen::MatrixXi F;
Eigen::MatrixXd C;
int main(int argc, char *argv[])
{
// Load a mesh in OFF format
igl::readOFF(tutorial_shared_path + "/screwdriver.off", V, F);
// Plot the mesh
igl::viewer::Viewer viewer;
viewer.data.set_mesh(V, F);
// Use the z coordinate as a scalar field over the surface
Eigen::VectorXd Z = V.col(2);
// Compute per-vertex colors
igl::jet(Z,true,C);
// Add per-vertex colors
viewer.data.set_colors(C);
// Launch the viewer
viewer.launch();
}