Basic4GL


Membuat Rotasi Perputaran Matahari, Bumi, Bulan, dan Planet Lain Dengan BASIC4GL


Sehubungan dengan Tugas yang diberikan, maka akan membagikan hasil tugas kami selanjutnya, yaitu membuat rotasi perputaran siklus Matahari, Bumi, Bulan, dan Planet Lain. 




Inilah Source Code Rotasi :

  sub Rotasi(I#)
    glBegin(GL_QUADS)                        ' Draw a quad
    'buat depan
           glcolor3f(1,1,0.1)
           glVertex3f(-1, 1, -1) 'A
           glVertex3f( 1, 1, -1) 'B
           glVertex3f( 1,-1, -1) 'C
           glVertex3f(-1,-1, -1) 'D
  
    'buat bawah
           glcolor3f(0.1,1,1)
           glVertex3f(-1, 1, 1) 'A
           glVertex3f( 1, 1, 1) 'B
           glVertex3f( 1,-1, 1) 'F
           glVertex3f(-1,-1, 1) 'E

    'buat sono
           glcolor3f(1,1,1)
           glVertex3f(-1,-1, 1) 'F
           glVertex3f(-1, 1, 1) 'E
           glVertex3f(-1, 1,-1) 'H
           glVertex3f(-1,-1,-1) 'G
  
    'buat atas
           glcolor3f(1,0.1,1)
           glVertex3f(1,-1, 1) 'H
           glVertex3f(1, 1, 1) 'G
           glVertex3f(1, 1,-1) 'C
           glVertex3f(1,-1,-1) 'D

    'kanan
           glcolor3f(0.1,0.1,1)
           glVertex3f(-1, 1, 1) 'B
           glVertex3f( 1, 1, 1) 'F
           glVertex3f( 1, 1,-1) 'G
           glVertex3f(-1, 1,-1) 'C
   
    'kiri
           glcolor3f(0.1,0.5,0.1)
           glVertex3f(-1,-1, 1) 'A
           glVertex3f( 1,-1, 1) 'E
           glVertex3f( 1,-1,-1) 'H
           glVertex3f(-1,-1,-1) 'D

    glEnd()
  end sub
  
   dim d#  : d#=0
   dim d1# : d1#=0
   dim d2# : d2#=0
   dim d3# : d3#=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,-50.0)             ' Move left 1.5 units and into the screen 6.0
     
     d#  =d#+1
     d1# =d1#-0.5
     d2# =d2#+0.1
     d3# =d3#+0.1
     
     glrotatef(d3#,0,1,1)  
     glTranslatef(0,0,0)             
     Rotasi(4)

     glrotatef(d2#,0,1,0)  
     glTranslatef(-10,0,0)             
     Rotasi(3)

     glrotatef(d1#,0,1,0)  
     glTranslatef(-3,0,0)             
     Rotasi(2)

     glrotatef(d#,0,1,0)  
     glTranslatef(-20,0,0)             
     Rotasi(1)
     
     SwapBuffers ()
     wend


Maka jika di running, hasilnya akan seperti dibawah ini :

Membuat Garis Dengan Basic4GL


Sehubungan dengan Tugas yang diberikan, maka kami akan membagikan hasil tugas kami, yaitu membuat garis dengan Basic4GL. 
Inilah Source Code Garis :
     
     sub Line(x0#,y0#,x1#,y1#)
     glBegin(GL_LINES)
     glcolor3f(1.0,0.0,0.0) : glcolor3f(1.0,0.0,0.0)
     glvertex2f(x0#,y0#) : glvertex2f(x1#,y1#)
     glEnd()                                   
  
     end sub
    

    glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)    ' Clear The Screen And The Depth Buffer
     glLoadIdentity()                            ' Reset The View
     glTranslatef(0.0,0.0,-90.0)
    
      glTranslatef(20,0,0)
      glRotatef(45,0,0,01)
      Line(0,0,20,0)
     
     
      glTranslatef(20,0,0)
      glRotatef(45,0,0,01)
      Line(0,0,20,0)
     
     
      glTranslatef(20,0,0)
      glRotatef(45,0,0,01)
      Line(0,0,20,0)
    
     SwapBuffers ()                  
Jika Di Running, hasilnya akan seperti berikut :






Sehubungan dengan Tugas yang diberikan, maka kami akan membagikan hasil tugas kami, yaitu membuat kotak dengan Basic4GL. 
Inilah Source Code Kotak :

     sub Square(x0#,y0#,z0#,x1#,y1#,z1#,x2#,y2#,z2#,x3#,y3#,z3#)
     glBegin(GL_QUADS)                      
      glColor3f(1.0,0.0,0.0)  : glColor3f(1.0,0.0,0.0)  : glColor3f(1.0,0.0,0.0)  : glColor3f(1.0,0.0,0.0)
      glVertex3f(x0#,y0#,z0#) : glVertex3f(x1#,y1#,z1#) : glVertex3f(x2#,y2#,z2#) : glVertex3f(x3#,y3#,z3#)
                  
     glEnd()
 
     end sub
   

     glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)    ' Clear The Screen And The Depth Buffer
     glLoadIdentity()                                       ' Reset The View
     glTranslatef(0,0,-10)

      
        'glRotatef(90,1,0,0)
        'Square(-1,1,0,3,3,0,-3,1,0,1,3,0)
      
        glRotatef(45,0,1,0)
        glTranslatef(1,0,0)
        Square(3,3,0,1,3,0,1,1,0,3,1,0)
      
        glRotatef(45,0,1,0)
        glTranslatef(1,0,0)
        Square(-3,3,0,-1,3,0,-1,1,0,-3,1,0)
      
        glRotatef(45,0,1,0)
        glTranslatef(1,0,0)
        Square(-1,1,0,-1,-1,0,1,-1,0,1,1,0)

    SwapBuffers()

 Jika Di Running, hasilnya akan seperti berikut :

Tidak ada komentar:

Posting Komentar