Langsung ke konten utama

Postingan

Menampilkan postingan dengan label Grafika Komputer

OpenGL : Kipas Angin

buat temen-temen yang nyari code script program OpenGL untuk objeck Kipas Angin, berikut kode nya. .  #include <glut.h> #include <math.h> void cylinder(float rbase,float rtop,float height); void blok(float tebal,int ratiol,int ratiop); void bilah (float r_inner,float r_outer,float tebal,int batang); int screen_width=800; int screen_height=600; int button_up=0,button_down=0; int Turn=0; double rotation_y=0,rotation_y_plus=-15,direction; double Rhead=0,Rheadplus=0; double rotate_All=0,All_plus=0; double Angguk=0,Anggukplus=0; double press=0,pressplus,pressplus1=180,pressplus2=0,pressplus3=0,pressplus4=0,pressplus5=0; bool Toleh=true,Tolehpress=true; bool RightTurn=true; bool speed1=true,speed2=false,speed3=false,speed4=false,speed5=false; //GLfloat ambient_light[]={0.3,0.3,0.45,1.0}; GLfloat ambient_light[]={0.0,0.0,0.45,1.0}; //GLfloat  source_light[]={0.9,0.8,0.8,1.0}; GLfloat  source_light[]={0.8,0.8,0.8,1.0}; //GLfloat     light_pos[]={7.0,0.0,1.0,...

OpenGL: Sendok

berikut ini code program OpenGL objeck sendok, semoga bermanfaat. #include <glut.h> #include <math.h> void cylinder(float rbase,float rtop,float height); void blok(float tebal,int ratiol,int ratiop); int screen_width=800; int screen_height=600; int button_up=0,button_down=0; int Turn=0; double rotation_y=0,rotation_y_plus=-15,direction; double Rhead=0,Rheadplus=0; double rotate_All=0,All_plus=0; double Angguk=0,Anggukplus=0; double press=0,pressplus,pressplus1=180,pressplus2=0,pressplus3=0,pressplus4=0,pressplus5=0; GLfloat ambient_light[]={0.0,0.0,0.45,1.0}; GLfloat  source_light[]={0.8,0.8,0.8,1.0}; GLfloat    light_pos[]={5.0,0.0,6.0,1.0}; void init(void) { glClearColor(1.0,1.0,1.0,0.0);  //putih    //glClearColor(0.0,0.0,0.4,0.0); //back color glShadeModel(GL_SMOOTH); glViewport(0,0,screen_width,screen_height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f,(GLfloat)screen_width/(GLfloat)screen_height,1.0f,1000.0f)...

Tugas OpenGL : Tong Sampah

brikut code nya, semoga bermanfaat. #include <glut.h> #include <math.h> #include <stdlib.h> #ifndef M_PI //#define M_PI 3.14 #define M_PI 22/7 #endif typedef struct { float v[3]; } vektor2D_t; typedef struct { float m[3][3]; } matrik2D_t; typedef struct { float x,y; } point2D_t; typedef struct { float r,g,b; } warna_t; point2D_t interpolasi(point2D_t a,point2D_t b, float m) { point2D_t c; c.x=m*a.x+(1.-m)*b.x; c.y=m*a.y+(1.-m)*b.y; return c; } point2D_t konversi(point2D_t p,float a) { point2D_t q; q.x=a*p.x; q.y=a*p.y; return(q); } // -------------- // Operasi Matrik // -------------- matrik2D_t BuatMatrikIdentitas() { int i,j; matrik2D_t I; for(i=0;i<3;i++) { for(j=0;j<3;j++) I.m[i][j]=0.; I.m[i][i]=1.; } return I; } matrik2D_t Translasi(float tambahx, float tambahy) { matrik2D_t a; a=BuatMatrikIdentitas(); a.m[0][2]=tambahx; a.m[1][2]=tambahy; return a; } matrik2D_t Scaling(float rx,fl...