def on_resize(width,height): cur_width = width cur_height = height pnt_cloud['projection'] = glm.perspective( 45.0, width / float(height), 1.0, 1000.0 ) quad['projection'] = glm.perspective( 45.0, width / float(height), 1.0, 1000.0 ) bldgs['projection'] = glm.perspective( 45.0, width / float(height), 1.0, 1000.0 ) paths['projection'] = glm.perspective( 45.0, width / float(height), 1.0, 1000.0 )
def _set_perspective_projection(self, w: int, h: int): ratio = w / float(h) self._view_to_projection = glm.perspective(45.0, ratio, znear=self._near_clip_z, zfar=self._far_clip_z) self.update()
def __init__(self, *args, **kwargs): """ Initialize the transform. """ code = library.get("transforms/trackball.glsl") Transform.__init__(self, code, *args, **kwargs) self._aspect = Transform._get_kwarg("aspect", kwargs) or 1 self._znear = Transform._get_kwarg("znear", kwargs) or 2.0 self._zfar = Transform._get_kwarg("zfar", kwargs) or 1000.0 theta = Transform._get_kwarg("theta", kwargs) or 45 phi = Transform._get_kwarg("phi", kwargs) or 45 self._distance = Transform._get_kwarg("distance", kwargs) or 8 self._zoom = Transform._get_kwarg("zoom", kwargs) or 35 self._width = 1 self._height = 1 self._window_aspect = 1 self._trackball = _trackball.Trackball(45, 45) aspect = self._window_aspect * self._aspect self._projection = glm.perspective(self._zoom, aspect, self._znear, self._zfar) self._view = np.eye(4, dtype=np.float32) glm.translate(self._view, 0, 0, -abs(self._distance))
def on_mouse_scroll(self, x, y, dx, dy): width = self._width height = self._height aspect = self._window_aspect * self._aspect self._zoom = min(max(self._zoom * (1 - dy / 100), 1.0), 179.0) self['projection'] = glm.perspective(self._zoom, aspect, self._znear, self._zfar)
def __init__(self, *args, **kwargs): """ Initialize the transform. """ code = library.get("transforms/trackball.glsl") Transform.__init__(self, code, *args, **kwargs) self._aspect = Transform._get_kwarg("aspect", kwargs) or 1 self._znear = Transform._get_kwarg("znear", kwargs) or 2.0 self._zfar = Transform._get_kwarg("zfar", kwargs) or 1000.0 theta = Transform._get_kwarg("theta", kwargs) or 45 phi = Transform._get_kwarg("phi", kwargs) or 45 self._distance = Transform._get_kwarg("distance", kwargs) or 8 self._zoom = Transform._get_kwarg("zoom", kwargs) or 35 self._width = 1 self._height = 1 self._window_aspect = 1 self._trackball = _trackball.Trackball(45,45) aspect = self._window_aspect * self._aspect self._projection = glm.perspective(self._zoom, aspect, self._znear, self._zfar) self._view = np.eye(4, dtype=np.float32) glm.translate(self._view, 0, 0, -abs(self._distance))
def on_draw(dt): global i, t, theta, phi, translate, program t += dt * 1000 if i != np.sum(timestamps < t) - 1: i = np.sum(timestamps < t) - 1 pointcloud = pointclouds[i] n = len(pointcloud) program = gloo.Program(vertex, fragment, count=n) program['position'] = pointcloud[:, :3] program['radius'] = 0.1 * np.ones(n) program['fg_color'] = 0, 0, 0, 1 colors = np.ones((n, 4)) colors[:, 3] = 1 program['bg_color'] = colors program['linewidth'] = 1.0 program['antialias'] = 1.0 program['model'] = np.eye(4, dtype=np.float32) program['projection'] = glm.perspective(45.0, width / float(height), 1.0, 1000.0) program['view'] = view window.clear() program.draw(gl.GL_POINTS) #theta += .5 #phi += .5 model = np.eye(4, dtype=np.float32) glm.rotate(model, theta, 0, 0, 1) glm.rotate(model, phi, 0, 1, 0) program['model'] = model
def zoom(self, value): """ Zoom level (aperture angle in degrees) """ aspect = self._window_aspect * self._aspect self._zoom = min(max(value, 1.0), 179.0) self['projection'] = glm.perspective(self._zoom, aspect, self._znear, self._zfar)
def _on_resize(self, width, height): aspect = width / float(height) self._projection = glm.perspective(self._fov, aspect, self._znear, self._zfar) self._view = np.eye(4, dtype=np.float32) self._width = width self._height = height
def _build_projection(self): # We need to have caught at least one resize event if self._width is None: return aspect = self._width / float(self._height) self['projection'] = glm.perspective(self.fovy, aspect, self._znear, self._zfar)
def on_mouse_scroll(self, x, y, dx, dy): width = self._width height = self._height aspect = self._window_aspect * self._aspect self._zoom = min(max(self._zoom*(1-dy/100), 1.0), 179.0) self['projection'] = glm.perspective(self._zoom, aspect, self._znear, self._zfar)
def on_resize(self, width, height): self._width = float(width) self._height = float(height) self._window_aspect = self._width / self._height aspect = self._window_aspect * self._aspect self["projection"] = glm.perspective(self._zoom, aspect, self._znear, self._zfar) Transform.on_resize(self, width, height)
def on_resize(self, width, height): self._width = float(width) self._height = float(height) self._window_aspect = self._width / self._height aspect = self._window_aspect * self._aspect self['projection'] = glm.perspective(self._zoom, aspect, self._znear, self._zfar) Transform.on_resize(self, width, height)
def init_program(self): self.program = gloo.Program(vertex, fragment, count=n) self.program['position'] = np.zeros((n, 3), dtype=np.float32) self.program['radius'] = 1 self.program['projection'] = glm.perspective( 45.0, self.winsize[0] / float(self.winsize[1]), 1.0, 1000.0) self.program["distance"] = np.linspace(0, 1, n) gl.glEnable(gl.GL_DEPTH_TEST) self.posx = 0 self.posy = 0
def update(self): if self.mesh != self.internal_mesh: self.load_mesh(mesh_dict[self.mesh]) self.internal_mesh = self.mesh # The model is rotated because the texturing is the wrong way around self.shader["model"] = self.model_matrix self.shader["view"] = glm.translation(0, 0, self.view_distance) # Scale is increased to fill the whole screen self.shader["scale"] = 1.0 self.shader["tex"] = to_tex_format(self.texture) width, height = self.window_size self.shader["projection"] = glm.perspective( # 45.0, 1.0, 2.0, 100.0 45.0, width / float(height), 2.0, 100.0, )
def on_resize(width, height): cube['u_projection'] = glm.perspective(45.0, width / float(height), 2.0, 100.0)
def on_resize(width, height): global obj obj['u_projection'] = glm.perspective(45.0, width / float(height), 2.0, 100.0)
def on_resize(self, width, height): fovy = self._fovy aspect = width / float(height) znear, zfar = self._znear, _zfar self["projection"] = glm.perspective(fovy, aspect, znear, zfar)
def on_resize(width, height): program['projection'] = glm.perspective(fovy, width / float(height), 1.0, 100.0) program['clip']['iResolution'] = width, height
def on_resize(width, height): cube['projection'] = glm.perspective(45.0, width / float(height), 2.0, 100.0)
def on_resize(w, h): if h != 0: ratio = w/float(h) renderer[PROJECTION_MATRIX] = glm.perspective(96., ratio, 0.01, 1000.)
def on_resize(width, height): gl.glViewport(0, 0, width, height) projection = glm.perspective(45.0, width / float(height), 1.0, 1000.0) program['u_projection'] = projection
def aspect(self, value): """ Projection aspect """ aspect = self._window_aspect * self._aspect self['projection'] = glm.perspective(self._zoom, aspect, self._znear, self._zfar)
def on_resize(width, height): gl.glViewport(0, 0, width, height) projection = glm.perspective(45.0, width / float(height), 1.0, 1000.0) program["u_projection"] = projection
""" quad = gloo.Program(vertex, fragment) quad2 = gloo.Program(vertex, fragment) quad2["position"] = np.array([(-0.5, -0.5), (-0.5, +0.5), (+0.5, -0.5), (+0.5, +0.5)]) # quad["position"] = np.array([(-1, -1), # (-1, +1), # (+1, -1), # (+1, +1)]) quad["position"] = np.array([(-0, -0), (-0, +1), (+1, -0), (+1, +1)]) quad["color"] = np.array([1, 0, 0, 1]) # red quad["time"] = np.array(0.0) cube['u_projection'] = glm.perspective(45.0, width / float(height), 2.0, 100.0) window_config = glumpy.app.configuration.get_default() window_config.double_buffer = True window_config.samples = 0 window_config.api = "ES" window_config.major_version = 3 window_config.minor_version = 1 window_config.profile = "core" window = glumpy.app.Window(width=width, height=height, config=window_config, visible=True) print(window.config) #fb = np.zeros((640, 480), np.float32).view(gloo.TextureFloat2D)
def on_resize(width, height): ratio = width / float(height) self.u_projection = glm.perspective(64.0, ratio, 1, 10000.0)
def on_resize(width, height): cube['u_projection'] = glm.perspective(45.0, width / float(height), 2.0, 100.0) model = np.eye(4, dtype=np.float32)
def on_resize(w, h): ratio = w / float(h) cube["u_projection"] = glm.perspective(45.0, ratio, 2.0, 100.0)
def on_resize(width, height): gl.glViewport(0, 0, width, height) cube['projection'] = glm.perspective(45.0, width / float(height), 2.0, 100.0) pixelate.viewport = 0, 0, width, height
def on_mouse_scroll(self, x, y, dx, dy): self._fovy = np.minimum(np.maximum(self._fovy*(1-dy/100), 1.0), 179.0) self['projection'] = glm.perspective(self._fovy, self._aspect, self._znear, self._zfar)
def on_resize(width, height): program = self.program program['projection'] = glm.perspective(45.0, width / float(height), 0.1, 100.0)
def on_resize(width, height): program['u_projection'] = glm.perspective( 15.0, width / float(height), 2.0, 2000.0)
def on_resize(width, height): program['projection'] = glm.perspective(45.0, width / float(height), 2.0, 100.0)
def set_projection(self, w, h): ratio = float(w) / float(h) self['program_shader']['u_projection'] = glm.perspective( 45.0, ratio, 2.0, 100.0)
def on_resize(width, height): ratio = width / float(height) self.program['u_projection'] = glm.perspective( 45.0, ratio, 0.001, 10000.0)
def on_mouse_scroll(x, y, dx, dy): global fovy fovy = np.minimum(np.maximum(fovy*(1+dy/100), 10.0), 179.0) program['projection'] = glm.perspective(fovy, window.width/float(window.height), 1.0, 100.0)
def zoom(self, value): self._fovy = np.minimum(np.maximum(value, 1.0), 179.0) self['projection'] = glm.perspective(self._fovy, self._aspect, self._znear, self._zfar)
texture[3] = data.get(abspath("Down2.png")) / 255. texture[0] = data.get(abspath("Right2.png")) / 255. texture[1] = data.get(abspath("Left2.png")) / 255. texture[4] = data.get(abspath("Front2.png")) / 255. texture[5] = data.get(abspath("Back2.png")) / 255. # Bind the vertex object to the cube program cube = gloo.Program(vertex, fragment) cube["a_position"] = [vertex_pos[i] for i in face_vertex_idx] cube['a_normal'] = [face_norm[i] for i in face_normal_idx] cube['u_texture'] = texture # Initiate all three matrix view = np.eye(4, dtype=np.float32) model = np.eye(4, dtype=np.float32) projection = glm.perspective(45.0, 1, 2.0, 100.0) # Minimize the model, and move the camera-view back glm.scale(model, 0.5, 1, 0.1) glm.translate(view, 0, 0, -5) # Pass all the matrix to the model cube['u_model'] = model cube['u_view'] = view cube['u_projection'] = projection cube["u_light_position"] = 0, 0, -2 cube["u_light_intensity"] = 1, 1, 1 # Initiaze the window phi = 0.5 theta = 0.1
def on_resize(width, height): spiral['projection'] = glm.perspective(30.0, width / float(height), 2.0, 100.0) spiral['viewport'] = width, height
def on_mouse_scroll(x, y, dx, dy): global fovy fovy = np.minimum(np.maximum(fovy * (1 + dy / 100), 10.0), 179.0) program['projection'] = glm.perspective( fovy, window.width / float(window.height), 1.0, 100.0)
def on_resize(width, height): ratio = width / float(height) program_ptCloud['u_projection'] = glm.perspective(45.0, ratio, 0.001, 10000.0)
def on_resize(self, width, height): self._viewport = width, height self._aspect = width / float(height) self['projection'] = glm.perspective(self._fovy, self._aspect, self._znear, self._zfar)
def on_resize(width, height): global projection ratio = width / float(height) projection = glm.perspective(45.0, ratio, 2.0, 100.0) cube['u_projection'] = projection