Over the past few weeks, I've created a planetary physics simulation for my Game Physics course. It uses OpenGL, GLUT, and GLUI to render out the simulation.
I've built a classic implementation of an Entity-Component system, where Entities only serve to bind data Components together, though my Entity also contains a position, since that is shared most often among components. The Systems operate on the Entities with certain Components. Thus, I have a PhysicsSystem which operates on all Entities with a PhysicsComponent. This allowed me to update the simulation all at once, instead of at a per-object basis, which could lead to some issues with state synchronization.
There were some challenges with the sheer scale of the numbers involved. In kilometers or kilograms, the distances or masses might be too large to operate on properly. I converted everything to astronomical units and solar masses, though this also caused some problems with very small numbers. In the end, though, I was able to get the simulation working mostly correctly. The Earth's moon is still a little weird, as I was not able to find the correct numbers to get it to work properly.
Getting the rendering to work also had a few challenges, most notably in rendering the planets with different textures. While I took a Graphics II course back in Montreal, that was in DirectX, and we had been given a solid framework to build off of. Here, I started from nothing to get an OpenGL renderer - not necessarily too challenging, but time-consuming.
No comments:
Post a Comment