Minggu, 30 Juni 2013

Tugas 5 Tentang Pembuatan Kubus Dengan Fungsi Translasi Rotasi & Transformasi yang dapat bergerak

Untuk tugas 5 kali ini saya mempostingkan tentang Pembuatan Kubus Dengan Fungsi Translasi Rotasi & Transformasi yang dapat bergerak. Untuk kali ini saya coding tersebut menggunakan aplikasi basic4gl. Dibawah ini coding tersebut :

sub KUBUS1()
glBegin(Gl_quads)
glcolor3f(1,1,0)
glVertex3f(-1,-1,-1)
glVertex3f( 1,-1,-1)
glVertex3f( 1, 1,-1)
glVertex3f(-1, 1,-1)
glcolor3f(1,0,1)
glVertex3f(-1,-1,-1)
glVertex3f(-1,-1, 1)
glVertex3f(-1, 1, 1)
glVertex3f(-1, 1,-1)
glcolor3f(1,1,1)
glVertex3f( 1,-1, 1)
glVertex3f( 1,-1,-1)
glVertex3f( 1, 1,-1)
glVertex3f( 1, 1, 1)
glcolor3f(0,0,1)
glVertex3f(-1,-1,-1)
glVertex3f( 1,-1,-1)
glVertex3f( 1,-1, 1)
glVertex3f(-1,-1, 1)
glcolor3f(0,1,0)
glVertex3f(-1,-1, 1)
glVertex3f( 1,-1, 1)
glVertex3f( 1, 1, 1)
glVertex3f(-1, 1, 1)
glColor3f(0,1,1)
glVertex3f(-1, 1, 1)
glVertex3f(-1, 1,-1)
glVertex3f( 1, 1,-1)
glVertex3f( 1, 1, 1)
glend()

end sub

sub KUBUS2()
glBegin(Gl_quads)
glcolor3f(0,1,1)
glVertex3f(-1,-1,-1)
glVertex3f( 1,-1,-1)
glVertex3f( 1, 1,-1)
glVertex3f(-1, 1,-1)
glcolor3f(1,1,1)
glVertex3f(-1,-1,-1)
glVertex3f(-1,-1, 1)
glVertex3f(-1, 1, 1)
glVertex3f(-1, 1,-1)
glcolor3f(0,1,0)
glVertex3f( 1,-1, 1)
glVertex3f( 1,-1,-1)
glVertex3f( 1, 1,-1)
glVertex3f( 1, 1, 1)
glcolor3f(1,0,1)
glVertex3f(-1,-1,-1)
glVertex3f( 1,-1,-1)
glVertex3f( 1,-1, 1)
glVertex3f(-1,-1, 1)
glcolor3f(0,0,1)
glVertex3f(-1,-1, 1)
glVertex3f( 1,-1, 1)
glVertex3f( 1, 1, 1)
glVertex3f(-1, 1, 1)
glColor3f(1,0,0)
glVertex3f(-1, 1, 1)
glVertex3f(-1, 1,-1)
glVertex3f( 1, 1,-1)
glVertex3f( 1, 1, 1)
glend()

end sub

sub KUBUS3()
glBegin(Gl_quads)
glcolor3f(1,1,0)
glVertex3f(-1,-1,-1)
glVertex3f( 1,-1,-1)
glVertex3f( 1, 1,-1)
glVertex3f(-1, 1,-1)
glcolor3f(1,0,0)
glVertex3f(-1,-1,-1)
glVertex3f(-1,-1, 1)
glVertex3f(-1, 1, 1)
glVertex3f(-1, 1,-1)
glcolor3f(1,0,0)
glVertex3f( 1,-1, 1)
glVertex3f( 1,-1,-1)
glVertex3f( 1, 1,-1)
glVertex3f( 1, 1, 1)
glcolor3f(1,0,1)
glVertex3f(-1,-1,-1)
glVertex3f( 1,-1,-1)
glVertex3f( 1,-1, 1)
glVertex3f(-1,-1, 1)
glcolor3f(0,1,0)
glVertex3f(-1,-1, 1)
glVertex3f( 1,-1, 1)
glVertex3f( 1, 1, 1)
glVertex3f(-1, 1, 1)
glColor3f(0,0,1)
glVertex3f(-1, 1, 1)
glVertex3f(-1, 1,-1)
glVertex3f( 1, 1,-1)
glVertex3f( 1, 1, 1)
glend()

end sub    

sub KUBUS4()
glBegin(Gl_quads)
glcolor3f(1,0,1)
glVertex3f(-1,-1,-1)
glVertex3f( 1,-1,-1)
glVertex3f( 1, 1,-1)
glVertex3f(-1, 1,-1)
glcolor3f(1,0,0)
glVertex3f(-1,-1,-1)
glVertex3f(-1,-1, 1)
glVertex3f(-1, 1, 1)
glVertex3f(-1, 1,-1)
glcolor3f(1,1,1)
glVertex3f( 1,-1, 1)
glVertex3f( 1,-1,-1)
glVertex3f( 1, 1,-1)
glVertex3f( 1, 1, 1)
glcolor3f(0,0,1)
glVertex3f(-1,-1,-1)
glVertex3f( 1,-1,-1)
glVertex3f( 1,-1, 1)
glVertex3f(-1,-1, 1)
glcolor3f(1,0,1)
glVertex3f(-1,-1, 1)
glVertex3f( 1,-1, 1)
glVertex3f( 1, 1, 1)
glVertex3f(-1, 1, 1)
glColor3f(0,1,0)
glVertex3f(-1, 1, 1)
glVertex3f(-1, 1,-1)
glVertex3f( 1, 1,-1)
glVertex3f( 1, 1, 1)
glend()

end sub



dim a#

while true
glClear(gl_color_buffer_bit or gl_depth_buffer_bit)
glLoadIdentity()
glTranslatef(0,0,-15)
   
    glTranslatef(0,0,-5)
    glrotatef(a#,a#,a#,a#)  
    KUBUS1()
   
    glTranslatef(1,0,-5)
    glrotatef(a#,a#,a#,a#)  
    KUBUS2()
   
    glTranslatef(1,0,-5)
    glrotatef(a#,a#,a#,a#)  
    KUBUS3()
   
    glTranslatef(1,0,-5)
    glrotatef(a#,a#,a#,a#)  
    KUBUS4()

SwapBuffers()
a# = a# + 0.1      

wend

maka jika menggunakan coding tersebut maka akan muncul gambar seperti di bawah ini :

Jika ingin mendownload ciding tersebut silahkan anda download disini.

Tidak ada komentar:

Posting Komentar