From 8bc88c1cfcfa91c8a8caa7e798cf99f97e4a77b6 Mon Sep 17 00:00:00 2001
From: Daniele Panozzo
2016 Alec Jacobson, Daniele Panozzo, Christian Schüller, Olga Diamanti, Qingnan -Zhou, Nico Pietroni, Stefan Brugger, Kenshi Takayama, Wenzel Jakob, Nikolas De +Zhou, Sebastian Koch, Nico Pietroni, Stefan Brugger, Kenshi Takayama, Wenzel Jakob, Nikolas De Giorgis, Luigi Rocca, Leonardo Sacht, Kevin Walliman, Olga Sorkine-Hornung, and others.
Please see individual files for appropriate copyright notices.
diff --git a/style-guidelines.html b/style-guidelines.html index 415b904cb..16d2eb49c 100644 --- a/style-guidelines.html +++ b/style-guidelines.html @@ -185,8 +185,8 @@ Eigen::SparseMatrix<Atype> adjacency_matrix(const ... & F);Functions taking Eigen dense matrices/arrays as inputs and outputs (but not
-return arguments), should template on top of Eigen::PlainObjectBase. Each
-parameter should be derived using its own template.
Eigen::PlainObjectBase. **Each
+parameter** should be derived using its own template.
For example,
@@ -264,8 +264,8 @@ unnecessary prefaces. For example, instead ofcompute_adjacency_matrixVariable naming conventions
-Libigl prefers short (even single character) variable names with heavy
-documentation in the comments in the header file or above the declaration of
+
Libigl prefers short (even single character) variable names _with heavy
+documentation_ in the comments in the header file or above the declaration of
the function. When possible use V to mean a list of vertex positions and F
to mean a list of faces/triangles.
diff --git a/tutorial/107_ScreenCapture/CMakeLists.txt b/tutorial/107_ScreenCapture/CMakeLists.txt
new file mode 100644
index 000000000..ed651e5c8
--- /dev/null
+++ b/tutorial/107_ScreenCapture/CMakeLists.txt
@@ -0,0 +1,8 @@
+cmake_minimum_required(VERSION 2.8.12)
+project(107_ScreenCapture)
+
+add_executable(${PROJECT_NAME}_bin
+ main.cpp)
+target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS})
+target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS})
+target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_EXTRA_LIBRARIES})
diff --git a/tutorial/107_ScreenCapture/main.cpp b/tutorial/107_ScreenCapture/main.cpp
new file mode 100755
index 000000000..d0846c4eb
--- /dev/null
+++ b/tutorial/107_ScreenCapture/main.cpp
@@ -0,0 +1,82 @@
+#include
+#include
+#include
+#include "tutorial_shared_path.h"
+#include
+#include
+
+// This function is called every time a keyboard button is pressed
+bool key_down(igl::viewer::Viewer& viewer, unsigned char key, int modifier)
+{
+ if (key == '1')
+ {
+ // Allocate temporary buffers
+ Eigen::Matrix R(1280,800);
+ Eigen::Matrix G(1280,800);
+ Eigen::Matrix B(1280,800);
+ Eigen::Matrix A(1280,800);
+
+ // Draw the scene in the buffers
+ viewer.core.draw_buffer(viewer.data,viewer.opengl,false,R,G,B,A);
+
+ // Save it to a PNG
+ igl::png::writePNG(R,G,B,A,"out.png");
+ }
+
+ if (key == '2')
+ {
+ // Allocate temporary buffers
+ Eigen::Matrix R,G,B,A;
+
+ // Read the PNG
+ igl::png::readPNG("out.png",R,G,B,A);
+
+ // Replace the mesh with a triangulated square
+ Eigen::MatrixXd V(4,3);
+ V <<
+ -0.5,-0.5,0,
+ 0.5,-0.5,0,
+ 0.5, 0.5,0,
+ -0.5, 0.5,0;
+ Eigen::MatrixXi F(2,3);
+ F <<
+ 0,1,2,
+ 2,3,0;
+ Eigen::MatrixXd UV(4,2);
+ UV <<
+ 0,0,
+ 1,0,
+ 1,1,
+ 0,1;
+
+ viewer.data.clear();
+ viewer.data.set_mesh(V,F);
+ viewer.data.set_uv(UV);
+ viewer.core.align_camera_center(V);
+ viewer.core.show_texture = true;
+
+ // Use the image as a texture
+ viewer.data.set_texture(R,G,B);
+
+ }
+
+
+ return false;
+}
+
+int main(int argc, char *argv[])
+{
+ // Load a mesh in OFF format
+ Eigen::MatrixXd V;
+ Eigen::MatrixXi F;
+ igl::readOFF(TUTORIAL_SHARED_PATH "/bunny.off", V, F);
+
+ std::cerr << "Press 1 to render the scene and save it in a png." << std::endl;
+ std::cerr << "Press 2 to load the saved png and use it as a texture." << std::endl;
+
+ // Plot the mesh and register the callback
+ igl::viewer::Viewer viewer;
+ viewer.callback_key_down = &key_down;
+ viewer.data.set_mesh(V, F);
+ viewer.launch();
+}
diff --git a/tutorial/CMakeLists.txt b/tutorial/CMakeLists.txt
index d09bad47e..bd43582fb 100644
--- a/tutorial/CMakeLists.txt
+++ b/tutorial/CMakeLists.txt
@@ -89,6 +89,9 @@ if(TUTORIALS_CHAPTER1)
add_subdirectory("104_Colors")
add_subdirectory("105_Overlays")
add_subdirectory("106_ViewerMenu")
+ if(LIBIGL_WITH_PNG)
+ add_subdirectory("107_ScreenCapture")
+ endif()
endif()
# Chapter 2
diff --git a/tutorial/tutorial.html.REMOVED.git-id b/tutorial/tutorial.html.REMOVED.git-id
index eb33265a4..a1ecdf5d3 100644
--- a/tutorial/tutorial.html.REMOVED.git-id
+++ b/tutorial/tutorial.html.REMOVED.git-id
@@ -1 +1 @@
-f46cce260ca12390184cb5fef8205ea121b3cb97
\ No newline at end of file
+0ba0c22d44c641478413576281dc8e745316e8c7
\ No newline at end of file
diff --git a/tutorial/tutorial.md.REMOVED.git-id b/tutorial/tutorial.md.REMOVED.git-id
index 1bcb51072..daf1831fe 100644
--- a/tutorial/tutorial.md.REMOVED.git-id
+++ b/tutorial/tutorial.md.REMOVED.git-id
@@ -1 +1 @@
-f87bfabc63b2facf8ce8a778e86028722a7af22f
\ No newline at end of file
+6c7992b923fba06ca0986754535c23cb220875da
\ No newline at end of file