def custom_cube_2(x, y, height, width, length): vertices, faces, outline = colorcube() for t in vertices['position']: t[0] *= 50 t[1] *= 50 t[2] = -1 print(vertices) return vertices, faces, outline
def custom_cube(x, y, height, width, length): vertices, faces, outline = colorcube() for t in vertices['position']: t[0] += x t[1] += y # height # if t[2] == 1: # t[2] = height # # width # if t[1] == 1: # t[1] = width # width if t[2] == 1: t[2] = length # print(vertices) return vertices, faces, outline
gl.glDepthMask(gl.GL_FALSE) cube['u_color'] = 0, 0, 0, 1 cube.draw(gl.GL_LINES, outline) gl.glDepthMask(gl.GL_TRUE) # Make cube rotate 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) cube['model'] = model # Build cube data V, I, O = colorcube() vertices = V.view(gloo.VertexBuffer) faces = I.view(gloo.IndexBuffer) outline = O.view(gloo.IndexBuffer) cube = gloo.Program(vertex, fragment) cube.bind(vertices) transform = PVMProjection(Position3D("position")) cube['transform'] = transform window.attach(transform) phi, theta = 0, 0 # OpenGL initalization gl.glEnable(gl.GL_DEPTH_TEST) gl.glPolygonOffset(1, 1)
gl.glDepthMask(gl.GL_FALSE) cube['u_color'] = 0, 0, 0, 1 cube.draw(gl.GL_LINES, outline) gl.glDepthMask(gl.GL_TRUE) # Make cube rotate 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) transform['model'] = model # Build cube data V, I, O = colorcube() vertices = V.view(gloo.VertexBuffer) faces = I.view(gloo.IndexBuffer) outline = O.view(gloo.IndexBuffer) cube = gloo.Program(vertex, fragment) cube.bind(vertices) transform = PVMProjection(Position("position")) cube['transform'] = transform window.attach(transform) phi, theta = 0, 0 # OpenGL initalization gl.glEnable(gl.GL_DEPTH_TEST) gl.glPolygonOffset(1, 1)
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) cube['model'] = model @window.event def on_resize(width, height): cube['projection'] = glm.perspective(45.0, width / float(height), 2.0, 100.0) @window.event def on_init(): gl.glEnable(gl.GL_DEPTH_TEST) gl.glPolygonOffset(1, 1) gl.glEnable(gl.GL_LINE_SMOOTH) gl.glLineWidth(0.75) vertices, faces, outline = colorcube() cube = gloo.Program(vertex, fragment) cube.bind(vertices) cube['model'] = np.eye(4, dtype=np.float32) cube['view'] = glm.translation(0, 0, -5) phi, theta = 0, 0 app.run()
gl.glDepthMask(gl.GL_TRUE) # Make cube rotate 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) cube['model'] = model @window.event def on_resize(width, height): cube['projection'] = glm.perspective(45.0, width / float(height), 2.0, 100.0) @window.event def on_init(): gl.glEnable(gl.GL_DEPTH_TEST) gl.glPolygonOffset(1, 1) gl.glEnable(gl.GL_LINE_SMOOTH) gl.glLineWidth(0.75) vertices, faces, outline = colorcube() cube = gloo.Program(vertex, fragment) cube.bind(vertices) cube['model'] = np.eye(4, dtype=np.float32) cube['view'] = glm.translation(0, 0, -15) phi, theta = 0, 0 app.run()
def __init__(self): from glumpy.geometry import colorcube vertices, faces, outline = colorcube() faces = faces.reshape((-1, 3)) super(CubeMesh, self).__init__(vertices["position"], faces, vertices["color"], vertices["normal"])