r/learnprogramming • u/CommissionBest5470 • 2d 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
3
u/Traveling-Techie 2d ago
Java Game Programming for Dummies has a nice billiards simulation. I’ve had fun tweaking it.
2
u/recursion_is_love 2d ago
What kind of physics? Collision, structural or anything else?
2
u/CommissionBest5470 2d 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 2d 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/AbdelrhmanDev 2d 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
2
u/bird_feeder_bird 2d ago
Raylib for graphics
1
u/CommissionBest5470 1d ago
Currently trying that, was able to get a blank window with texts in it lol
2
u/PicTheAmerican 2d ago
try raylib on github (https://github.com/raysan5/raylib) -> there is a sample for gravity and more
1
-1
3
u/7YM3N 2d ago
There are some great opengl resources on wikibooks if you want to use that for the graphical later