~mht/surcut

bbf8ee4f887fc1bb6ce39e656c9d632f9eeca21b — Martin Hafskjold Thoresen 5 years ago 32b36a4
Add screenshot with antialiasing

Somehow, the anti aliasing with GLFW doesn't work (also doesn't work
with a clean GLFW project - weird opengl driver on linux?) Since we just
wanted nice screenshots anyways, this is a decent workaround.
2 files changed, 16 insertions(+), 5 deletions(-)

M CMakeLists.txt
M main.cpp
M CMakeLists.txt => CMakeLists.txt +6 -2
@@ 7,13 7,17 @@ option(LIBIGL_WITH_OPENGL            "Use OpenGL" ON)
option(LIBIGL_WITH_OPENGL_GLFW       "Use GLFW"   ON)
option(LIBIGL_WITH_OPENGL_GLFW_IMGUI "Use ImGui"  ON)
option(LIBIGL_WITH_TETGEN            "Use TetGen" ON)
option(LIBIGL_WITH_PNG               "Use PNG"    ON)


find_package(LIBIGL REQUIRED QUIET)
igl_download_stb()
find_package(OpenMP REQUIRED)

file(GLOB SRCFILES *.cpp)
add_executable(${PROJECT_NAME} ${SRCFILES} mesh.cpp)
target_link_libraries(${PROJECT_NAME} igl::core igl::opengl igl::opengl_glfw igl::opengl_glfw_imgui igl::tetgen OpenMP::OpenMP_CXX)
target_compile_options(${PROJECT_NAME} PRIVATE -g -O2 -Wall -Werror -Wpedantic)
target_link_libraries(${PROJECT_NAME} igl::core igl::opengl igl::opengl_glfw igl::opengl_glfw_imgui
  igl::tetgen OpenMP::OpenMP_CXX igl_stb_image)
target_compile_options(${PROJECT_NAME} PRIVATE -g -O2 -Wall -Werror -Wpedantic -DDEBUG)

igl_download_tutorial_data()

M main.cpp => main.cpp +10 -3
@@ 2,6 2,7 @@
#include <igl/opengl/glfw/imgui/ImGuiHelpers.h>
#include <igl/opengl/glfw/imgui/ImGuiMenu.h>
#include <igl/per_face_normals.h>
#include <igl/png/writePNG.h>
#include <igl/readOBJ.h>
#include <imgui/imgui.h>



@@ 322,7 323,8 @@ void compute_things(Mesh &mesh, bool only_plane) {
        // at the dynamics implementation in `arap-mold.cpp`.

        // Symmetric forces - think springs
        Vector3d force = force_direction * area * (double)force_scale;
        Vector3d force =
            force_direction * area * (double)force_scale * force_direction.squaredNorm() / scale;

        mesh.forces.row(v) += force;
        forces_endpoints.row(v) = other_vertex;


@@ 343,8 345,6 @@ void compute_things(Mesh &mesh, bool only_plane) {

// Draw the cut plane in a very hacky way.
void draw_plane(Viewer &viewer, Mesh &mesh) {
  // Must clear the previous plane from the screen. Maybe there's a better way
  // of doing this than to clear the entire thing.
  viewer.data().lines.resize(0, 0);

  Eigen::Vector3d dir1(plane_n.cross(Eigen::Vector3d(0, 0, 1)));


@@ 592,6 592,13 @@ int main(int argc, char *argv[]) {
      mesh.vertices = mesh.rest_state = tetmesh_out.vertices;
      arap::precomputation(mesh, arap_data);
      compute_things(mesh);
    } else if (key == 'P') {
      Eigen::Matrix<unsigned char, Eigen::Dynamic, Eigen::Dynamic> R(1280, 800);
      Eigen::Matrix<unsigned char, Eigen::Dynamic, Eigen::Dynamic> G(1280, 800);
      Eigen::Matrix<unsigned char, Eigen::Dynamic, Eigen::Dynamic> B(1280, 800);
      Eigen::Matrix<unsigned char, Eigen::Dynamic, Eigen::Dynamic> A(1280, 800);
      viewer.core().draw_buffer(viewer.data(), false, R, G, B, A);
      igl::png::writePNG(R, G, B, A, "out.png");
    }
    return false;
  };