camX = 10 * np.sin(camera_theta) camY = 10 * np.cos(camera_theta) viewPos = np.array([camX, camY, 10]) view = tr2.lookAt(viewPos, np.array([0, 0, 0]), np.array([0, 0, 1])) glUniformMatrix4fv( glGetUniformLocation(pipeline.shaderProgram, "view"), 1, GL_TRUE, view) # Setting up the projection transform if controller.projection == PROJECTION_ORTHOGRAPHIC: projection = tr2.ortho(-8, 8, -8, 8, 0.1, 100) elif controller.projection == PROJECTION_FRUSTUM: projection = tr2.frustum(-5, 5, -5, 5, 9, 100) elif controller.projection == PROJECTION_PERSPECTIVE: projection = tr2.perspective(60, float(width) / float(height), 0.1, 100) else: raise Exception() glUniformMatrix4fv( glGetUniformLocation(pipeline.shaderProgram, "projection"), 1, GL_TRUE, projection)
1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3]) translation3 = random.choice([-0.5, -0.6, -0.7, -0.8, -0.9, -1, -1.1, -1.2, -1.3, -1.4, -1.5, -1.6, -1.7, -1.8, -1.9, -2, -2.1, -2.2, -2.3, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.1, 2.2, 2.3]) tpose.move(rotation, size, translation1, translation2, translation3) tpose_list.append(tpose) controller.set_toggle(tpose, 'face') controller.set_toggle(axis, 'axis') # Creamos la camara y la proyección projection = tr2.ortho(-1, 1, -1, 1, 0.1, 100) view = tr2.lookAt( np.array([80, 10, 5]), # Donde está parada la cámara np.array([0, 0, 0]), # Donde estoy mirando np.array([0, 0, 1]) # Cual es vector UP ) while not glfw.window_should_close(window): # Using GLFW to check for input events glfw.poll_events() # Filling or not the shapes depending on the controller state if controller.fill_polygon: glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) else:
glfw.set_key_callback(window, controller.on_key) # Creating shader programs for textures and for colores textureShaderProgram = es.SimpleTextureModelViewProjectionShaderProgram( ) # TEXTURAS colorShaderProgram = es.SimpleModelViewProjectionShaderProgram() # COLORES # Setting up the clear screen color glClearColor(0.15, 0.15, 0.15, 1.0) # As we work in 3D, we need to check which part is in front, # and which one is at the back glEnable(GL_DEPTH_TEST) # crear la camara y la proyeccion son usadas por el shader projection = tr2.ortho(-1, 1, -1, 1, 0.1, 100) # volumen de visualizacion view = tr2.lookAt( # hacia donde apunto y donde está la camara np.array([10, 10, 5]), np.array([0, 0, 0]), np.array([0, 0, 1])) tpose = Tpose('img/ricardo.png') axis = Axis() # Definimos las referencias cruzadas controller.set_tpose(tpose) while not glfw.window_should_close(window): # Using GLFW to check for input events glfw.poll_events() # Clearing the screen in both, color and depth glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)