Postingan kali ini tentang Tugas 5 PKG Pembuatan 4 Kubus Dengan Fungsi Translasi Rotasi & Transformasi (TRT) Yang Dapat Bergerak, tetapi dalam tugas kami kali ini kami membuatnya melalui aplikasi Basic4GL, Berikut Dibawah ini untuk selengkapnya :
dim tx#: tx#=0
dim ty#: ty#=0
dim rb#: rb#=0
dim x#: x#=0
dim y#: y#=0
dim z#: z#=0
dim r#: r#=0
dim key$
sub kotak (l1#)
glbegin(GL_QUADS)
'depan
glcolor3f(0,1,0.4)
glvertex3f(0,0,0)
glvertex3f(l1#,0,0)
glvertex3f(l1#,l1#,0)
glvertex3f(0,l1#,0)
'bawah
glcolor3f(0.1,1,1)
glvertex3f(0,0,0) 'A
glvertex3f(l1#,0,0) 'B
glvertex3f(l1#,0,-l1#) 'F
glvertex3f(0,0,-l1#) 'E
'belakang
glcolor3f(1,1,1)
glvertex3f(l1#,0,-l1#) 'F
glvertex3f(0,0,-l1#) 'E
glvertex3f(0,l1#,-l1#) 'H
glvertex3f(l1#,l1#,-l1#) 'G
'atas
glcolor3f(1,0.1,1)
glvertex3f(0,l1#,-l1#) 'H
glvertex3f(l1#,l1#,-l1#) 'G
glvertex3f(l1#,l1#,0) 'C
glvertex3f(0,l1#/2,0) 'D
'kanan
glcolor3f(0.1,0.1,1)
glvertex3f(l1#,0,0) 'B
glvertex3f(l1#,0,-l1#/2) 'F
glvertex3f(l1#,l1#,-l1#) 'G
glvertex3f(l1#,l1#,0) 'C
'kiri
glcolor3f(0.1,0.5,0.1)
glvertex3f(0,0,0) 'A
glvertex3f(0,0,-l1#/2) 'E
glvertex3f(0,l1#,-l1#) 'H
glvertex3f(0,l1#,0) 'D
glEnd()
end sub
dim d1#
d1#=0
while true
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT) ' Clear screen and depth buffer
'Matrix View Point
glLoadIdentity() ' Reset the current modelview matrix
glTranslatef(0,0.0,-250.0) ' Move left 1.5 units and into the screen 6.0
rb# = rb# + 2
glrotatef(r#,x#,y#,z#)
gltranslatef(tx#,ty#,0)
if tx# > 230 then
tx# = -230
elseif tx# < -230 then
tx# = 230
elseif ty# > 120 then
ty# = -120
elseif ty# < -120 then
ty# = 120
endif
glpushmatrix()
d1#=d1#-0.1
glrotatef(-d1#,0,0,1)
'glTranslatef()
kotak (10)
glpopmatrix()
glTranslatef(-40,0.0,0.0)
'glrotatef(d1#,0,0,1)
kotak (20)
glTranslatef(-50,0.0,0.0)
'glrotatef(d1#,0,0,1)
kotak (30)
glTranslatef(-60,0.0,0.0)
glrotatef(d1#,0,0,1)
kotak (40)
SwapBuffers ()
key$ = Inkey$ ()
if key$ = "R" or key$ = "r" then
tx#=0: ty#=0: rb#=0: x#=0: y#=0: z#=0: r#=0
endif
if key$ = "X" or key$ = "x" then
if x# = 0 then
x#=1
else
x#=0
endif
endif
if key$ = "Y" or key$ = "y" then
if y# = 0 then
y#=1
else
y#=0
endif
endif
if key$ = "Z" or key$ = "z" then
if z# = 0 then
z#=1
else
z#=0
endif
endif
if ScanKeyDown (VK_PRIOR) then
r# = r# - 0.1
endif
if ScanKeyDown (VK_NEXT) then
r# = r# + 0.1
endif
if ScanKeyDown (VK_UP) then
ty# = ty# + 0.1
endif
if ScanKeyDown (VK_DOWN) then
ty# = ty# - 0.1
endif
if ScanKeyDown (VK_RIGHT) then
tx# = tx# + 0.1
endif
if ScanKeyDown (VK_LEFT) then
tx# = tx# - 0.1
endif
wend
Nah seperti itulah project yang kami buat, dan sekiranya ada yang kurang sempurna ataupun salah kami harap dapat dimaklumi, karena kami sendiri juga masih dalam tahap pembelajaran , dan jika anda mau mendownload file source code project diatas sebagai bahan referensi pembelajaran, anda dapat mendownloadnya dengan link di bawah ini :
ini source codenya : Download