Skip to content

Tolisz/Simulation_PR3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jelly Simulator

example_monkey.mp4
example_jelly.mp4

About project

This is the third project created during "Physical simulations in a virtual environment" course, specialty CAD/CAM systems design of degree in Computer Science and Information Systems at Warsaw University of Technology.

The project is a simulation of 64 mass points arranged in a 4x4x4 cube (jelly) and connected to each other by springs. Jelly's corner points are connected to the corners of the control frame with special springs of zero rest length. User can freely move and rotate the control frame that the jelly will follow.

The jelly is inside the collision frame that he can't get out of. The control frame can be freely moved outside the collision frame.

Normaly the jelly is rendered as 6 Bézier patches based on control points which are outer jelly's points. Additionally, any user's model can be inserted inside the jelly. A model will be deformed using free-form deformation (FFD):

$$F(u, v, w) = \sum_{i}^3\sum_{j}^3\sum_{k}^3 P^{ijk} B_i^3(u)B_j^3(v)B_j^3(w),$$

where $(u, v, w) \in [0, 1]^3$, $P^{ijk}$ - jelly points, $B^3_i(t)$ - bernstein polynomial.

The project has 4 example models which can be found in ./resources/models folder.

User model shading is computed based on this definition of FFD transofrmation.

Navigation

Camera
MMB hold camera rotation
Shift + MMB hold camera movement
MMB scroll camera zoom in/out
Collision Frame (if enabled)
Ctrl + LMB move collision frame
R rotate collision frame around camera's front vector. To accept rotation click LMB
R + R rotate collision frame around camera's right and up vectors. To accept rotation click LMB
Jelly's points (if collision frame is disabled)
Ctrl + LMB move selected point

Compilation

The project is written in C++ (OpenGL) using CMake as a build system. It has two configuration CMake options:

Option Description
PR3_EMBEDDED_SHADERS If ON shader code will be embedded into a resulting app's binary. If OFF shader code will be read from shaders directory, so a binary has to be run from repository root directory.
PR3_SHOW_DEBUG_CONSOLE If ON - beside app's window - a debug console will be shown on app start up. If OFF only app's window will be shown.

MS Windows

All subsequent commands should be called from Windows Power Shell.

git clone --recurse-submodules -j8 https://github.com/Tolisz/Simulation_PR3.git
cd Simulation_PR3
cmake -S . -B build -DPR3_EMBEDDED_SHADERS=ON -DPR3_SHOW_DEBUG_CONSOLE=OFF
cmake --build build --config Release
.\build\Release\SimulationPr3.exe

Linux

All subsequent commands should be called from terminal. Compilation was checked using g++ (version 11.4.0) and clang++ (version 14.0.0) compilers.

$ git clone --recurse-submodules -j8 https://github.com/Tolisz/Simulation_PR3.git
$ cd Simulation_PR3
$ cmake -S . -B build -DPR3_EMBEDDED_SHADERS=ON -DPR3_SHOW_DEBUG_CONSOLE=OFF
$ cmake --build build --config Release -j 26
./build/SimulationPr3

Used Libraries

Libraries GLFW, GLM, Assimp, STB and ImGui are used as submodules located in externals directory. GLAD is used as a generated file from glad web page.

Library Licence
GLFW Zlib
GLM Modified MIT
ImGui MIT
GLAD MIT
STB Modified MIT
Assimp BSD