You may work with one partner on this assignment. For this lab, you will be writing code from scratch, but you can use the planet.c example in w04-transforms as a possible starting point. You will be modeling an entire solar system, using coordinate transformations. Mostly you will be making judicious use of glTranslatef, glRotatef, glPopMatrix, glPushMatrix, to work in different coordinate systems.
You can parse this data file using code similar to that in parseData.cpp which you can compile and run using g++ parseData.cpp -o parseData && ./parseData
You must create a planet class or planet struct to organize necessary planet info.
You must draw and animate all the planets listed. All planets should revolve in the same direction around the sun, but not at the same rate. You may assume the planets revolve in circular orbits, but the eccentricity is given if you want to model elliptical orbits. You can use glutSolidSphere to model the planets
Assign a color to each of the planets. You may want to add these parameters to the data file, so you can refresh them without recompiling.
You must model at least one moon around one of the planets. You can choose the size of the moon, radius of orbit, and period of rotation, or consult a source for reasonable defaults.
You should enable double buffering as well as the depth buffer. Code samples will demonstrate how to enable these features.
Add keyboard controls to pan and zoom. You can decide how this is implemented. Remember you can change either the projection or model view.
To get a working build system, you may start as follows.
cd cs40/labs/04 cp ../../class/w04-3d/planet.c ./solarSystem.cppFor the purposes of this example, I implemented my planet class in planet.h and planet.cpp and my test code is in solarSystem.cpp. My CMakeLists.txt looks like this
#create a new library called planet #a library consists of compiled cpp code, but #does not have a main function #put all the .h files needed for your library here #planet_hdrs is just a variable name, not a header file set(planet_hdrs planet.h ) #put all the .cpp files needed for your library here set(planet_src planet.cpp) #tell cmake that the new "planet" library depends on #the hdrs and src defined above add_library(planet ${planet_hdrs} ${planet_src}) #stuff any openGL app usually needs. set(CORELIBS ${GLUT_LIBRARY} ${OPENGL_LIBRARY} m) #create a new solarSystem executable based on #solarSystem.cpp. This code has a main function add_executable(solarSystem solarSystem.cpp) #link compiled solarSystem code with openGL libraries #and your new planet library target_link_libraries(solarSystem ${CORELIBS} planet) #tell cmake that the solarSystem executable depends #on some data files too and symlink them symlink_data(solarSystem solarData.txt) #parseData is just a simple cpp program and doesn't need #to link against anything add_executable(parseData parseData.cpp)Remember to edit the CMakeLists.txt file in the parent directory and add add_subdirectory(04). Then go into cs40/labs/build and type make. If all goes well, it should create a 04 subdirectory, build and link solarSystem, and symlink your solarData.txt file. If solarData.txt does not appear in your build directory, you may need to symlink the file yourself using
ln -s ../../04/solarData.txt ./