#include #include #include #include #include //Dilosi metavliton ton 9 planiton toy iliakoy suystimatos mas static int year = 0, day = 0; //metavliti gia tin peristrofi gyro apo ton ilio kai giro apo ton eayto ton planiton static int afrody = 0, afrodd = 0; //afroditi static int ermisy = 0, ermisd = 0; //ermis static int earthy = 0, earthd = 0; //earth static int arisy = 0, arisd = 0; //Aris static int diasy = 0, diasd = 0; //Dias static int kronosy = 0, kronosd = 0; //Kronos static int ouranosy = 0, ouranosd = 0; //Ouranos static int posidony = 0, posidond = 0; //Posidonos static int plutony = 0, plutond = 0; //Ploutonas static int moony = 0, moond=0; //Moon static int diasd1y=0, diasd1d=0; //Dias_Doriforos_1 static int diasd2y=0, diasd2d=0; //Dias_Doriforos_2 void init(void) { GLfloat light_ambient[] = { 1.0, 0.0, 0.0, 0.0 }; //einai gia to xroma tis sfairas GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat light_diffuse[] = { 1.0, 1.0, 0.0, 0.0 }; // einai gia to xroma tis sfairas GLfloat mat_shininess[] = { 60.0 }; GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.5 }; // einai gia tin topo8esia tou fotismou glClearColor (0.0, 0.0, 0.0, 0.0); //ka8arizoume to xroma glShadeModel (GL_SMOOTH); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); glLightfv(GL_LIGHT0, GL_POSITION, light_position); glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); } void display(void) { glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glutSolidSphere (0.8, 20, 16); //sun// glRotatef ((GLfloat) year, 0.0, 1.0, 0.3); glRotatef ((GLfloat) afrody, 0.0, 1.0, 0.3); glTranslatef (1.0, 0.0, 0.0); glRotatef ((GLfloat) day, 0.0, 1.0, 1.0); glRotatef ((GLfloat) afrodd, 0.0, 1.0, 1.0); glutSolidSphere(0.1, 20, 16); //Afroditi// glFlush (); glPopMatrix(); glPushMatrix(); glutSolidSphere (0.8, 20, 16); //sun// glRotatef ((GLfloat) year, 0.0, 1.0, 0.3); glRotatef ((GLfloat) ermisy, 0.0, 1.0, 0.3); glTranslatef (1.5, 0.0, 0.0); glRotatef ((GLfloat) day, 0.0, 1.0, 1.0); glRotatef ((GLfloat) ermisd, 0.0, 1.0, 1.0); glutWireSphere(0.13, 20, 16); //Ermis// glFlush (); glPopMatrix(); glPushMatrix(); glutSolidSphere (0.8, 20, 16); //Sun// glRotatef ((GLfloat) year, 0.0, 1.0, 0.3); glRotatef ((GLfloat) earthy, 0.0, 1.0, 0.3); glTranslatef (2.0, 0.0, 0.0); glRotatef ((GLfloat) day, 0.0, 1.0, 1.0); glRotatef ((GLfloat) earthd, 0.0, 1.0, 1.0); glutSolidSphere(0.2, 20, 16); //Earth// glFlush (); glPopMatrix(); glPushMatrix(); glRotatef ((GLfloat) year, 0.0, 1.0, 0.3); glRotatef ((GLfloat) earthy, 0.0, 1.0, 0.3); glTranslatef (2.0, 0.0, 0.0); glutSolidSphere(0.2, 20, 16); //Earth// glRotatef ((GLfloat) moony, 0.0, 1.0, 0.3); glRotatef ((GLfloat) year, 0.0, 1.0, 0.3); glTranslatef (0.3, 0.0, 0.0); glRotatef ((GLfloat) day, 0.0, 1.0, 1.0); glRotatef ((GLfloat) moond, 0.0, 1.0, 1.0); glutWireSphere(0.05, 20, 16); //Moon// glFlush (); glPopMatrix(); glPushMatrix(); glutSolidSphere (0.8, 20, 16); //Sun// glRotatef ((GLfloat) year, 0.0, 1.0, 0.3); glRotatef ((GLfloat) arisy, 0.0, 1.0, 0.3); glTranslatef (3.0, 0.0, 0.0); glRotatef ((GLfloat) day, 0.0, 1.0, 1.0); glRotatef ((GLfloat) arisd, 0.0, 1.0, 1.0); glutWireSphere(0.16, 20, 16); //Aris// glFlush (); glPopMatrix(); glPushMatrix(); glutSolidSphere (0.8, 20, 16); //Sun// glRotatef ((GLfloat) year, 0.0, 1.0, 0.3); glRotatef ((GLfloat) diasy, 0.0, 1.0, 0.3); glTranslatef (4.5, 0.0, 0.0); glRotatef ((GLfloat) day, 0.0, 1.0, 1.0); glRotatef ((GLfloat) diasd, 0.0, 1.0, 1.0); glutSolidSphere(0.4, 20, 16); //Dias// glFlush (); glPopMatrix(); glPushMatrix(); glRotatef ((GLfloat) year, 0.0, 1.0, 0.3); glRotatef ((GLfloat) diasy, 0.0, 1.0, 0.3); glTranslatef (4.5, 0.0, 0.0); glutSolidSphere(0.4, 20, 16); //Dias// glRotatef ((GLfloat) year, 0.0, 1.0, 0.3); glRotatef ((GLfloat) diasd1y, 0.0, 1.0, 0.3); glTranslatef (0.4, 0.0, 0.0); glRotatef ((GLfloat) day, 0.0, 1.0, 1.0); glRotatef ((GLfloat) diasd1d, 0.0, 1.0, 1.0); glutSolidSphere(0.05, 20, 16); //Doriforos 1// glFlush (); glPopMatrix(); glPushMatrix(); glRotatef ((GLfloat) year, 0.0, 1.0, 0.3); glRotatef ((GLfloat) diasy, 0.0, 1.0, 0.3); glTranslatef (4.5, 0.0, 0.0); glutSolidSphere(0.4, 20, 16); //Dias// glRotatef ((GLfloat) year, 0.0, 1.0, 0.3); glRotatef ((GLfloat) diasd2y, 0.0, 1.0, 0.3); glTranslatef (0.6, 0.0, 0.0); glRotatef ((GLfloat) day, 0.0, 1.0, 1.0); glRotatef ((GLfloat) diasd2d, 0.0, 1.0, 1.0); glutWireSphere(0.09, 20, 16); //Doriforos 2// glFlush (); glPopMatrix(); glPushMatrix(); glutSolidSphere (0.8, 20, 16); //Sun// glRotatef ((GLfloat) year, 0.0, 1.0, 0.3); glRotatef ((GLfloat) kronosy, 0.0, 1.0, 0.3); glTranslatef (6.0, 0.0, 0.0); glRotatef ((GLfloat) day, 0.0, 1.0, 1.0); glRotatef ((GLfloat) kronosd, 0.0, 1.0, 1.0); glutWireSphere(0.25, 20, 16); //Kronos// glFlush (); glPopMatrix(); glPushMatrix(); glutSolidSphere (0.8, 20, 16); //Sun// glRotatef ((GLfloat) year, 0.0, 1.0, 0.3); glRotatef ((GLfloat) ouranosy, 0.0, 1.0, 0.3); glTranslatef (7.0, 0.0, 0.0); glRotatef ((GLfloat) day, 0.0, 1.0, 1.0); glRotatef ((GLfloat) ouranosd, 0.0, 1.0, 1.0); glutSolidSphere(0.2, 20, 16); //Ouranos// glFlush (); glPopMatrix(); glPushMatrix(); glutSolidSphere (0.8, 20, 16); //Sun// glRotatef ((GLfloat) year, 0.0, 1.0, 0.3); glRotatef ((GLfloat) posidony, 0.0, 1.0, 0.3); glTranslatef (8.0, 0.0, 0.0); glRotatef ((GLfloat) day, 0.0, 1.0, 1.0); glRotatef ((GLfloat) posidond, 0.0, 1.0, 1.0); glutWireSphere(0.19, 20, 16); //Posidonas// glFlush (); glPopMatrix(); glPushMatrix(); glutSolidSphere (0.8, 20, 16); //Sun// glRotatef ((GLfloat) year, 0.0, 1.0, 0.8); glRotatef ((GLfloat) plutony, 0.0, 1.0, 0.8); glTranslatef (9.0, 0.0, 0.0); glRotatef ((GLfloat) day, 0.0, 1.0, 1.0); glRotatef ((GLfloat) plutond, 0.0, 1.0, 1.0); glutSolidSphere(0.12, 20, 16); //Plutonas// glFlush (); glPopMatrix(); glutSwapBuffers(); } void reshape (int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); glLoadIdentity (); gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt (0.0, 0.0, 11.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); } void keyboard (unsigned char key, int x, int y) { switch (key) { case '1': afrody = (afrody + 5 ) % 360; glutPostRedisplay(); break; case '2': ermisy = (ermisy + 5 ) % 360; glutPostRedisplay(); break; case '3': earthy = (earthy + 5) % 360; moony = (moony + 9 ) % 360; glutPostRedisplay(); break; case '4': arisy = (arisy + 5 ) % 360; glutPostRedisplay(); break; case '5': diasy = (diasy + 5 ) % 360; diasd1y = (diasd1y + 8 ) % 360; diasd2y = (diasd2y + 6 ) % 360; glutPostRedisplay(); break; case '6': kronosy = (kronosy + 5 ) % 360; glutPostRedisplay(); break; case '7': ouranosy = (ouranosy + 5 ) % 360; glutPostRedisplay(); break; case '8': posidony = (posidony + 5 ) % 360; glutPostRedisplay(); break; case '9': plutony = (plutony + 5 ) % 360; glutPostRedisplay(); break; case 'm': moony = (moony + 9 ) % 360; moond = (moond + 10) % 360; glutPostRedisplay(); break; case 'a': diasd1y = (diasd1y + 8 ) % 360; diasd1d = (diasd1d + 10) % 360; glutPostRedisplay(); break; case 'b': diasd2y = (diasd2y + 6 ) % 360; diasd2d = (diasd2d + 10) % 360; glutPostRedisplay(); break; case 'd': day = (day + 10) % 360; glutPostRedisplay(); break; case 'y': year = (year + 3) % 360; moony = (moony + 9 ) % 360; diasd1y = (diasd1y + 8 ) % 360; diasd2y = (diasd2y + 6 ) % 360; glutPostRedisplay(); break; default: break; } } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize (800,600); glutInitWindowPosition (100,100); glutCreateWindow (argv[0]); init (); glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard); glutMainLoop(); return 0; }