The task is to implement a simple physical simulation in 3D: balls (marbles) moving in a homogeneous gravitational field, bouncing off of transparent walls and one another.
The following components will need to be designed and implemented:
The project 058marbles from the
grcis
repository will serve as the basis.
The application has a basic support of real-time simulation on the CPU and
rendering using OpenGL.
The following classes (all in the file Marbles.cs) will need to be modified to implement the assignment:
You may read up on the elastic or inelastic collisions in most game development books or in Wikipedia (follow references). Read up for example here on the impact response. It is assumed that you will spend some time studying the problem yourself.
One step of the physical simulation is run in the method Form1.Simulate(). Two variants of the simulation loops are implemented:
Synchronous: one simulation step is immediately followed by rendering one frame. This is implemented in the function Application_Idle(). When V-sync is on, the simulation and rendering speed are limited by the display refresh frequency (of course, you may turn VSync off).
Asynchronous: simulation and rendering are performed in two separate threads. If you turn on the asynchronous MT mode, the simulation will run at a maximum possible speed in a separate thread, employing 100% of one of your CPU cores (see Form1.SimulationLoop()). The rendering remains in the method Application_Idle() and it is usually driven by the display refresh (since the simulated scene will usually not represent a significant load for your GPU).
The project 058marbles has a "screencast" functionality, which allows to save individual frames in real-time to the disk (can be used later to assemble a video). The functionality of a transparent, independent screencast is implemented by the class OpenglSupport.Screencast. The screencast mode is enabled in the parameter line by setting screencast=true (to switch it off again, use screencast=false).
The frames are written to the disk in the PNG format. This mechanism is implemented asynchronously in a separate CPU thread and should not slow your program down. Should the disk be too slow to write the frames, the program will keep a queue of up to 500 unsaved frames. The current queue length is displayed as the number in parentheses in the program's status line. Should this number systematically increase, you computer may not be fast enough to save the frames and it may be better to switch the screencast off. We recommend using VSync in the screencast mode.
Bonus points will be awarded for any additional effort over the standard solution: dynamically added balls (they can be added or they can die off), more complex geometry of the collision scene, ball rotation and corresponding response, a more realistic imperfect-elastic collision, air friction (realistic ballistics), alternative interesting gravitational field (a la "Angry Birds Space"), a spatial data structure for faster collision detection (switching between the advanced and brute-force solution will be necessary to compare the speed), etc.
The due date is: 17. 2. 2019
Basis: 12 pts (simple but functional simulation, mandatory features are: ball-ball and ball-wall collisions,
gravitational field),
further up to 10 pts: bonus for interesting extensions (see above)
Visual Studio project: 058marbles.
Make sure to always update the grcis repo before
you start working on an assignment.
Modify an hand in the file: Marbles.cs (and potentially also the modified shader files)
Write your entire name in the function InitParams().
Copyright (C) 2012-2018 J.Pelikán and J.Krivánek, last change: 2019-05-09 17:52:59 +0200 (Thu, 09 May 2019)