3d Solar System Model

Before I started reading The Nature of Code I wanted to go over the some of the magical processing tricks I had learned so far so they had a better chance of staying lodged somewhere in my brain. One of the exercises in Learning Processing was to build a 3d Model of a solar system which was quite good fun in itself. I decided to expand on this so that I could include a few extras. Namely moons, different planet orbit speeds, asteroids, planets with rings, a function to take snapshots as well as a zoom and a manual camera function linked to the mouse.

Everything came together quite easily which I was rather chuffed about. The only thing outside my capabilities was generating random shaped asteroids. Luckily and as with most things these days in the coding game, some bright sparks had already done some pretty good jobs which they have admirably published and shared on the internet. After some quick research and code-browsing,  I decided to use the algorithm written by Gendou for the building blocks of my asteroid class. I also learnt a few extra tricks to boot.

I’m also planning on developing this program further. After I’ve delved into my next book, it will be great to add some random flying objects like meteorites and comets. I also know you can use images wrapped around the spheres so this would give me the tools to make my planets look more lifelike. A more functional manual camera that would allow you to zoom in on planets rather than just the sun would also be good but I need to get my head further around translation, matrices and 3D modelling before any of this can take shape. I also want to make the planet orbits more lifelike rather than just a perfect circle. All in good time.

Anyway, this is a bit of a monster so it won’t run very well on an old laptop, which is what I used to develop most of it, sitting on the train. –  That’s Something else I can look at improving! Most parameters can be customised so if you want, you can design your own solar system or improve on the code I have already written.

The zip is available for download at the bottom or the code is also on github