Files
igl/tutorial/107_MultipleMeshes/main.cpp
T
b0fd49d598 CMake refactor (#1805)
* Start CMake refactoring.

* WIP on instlal().

* Handle install + hunter setup.

* Handle module options + igl_include helper.

* Build all tutorials again.

* Update CMake for unit tests.

* Update triangle lib.

* Update Hunter integration.

* Fix for header-only mode.

* Fix Windows compilation + add GMP/MPFR find_package + set VS folders.

* Fix CGAL build.

* Add copy dll for Windows + improve find gmp/mpfr.

* Update Github Actions.

* Update README.

* Fixes for CMake 3.18

* Fix include option.

* Rename libigl_imgui_front to avoid conflicts.

* Fix when disabling unit tests.

* Build imguizmo with C++11.

* Update CMake option comments.

* Rename nonfree -> restricted.

* Update triangle and tetgen versions.

* Fix compilation issue.

* Update continuous.yml

* remove cork

* finding matlab with default

* mosek module compiles; default detected; osx dylib hack

* Reduce build parallelism.

* Fix find GMP/MPFR on Windows + cleanup CGAL changes.

* Update readme.

Co-authored-by: Alec Jacobson <alecjacobson@adobe.com>
Co-authored-by: Alec Jacobson <alecjacobson@gmail.com>
2022-02-09 18:58:40 -08:00

55 lines
1.4 KiB
C++
Executable File

#include <igl/opengl/glfw/Viewer.h>
#include <GLFW/glfw3.h>
#include <string>
#include <iostream>
#include <map>
int main(int argc, char * argv[])
{
igl::opengl::glfw::Viewer viewer;
const auto names =
{"cube.obj","sphere.obj","xcylinder.obj","ycylinder.obj","zcylinder.obj"};
std::map<int, Eigen::RowVector3d> colors;
int last_selected = -1;
for(const auto & name : names)
{
viewer.load_mesh_from_file(std::string(TUTORIAL_SHARED_PATH) + "/" + name);
colors.emplace(viewer.data().id, 0.5*Eigen::RowVector3d::Random().array() + 0.5);
}
viewer.callback_key_down =
[&](igl::opengl::glfw::Viewer &, unsigned int key, int mod)
{
if(key == GLFW_KEY_BACKSPACE)
{
int old_id = viewer.data().id;
if (viewer.erase_mesh(viewer.selected_data_index))
{
colors.erase(old_id);
last_selected = -1;
}
return true;
}
return false;
};
// Refresh selected mesh colors
viewer.callback_pre_draw =
[&](igl::opengl::glfw::Viewer &)
{
if (last_selected != viewer.selected_data_index)
{
for (auto &data : viewer.data_list)
{
data.set_colors(colors[data.id]);
}
viewer.data_list[viewer.selected_data_index].set_colors(Eigen::RowVector3d(0.9,0.1,0.1));
last_selected = viewer.selected_data_index;
}
return false;
};
viewer.launch();
return EXIT_SUCCESS;
}