Monday, 22 October 2012

An Astronomical Step Forward

                This week I managed to get the entirety of medium question 1, the solar system with clickable planets and moons that displayed information about them, completed. It took four days of non-stop work, but I managed to pull it off, and subsequently earned enough XP to write the midterm in the next hour. However, the experience was not easy. Even “medium” is a stretch.
                I initially encountered a problem when trying to load the texture onto my sun. I’ve run into this problem for practically every single assignment I’ve attempted, so I wasn’t surprised. Frustration set in when I realised that I’d done everything that in previous instances had solved my issue. After an hour or so of looking through past assignments, googling, and swearing at my computer, I realised that I’d been working out of the folder for Easy Question 1, not Medium Question 1.
                After that, I was able to get all of my planets loaded in and textured appropriately. To calculate the distance of each planet to the sun I went off of the Parenting example. In that example Earth is five units away from the Sun, so I looked up how far away the Earth is from the sun and divided by five. I then looked up all of the other planets’ distances and divided them by that resultant to determine how many units away each planet was from the Sun.
                Rotations were also a huge problem. The provided equation wasn’t working for me, so I ended up devising my own math for the planets’ orbital and rotation periods. I divided the degrees of a full circle (360) by the frames per second that the engine was running at (60). Then I divided that number by a ratio of the planet’s orbital or rotation period by the degrees of a circle. Finally, I divided that number by a variable called “choke”, which when increased would slow own the simulation in order to make it easier to click on some of the celestial bodies with shorter orbital periods. In the end, this equation worked for the orbits and rotations of every celestial body and the rest was a matter of copy and paste.
mPlanetOrbit = ((360/60)/(Orbital Period/360))/choke
mPlanetSpin = ((360/60)/(Rotation Period/360))/choke
                What this does is tell Ogre how many degrees to rotate each object per frame, and provided me with a system that was accurate to reality.
                Selecting the objects were done via the Ray Picking example and differentiating objects was done via a simple string compare function based on each node’s name. After I’d figured out that all I had to do was fill in information pertaining to each celestial body and the ordeal was over.
                Two successful weeks in a row. Scary stuff.


No comments:

Post a Comment