Mercurial > solar_system
changeset 4:7ae4ee5c27f8 tip
Corrected orientation and orbital speed of Moon
author | Eris Caffee <discordia@eldalin.com> |
---|---|
date | Sun, 28 Apr 2013 18:36:00 -0500 |
parents | c24af3462002 |
children | |
files | CMakeLists.txt src/solar-system.cpp textures/Marble.tga textures/Marslike.tga textures/MoonLike.tga textures/marble.tga |
diffstat | 6 files changed, 35 insertions(+), 15 deletions(-) [+] |
line diff
1.1 --- a/CMakeLists.txt Sat Apr 27 13:22:17 2013 -0500 1.2 +++ b/CMakeLists.txt Sun Apr 28 18:36:00 2013 -0500 1.3 @@ -117,7 +117,7 @@ 1.4 # C -std=gnu99 -std=c99 1.5 1.6 if (CMAKE_COMPILER_IS_GNUCXX) 1.7 - add_definitions(-pedantic -Wall -std=c++0x) 1.8 + add_definitions(-Wall -std=c++0x) 1.9 endif () 1.10 1.11
2.1 --- a/src/solar-system.cpp Sat Apr 27 13:22:17 2013 -0500 2.2 +++ b/src/solar-system.cpp Sun Apr 28 18:36:00 2013 -0500 2.3 @@ -14,9 +14,13 @@ 2.4 2.5 #include <dirent.h> 2.6 2.7 +#include <string> 2.8 + 2.9 #include <GL/glut.h> 2.10 #include <GL/glx.h> 2.11 2.12 +//////////////////////////////////////////////////////////////////////////////// 2.13 + 2.14 GLShaderManager shaderManager; 2.15 GLMatrixStack modelViewMatrix; 2.16 GLMatrixStack projectionMatrix; 2.17 @@ -29,17 +33,16 @@ 2.18 2.19 int width = 800; 2.20 int height = 600; 2.21 -int fullscreen = 0; 2.22 +int fullscreen = 1; 2.23 2.24 -#define NUM_SPHERES 50 2.25 -GLFrame spheres[NUM_SPHERES]; 2.26 +//////////////////////////////////////////////////////////////////////////////// 2.27 2.28 GLTriangleBatch jupiterBatch; 2.29 -GLTriangleBatch sphereBatch; 2.30 GLTriangleBatch earthBatch; 2.31 GLTriangleBatch moonBatch; 2.32 GLTriangleBatch sunBatch; 2.33 -GLBatch floorBatch; 2.34 + 2.35 +//////////////////////////////////////////////////////////////////////////////// 2.36 2.37 #define TEX_EARTH 1 2.38 #define TEX_MOON 2 2.39 @@ -49,6 +52,11 @@ 2.40 GLuint uiTextures[NUM_TEXTURES]; 2.41 2.42 //////////////////////////////////////////////////////////////////////////////// 2.43 + 2.44 +const std::string Data_Dir("../textures/"); 2.45 + 2.46 +//////////////////////////////////////////////////////////////////////////////// 2.47 + 2.48 #define SCREENSHOT_FILENAME_BASE "screenshot-" 2.49 #define SCREENSHOT_FILENAME_BASELEN 11 2.50 #define SCREENSHOT_FILENAME_EXT ".tga" 2.51 @@ -148,7 +156,7 @@ 2.52 2.53 float MoonRotSpeed = 1.0/29.5 * RotScale; 2.54 float MoonAxialTilt = 6.7; 2.55 - float MoonOrbitSpeed = 1.0/29.5 * RotScale; 2.56 + float MoonOrbitSpeed = 1.0/(24*29.5) * RotScale; 2.57 float MoonOrbitTilt = 5.145; 2.58 2.59 static CStopWatch rotTimer; 2.60 @@ -271,13 +279,15 @@ 2.61 2.62 // orbit the Earth 2.63 modelViewMatrix.Rotate(MoonOrbitTilt, 0.0f, 0.0f, 1.0f); 2.64 + 2.65 // NOrth is up! 2.66 - modelViewMatrix.Rotate(-90.0f - MoonAxialTilt, 0.0f, 1.0f, 0.0f); 2.67 + modelViewMatrix.Rotate(90.0f - MoonAxialTilt, -1.0f, 0.0f, 0.0f); 2.68 + modelViewMatrix.Rotate(90.0f, 0.0f, 0.0f, 1.0f); 2.69 2.70 float MoonRot = rotTimer.GetElapsedSeconds() * MoonOrbitSpeed * 10; 2.71 - modelViewMatrix.Rotate(MoonRot, 0.0f, 1.0f, 0.0f); 2.72 + modelViewMatrix.Rotate(MoonRot, 0.0f, 0.0f, 1.0f); 2.73 2.74 - modelViewMatrix.Translate(0.5f, 0.0f, 0.0f); 2.75 + modelViewMatrix.Translate(0.0f, 0.5f, 0.0f); 2.76 2.77 2.78 glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_MOON]); 2.79 @@ -347,17 +357,23 @@ 2.80 2.81 glGenTextures(NUM_TEXTURES, uiTextures); 2.82 2.83 + std::string f; 2.84 + 2.85 + f.assign(Data_Dir).append("earth.tga"); 2.86 glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_EARTH]); 2.87 - LoadTGATexture("../textures/earth.tga", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE); 2.88 + LoadTGATexture(f.c_str(), GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE); 2.89 2.90 + f.assign(Data_Dir).append("moon.tga"); 2.91 glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_MOON]); 2.92 - LoadTGATexture("../textures/moon.tga", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE); 2.93 + LoadTGATexture(f.c_str(), GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE); 2.94 2.95 + f.assign(Data_Dir).append("jupiter.tga"); 2.96 glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_JUPITER]); 2.97 - LoadTGATexture("../textures/jupiter.tga", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE); 2.98 + LoadTGATexture(f.c_str(), GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE); 2.99 2.100 + f.assign(Data_Dir).append("sun.tga"); 2.101 glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_SUN]); 2.102 - LoadTGATexture("../textures/sun.tga", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE); 2.103 + LoadTGATexture(f.c_str(), GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE); 2.104 2.105 static M3DMatrix44f mCamera; 2.106 cameraFrame.GetCameraMatrix(mCamera); 2.107 @@ -522,7 +538,7 @@ 2.108 glutInit(&argc, argv); 2.109 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL); 2.110 glutInitWindowSize(800, 600); 2.111 - glutCreateWindow("OpenGL SphereWorld"); 2.112 + glutCreateWindow("OpenGL Solar System"); 2.113 2.114 glutReshapeFunc(ChangeSize); 2.115 glutDisplayFunc(RenderScene); 2.116 @@ -552,6 +568,10 @@ 2.117 SwapInterval(1); 2.118 2.119 SetupRC(); 2.120 + 2.121 + glutFullScreen(); 2.122 + fullscreen = 1; 2.123 + 2.124 glutMainLoop(); 2.125 ShutDownRC(); 2.126
3.1 Binary file textures/Marble.tga has changed
4.1 Binary file textures/Marslike.tga has changed
5.1 Binary file textures/MoonLike.tga has changed
6.1 Binary file textures/marble.tga has changed