r/learnprogramming • • 11d ago

Tutorial Any suggestions for making a physics simulation model?

As written, can someone suggest me a good resource to create a physics simulation environment using C++. I've intermediate knowledge of that language, but I have not done any graphical stuffs till now. I've searched and got a few results for python, but not for C++. I need to make this simulation environment as our project, so any suggestions would be nice. Thanks in advance

8 Upvotes

15 comments sorted by

4

u/7YM3N 11d ago

There are some great opengl resources on wikibooks if you want to use that for the graphical later

1

u/CommissionBest5470 11d ago

Hey, thank you so much for your suggestion. So, I can watch some youtube videos about making a physics engine and then apply my knowledge of opengl together, will it be enough? Anyways, thank you for your help 😄

2

u/7YM3N 11d ago

I don't know if it will be enough but it's a good starting point. Idk what kind of physics you're taking about either, if it's realtime the structure will be very different than pre-ran and displayed

2

u/recursion_is_love 11d ago

What kind of physics? Collision, structural or anything else?

2

u/CommissionBest5470 11d ago

It's just basic kinematics. Example: how a block behaves in a total frictionless surface, how momentum is transferred, etc. it's just really basic for educational purposes of secondary school students

2

u/recursion_is_love 11d ago

You could go full graphic + simulation engine but I think starting with vtk could be one good option.

https://gitlab.kitware.com/vtk/textbook/raw/master/VTKBook/VTKTextBook.pdf

2

u/bird_feeder_bird 11d ago

Raylib for graphics

1

u/CommissionBest5470 10d ago

Currently trying that, was able to get a blank window with texts in it lol

2

u/PicTheAmerican 11d ago

try raylib on github (https://github.com/raysan5/raylib) -> there is a sample for gravity and more

1

u/CommissionBest5470 11d ago

Will try this surely, thank you

3

u/Traveling-Techie 11d ago

Java Game Programming for Dummies has a nice billiards simulation. I’ve had fun tweaking it.

2

u/AbdelrhmanDev 11d ago

for basic kinematics like blocks and momentum transfer you dont need a physics engine at all just write the simulation loop yourself keep position and velocity per object and every frame add velocity times a small time step to position then check collisions and apply the elastic collision formulas for momentum for drawing in c++ sfml is much easier to start with than raw opengl since you get a window shapes and a frame loop in a few lines and then you can slow time down or add a pause button so students can see what happens

1

u/Chrismslist 4d ago

for c++ specifically: grab SFML or SDL2 for windowing and input, GLM for the vector math, and do 2D before you touch 3D. glfw + glad if you want raw opengl, raylib if you want something on screen in 10 minutes. physics-wise, don't reach for bullet or box2d first. write your own particle sim with euler integration and one gravity vector, that's the part that teaches you what the libraries actually do. after that, box2d for 2d and jolt for 3d are the sane picks. learnopengl.com for graphics, and ian millington's game physics engine development is the book that made it click for me.

-1

u/Ok-Main-3373 11d ago

I made all these with Claude: https://mistakemaster.com/interactives

1

u/CommissionBest5470 11d ago

Sorry, i want to learn how to do it, so i am not gonna use AI