Skip to content

N-body-type simulation of a galaxy using compute shader.

License

Notifications You must be signed in to change notification settings

ahmedkerouat/galaxySimulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

galaxySimulator

Table of content

About the project

This project is a n-body-type simulation of a galaxy. It utilizes a compute shader for real-time calculations of gravitational interactions between randomly generated spheres acting as stars. The simulation, built using OpenGL and GLFW, provides an environment to observe the effects of gravity, dark matter, and dark energy on celestial bodies as they move and interact in a virtual space. For this project, I was inspired by Angel Uriot. 🌌

Getting Started

Dependencies

Installation

> git clone https://github.com/ahmedkerouat/galaxySimulator.git
> cd galaxySimulator
> mkdir build
> cd build
> cmake ..
> make
> ./galaxySimulator

Structure

The project consists of multiple header files, each providing specific functionalities. Here's an overview of the key components:

  • sphere.h: This header file contains the Sphere class, which is used for rendering stars. It allows customization of the number of vertices and triangles that make up a sphere.

  • shader.h: The shader.h file provides functions for loading and compiling OpenGL shaders and creating shader programs. For instance, it includes a utility function, loadShaderSource, to load shader source code from external files.

  • shader_config.h: This header includes the configuration data for fragment & vertex shaders.

  • camera.h: The Camera class defined in this header is responsible for controlling the view and perspective within the simulation. It manages user input for camera movements.

Usage

You can control various aspects of the simulation through the user interface.

  • Number of Spheres: Adjust the number of randomly generated celestial spheres.

  • Radius: Customizes the radius of the galaxy.

  • Epsilon: A simulation parameter that limits the interaction between the spheres.

  • Delta Time: Specifies the time step for the simulation.

  • Dark Matter Mass: Sets the mass of dark matter within the simulation.

  • Dark Energy Effect: Determines the acceleration due to dark energy.

  • Pause/Resume: Pauses and resumes the simulation.

Controls

Within the simulation, you can control diverse camera parameters :

  • Right Mouse Button : Controls the camera's rotation.

  • Left Mouse Button : Controls the camera's position.

  • Scroll: Zoom in and out of the simulation.

  • Space button : Resets camera position to default.

On the menu Ctrl + Lmb to change precisely a simulation parameter using the slider

Screenshots

1 2

Contributing

If you have a suggestion to improve the project, please feel free to create a pull request. Alternatively, you can open an issue to discuss your ideas.

License

Project is licensed under the MIT LICENSE

About

N-body-type simulation of a galaxy using compute shader.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages