This is a simple physics engine written in C++ using Glad, GLFW, OpenGl3 and Dear ImGui.
This repository is a port of the PhysicalEngine project to WebGL2.
Note
The project is made as an educational project to learn more about physics and game engine development.
- Basic object types (Sphere, Cube, Cylinder, Plane)
- Particle and Rigid Body Physics
- Collision Detection
- Forces (Gravity, Drag, Spring, Buoyancy)
- Torque forces (Angular Drag, Angular Spring)
- Different types of constraints
- Camera Controls
- GameObjects Inspector
- Scene Hierarchy
- Basic ECS (Entity Component System)
- Component Oriented Programming
- Fixed Framerate
- GameObject's speed Graph visualization
To build the project, you need to use a UNIX system, like Ubuntu or if you're on Windows you can use WSL.
Then you have to install Emscripten. You can find
instructions on how to install Emscripten here:
https://emscripten.org/docs/getting_started/downloads.html
You also need to have CMake and make installed. You can find instructions on how to
install CMake here:
https://cmake.org/install/
Make can be installed by running this command in the terminal:
sudo apt install make
Once you have Emscripten and CMake installed run this command in the project root directory:
emcmake cmake .
Then run this command in the same directory:
emmake make
To test the website locally, you need to have Python installed. You can find instructions on how to install Python here:
https://www.python.org/downloads/
Once you have Python installed, run this command in the project build directory:
python -m http.server
Then open your browser and go to this address:
To modify the speed value, you can use the ImGui window named Speed handler
.
Action | Key |
---|---|
Add speed to the left | ← |
Add speed to the right | → |
Add speed forwardly | ↑ |
Add speed rearward | ↓ |
Action | Key |
---|---|
Toggle fullscreen | F11 |
Camera zoom | Mouse wheel |
Translate camera to the left | Right Mouse Button + Mouse ← movement |
Translate camera to the right | Right Mouse Button + Mouse → movement |
Translate camera upwards | Right Mouse Button + Mouse ↑ movement |
Translate camera downwards | Right Mouse Button + Mouse ↓ movement |
Exit app | ESC |
- C++ 14
- CMake
- Emscripten (2.0.29)
- GLFW (3.3.8)
- OpenGl (3.3)
- Glad (0.1.36)
- Dear ImGui (1.89.4)
- glm (0.9.8)
The project has unit tests to check come common classes. You can find them in the test
folder.
This project uses GitHub Actions to build the project and deploy it to GitHub
The project is set with a set of different scripts:
- CodeQL: This script is used to check the code for security issues.
- CMake: This script is used to build the project.
- Cpp Cmake Publish: This script is used to publish the project on GitHub.
- Flawfinder: This script is used to check the code for security issues.
- Microsoft C++ Code Analysis: This script is used to check the code for security issues.
- Cpp Linter: This script is used to check the code for security issues.
- Emscripten CMake: This script is used to test build of the project using Emscripten toolchain.
- Emscripten-Publish: This script build to webgl and publish the project on GitHub Pages.
OpenGL:
https://www.khronos.org/registry/OpenGL-Refpages/gl4/
OpenGL loading library:
https://www.khronos.org/opengl/wiki/OpenGL_Loading_Library
GLFW:
https://www.glfw.org/docs/latest/
Dear ImGui:
https://github.com/ocornut/imgui
GLAD:
https://glad.dav1d.de/
GLM:
https://glm.g-truc.net/0.9.8/index.html
STB:
https://github.com/nothings/stb
ImPlot:
https://github.com/epezent/implot
Learn OpenGL:
https://learnopengl.com/Getting-started/Hello-Triangle
Developpez Learn OpenGL (Translated in French):
https://opengl.developpez.com/tutoriels/apprendre-opengl/?page=creer-une-fenetre#L4-5
https://opengl.developpez.com/tutoriels/opengl-tutorial/
Sphere OpenGL:
http://www.songho.ca/opengl/gl_sphere.html
unrealistic.dev (Change CMake working directory):
https://unrealistic.dev/posts/setting-debug-parameters-with-cmake-tools-for-visual-studio
Quentin MOREL:
- @Im-Rises
- https://github.com/Im-Rises
Quentin MOREL:
- @Im-Rises
- https://github.com/Im-Rises
Gabriel REBOUL:
- @spiryti
- https://github.com/spiryti
Clémence CLAVEL:
- @clemos38
- https://github.com/clemos38