Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/im-rises/physicalengine

Physical Engine written in C++ with GLFW, Glad, OpenGL 3 and Dear ImGui
https://github.com/im-rises/physicalengine

3d-graphics cmake cpp game game-development game-engine glad glfw glm gui imgui opengl particles-simulation

Last synced: 2 months ago
JSON representation

Physical Engine written in C++ with GLFW, Glad, OpenGL 3 and Dear ImGui

Awesome Lists containing this project

README

        

# PhysicalEngine


cmakeLogo
cppLogo
openglLogo
glfwLogo

## Description

This is a simple physics engine written in C++ using Glad, GLFW, OpenGl3 and Dear ImGui.

It is implemented using Fixed Framerate and Component Oriented Programming.

## πŸš€πŸš€ [You can test it online here](https://im-rises.github.io/physical-engine-webgl/) πŸš€πŸš€

The source code of the WebGL can be found at the following link:

> **Note**
> The project is made as a educational project to learn more about physics and game engine development.

## Features

### Physics features

- [x] Basic object types (Sphere, Cube, Cylinder, Plane)
- [x] Particle and Rigid Body Physics
- [x] Collision Detection
- [x] Forces (Gravity, Drag, Spring, Buoyancy)
- [x] Torque forces (Angular Drag, Angular Spring)
- [x] Different types of constraints

### User Interface features

- [x] Camera Controls
- [x] GameObjects Inspector
- [x] Scene Hierarchy

### Other features

- [x] Basic ECS (Entity Component System)
- [x] Component Oriented Programming
- [x] Fixed Framerate
- [x] GameObject's speed Graph visualization

## Images

![RigidBodyImage](https://user-images.githubusercontent.com/59691442/204342827-5407dc9f-c05e-4a26-b513-b37ce5ab7d14.png)

![screenshot2](https://user-images.githubusercontent.com/59691442/206077820-3edaff06-8d5e-4187-a575-251b4acec8d3.png)

## Quickstart

To download the app, you can click one of the icons below (depending on your operating system). You can also click the
release section of the GitHub page.

Depending on you `operating system` you will need to install some libs, they are installed differently depending on your
system, please follow one of the section below `Windows` or `Linux` or `MacOs`.

> **Warning**
> Be sure to put the `imgui.ini` file in the same folder as the executable.
> You can find it in the `root` of the project. If you don't do this, the UI will not be displayed correctly.

### Windows

cmakeLogo

For Windows users you don't need to install the libs. You can just download the app and run it.

```bash
.\PhysicalEngine.exe
```

> **Warning**
> The project is set up to be built using CMake and vc2019 for Windows. If you want to modify the
> compiler for vc2022 or other you will need to change the CMakeLists.txt .lib linking file accordingly to your vc20**
> version.

### Linux

cmakeLogo

For Linux users, you need to install the GLFW lib, to do so type one of the following commands:

```bash
sudo apt-get install libglfw3
```

or if you're a developer and want to compile the app, please install this version of GLFW:

```bash
sudo apt-get install libglfw3-dev
```

Then you can start by double-clicking the executable of typing the following command next to it:

```bash
./PhysicalEngine
```

### MacOs

cmakeLogo

For macOS users you will need to install Brew, please follow the instruction in the link below:

Once it is installed, you can type the following command to install GLFW.

```bash
brew install glfw
```

Then you can start by double-clicking the executable of typing the following command next to it:

```bash
./PhysicalEngine
```

## Controls

### Game controls

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 | ↓ |

### User controls

| 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 |

## Project Architecture

~~~
PhysicalEngine
β”œβ”€β”€ .github
| β”œβ”€β”€ labels.yml
| β”œβ”€β”€ release.yml
β”‚ β”œβ”€β”€ workflows
β”‚ β”‚ |── cmake.yml
β”‚ β”‚ |── codeql.yml
β”‚ β”‚ |── cpp-cmake-publish.yml
β”‚ β”‚ |── cpp-linter.yml
β”‚ β”‚ |── dependency-review.yml
β”‚ β”‚ |── flawfinder.yml
β”‚ β”‚ |── greetings.yml
β”‚ β”‚ |── label.yml
β”‚ β”‚ |── msvc.yml
β”‚ β”‚ |── stale.yml
β”œβ”€β”€ dependencies
| β”œβ”€β”€ glad
| β”œβ”€β”€ glfw
| β”œβ”€β”€ glm
| β”œβ”€β”€ imgui
| β”œβ”€β”€ stb
β”œβ”€β”€ PhysicalEngine
| β”œβ”€β”€ Contact (Particles)
β”‚ β”‚ |── *
| β”œβ”€β”€ Force
β”‚ β”‚ |── *
| β”œβ”€β”€ Octree
β”‚ β”‚ |── *
| β”œβ”€β”€ RigidbodyContact
β”‚ β”‚ |── *
| β”œβ”€β”€ Scene
β”‚ β”‚ |── *
| β”œβ”€β”€ Shader
β”‚ β”‚ |── *
| β”œβ”€β”€ Utility
β”‚ β”‚ |── *
| β”œβ”€β”€ CMakeLists.txt
| β”œβ”€β”€ Game.cpp
| β”œβ”€β”€ Game.h
| β”œβ”€β”€ InputManager.cpp
| β”œβ”€β”€ InputManager.h
| β”œβ”€β”€ main.cpp
| β”œβ”€β”€ PhysicalEngineLauncher.cpp
| β”œβ”€β”€ PhysicalEngineLauncher.h
β”œβ”€β”€ test
| β”œβ”€β”€ TestParticle
β”‚ β”‚ |── *
| β”œβ”€β”€ CMakeLists.txt
| β”œβ”€β”€ matrix33Test.cpp
| β”œβ”€β”€ matrix34Test.cpp
| β”œβ”€β”€ quaternionTest.cpp
| β”œβ”€β”€ vector3dTest.cpp
β”œβ”€β”€ .clang-format
β”œβ”€β”€ .editorconfig
β”œβ”€β”€ .gitattributes
β”œβ”€β”€ .gitignore
β”œβ”€β”€ CMakelists.txt
β”œβ”€β”€ CMakePresets.json
β”œβ”€β”€ CMakeSettings.json
β”œβ”€β”€ imgui.ini
β”œβ”€β”€ README.md
~~~

## Dependencies

- C++ 14
- CMake
- C++ compiler (MSVC, Mingw, ...)
- Glad
- GLFW (3.3.8)
- OpenGl (3.3)
- Dear ImGui (1.88)
- glm (0.9.8.5)

## Compilation

To compile the app, the first thing you need to do is install a C++ compiler:

- Visual Studio (MSVC)
- Mingw
- ...

You also need to install Cmake:

Once your environment is set up, depending on your operating system you'll need to install some libs before compiling
the project. Refer to the section below `Windows` or `Linux` or `MacOs`.

### Windows

Windows users can directly compile the project by typing the following command at the project root folder:

```bash
cmake .
```

> **Note**
> If you're using Visual Studio, you can install CMake directly from the IDE (Visual Studio Installer).
> Then you need to open the Project as a CMake Project, not a Visual Studio Project!

### Linux

Linux's users need to install some libs before compiling the project:

First thing to do is to install CMake, type the following command to install it.

```bash
sudo apt-get install cmake
```

You also need to install the GLFW lib. Type the following command at the project root.

```bash
sudo apt-get install libglfw3-dev
```

You are now able to compile the project. Go to the project root and type the following command:

```bash
cmake .
```

### MacOs

For macOS user, you should install brew package manager by following the instructions in the link below:

Then type the following command to install cmake:

```bash
brew install cmake
```

and this one to install GLFW

```bash
brew install glfw
```

You are now able to compile the project. Go to the project root and type the following command:

```bash
cmake .
```

## Oriented Components Architecture

Placeholder

## Run tests

A CMake test is set up to directly test the program. You can find it in the `test`folder and start it by typing the
command below at the project root folder.

```bash
ctest
```

## Github-Actions

[![CodeQL](https://github.com/Im-Rises/PhysicalEngine/actions/workflows/codeql.yml/badge.svg?branch=main)](https://github.com/Im-Rises/PhysicalEngine/actions/workflows/codeql.yml)
[![CMake](https://github.com/Im-Rises/PhysicalEngine/actions/workflows/cmake.yml/badge.svg?branch=main)](https://github.com/Im-Rises/PhysicalEngine/actions/workflows/cmake.yml)
[![Cpp Cmake Publish](https://github.com/Im-Rises/PhysicalEngine/actions/workflows/cpp-cmake-publish.yml/badge.svg?branch=main)](https://github.com/Im-Rises/PhysicalEngine/actions/workflows/cpp-cmake-publish.yml)
[![flawfinder](https://github.com/Im-Rises/PhysicalEngine/actions/workflows/flawfinder.yml/badge.svg?branch=main)](https://github.com/Im-Rises/PhysicalEngine/actions/workflows/flawfinder.yml)
[![Microsoft C++ Code Analysis](https://github.com/Im-Rises/PhysicalEngine/actions/workflows/msvc.yml/badge.svg?branch=main)](https://github.com/Im-Rises/PhysicalEngine/actions/workflows/msvc.yml)
[![cpp-linter](https://github.com/Im-Rises/PhysicalEngine/actions/workflows/cpp-linter.yml/badge.svg?branch=main)](https://github.com/Im-Rises/PhysicalEngine/actions/workflows/cpp-linter.yml)

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.

## Documentations

OpenGL:

OpenGL loading library:

GLFW:

Dear ImGui:

GLAD:

GLM:

STB:

ImPlot:

Learn OpenGL:

Developpez Learn OpenGL (Translated in French):

Sphere OpenGL:

unrealistic.dev (Change CMake working directory):

## Contributors

Quentin MOREL:

- @Im-Rises
-

Gabriel REBOUL:

- @spiryti
-

ClΓ©mence CLAVEL:

- @clemos38
-

[![GitHub contributors](https://contrib.rocks/image?repo=Im-Rises/PhysicalEngine)](https://github.com/Im-Rises/PhysicalEngine/graphs/contributors)