00001
00002
00003
00004
00005
00006
00011 #include "Sun.h"
00012 #include "TextureManager.h"
00013 #include "Window.h"
00014 #include "Opengl.h"
00015
00019 void Sun::draw() {
00020 drawBegin();
00021 glColor3f(1.0, 1.0, 1.0);
00022
00023 GLfloat light_ambient[] = { 0.01, 0.01, 0.01,1.0 };
00024 GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 };
00025 int light =Opengl::getNextLight();
00026
00027 glLightfv(light, GL_AMBIENT, light_ambient);
00028 glLightfv(light, GL_DIFFUSE, light_specular);
00029 glLightfv(light, GL_SPECULAR, light_specular);
00030 glLightf(light, GL_CONSTANT_ATTENUATION, 0.8);
00031 glLightf(light,GL_LINEAR_ATTENUATION,0.0);
00032 glLightf(light,GL_QUADRATIC_ATTENUATION,0.0);
00033
00034
00035 GLfloat light0Pos_[] = { pos.x, pos.y, pos.z, 1.0};
00036 glLightfv(light, GL_POSITION, light0Pos_);
00037 glEnable(light);
00038
00039 GLfloat emission[] = { 1.0, 1.0, 1.0, 1.0 };
00040 glMaterialfv(GL_FRONT, GL_EMISSION, emission);
00041
00042 glPushMatrix();
00043
00044
00045 Vector adaptedpos = getScaledPos();
00046 glTranslatef(adaptedpos.x,adaptedpos.y,adaptedpos.z);
00047
00048
00049 GLUquadricObj * planetQuadric = gluNewQuadric();
00050
00051 if(ourConfiguration.showTextures) {
00052 glEnable (GL_TEXTURE_2D);
00053 glBindTexture (GL_TEXTURE_2D, getOpenglTextureNumber());
00054 gluQuadricTexture( planetQuadric, GL_TRUE );
00055 }
00056
00057 gluSphere( planetQuadric,getScaledRadius(),
00058 ourConfiguration.sphereDetaillevel,
00059 ourConfiguration.sphereDetaillevel );
00060
00061 glDisable(GL_TEXTURE_2D);
00062
00063 glPopMatrix();
00064 gluDeleteQuadric(planetQuadric);
00065 drawEnd();
00066 }
00067
00071 char * Sun::getType() {
00072 return "sun";
00073 }