Entradas

Mostrando las entradas de noviembre, 2017

Cubo y triangulo 3D en Python

Cubo en 3D en Python import pygame from pygame . locals import * from OpenGL . GL import * from OpenGL . GLU import * verticies = ( ( 1 , - 1 , - 1 ), ( 1 , 1 , - 1 ), (- 1 , 1 , - 1 ), (- 1 , - 1 , - 1 ), ( 1 , - 1 , 1 ), ( 1 , 1 , 1 ), (- 1 , - 1 , 1 ), (- 1 , 1 , 1 ) ) edges = ( ( 0 , 1 ), ( 0 , 3 ), ( 0 , 4 ), ( 2 , 1 ), ( 2 , 3 ), ( 2 , 7 ), ( 6 , 3 ), ( 6 , 4 ), ( 6 , 7 ), ( 5 , 1 ), ( 5 , 4 ), ( 5 , 7 ) ) 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 : ...