Particle Simulation - Learning OpenGL and C++ banner

Particle Simulation - Learning OpenGL and C++

9 devlogs
19h 21m 47s

A particle simulation as a way to learn about C++ and OpenGL.

This project uses AI

Used ChatGPT and Claude for learning and debugging C++, and to help me setup and create a github workflow

Demo Repository

Loading README...

AVD

Tagged your project as well cooked!

🔥 AVD marked your project as well cooked! As a prize for your nicely cooked project, look out for a bonus prize in the mail :)

Jahaan

Shipped this project!

Hours: 18.5
Cookies: 🍪 108
Multiplier: 5.83 cookies/hr

I built a really simple particle simulation that includes verlet integration and gravity, however this was a means for me to learn about C++ and OpenGL. In the future I will be creating a fluid simulation, and using this experience as a guide. Thank you, I know this isn’t really demoable, but pls see the videos in my journals if you want to see the demos. THANK YOU

Jahaan

Updates:

  • Fixed verlet integration to update based on gravitational acceleration rather than each particles acceleration
  • Added gravitational acceleration to the bottom center of the boundary sphere
  • Updated the boundary visualisation into lines instead of dots
  • Fixed up code so that it would work alongside the gravity acceleration
0
Jahaan

Updates:

  • Added verlet integration for smoother and stable positional updates. Also cleaned up code.
  • Added Clamping to the camera pitch to make sure we dont end up in some weird camera position, and to make it a orbital camera instead of free moving.

P.S. Dont know how I have 1 hour on this?

0
Jahaan

Updates:

  • Implemented Quaternion Class and Camera class for a fully functional camera system. Prevents Gimbal Lock and faster computation and same rotation irrelevant of what comes first or next in multiplication.
  • I had learned about Quaternions in my previous project when building a software rasterizer I just had to understand and add the neccessary function to implement in C++.

Next Steps:

  • Realistic collision (Elastic and Inelastic)
  • Different effect depending on collision of different masses
  • Introduce friction, air drag, and other natural variables
0
Jahaan

Updates:

  • Cleaned up Code and added structured comments to each part for clean readability.
  • Updated readme file
  • added test particle for future testing.
  • Added lighting to the simulation for more realistic affect
Attachment
0
Jahaan

Updates:

(Inspired by Michael Richardson)

  • Added 3D particle collision by comparing the current iteration particle to the next iteration (i + 1), and seeing if there distances (positional) were less than there radius + and other radius (if they are not into each other)
  • Created a Sphere Boundary for better visual effects
  • Implemented energy loss (damping) for each collision
  • Spawned particles from a bit above the center of the sphere boundary

Current Bugs:

  1. The spawned particles are initially being stuck and frozen on the starting position, and I dont know why

Next Steps:

  • Optimize particle collision algorithm (currently need 0(n^2) because it uses two for loops to check for collisions
  • Add better gravity simulation and other natural variables affect in simulation
0
Jahaan

Updates:

  • Added 3D particles and camera
  • Learned about OpenGL 3D rendering pipeline
  • Create Particle3D class for drawing 3D spheres, and boundary collision
  • Added Lighting and Visible boundary box
  • Also implemented gravity mode and I can control the gravity acceleration
  • Control over the angle of particle movement (phi and theta)

Next Steps:

  • I want to be able to now spawn particles at one point and add particle collision and just simulate the effect of that. I will also need to optimize the code so that it can handle hundreds of particles
0
Jahaan

Added gravity acceleration. The particle is now filled and is bounded by the screen size, moreover added mouse mode where the particle follows the mouse. The particle is attracter to the center of the screen.

0
Jahaan

As this was my first time using C++ or any language that goes directly for compiling, I had to learn about the tasks.json files, and C++ syntax and how everything works (classes, variables, pointers, etc). And this was my first time using OpenGL, I had to set it up and other libraries and dependencies. After I got the hang of everything, I made a triangle, and then tried to implement my own particle class. Eventually I drew a circle with velocity.

0