jueves, 29 de noviembre de 2018

Unidad 4: Figura 3D (Tetraedro)

Figura 3D (Tetraedro)




Código:

import pygame
from pygame.locals import *

from OpenGL.GL import *
from OpenGL.GLU import *

verticies = (
    (0,0,0),
    (1,0, 0),
    (0.5,-0.46,0.73),
    (0.5, -0.84,-.19)
)
edges = (
    (1,0),
    (1,2),
    (1,3),
    (3,0),
    (3,2),
    (2,0)
)

def Cube():
    glBegin(GL_LINES)
    for edge in edges:
        for vertex in edge:
            glVertex3fv(verticies[vertex])
    glEnd()

def main():
    pygame.init()
    display = (700, 500)
    pygame.display.set_mode(display, DOUBLEBUF | OPENGL)

    gluPerspective(45, (display[0] / display[1]), 0.1, 50.0)

    glTranslatef(0.0, 0.0, -5)

    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                quit()

        glRotatef(1, 3, 1, 1)
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        Cube()
        pygame.display.flip()
        pygame.time.wait(10)

main()



No hay comentarios:

Publicar un comentario