mi figura 3d

import pygame
from pygame.locals import *

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

verticies = (
    (0.5, 1, -0.5),#0A
    (0.5, -1, -0.5),#1B
    (-0.5, -1, -0.5),#2C
    (-0.5, 1, -0.5),#3D
    (0, -0.5, 0.5),#4E
    (0, 0.5, 0.5),#5F

    )

edges = (
    (0,1),
    (0,3),
    (0,5),

    (2,1),
    (2,3),
    (2,4),

    (4, 5),
    (4, 1),
    (4, 2),

    (5, 4),
    (5, 0),
    (5, 3)
    )


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


def main():
    pygame.init()
    display = (800,600)
    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(5)


main()

Entradas populares de este blog

1.4 Aspectos matematicos de la graficacion (geometria fractal)

1.2 Dispositivos de hardware y software para el despliegue gráfico.

Ejemplos de compañeros en clase