GithubHelp home page GithubHelp logo

texelbox / cage-tool Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 3.0 101.91 MB

C++/OpenGL tool for cage-based deformation, including functionality for cage generation. Originally developed as a fall 2019 term project for CPSC589 @ University of Calgary.

C 1.30% Objective-C 0.04% CMake 0.01% C++ 98.63% GLSL 0.01% Perl 0.01% HTML 0.01% M4 0.01% Batchfile 0.01% Shell 0.01%
cage deformation generation cpp opengl glfw glew glm dear-imgui windows

cage-tool's Introduction

CageTool

C++/OpenGL tool for cage-based deformation, including functionality for cage generation. Originally developed as a fall 2019 term project for CPSC589 @ University of Calgary.


Screenshots

screenshot-1

screenshot-2

screenshot-3

screenshot-4

screenshot-5

screenshot-6


[WIP]


CONTROLS/FEATURES:

  • LEFT CLICK + DRAG === pan the spherical camera
  • SCROLL === zoom the spherical camera
  • EDIT WINDOW - can be toggled in/out of view, resized, moved (config saved in imgui.ini file)
  • GENERAL IMGUI NOTE: most fields can have directly typed input entered by CTRL + LEFT CLICK, then saved with ENTER
  • CLEAR COLOR - self explanatory
  • CARTESIAN PLANE TOGGLE BUTTONS - these provide useful visual aid for alignment
  • LOAD MODEL / LOAD CAGE - type filename (sans extension) in textbox (note: case-sensitive on Linux), press ENTER and it searches for Wavefront OBJ file in models/imports/
  • NOTE: this program only has support for Wavefront OBJ pure tri-meshes. Files must have verts/faces. UVS are optional and currently only a default pink/black checkered texture will get applied. Any normals in the file are ignored since the program will generate both per-face and per-vertex normals, the latter being used for rendering.
  • POSITION/ROTATION/SCALE transforms - these model transforms only apply visually (no internal change to positions), they were left in since they could be useful to move the cage out of the way to view the model unobscured.
  • CLEAR MODEL / CLEAR CAGE - removes the respective mesh from the scene (e.g. want to load in a new mesh).
  • EXPORT MODEL / EXPORT CAGE - similar to import instructions, writes to file in models/exports/. If the file doesn't exist, it will create a new one and write to it, otherwise it will deliberately fail to prevent overwriting existing files.
  • NOTE: exporting a model, exports verts, auto-generated per-vertex normals, faces and uvs if present.
  • NOTE: exporting a cage, just exports verts/faces.
  • CAGE GENERATION - currently incomplete, but very close (just missing the internal face culling and face registration)
  • TERMINATION CONSTANTS - get set before clicking GENERATE CAGE button - refer to our paper for an explanation
  • CAGE DEFORMATION (MVC) - once a model + cage pair are loaded in the scene, you can press the COMPUTE CAGE WEIGHTS button to compute MVC weights of the cage vertices on the model vertices. You can then either use any of the 3 buttons (SELECT/UNSELECT/TOGGLE ALL VERTS) or individually RIGHT-CLICK on the black cage-verts (turn them YELLOW for SELECTED) and then deform the cage (and consequently the model) by translating the selected cage verts with the keys Q, W, E, A, S, D (1 key per direction on 3 axes).
  • NOTE: this cage movement with Q, W, E, A, S, D can also be used to just alter a cage if wanted. To do this, just make sure to CLEAR CAGE WEIGHTS first, or CLEAR MODEL.
  • NOTE: there is a slider for the "selected cage vert translation amount" (can also be CTRL+LEFT CLICKED) to allow finer control on how many units the cage verts move by key inputs.

OPTIONAL/FUTURE FEATURES:
  • port to Linux (Makefile?)
  • finish / implement more coarse cage-generation techniques (e.g. improved OBBs method, normals, mesh-simplification, cutting planes, user-tracing, etc.)
  • add improved manners of user-interaction for transforming the cage (e.g. view-plane translation, movement along normals (per vertex? per face?), face extrusion/intrusion, etc.)
  • improved file picker functionality for both importing/exporting (model and cage)
  • additional export options (e.g. which data to export)
  • file picker functionality for importing TEXTURE (.png file), only if MODEL has uvs
  • update per-vertex normal computation to be angle-weighted
  • debug functionality for rendering normals
  • implement HC functionality (compute weights + deformation)
  • implement GC functionality (compute weights + deformation)
  • implement coordinate switching which will trigger the respective weight-recomputing algorithm
  • add an imgui window that serves as an output log (debug msgs, error msgs, user info, etc.)
  • undo/redo functionality
  • support for other file formats beside Wavefront OBJ, maybe even support for non-tri meshes
  • support for animation (run through deformed model poses)
  • ...
  • closer to release, decide on a LICENSE, include copy of every dependency licenses
  • port to macOS?
  • improve this README (build instructions, controls, assumptions, etc.)

REFERENCES


cage-tool's People

Contributors

texelbox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cage-tool's Issues

Issues of Porting the cage-tool Project to Ubuntu

Issues of Porting the cage-tool Project to Ubuntu

I am encountering an issue while porting the cage-tool project from Windows to Ubuntu 22.04. The project was originally built for Windows, but I'm trying to run it on Ubuntu. I have made some modifications to the CMakeLists.txt file and fixed some build errors, but the program is still crashing shortly after startup.

Problem Description

  • The program compiles successfully using CMake and Make on Ubuntu 22.04.
  • However, when running the executable, a window appears briefly and then closes immediately.
  • The program seems to be crashing during the initialization of the RenderEngine object, specifically when compiling shaders using the ShaderTools::compileShaders function.

Debugging Attempts

  1. I used GDB to debug the program and set a breakpoint at the RenderEngine constructor.
  2. Stepping through the code, I observed that the program enters the ShaderTools::compileShaders function and starts loading the shader source files.
  3. The vertex shader and fragment shader source files are loaded correctly using the loadshader function.
  4. However, the program crashes with a segmentation fault inside the __strlen_avx2 function, which is a low-level string length function optimized for AVX2 instructions.

CMakeLists.txt

# Set the minimum required version
cmake_minimum_required(VERSION 3.22)

# Define project name and specify the languages used
project(CageTool LANGUAGES CXX)

# Specify the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# List the source files for ImGui
set(IMGUI_SOURCES
    include/imgui/imgui.cpp
    include/imgui/imgui_demo.cpp
    include/imgui/imgui_draw.cpp
    include/imgui/imgui_widgets.cpp
    include/imgui/imgui_impl_glfw.cpp
    include/imgui/imgui_impl_opengl3.cpp
)

# Create a static library for ImGui
add_library(ImGui STATIC ${IMGUI_SOURCES})
target_include_directories(ImGui PUBLIC 
    ${CMAKE_CURRENT_SOURCE_DIR}/include/imgui
)

# Find packages
find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)
find_package(glfw3 REQUIRED)

# Explicitly set OpenGL preference (new policy in CMake 3.11 and later)
set(OpenGL_GL_PREFERENCE GLVND)

# List source files
set(SOURCES
    src/main.cpp
    src/Camera.cpp
    src/InputHandler.cpp
    src/lodepng.cpp
    src/MeshObject.cpp
    src/ObjectLoader.cpp
    src/Program.cpp
    src/RenderEngine.cpp
    src/ShaderTools.cpp
    src/Texture.cpp
)

# Define project's executable
add_executable(${PROJECT_NAME} ${SOURCES})

# Link project with required libraries
target_link_libraries(${PROJECT_NAME} 
    OpenGL::GL
    GLEW::GLEW
    glfw
    ImGui
)

# Include directories
target_include_directories(${PROJECT_NAME} PUBLIC 
    ${CMAKE_CURRENT_SOURCE_DIR}/include
    ${CMAKE_CURRENT_SOURCE_DIR}/include/GLFW
    ${CMAKE_CURRENT_SOURCE_DIR}/include/glm
)

Relevant Code

  • RenderEngine constructor in RenderEngine.cpp:
RenderEngine::RenderEngine(GLFWwindow *window, std::shared_ptr<Camera> camera) : window(window), camera(camera) {
    // ...
    trivialProgram = ShaderTools::compileShaders("shaders/trivial.vert", "shaders/trivial.frag");
    mainProgram = ShaderTools::compileShaders("shaders/main.vert", "shaders/main.frag");
    lightProgram = ShaderTools::compileShaders("shaders/light.vert", "shaders/light.frag");
    pickingProgram = ShaderTools::compileShaders("shaders/picking.vert", "shaders/picking.frag");
    // ...
}
  • ShaderTools::compileShaders function in ShaderTools.cpp:
GLuint ShaderTools::compileShaders(const char* vertexFilename, const char* fragmentFilename) {
    // ...
    const GLchar * vertex_shader_source [] = {loadshader(vertexFilename)};
    const GLchar * fragment_shader_source [] = {loadshader(fragmentFilename)};
    // ...
}
  • GDB Backtrace
Program received signal SIGSEGV, Segmentation fault.
__strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:74
74	../sysdeps/x86_64/multiarch/strlen-avx2.S: No such file or directory.
(gdb) backtrace
#0  __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:74
#1  0x00007ffff4d3998c in ?? () from /lib/x86_64-linux-gnu/libnvidia-glcore.so.535.161.07
#2  0x00007ffff4d39f14 in ?? () from /lib/x86_64-linux-gnu/libnvidia-glcore.so.535.161.07
#3  0x00005555555b7435 in ShaderTools::compileShaders(char const*, char const*) ()
#4  0x00005555555b5763 in RenderEngine::RenderEngine(GLFWwindow*, std::shared_ptr<Camera>) ()
...

Possible Causes

  • The crash could be related to differences in how the shader files are handled or how the OpenGL context is set up on Ubuntu compared to Windows.
  • There might be platform-specific assumptions or dependencies in the code that are not met on Ubuntu.
  • The issue could be related to shader compilation or loading, as the crash occurs during the shader compilation process.
    I have tried adding more error checking and logging statements in the shader compilation code, but the exact cause of the crash remains unclear.

Any suggestions or insights on how to resolve this issue and successfully port the cage-tool project to Ubuntu would be greatly appreciated. Please let me know if you need any additional information or code snippets to further investigate the problem.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.