def matrix_model(model): glm.scale(model, self.size, self.size, self.size) glm.rotate(model, self.deg_y, 1, 0, 0) glm.rotate(model, self.deg_x, 0, 0, 1) glm.translate(model, self.mov_x, -self.mov_y, 0) # model[3,3] = 1 return model
def create_transform(self, m, texture_size, target_size): texture_aspect = texture_size[0] / texture_size[1] target_aspect = target_size[0] / target_size[1] model = np.eye(4, dtype=np.float32) view = np.eye(4, dtype=np.float32) projection = glm.ortho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0) texture = np.eye(4, dtype=np.float32) if abs(texture_aspect - target_aspect) < 0.1: pass elif texture_aspect < target_aspect: # border left/right glm.scale(model, texture_aspect, 1.0, 1.0) #glm.scale(projection, 1.0 / target_aspect, 1.0, 1.0) glm.scale(texture, target_aspect, 1.0, 1.0) else: # border top/bottom glm.scale(model, 1.0, 1.0 / texture_aspect, 1.0) #glm.scale(projection, 1.0, target_aspect, 1.0) glm.scale(texture, 1.0, 1.0 / target_aspect, 1.0) model = np.dot(model, m) glm.scale(model, 1.0, -1.0, 1.0) return model, view, projection, texture
def transform_destination(self, texture_size, target_size): model, view, projection = self._create_transformation( texture_size, target_size) model = transform.apply_transform(self._transform_model, model) if self._transform_flipy: glm.scale(model, 1.0, -1.0, 1.0) return np.dot(model, np.dot(view, projection))
def matrix_model(): model = np.eye(4, dtype=np.float32) glm.scale(model, self.size, self.size, self.size) glm.rotate(model, self.deg_y, 1, 0, 0) glm.rotate(model, self.deg_x, 0, 1, 0) # glm.translate(model, -self.deg_x/100, -self.deg_y/100, 0) # model[3,3] = 1 return model
def update(self): model = correctly_rotated_model_matrix() glm.rotate(model, self.rotation[0], 1, 0, 0) glm.rotate(model, self.rotation[1], 0, 1, 0) glm.rotate(model, self.rotation[2], 0, 0, 1) glm.translate(model, self.position[0], self.position[1], self.position[2]) glm.scale(model, self.scale[0], self.scale[1], self.scale[2]) self.model_matrix = model
def matrix_model(): model = np.eye(4, dtype=np.float32) #model *= size glm.rotate(model, theta, 1, 0, 0) glm.rotate(model, -phi, 0, 1, 0) glm.translate(model, tx, ty, 0) glm.scale(model, size) #model[3,3] = 1 return model
def on_draw(dt): window.clear() global ALL_DATA, ALL_N, n, n_particles global rng global omega, phi_g, phi_p global positions, velocities, fitness_scores, best_positions, best_fitness_scores global global_best_position, global_best_fitness Rp = rng.rand() Rg = rng.rand() velocities *= omega velocities += (best_positions - positions) * (phi_p * Rp) velocities += (global_best_position - positions) * (phi_g * Rg) positions += velocities results = Parallel(n_jobs=1)(delayed(evaluate_particle)(particle, pos) for particle, pos in enumerate(positions)) fitness_scores = np.array([f[2] for f in results], dtype=np.float32) diff_indices = np.where(fitness_scores < best_fitness_scores)[0] if len(diff_indices) > 0: best_positions[diff_indices, :] = positions[diff_indices, :] best_fitness_scores[diff_indices] = fitness_scores[diff_indices] new_best_fitness_indices = np.where( fitness_scores < global_best_fitness)[0] if len(new_best_fitness_indices) > 0: new_best_fitness_value = np.min( fitness_scores[new_best_fitness_indices]) new_best_fitness_arg = np.argmin( fitness_scores[new_best_fitness_indices]) global_best_fitness = new_best_fitness_value global_best_position = positions[new_best_fitness_arg] # # # global program ALL_DATA = np.vstack((VIEW_DATA, positions)) program["position"] = 0.75 * ALL_DATA # # # global theta, phi, translate global sx, sy, sz window.clear() program.draw(gl.GL_POINTS) model = np.eye(4, dtype=np.float32) glm.scale(model, sx, sy, sz) glm.rotate(model, theta, 1, 0, 0) glm.rotate(model, phi, 0, 1, 0) glm.translate(model, tx, ty, tz) program["model"] = model
def get_view(self): view = np.eye(4, dtype=np.float) glm.translate( view, *(-self._position )) # shift the world so that the camera is at the origin glm.yrotate(view, self._yaw) # rotate the world so that it faces the camera glm.xrotate(view, self._pitch) glm.zrotate(view, self._roll) glm.scale(view, 1, -1, -1) return view
def __init__(self, file_name: str = None, gg2_map: GG2Map = None): if (file_name is not None) == (gg2_map is not None): raise ValueError('Only one of file_name or GG2Map must be defined') gg2_map = GG2Map(file_name) if file_name is not None else gg2_map extractor = ImageToPolygon(gg2_map.mask) width, height = gg2_map.width*SCALE, gg2_map.height*SCALE super(GG2Level, self).__init__(extractor.get_polygons(), width, height) self._bg = BackGroundVertexBuffer(width, height) self._tex = self._spaghetto(gg2_map.image, 255 - gg2_map.mask) glm.scale(self._tex_mat, 1, 1/2, 1)
def on_draw(dt): nonlocal phi, theta, omega, dx, dy, dz, scale, d model = np.eye(4, 4, dtype=np.float32) glm.xrotate(model, omega) glm.yrotate(model, phi) glm.zrotate(model, theta) glm.scale(model, scale, scale, scale) glm.translate(model, dx, dy, dz) cube['model'] = model cube['color'] = color window.clear() cube.draw(gl.GL_TRIANGLES, I)
def on_draw(dt): nonlocal phi, theta, omega, dx, dy, dz, scale, d matrix = np.eye(4, 4, dtype=np.float32) glm.xrotate(matrix, omega) glm.yrotate(matrix, phi) glm.zrotate(matrix, theta) glm.scale(matrix, scale, scale, scale) glm.translate(matrix, dx, dy, dz) result = [np.matmul([*p, 1], matrix)[0:3] for p in V] cube['position'] = [project(*p, d) for p in result] window.clear() cube.draw(gl.GL_LINE_LOOP, I)
def on_draw(dt): global phi, theta, duration window.clear() gl.glDisable(gl.GL_BLEND) gl.glEnable(gl.GL_DEPTH_TEST) cube.draw(gl.GL_TRIANGLES, indices) # Rotate cube theta += 0.5 # degrees phi += 0.5 # degrees model = np.eye(4, dtype=np.float32) glm.rotate(model, theta, 0, 0, 1) glm.rotate(model, phi, 0, 1, 0) glm.scale(model, 1) cube['u_model'] = model
def __init__(self, harmonics, view, projection, sectors=100): self.__time = 0 self.__sectors = sectors self.__sps = int(sectors / 4) self.__msps = int(1000 / self.__sps) self.__aps = 2 * math.pi / sectors self.__harmonics = harmonics self.__view = view self.__projection = projection vertices, indices, outline = circle.circle(sectors=sectors) self.__circle_v = vertices self.__circle_i = indices self.__ocircle_i = outline self.__circle_color = [1, 1, 0, 0.2] self.__ocircle_color = [0.5, 1, 0, 1] unformatted_vertex = shader.source('./static/shaders/vshader.vs') path_vertex = unformatted_vertex.format('', 'position') simple_vertex = unformatted_vertex.format('attribute vec3 a_position;', 'a_position') fragment = shader.source('./static/shaders/fshader.fs') self.__circles_program = gloo.Program(simple_vertex, fragment) self.__circles_program.bind(vertices) self.__circles_program[self.u_view] = view self.__circles_program[self.u_proj] = projection model = np.eye(4, dtype=np.float32) glm.scale(model, 0.5, 0.5, 1) self.__radiuses_program = gloo.Program(simple_vertex, fragment, count=len(harmonics) + 1) self.__radiuses_program[self.u_model] = model self.__radiuses_program[self.u_view] = view self.__radiuses_program[self.u_proj] = projection self.__radiuses_program[self.u_color] = 1, 0, 1, 1 self.__path_program = collections.RawPathCollection(color="shared", vertex=path_vertex, fragment=fragment) self.__path_program[self.u_model] = model self.__path_program[self.u_view] = view self.__path_program[self.u_proj] = projection self.__path_program[self.u_color] = 0, 1, 1, 1
def on_key_press(symbol, modifiers): global vertex_list, index_list, obj shift = True if modifiers == 1 else False letra = '' if symbol == 65307: print('fechou') try: window.close() except: print('janela fechada') finally: return if symbol != -1: letra = chr(symbol) mat = np.eye(4, dtype=np.float32) if letra == 'W': glm.translate(mat, 0, 0.1, 0) elif letra == 'S': glm.translate(mat, 0, -0.1, 0) elif letra == 'D': glm.translate(mat, 0.1, 0, 0) elif letra == 'A': glm.translate(mat, -0.1, 0, 0) elif letra == 'N': glm.translate(mat, 0, 0, 0.1) elif letra == 'M': glm.translate(mat, 0, 0, -0.1) elif letra == '-': glm.scale(mat, 0.9, 0.9, 0.9) elif letra == '=': glm.scale(mat, 1.1, 1.1, 1.1) elif letra == 'Z': alpha = -0.8 if shift else 0.8 glm.rotate(mat, alpha, 0, 0, 1) elif letra == 'X': alpha = -0.8 if shift else 0.8 glm.rotate(mat, alpha, 0, 1, 0) elif letra == 'Y': alpha = -0.8 if shift else 0.8 glm.rotate(mat, alpha, 1, 0, 0) vertex_list = multiplica(mat, vertex_list) obj['a_position'] = vertex_list # window.clear() obj.draw(gl.GL_TRIANGLES, index_list)
def _draw_circles(self, centers): gl.glEnable(gl.GL_BLEND) gl.glEnable(gl.GL_LINE_SMOOTH) gl.glDisable(gl.GL_DEPTH_TEST) gl.glLineWidth(3) for i in range(len(centers)): center = centers[i] radius = self.__harmonics[i].radius model = np.eye(4, dtype=np.float32) glm.scale(model, radius / 2, radius / 2, 1) glm.translate(model, center[0] / 2, center[1] / 2, 0) self.__circles_program[self.u_model] = model self.__circles_program[self.u_color] = self.__circle_color self.__circles_program.draw(gl.GL_TRIANGLE_FAN, self.__circle_i) self.__circles_program[self.u_color] = self.__ocircle_color self.__circles_program.draw(gl.GL_LINE_LOOP, self.__ocircle_i)
def __init__(self, polygons: Iterator[Polygon], width: int, height: int): self._buffers = [] for p in polygons: self._buffers.append(ExtrudedSurfaceVertexBuffer(p.face(slice(None)), p.triangles())) self._buffers.append(ExtrudedPerimeterVertexBuffer(p.contour.vertices)) for h in p.holes: self._buffers.append(ExtrudedPerimeterVertexBuffer(h.vertices)) #self._model = glm.translation(-width//2, -height//2, 0) #glm.scale(self._model, 2/max(width, height)) self._model = np.eye(4, dtype=np.float32) self._tex_mat = glm.scale(np.eye(4, dtype=np.float32), 1/width, 1/height, 1)
def on_draw(dt): global alpha window.clear() gl.glEnable(gl.GL_BLEND) gl.glDisable(gl.GL_DEPTH_TEST) for i in range(len(image_info)): img = image_info[i] if img is not None: modelmat = np.eye(4, dtype=np.float32) if i > 0: alpha = min(1.0, alpha + dt * 0.4) print('current alpha: {}'.format(alpha)) program['alpha'] = alpha # min(0.6, alpha) gl.glEnable(gl.GL_BLEND) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) # target position. front_center = face_rect_center(img['face_rect']) back_center = face_rect_center(image_info[i - 1]['face_rect']) translate = back_center - front_center # print('translation: {}, front center: {}, back center: {}'.format(translate, front_center, back_center)) translate = mix(np.zeros(2, dtype=np.float32), translate, alpha) T2 = glm.translation(translate[0], translate[1], 0.0) T1 = np.matrix( glm.translation(front_center[0], front_center[1], 0.0)) # target scale. front_sz = face_rect_size(img['face_rect']) back_sz = face_rect_size(image_info[i - 1]['face_rect']) scale = mix(1.0, back_sz / front_sz, alpha) S = np.eye(4, dtype=np.float32) S = glm.scale(S, scale, scale, 1.0) modelmat = T1.I * S * T1 * T2 else: program['alpha'] = 1.0 - alpha program['u_model'] = modelmat program['position'] = img['image_rect'] program['tex'] = img['image'].view(gloo.Texture2D) program['u_lineflag'] = 0.0 program.draw(gl.GL_TRIANGLE_STRIP) program['position'] = img['face_rect'] program['u_lineflag'] = 1.0 program['u_linecolor'] = [1.0, 0.0, 0.0] program.draw(gl.GL_LINE_LOOP)
def get_key_point_transform(self, position, caller): """ From position to transformation matrix Apply corresponding scale first :param position: len 3 np.array of the new positions to be updated :param caller: caller name, defined in self.component_names """ if caller == "arm": return glm.translation(*position) else: return glm.translate( glm.scale(np.eye(4, dtype=np.float32), self.finger_scale, self.finger_scale, self.finger_scale), *position)
def on_key_press(symbol, modifiers): global pontos, cube shift = True if modifiers == 1 else False letra = '' if symbol != -1: letra = chr(symbol) mat = np.eye(4, dtype=np.float32) if letra == 'W': glm.translate(mat, 0, 0.1, 0) elif letra == 'S': glm.translate(mat, 0, -0.1, 0) elif letra == 'D': glm.translate(mat, 0.1, 0, 0) elif letra == 'A': glm.translate(mat, -0.1, 0, 0) elif letra == 'N': glm.translate(mat, 0, 0, 0.1) elif letra == 'M': glm.translate(mat, 0, 0, -0.1) elif letra == '-': glm.scale(mat, 0.9, 0.9, 0.9) elif letra == '=': glm.scale(mat, 1.1, 1.1, 1.1) elif letra == 'Z': alpha = -0.8 if shift else 0.8 glm.rotate(mat, alpha, 0, 0, 1) elif letra == 'X': alpha = -0.8 if shift else 0.8 glm.rotate(mat, alpha, 0, 1, 0) elif letra == 'Y': alpha = -0.8 if shift else 0.8 glm.rotate(mat, alpha, 1, 0, 0) pontos = multiplica(mat, pontos) pts_perspectiva = perspectiva(pontos) cube['position'] = pts_perspectiva # window.clear() cube.draw(gl.GL_LINE_LOOP, triangulos)
def _create_transformation(self, texture_size, target_size): texture_aspect = texture_size[0] / texture_size[1] target_aspect = target_size[0] / target_size[1] model = np.eye(4, dtype=np.float32) view = np.eye(4, dtype=np.float32) projection = glm.ortho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0) if texture_aspect < target_aspect: # border left/right glm.scale(model, texture_aspect, 1.0, 1.0) glm.scale(projection, 1.0 / target_aspect, 1.0, 1.0) else: # border top/bottom glm.scale(model, 1.0, 1.0 / texture_aspect, 1.0) glm.scale(projection, 1.0, target_aspect, 1.0) return model, view, projection
def get_bone_transform(self, start, end, compensation_cube_scale, caller): """ From two positions to transformation matrix Apply corresponding scale first :param start: len 3 np.array of the starting point :param end: len 3 np.array of the ending point :param compensation_cube_scale: the OpenGL cube scale, to compasate for transformation :param caller: caller name, defined in self.component_names """ if caller == "arm": finger_scale = 1 else: finger_scale = self.finger_scale bone_scale = self.bone_scale * finger_scale direction = end - start m = glm.scale(np.eye(4, dtype=np.float32), bone_scale, 1 / compensation_cube_scale / 2 * np.linalg.norm(direction), bone_scale) # scale down a little bit m = rotate_to_direction(m, direction) m = glm.translate(m, *((start + end) / 2)) # to middle point return m
def video_transform(model): glm.zrotate(model, 15.0 * time.time()) #glm.zrotate(model, 45) glm.scale(model, 0.5) return model
curves_loop.append(border_line) ############# # Buildings # ############# # Corpus Christi Hall (CCH) bldg_cch_vertices = np.array([(-0.7, 0.2), (0.1, 0.2), (0.1, 1), (0.1, -1), (-0.4, 0.2), (0.1, 0.2), (-0.4, -1), (0.1, -1), (0.1, 0.2)]) bldg_cch = gloo.Program(vertex_m, fragment_uni, count=len(bldg_cch_vertices)) bldg_cch["position"] = bldg_cch_vertices bldg_cch["color"] = (*bldgs[0], 0.9) bldg_cch_model = np.eye(4, dtype=np.float32) glm.rotate(bldg_cch_model, 0.3, 0, 0, 1) glm.scale(bldg_cch_model, 0.1, 0.1, 1) glm.translate(bldg_cch_model, -0.08, .65, 0.0) bldg_cch["model"] = bldg_cch_model shapes.append(bldg_cch) # Center for the Arts (CA) bldg_ca_vertices = np.array([ (0, 0), (.7, 0), (0, 0.5), (.7, .5), (.7, 0), (0, 0.5), (.7, 0), (.7, .5), (1, 0.0),
def parse(self): palm = self.hand.palm.copy() wrist = self.hand.wrist.copy() # elbow = self.hand.elbow.copy() palm_normal = self.hand.palm_normal.copy() fist = palm + 0.05 * normalized(palm-wrist) + 0.35 * palm_normal # arm_direction = wrist - elbow #[angle_hor, angle_ver] = self.get_angle(arm_direction) palm_normal = self.hand.palm_normal.copy() holding = self.is_hold() is_wrap = [] for finger in self.hand.finger_names: is_wrap.append(self.is_wrap(fist, finger)) msg = {} if self.direction == 1 : if holding: self.palm_open_count = self.palm_open_count_max else: self.palm_open_count -= 1 apply_force = self.palm_open_count > 0 force = np.zeros(2, dtype=np.float32) cube_scale = self.cube_scale if apply_force: force = (palm - self.base_right)[[0, 2]] force[1] *= -1 cube_scale *= 1.5 # log.info(f"Adding force: {force}") # else: # self.base = palm m = rotate_to_2directions(np.eye(4, dtype=np.float32), palm_normal, palm-wrist) m = glm.scale(m, cube_scale, cube_scale, cube_scale) m = glm.translate(m, *fist) # log.info(f"New transformation:\n{m}") self.debug_cube.transform = m # remapping of force to wheel voltage # ! Assuming Arduino.h: LOW 0x0, HIGH 0x1 LOW = 0x0 HIGH = 0x1 # M = np.array([ # [-np.sqrt(3)/2, -np.sqrt(3)/2], # [-1/2, 1/2] # ]) # Transform from Arduino space to Our space # M = np.linalg.inv(M) # Transfrom from Out space to Arduino space # M = np.array([ # [np.sqrt(2)/2, np.sqrt(2)/2], # [-np.sqrt(2)/2,np.sqrt(2)/2] # ]) M = np.array([ [0.57735027, 1.], [-0.57735027, 1.] ]) coords = M.dot(force) # transformed into voltage space # log.info(f"Transformed force in arduino space: {coords}") voltage = np.array([[c < 0, np.abs(c)] for c in coords]).ravel() multiplier = [255, 255, 255, 255] values = voltage * multiplier values = np.clip(values, 0, 255).astype("uint8") # msg["voltage"] = values.tolist() # ! being hacky return values.tobytes() else: # 默认状态下 爪子稍微张开,bottom舵机发送信号为0,表示不动 msg["angle0"] = "0" msg["angle3"] = "20" if is_wrap[1] and is_wrap[2] and is_wrap[3]: msg["angle3"] = "10" # 爪子闭合 elif (not is_wrap[1]) and (not is_wrap[2]) and (not is_wrap[3]): msg["angle3"] = "70" # 爪子打开 if is_wrap[0] and not is_wrap[4]: msg["angle0"] = "63" # 向右转 if is_wrap[4] and not is_wrap[0]: msg["angle0"] = "127" # 向左转 # 在y上的移动大概是[1.3, 2.6] # 在z上的移动大概是[0, -1.5] # # 上臂舵机[10, 140], up <-> + # 下臂舵机[40, 170], up <-> - # y -> 上臂 # z -> 下臂 dis_pos = (palm - self.base_left)[[1, 2]] print(dis_pos) dis_pos[1] = max(-1.5, min(0.6, dis_pos[1])) dis_pos[0] = max(0.6, min(3.3, dis_pos[0])) msg["angle2"] = 10 + round((100 - 10) * (dis_pos[0] / (3.3 - 0.6))) msg["angle1"] = 40 + round((120 - 40) * (dis_pos[1] / (-1.5))) print(dis_pos) print(msg["angle2"]) print(msg["angle1"]) msggg = [msg["angle0"], msg["angle1"], msg["angle2"], msg["angle3"]] # 底部舵机是否左右转 # 下臂舵机角度 # 上臂舵机角度 # 爪子舵机角度 msggg = np.array(msggg).astype("uint8") return msggg.tobytes()
def on_draw(dt): nonlocal bpm_window_average, p window.clear() audio.process() if audio.beat_on.value: bpm = float(bpm_from_last_beat) print(bpm) if is_bpm_sensible(bpm): current_bpm.value = bpm_window_average(bpm) print("--- bpm", bpm, "---") else: print("hmm?", bpm) last_beat.value = float(time) is_beat_running = bpm_fits_lower_threshold(bpm_from_last_beat) if not is_beat_running and not p: bpm_window_average = sliding_window_average(8) print("-- empty --") p = True if is_beat_running: p = False w, h = window.get_size() pipeline.render_screen(None, (w, h)) if render_hud: #print(audio._current_beat_amplitude, audio.vu.value, audio.vu_norm.value) #print(audio.vu._evaluated, audio.vu._value) color = (0.0, 1.0, 0.0, 1.0) bg_color = (0.0, 0.0, 0.0, 0.8) box_height = 200 bounds = (10, h - box_height - 10, w - 10, h - 10) threshold_color = (1.0, 0.0, 0.0, 1.0) threshold = audio.beat_threshold threshold_y = float( var.Const(threshold).map_range(0.0, 1.0, bounds[3], bounds[1])) ortho_px = glm.ortho(0, w, 0, h, -1.0, 1.0) glm.scale(ortho_px, 1.0, -1.0, 1.0) plot_values(audio.beat_values, ortho_px, bounds, color, bg_color, [0.0, 1.0]) primitive.draw_line((bounds[0], threshold_y), (bounds[2], threshold_y), threshold_color, ortho_px) #fft = audio._current_fft #freqs = fftpack.fftfreq(len(fft), d=1.0 / 5000.0) #fft = fft[0:len(fft) // 2] * 0.05 #if len(fft) > 1: # plot_bar_values(fft, ortho_px, (10, 10, w - 10, 210), color, bg_color, [0.0, 1.0]) #print(freqs) imgui_renderer.process_inputs() imgui.new_frame() imgui.show_test_window() imgui.set_next_window_position(10, 10, condition=imgui.ALWAYS, pivot_x=0, pivot_y=0) imgui.set_next_window_size(0.0, 0.0) flags = imgui.WINDOW_NO_TITLE_BAR | imgui.WINDOW_NO_RESIZE + imgui.WINDOW_NO_MOVE + imgui.WINDOW_NO_COLLAPSE imgui.begin("Stats", None, flags) imgui.text("FPS: %.2f" % app.clock.get_fps()) imgui.text("Current BPM: %.2f" % current_bpm.value) imgui.text("Beat running: %s" % { True: "Yes", False: "Nope" }[is_beat_running]) imgui.end() imgui.render() imgui_renderer.render(imgui.get_draw_data()) #print("Resetting:", repr(Event), audio.vu in Event._instances) Event.reset_instances() GenerativeStage.reset_instances() var.ReloadVar.reload_vars()
def _scale(model): glm.scale(model, float(x), float(y), float(z)) return model
def _apply_scale(self): glm.scale(self._matrix, *self._scale)
def transform_circle(model): glm.scale(model, 0.75) return model
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 kappa = 1 window = app.Window(800, 600)
def rotate_rombus(model): glm.zrotate(model, 15.0 * time.time()) glm.scale(model, 0.5) return model