SlideShare a Scribd company logo
Transformasi 2 dmensi
Tata Surya
#include <stdio.h>
#include <stdlib.h>
#include <gl/glut.h>
#include <math.h>
#include "kamera.c"
#include "menu.c"
#include "cahaya.c"
#include "bola.c"
//#include "tekstur.c"
#define TimerMSecs 33
GLenum polygonMode = GL_FILL;
int SpinOn = 0, SpinBreak = 1, startTime, prevTime, Velocity
= 1;
static double Mer = 0.0, Ven = 0.0, Ear = 0.0, Moo = 0.0,
Moo2 = 0.0, Mar = 0.0, Jup =
0.0, Sat = 0.0, Ura = 0.0, Nep = 0.0, Plu = 0.0;
GLfloat Shine[] = {10};
GLfloat MooCol[] = {2.3, 2.3, 2.3};
GLfloat Moo2Col[] = {0.93, 0.93, 0.93};
GLfloat MerCol[] = {2.05, 1.90, 1.12};
GLfloat VenCol[] = {1.39, 0.54, 0.26};
GLfloat EarCol[] = {0.0, 0.3, 0.6};
GLfloat MarCol[] = {1.39, 0.26, 0.0};
GLfloat JupCol[] = {0.80, 0.53, 0.25};
GLfloat SatCol[] = {0.6, 0.5, 0.09};
GLfloat UraCol[] ={0.40, 0.900, 1.0};
GLfloat NepCol[] = {0.135, 0.115, 0.85};
GLfloat PluCol[] = {0.7, 0.8, 1.00};
void SceneSpin(int value)
{
int currTime = glutGet(GLUT_ELAPSED_TIME);
if(SpinOn == 1)
glutTimerFunc(TimerMSecs, SceneSpin, 0);
Mer += 11.0 * Velocity;
if(Mer > 360.0)
Mer = Mer - 360.0;
Ven += 7.0 * Velocity;
if(Ven > 360.0)
Ven = Ven - 360.0;
Ear += 5.0 * Velocity;
if(Ear > 360.0)
Ear = Ear - 360.0;
Moo += 0.2 * Velocity;
if(Moo > 360.0)
Moo = Moo - 360.0;
Moo2 += 0.1 * Velocity;
if(Moo2 > 360.0)
Moo2 = Moo2 - 360.0;
Mar += 3.0 * Velocity;
if(Mar > 360.0)
Mar = Mar - 360.0;
Jup += 5.0 * Velocity;
if(Jup > 360.0)
Jup = Jup - 360.0;
Sat += 1.0 * Velocity;
if(Sat > 360.0)
Sat = Sat - 360.0;
Ura += 2.0 * Velocity;
if(Ura > 360.0)
Ura = Ura - 360.0;
Nep += 1.0 * Velocity;
if(Nep > 360.0)
Nep = Nep - 360.0;
Plu += 0.5 * Velocity;
if(Plu > 360.0)
Plu = Plu - 360.0;
glutPostRedisplay();
prevTime = currTime;
}
void draw(void)
{
GLfloat position[] = { 0.0, 0.0, 1.5, 1.0 };
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, Shine);
glPushMatrix();
gluLookAt(80.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 1.0,
0.0);
glPushMatrix();
//Membuat Merkurius
glRotated((GLdouble) Mer, 0.0, 1.0, 0.0);
glTranslated(0.0, 0.0, 4.9);
glRotated((GLdouble) Mer, 0.0, 1.0, 0.0);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MerCol);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, MerCol);
glutSolidSphere(0.049, 20, 20);
glDisable(GL_DIFFUSE);
glPopMatrix();
glPushMatrix();
//Membuat Venus
glRotated((GLdouble) Ven, 0.0, 1.0, 0.0);
glTranslated(0.1, 0.0, 5.2);
glRotated((GLdouble) Ven - 1, 0.0, 1.0, 0.0);
//Counter Rotation
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, VenCol);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, VenCol);
glutSolidSphere(0.12, 20, 20);
glDisable(GL_DIFFUSE);
glPopMatrix();
glPushMatrix();
//Membuat Bumi
glRotated((GLdouble) Ear, 0.0, 1.0, 0.0);
glTranslated(0.1, 0.0, 5.6);
glRotated((GLdouble) Ear, 0.0, 1.0, 0.0);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, EarCol);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, EarCol);
glutSolidSphere(0.13, 20, 20);
glDisable(GL_DIFFUSE);
glPushMatrix();
//Membuat Bulan / Satelit Bumi
glRotated((GLdouble) Moo, 0.0, 1.0, 0.0);
glTranslated(0.1, 0.0, 0.1);
glRotated((GLdouble) Moo, 0.0, 1.0, 0.0);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MooCol);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, MooCol);
glutSolidSphere(0.02, 20, 20);
glDisable(GL_DIFFUSE);
glPopMatrix();
glPopMatrix();
glPushMatrix();
//Membuat Mars
glRotated((GLdouble) Mar, 0.0, 1.0, 0.0);
glTranslated(0.1, 0.0, 6.0);
glRotated((GLdouble) Mar, 0.0, 1.0, 0.0);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MarCol);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, MarCol);
glutSolidSphere(0.067, 20, 20);
glDisable(GL_DIFFUSE);
glPushMatrix();
//Membuat Satelit 1 Mars
glRotated((GLdouble) Moo, 0.0, 1.0, 0.0);
glTranslated(0.0, 0.0, 0.1);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MooCol);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, MooCol);
glRotated((GLdouble) Moo, 0.0, 1.0, 0.0);
glutSolidSphere(0.015, 20, 10);
glPopMatrix();
glPushMatrix();
//Membuat Satelit 2 Mars
glRotated((GLdouble) Moo2, 0.0, 1.0, 0.0);
glTranslated(0.0, 0.0, 0.15);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE,
Moo2Col);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, Moo2Col);
glRotated((GLdouble) Moo2, 0.0, 1.0, 0.0);
glutSolidSphere(0.01, 20, 10);
glPopMatrix();
glPopMatrix();
glPushMatrix();
//Membuat Jupiter
glRotated((GLdouble) Jup, 0.0, 1.0, 0.0);
glTranslated(0.1, 0.0, 9.7);
glRotated((GLdouble) Jup, 0.0, 1.0, 0.0);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, JupCol);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, JupCol);
glutSolidSphere(1.42, 20, 20);
glDisable(GL_DIFFUSE);
glPopMatrix();
glPushMatrix();
//Membuat Saturnus
glRotated((GLdouble) Sat, 0.0, 1.0, 0.0);
glTranslated(0.1, 0.0, 14.0);
glRotated((GLdouble) Sat, 0.0, 1.0, 0.0);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, SatCol);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, SatCol);
glutSolidSphere(1.20, 20, 20);
glDisable(GL_DIFFUSE);
glPopMatrix();
glPushMatrix();
//Membuat Uranus
glRotated((GLdouble) Ura, 0.0, 1.0, 0.0);
glTranslated(0.1, 0.0, 23.5);
glRotated((GLdouble) Ura - 1, 1.0, 0.1, 0.0);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, UraCol);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, UraCol);
glutSolidSphere(0.51, 20, 20);
glDisable(GL_DIFFUSE);
glPopMatrix();
glPushMatrix();
//Membuat Neptunus
glRotated((GLdouble) Nep, 0.0, 1.0, 0.0);
glTranslated(0.1, 0.0, 34.5);
glRotated((GLdouble) Nep, 0.0, 1.0, 0.0);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, NepCol);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, NepCol);
glutSolidSphere(0.49, 20, 20);
glDisable(GL_DIFFUSE);
glPopMatrix();
glPushMatrix();
//Membuat Pluto
glRotated((GLdouble) Plu, 0.0, 1.0, 0.0);
glTranslated(0.1, 0.0, 44.0);
glRotated((GLdouble) Plu, 0.0, 1.0, 0.0);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, PluCol);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, PluCol);
glutSolidSphere(0.1, 20, 20);
glDisable(GL_DIFFUSE);
glPopMatrix();
glLightfv(GL_LIGHT0, GL_POSITION, position);
GLfloat global_ambient[] = {0.5f, 0.5f, 0.5f, 1.0f};
//Emission
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, global_ambient);
//Emission
glDisable(GL_LIGHTING);
glColor3f(1.0, 1.0, 0.0);
glRotated((GLdouble) Ear, 0.0, 1.0, 0.0);
glutSolidSphere(4.00, 20, 20);
glEnable(GL_LIGHTING);
glPopMatrix();
}
void display(void)
{
float angle=0.0;
glClearColor (0.0,0.0,0.0,1.0);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
camera();
enable();
draw();
glutSwapBuffers();
glPolygonMode(GL_FRONT_AND_BACK, polygonMode);
angle++;
}
void WireFrameMode() {
if (polygonMode == GL_FILL ) {
polygonMode = GL_LINE;
}
else {
polygonMode = GL_FILL;
}
}
void Keyboard(unsigned char key, int A, int B)
{
float xpos = 0, ypos = 0, zpos = 0, xrot = 0, yrot = 0;
if(key == 'x')
{
xrot += 1;
if(xrot > 360) xrot -= 360;
}
if(key == 'z')
{
xrot -= 1;
if(xrot <-360) xrot += 360;
}
if(key == 'w')
{
float xrotrad,yrotrad;
yrotrad = (yrot/180 * 3.141592654f);
xrotrad = (xrot/180 * 3.141592654f);
xpos += float(sin(yrotrad));
zpos -= float(cos(yrotrad));
ypos -= float(sin(xrotrad));
}
if(key == 's')
{
float xrotrad,yrotrad;
yrotrad = (yrot/180 * 3.141592654f);
xrotrad = (xrot/180 * 3.141592654f);
xpos -= float(sin(yrotrad));
zpos += float(cos(yrotrad));
ypos += float(sin(xrotrad));
}
if(key == 'd')
{
yrot+=1;
if(yrot>360) yrot -= 360;
}
if(key == 'a')
{
yrot -= 1;
if(yrot<-360) yrot += 360;
}
switch(key)
{
case '1':SpinOn = 1;
if(SpinBreak == 0){
SpinOn = 0;
}
if(SpinBreak == 1){
glutTimerFunc(TimerMSecs, SceneSpin, 0);
}
if (SpinBreak == 0){
SpinBreak = 1;
}
else SpinBreak = 0;
break;
case '2':SpinOn = 1;
Velocity = Velocity + 1;
break;
case '3':SpinOn = 1;
Velocity = Velocity - 1;
break;
case 27: exit(0);
break;
default:
break;
}
}
void mouseMenu(int value)
{
if(value == 1)
SpinOn = 1;
if(SpinBreak == 0){
SpinOn = 0;
}
if(SpinBreak == 1){
glutTimerFunc(TimerMSecs, SceneSpin, 0);
}
if (SpinBreak == 0){
SpinBreak = 1;
}
else SpinBreak = 0;
if(value == 2)
SceneSpin(2);
if(value == 3)
WireFrameMode();
if(value == 4)
exit(0);
}
int main(int argc, char **argv)
{
menu();
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowPosition(300, 300);
glutInitWindowSize(500, 500);
glutCreateWindow("Sistem Tata Surya oleh kelompok 5 - IF
13");
glutCreateMenu(mouseMenu);
glutAddMenuEntry("Start/Pause", 1);
glutAddMenuEntry("Langkah Animasi", 2);
glutAddMenuEntry("Bingkai Kawat", 3);
glutAddMenuEntry("Keluar", 4);
glutAttachMenu(GLUT_RIGHT_BUTTON);
glEnable(GL_LIGHT_MODEL_AMBIENT);
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(Keyboard);
startTime = glutGet(GLUT_ELAPSED_TIME);
prevTime = startTime;
glutMainLoop();
return 0;
}
cahaya
#include <stdio.h>
#include <GL/glut.h>
void enable(void)
{
glShadeModel(GL_SMOOTH);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
}
bola.c
#include <stdio.h>
#include <GL/glut.h>
void reshape(int w, int h)
{
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(40.0, (GLfloat) w/(GLfloat) h, 1.0,
500.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
menu
#include <stdio.h>
void menu(void)
{
printf("--------MENU--------n");
printf("Tekan 1 untuk start/pausen");
printf("Tekan 2 untuk meninggkatkan kecepatann");
printf("Tekan 3 untuk menurunkan kecepatann");
printf("Klik kanan untuk informasi lebihnn");
printf("-----KONTROL KAMERA-----n");
printf("W A S D untuk maju mundur dan kanan kirin");
printf("x dan z untuk zoom in dan zoom outnn");
printf("-----------------------n");
printf("Tekan Esc untuk keluarn");
printf("-----------------------n");
}
kamera
#include <GL/glut.h>
void camera(void)
{
float xpos = 0, ypos = 0, zpos = 0, xrot = 0, yrot = 0;
glRotatef(xrot,1.0,0.0,0.0);
glRotatef(yrot,0.0,1.0,0.0);
glTranslated(-xpos,ypos,-zpos);
glutPostRedisplay();
}
tekstur
#include <windows.h>
#include <glgl.h>
#include <glglu.h>
#include <glaux.h>
#include <stdio.h>
#include <math.h>
AUX_RGBImageRec *LoadBMP(char *Filename)
{
FILE *File=NULL;
if (!Filename)
{
return NULL;
}
File=fopen(Filename,"r");
if (File)
{
fclose(File);
return auxDIBImageLoad(Filename);
}
return NULL;
}
int LoadTextures()
{
GLint loop;
GLuint texture[14];
int Status = FALSE;
AUX_RGBImageRec *TextureImage[14];
memset(TextureImage, 0, sizeof(void *)*14);
if ( (TextureImage[0]=LoadBMP("earth.bmp")) &&
(TextureImage[1]=LoadBMP("belka.bmp")) &&
(TextureImage[2]=LoadBMP("ziemia.bmp"))&&
(TextureImage[3]=LoadBMP("moon.bmp"))&&
(TextureImage[4]=LoadBMP("fonty.bmp")) &&
(TextureImage[5]=LoadBMP("mars.bmp")) &&
(TextureImage[6]=LoadBMP("wenus.bmp")) &&
(TextureImage[7]=LoadBMP("merkury.bmp")) &&
(TextureImage[8]=LoadBMP("satelitemaska.bmp")) &&
(TextureImage[9]=LoadBMP("satelite.bmp")) &&
(TextureImage[10]=LoadBMP("saturnmaska.bmp")) &&
(TextureImage[11]=LoadBMP("saturn.bmp")) &&
(TextureImage[12]=LoadBMP("space.bmp")) &&
(TextureImage[13]=LoadBMP("sun.bmp")))
{
Status=TRUE;
glGenTextures(14, &texture[0]);
for(loop=0;loop<14;loop++)
{
glBindTexture(GL_TEXTURE_2D, texture[loop]);
gluBuild2DMipmaps(GL_TEXTURE_2D,
3,TextureImage[loop]->sizeX, TextureImage[loop]->sizeY,
GL_RGB, GL_UNSIGNED_BYTE, TextureImage[loop]->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR)
; // Linear Filtering
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR)
; // Linear Filtering
}
for(loop=0;loop<14;loop++)
{
if (TextureImage[loop])
{
if (TextureImage[loop]->data)
free(TextureImage[loop]->data);
free(TextureImage[loop]);
}
}
}
return Status;
}

More Related Content

Similar to Transformasi 2 dmensi

#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx
#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx
#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx
ajoy21
 
Robot Motion Source code
Robot Motion Source codeRobot Motion Source code
Robot Motion Source code
Brian Goggins
 
Ass day3 2_olympic logos
Ass day3 2_olympic logosAss day3 2_olympic logos
Ass day3 2_olympic logos
Robi Parvez
 
Practica
PracticaPractica
Ass day2 2_rotating my name (robi)
Ass day2 2_rotating my name (robi)Ass day2 2_rotating my name (robi)
Ass day2 2_rotating my name (robi)
Robi Parvez
 
openGl example
openGl exampleopenGl example
openGl example
Brian Goggins
 
Tutorial Open GL (Listing Code)
Tutorial Open GL (Listing Code)Tutorial Open GL (Listing Code)
Tutorial Open GL (Listing Code)
Aila Gema Safitri
 
The Ring programming language version 1.10 book - Part 66 of 212
The Ring programming language version 1.10 book - Part 66 of 212The Ring programming language version 1.10 book - Part 66 of 212
The Ring programming language version 1.10 book - Part 66 of 212
Mahmoud Samir Fayed
 
Ass day2 3_sun_moon_earth
Ass day2 3_sun_moon_earthAss day2 3_sun_moon_earth
Ass day2 3_sun_moon_earth
Robi Parvez
 
Programa de objetos 3 d wire
Programa de objetos 3 d wirePrograma de objetos 3 d wire
Programa de objetos 3 d wire
René Domínguez
 
The Ring programming language version 1.7 book - Part 60 of 196
The Ring programming language version 1.7 book - Part 60 of 196The Ring programming language version 1.7 book - Part 60 of 196
The Ring programming language version 1.7 book - Part 60 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 65 of 184
The Ring programming language version 1.5.3 book - Part 65 of 184The Ring programming language version 1.5.3 book - Part 65 of 184
The Ring programming language version 1.5.3 book - Part 65 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 65 of 210
The Ring programming language version 1.9 book - Part 65 of 210The Ring programming language version 1.9 book - Part 65 of 210
The Ring programming language version 1.9 book - Part 65 of 210
Mahmoud Samir Fayed
 
animation.#include windows.h#include GLglut.h#inclu.pdf
animation.#include windows.h#include GLglut.h#inclu.pdfanimation.#include windows.h#include GLglut.h#inclu.pdf
animation.#include windows.h#include GLglut.h#inclu.pdf
ambritgames
 
Ass day3 1_bd flag
Ass day3 1_bd flagAss day3 1_bd flag
Ass day3 1_bd flag
Robi Parvez
 
The Ring programming language version 1.10 book - Part 67 of 212
The Ring programming language version 1.10 book - Part 67 of 212The Ring programming language version 1.10 book - Part 67 of 212
The Ring programming language version 1.10 book - Part 67 of 212
Mahmoud Samir Fayed
 
OpenGL Starter L02
OpenGL Starter L02OpenGL Starter L02
OpenGL Starter L02
Mohammad Shaker
 
The Ring programming language version 1.5.4 book - Part 54 of 185
The Ring programming language version 1.5.4 book - Part 54 of 185The Ring programming language version 1.5.4 book - Part 54 of 185
The Ring programming language version 1.5.4 book - Part 54 of 185
Mahmoud Samir Fayed
 
Disney Effects: Building web/mobile castle in OpenGL 2D & 3D
Disney Effects: Building web/mobile castle in OpenGL 2D & 3DDisney Effects: Building web/mobile castle in OpenGL 2D & 3D
Disney Effects: Building web/mobile castle in OpenGL 2D & 3D
SVWB
 
Ass day2 1_checkerboard...copy in cpp
Ass day2 1_checkerboard...copy in cppAss day2 1_checkerboard...copy in cpp
Ass day2 1_checkerboard...copy in cpp
Robi Parvez
 

Similar to Transformasi 2 dmensi (20)

#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx
#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx
#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx
 
Robot Motion Source code
Robot Motion Source codeRobot Motion Source code
Robot Motion Source code
 
Ass day3 2_olympic logos
Ass day3 2_olympic logosAss day3 2_olympic logos
Ass day3 2_olympic logos
 
Practica
PracticaPractica
Practica
 
Ass day2 2_rotating my name (robi)
Ass day2 2_rotating my name (robi)Ass day2 2_rotating my name (robi)
Ass day2 2_rotating my name (robi)
 
openGl example
openGl exampleopenGl example
openGl example
 
Tutorial Open GL (Listing Code)
Tutorial Open GL (Listing Code)Tutorial Open GL (Listing Code)
Tutorial Open GL (Listing Code)
 
The Ring programming language version 1.10 book - Part 66 of 212
The Ring programming language version 1.10 book - Part 66 of 212The Ring programming language version 1.10 book - Part 66 of 212
The Ring programming language version 1.10 book - Part 66 of 212
 
Ass day2 3_sun_moon_earth
Ass day2 3_sun_moon_earthAss day2 3_sun_moon_earth
Ass day2 3_sun_moon_earth
 
Programa de objetos 3 d wire
Programa de objetos 3 d wirePrograma de objetos 3 d wire
Programa de objetos 3 d wire
 
The Ring programming language version 1.7 book - Part 60 of 196
The Ring programming language version 1.7 book - Part 60 of 196The Ring programming language version 1.7 book - Part 60 of 196
The Ring programming language version 1.7 book - Part 60 of 196
 
The Ring programming language version 1.5.3 book - Part 65 of 184
The Ring programming language version 1.5.3 book - Part 65 of 184The Ring programming language version 1.5.3 book - Part 65 of 184
The Ring programming language version 1.5.3 book - Part 65 of 184
 
The Ring programming language version 1.9 book - Part 65 of 210
The Ring programming language version 1.9 book - Part 65 of 210The Ring programming language version 1.9 book - Part 65 of 210
The Ring programming language version 1.9 book - Part 65 of 210
 
animation.#include windows.h#include GLglut.h#inclu.pdf
animation.#include windows.h#include GLglut.h#inclu.pdfanimation.#include windows.h#include GLglut.h#inclu.pdf
animation.#include windows.h#include GLglut.h#inclu.pdf
 
Ass day3 1_bd flag
Ass day3 1_bd flagAss day3 1_bd flag
Ass day3 1_bd flag
 
The Ring programming language version 1.10 book - Part 67 of 212
The Ring programming language version 1.10 book - Part 67 of 212The Ring programming language version 1.10 book - Part 67 of 212
The Ring programming language version 1.10 book - Part 67 of 212
 
OpenGL Starter L02
OpenGL Starter L02OpenGL Starter L02
OpenGL Starter L02
 
The Ring programming language version 1.5.4 book - Part 54 of 185
The Ring programming language version 1.5.4 book - Part 54 of 185The Ring programming language version 1.5.4 book - Part 54 of 185
The Ring programming language version 1.5.4 book - Part 54 of 185
 
Disney Effects: Building web/mobile castle in OpenGL 2D & 3D
Disney Effects: Building web/mobile castle in OpenGL 2D & 3DDisney Effects: Building web/mobile castle in OpenGL 2D & 3D
Disney Effects: Building web/mobile castle in OpenGL 2D & 3D
 
Ass day2 1_checkerboard...copy in cpp
Ass day2 1_checkerboard...copy in cppAss day2 1_checkerboard...copy in cpp
Ass day2 1_checkerboard...copy in cpp
 

Recently uploaded

Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Zilliz
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 

Recently uploaded (20)

Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 

Transformasi 2 dmensi

  • 1. Transformasi 2 dmensi Tata Surya #include <stdio.h> #include <stdlib.h> #include <gl/glut.h> #include <math.h> #include "kamera.c" #include "menu.c" #include "cahaya.c" #include "bola.c" //#include "tekstur.c" #define TimerMSecs 33 GLenum polygonMode = GL_FILL; int SpinOn = 0, SpinBreak = 1, startTime, prevTime, Velocity = 1; static double Mer = 0.0, Ven = 0.0, Ear = 0.0, Moo = 0.0, Moo2 = 0.0, Mar = 0.0, Jup = 0.0, Sat = 0.0, Ura = 0.0, Nep = 0.0, Plu = 0.0; GLfloat Shine[] = {10}; GLfloat MooCol[] = {2.3, 2.3, 2.3}; GLfloat Moo2Col[] = {0.93, 0.93, 0.93}; GLfloat MerCol[] = {2.05, 1.90, 1.12}; GLfloat VenCol[] = {1.39, 0.54, 0.26}; GLfloat EarCol[] = {0.0, 0.3, 0.6}; GLfloat MarCol[] = {1.39, 0.26, 0.0};
  • 2. GLfloat JupCol[] = {0.80, 0.53, 0.25}; GLfloat SatCol[] = {0.6, 0.5, 0.09}; GLfloat UraCol[] ={0.40, 0.900, 1.0}; GLfloat NepCol[] = {0.135, 0.115, 0.85}; GLfloat PluCol[] = {0.7, 0.8, 1.00}; void SceneSpin(int value) { int currTime = glutGet(GLUT_ELAPSED_TIME); if(SpinOn == 1) glutTimerFunc(TimerMSecs, SceneSpin, 0); Mer += 11.0 * Velocity; if(Mer > 360.0) Mer = Mer - 360.0; Ven += 7.0 * Velocity; if(Ven > 360.0) Ven = Ven - 360.0; Ear += 5.0 * Velocity; if(Ear > 360.0) Ear = Ear - 360.0; Moo += 0.2 * Velocity; if(Moo > 360.0) Moo = Moo - 360.0; Moo2 += 0.1 * Velocity; if(Moo2 > 360.0) Moo2 = Moo2 - 360.0; Mar += 3.0 * Velocity; if(Mar > 360.0) Mar = Mar - 360.0; Jup += 5.0 * Velocity; if(Jup > 360.0) Jup = Jup - 360.0; Sat += 1.0 * Velocity; if(Sat > 360.0) Sat = Sat - 360.0; Ura += 2.0 * Velocity; if(Ura > 360.0) Ura = Ura - 360.0; Nep += 1.0 * Velocity; if(Nep > 360.0)
  • 3. Nep = Nep - 360.0; Plu += 0.5 * Velocity; if(Plu > 360.0) Plu = Plu - 360.0; glutPostRedisplay(); prevTime = currTime; } void draw(void) { GLfloat position[] = { 0.0, 0.0, 1.5, 1.0 }; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, Shine); glPushMatrix(); gluLookAt(80.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glPushMatrix(); //Membuat Merkurius glRotated((GLdouble) Mer, 0.0, 1.0, 0.0); glTranslated(0.0, 0.0, 4.9); glRotated((GLdouble) Mer, 0.0, 1.0, 0.0); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MerCol); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, MerCol); glutSolidSphere(0.049, 20, 20); glDisable(GL_DIFFUSE); glPopMatrix(); glPushMatrix(); //Membuat Venus glRotated((GLdouble) Ven, 0.0, 1.0, 0.0); glTranslated(0.1, 0.0, 5.2); glRotated((GLdouble) Ven - 1, 0.0, 1.0, 0.0); //Counter Rotation glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, VenCol); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, VenCol); glutSolidSphere(0.12, 20, 20); glDisable(GL_DIFFUSE); glPopMatrix(); glPushMatrix(); //Membuat Bumi glRotated((GLdouble) Ear, 0.0, 1.0, 0.0); glTranslated(0.1, 0.0, 5.6); glRotated((GLdouble) Ear, 0.0, 1.0, 0.0); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, EarCol); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, EarCol); glutSolidSphere(0.13, 20, 20); glDisable(GL_DIFFUSE);
  • 4. glPushMatrix(); //Membuat Bulan / Satelit Bumi glRotated((GLdouble) Moo, 0.0, 1.0, 0.0); glTranslated(0.1, 0.0, 0.1); glRotated((GLdouble) Moo, 0.0, 1.0, 0.0); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MooCol); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, MooCol); glutSolidSphere(0.02, 20, 20); glDisable(GL_DIFFUSE); glPopMatrix(); glPopMatrix(); glPushMatrix(); //Membuat Mars glRotated((GLdouble) Mar, 0.0, 1.0, 0.0); glTranslated(0.1, 0.0, 6.0); glRotated((GLdouble) Mar, 0.0, 1.0, 0.0); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MarCol); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, MarCol); glutSolidSphere(0.067, 20, 20); glDisable(GL_DIFFUSE); glPushMatrix(); //Membuat Satelit 1 Mars glRotated((GLdouble) Moo, 0.0, 1.0, 0.0); glTranslated(0.0, 0.0, 0.1); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MooCol); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, MooCol); glRotated((GLdouble) Moo, 0.0, 1.0, 0.0); glutSolidSphere(0.015, 20, 10); glPopMatrix(); glPushMatrix(); //Membuat Satelit 2 Mars glRotated((GLdouble) Moo2, 0.0, 1.0, 0.0); glTranslated(0.0, 0.0, 0.15); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, Moo2Col); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, Moo2Col); glRotated((GLdouble) Moo2, 0.0, 1.0, 0.0); glutSolidSphere(0.01, 20, 10); glPopMatrix(); glPopMatrix(); glPushMatrix(); //Membuat Jupiter glRotated((GLdouble) Jup, 0.0, 1.0, 0.0); glTranslated(0.1, 0.0, 9.7); glRotated((GLdouble) Jup, 0.0, 1.0, 0.0); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, JupCol);
  • 5. glLightModelfv(GL_LIGHT_MODEL_AMBIENT, JupCol); glutSolidSphere(1.42, 20, 20); glDisable(GL_DIFFUSE); glPopMatrix(); glPushMatrix(); //Membuat Saturnus glRotated((GLdouble) Sat, 0.0, 1.0, 0.0); glTranslated(0.1, 0.0, 14.0); glRotated((GLdouble) Sat, 0.0, 1.0, 0.0); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, SatCol); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, SatCol); glutSolidSphere(1.20, 20, 20); glDisable(GL_DIFFUSE); glPopMatrix(); glPushMatrix(); //Membuat Uranus glRotated((GLdouble) Ura, 0.0, 1.0, 0.0); glTranslated(0.1, 0.0, 23.5); glRotated((GLdouble) Ura - 1, 1.0, 0.1, 0.0); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, UraCol); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, UraCol); glutSolidSphere(0.51, 20, 20); glDisable(GL_DIFFUSE); glPopMatrix(); glPushMatrix(); //Membuat Neptunus glRotated((GLdouble) Nep, 0.0, 1.0, 0.0); glTranslated(0.1, 0.0, 34.5); glRotated((GLdouble) Nep, 0.0, 1.0, 0.0); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, NepCol); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, NepCol); glutSolidSphere(0.49, 20, 20); glDisable(GL_DIFFUSE); glPopMatrix(); glPushMatrix(); //Membuat Pluto glRotated((GLdouble) Plu, 0.0, 1.0, 0.0); glTranslated(0.1, 0.0, 44.0); glRotated((GLdouble) Plu, 0.0, 1.0, 0.0); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, PluCol); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, PluCol); glutSolidSphere(0.1, 20, 20); glDisable(GL_DIFFUSE); glPopMatrix(); glLightfv(GL_LIGHT0, GL_POSITION, position);
  • 6. GLfloat global_ambient[] = {0.5f, 0.5f, 0.5f, 1.0f}; //Emission glLightModelfv(GL_LIGHT_MODEL_AMBIENT, global_ambient); //Emission glDisable(GL_LIGHTING); glColor3f(1.0, 1.0, 0.0); glRotated((GLdouble) Ear, 0.0, 1.0, 0.0); glutSolidSphere(4.00, 20, 20); glEnable(GL_LIGHTING); glPopMatrix(); } void display(void) { float angle=0.0; glClearColor (0.0,0.0,0.0,1.0); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); camera(); enable(); draw(); glutSwapBuffers(); glPolygonMode(GL_FRONT_AND_BACK, polygonMode); angle++; } void WireFrameMode() { if (polygonMode == GL_FILL ) { polygonMode = GL_LINE; } else { polygonMode = GL_FILL; } } void Keyboard(unsigned char key, int A, int B) { float xpos = 0, ypos = 0, zpos = 0, xrot = 0, yrot = 0; if(key == 'x') { xrot += 1; if(xrot > 360) xrot -= 360; } if(key == 'z') { xrot -= 1; if(xrot <-360) xrot += 360;
  • 7. } if(key == 'w') { float xrotrad,yrotrad; yrotrad = (yrot/180 * 3.141592654f); xrotrad = (xrot/180 * 3.141592654f); xpos += float(sin(yrotrad)); zpos -= float(cos(yrotrad)); ypos -= float(sin(xrotrad)); } if(key == 's') { float xrotrad,yrotrad; yrotrad = (yrot/180 * 3.141592654f); xrotrad = (xrot/180 * 3.141592654f); xpos -= float(sin(yrotrad)); zpos += float(cos(yrotrad)); ypos += float(sin(xrotrad)); } if(key == 'd') { yrot+=1; if(yrot>360) yrot -= 360; } if(key == 'a') { yrot -= 1; if(yrot<-360) yrot += 360; } switch(key) { case '1':SpinOn = 1; if(SpinBreak == 0){ SpinOn = 0; } if(SpinBreak == 1){ glutTimerFunc(TimerMSecs, SceneSpin, 0); } if (SpinBreak == 0){ SpinBreak = 1; } else SpinBreak = 0; break; case '2':SpinOn = 1; Velocity = Velocity + 1; break; case '3':SpinOn = 1; Velocity = Velocity - 1; break;
  • 8. case 27: exit(0); break; default: break; } } void mouseMenu(int value) { if(value == 1) SpinOn = 1; if(SpinBreak == 0){ SpinOn = 0; } if(SpinBreak == 1){ glutTimerFunc(TimerMSecs, SceneSpin, 0); } if (SpinBreak == 0){ SpinBreak = 1; } else SpinBreak = 0; if(value == 2) SceneSpin(2); if(value == 3) WireFrameMode(); if(value == 4) exit(0); } int main(int argc, char **argv) { menu(); glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowPosition(300, 300); glutInitWindowSize(500, 500); glutCreateWindow("Sistem Tata Surya oleh kelompok 5 - IF 13"); glutCreateMenu(mouseMenu); glutAddMenuEntry("Start/Pause", 1); glutAddMenuEntry("Langkah Animasi", 2); glutAddMenuEntry("Bingkai Kawat", 3); glutAddMenuEntry("Keluar", 4); glutAttachMenu(GLUT_RIGHT_BUTTON); glEnable(GL_LIGHT_MODEL_AMBIENT);
  • 9. glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(Keyboard); startTime = glutGet(GLUT_ELAPSED_TIME); prevTime = startTime; glutMainLoop(); return 0; } cahaya #include <stdio.h> #include <GL/glut.h> void enable(void) { glShadeModel(GL_SMOOTH); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); } bola.c #include <stdio.h> #include <GL/glut.h> void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(40.0, (GLfloat) w/(GLfloat) h, 1.0, 500.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } menu #include <stdio.h>
  • 10. void menu(void) { printf("--------MENU--------n"); printf("Tekan 1 untuk start/pausen"); printf("Tekan 2 untuk meninggkatkan kecepatann"); printf("Tekan 3 untuk menurunkan kecepatann"); printf("Klik kanan untuk informasi lebihnn"); printf("-----KONTROL KAMERA-----n"); printf("W A S D untuk maju mundur dan kanan kirin"); printf("x dan z untuk zoom in dan zoom outnn"); printf("-----------------------n"); printf("Tekan Esc untuk keluarn"); printf("-----------------------n"); } kamera #include <GL/glut.h> void camera(void) { float xpos = 0, ypos = 0, zpos = 0, xrot = 0, yrot = 0; glRotatef(xrot,1.0,0.0,0.0); glRotatef(yrot,0.0,1.0,0.0); glTranslated(-xpos,ypos,-zpos); glutPostRedisplay(); } tekstur #include <windows.h> #include <glgl.h> #include <glglu.h> #include <glaux.h> #include <stdio.h> #include <math.h> AUX_RGBImageRec *LoadBMP(char *Filename) { FILE *File=NULL; if (!Filename) { return NULL; } File=fopen(Filename,"r"); if (File)
  • 11. { fclose(File); return auxDIBImageLoad(Filename); } return NULL; } int LoadTextures() { GLint loop; GLuint texture[14]; int Status = FALSE; AUX_RGBImageRec *TextureImage[14]; memset(TextureImage, 0, sizeof(void *)*14); if ( (TextureImage[0]=LoadBMP("earth.bmp")) && (TextureImage[1]=LoadBMP("belka.bmp")) && (TextureImage[2]=LoadBMP("ziemia.bmp"))&& (TextureImage[3]=LoadBMP("moon.bmp"))&& (TextureImage[4]=LoadBMP("fonty.bmp")) && (TextureImage[5]=LoadBMP("mars.bmp")) && (TextureImage[6]=LoadBMP("wenus.bmp")) && (TextureImage[7]=LoadBMP("merkury.bmp")) && (TextureImage[8]=LoadBMP("satelitemaska.bmp")) && (TextureImage[9]=LoadBMP("satelite.bmp")) && (TextureImage[10]=LoadBMP("saturnmaska.bmp")) && (TextureImage[11]=LoadBMP("saturn.bmp")) && (TextureImage[12]=LoadBMP("space.bmp")) && (TextureImage[13]=LoadBMP("sun.bmp"))) { Status=TRUE; glGenTextures(14, &texture[0]); for(loop=0;loop<14;loop++) { glBindTexture(GL_TEXTURE_2D, texture[loop]); gluBuild2DMipmaps(GL_TEXTURE_2D, 3,TextureImage[loop]->sizeX, TextureImage[loop]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[loop]->data); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR) ; // Linear Filtering glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR) ; // Linear Filtering } for(loop=0;loop<14;loop++) { if (TextureImage[loop]) {