Rabu, 16 Juli 2014

Membuat 3D persegi bergerak Basic4gl

Posting kali ini mengenai membuat objek persegi 3D bergerak menggunakan basic4gl. Dan source code nya seperti berikut :
dim putar#

while true
glclear(GL_DEPTH_BUFFER_BIT OR GL_COLOR_BUFFER_BIT)
glLoadIdentity ()
glTranslatef (0,0,-10)

gltranslatef(0,-1,0)
glrotatef(20,1,1,0)
glrotatef(-45,0,1,0)
gosub kotak

gltranslatef(0,-2,0)
glrotatef(45,0,1,0)
gosub kotak

gltranslatef(0,6,0)
glRotatef(putar#,1,1,0)
gosub kotak



swapBuffers()
' - = searah jarum jam
' + = berlawanan jarum jam
putar# = putar#-0.1 
wend

kotak:

gltranslatef(0,-1,0)
glColor3f(1,1,1)
glRotatef(90,1,0,0) 
gosub kotang

glRotatef(-90,1,0,0)
gltranslatef(0,3,-1)
gltranslatef(0,-1,0)
glRotatef(90,1,0,0)
gltranslatef(0,1,0)
glColor3f(1,1,0)
gosub kotang

gltranslatef(0,1,0)
glRotatef(-90,1,0,0)
gltranslatef(0,-1,0)
glColor3f(0,1,1)
gosub kotang
glRotatef(-90,0,1,0)
gltranslatef(-1,0,0)
gltranslatef(0,0,1)
glColor3f(0,0,1)
gosub kotang
glRotatef(-90,0,1,0)
gltranslatef(-1,0,0)
gltranslatef(0,0,1)
glColor3f(0,1,0)
gosub kotang
glRotatef(-90,0,1,0)
gltranslatef(-1,0,0)
gltranslatef(0,0,1)
glColor3f(1,0,0)
gosub kotang
return 

kotang:
glBegin(GL_QUADS)
glvertex2f (-1,1)
glvertex2f (-1,-1)
glvertex2f (1,-1)
glvertex2f (1,1)
glEnd()
return 


Hasil Run Program :

2 komentar:

 
;
notifikasi
close