Esempio n. 1
0
}
""")


rows,cols = 3,3
window = app.Window(width=1024, height=1024, color=(0.30, 0.30, 0.35, 1.00))

# Build collection
dtype = [("position", np.float32, 3),
         ("normal",   np.float32, 3),
         ("texcoord", np.float32, 2),
         ("color",    np.float32, 4),
         ("index",    np.float32, 1)]
cubes = BaseCollection(vtype=dtype, itype=np.uint32)
V,I = primitives.cube()
C = np.zeros(len(V),dtype=dtype)
C[...] = V
for i in range(rows*cols):
    C["index"] = i
    cubes.append(vertices=C, indices=I)
cubes._update() #build_buffers()
V = cubes._vertices_buffer
I = cubes._indices_buffer


@window.event
def on_draw(dt):
    global phi, theta
    window.clear()
    program.draw(gl.GL_TRIANGLES, I)
Esempio n. 2
0
@window.event
def on_init():
    gl.glEnable(gl.GL_DEPTH_TEST)

@window.event
def on_key_press(key, modifiers):
    global vertices, indices, index
    if key == ord(' '):
        index = (index+1) % len(shapes)
        vertices, indices = shapes[index]
        program.bind(vertices)

index = 0
shapes = [ primitives.plane(1.5),
           primitives.cube(1.5),
           primitives.sphere(),
           primitives.cubesphere(),
           primitives.cylinder(),
           primitives.torus(),
           primitives.cone(),
           primitives.pyramid(),
           primitives.teapot() ]
vertices, indices = shapes[index]

program = gloo.Program(vertex, fragment)
program.bind(vertices)
view = np.eye(4, dtype=np.float32)
model = np.eye(4, dtype=np.float32)
projection = np.eye(4, dtype=np.float32)
glm.translate(view, 0, 0, -5)
Esempio n. 3
0
    phi += 0.5
    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):
    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

@window.event
def on_mouse_scroll(x, y, dx, dy):
    p = compose["level"]
    compose["level"] = min(max(8, p + .01 * dy * p), 512)


# Build cube data
vertices, faces = primitives.cube()
cube = gloo.Program(vertex, fragment)
cube.bind(vertices)
view = np.eye(4, dtype=np.float32)
glm.translate(view, 0, 0, -3)
cube['view'] = view
cube['model'] = np.eye(4, dtype=np.float32)
cube['texture'] = data.checkerboard()
phi, theta = 0, 0
app.run()
    if( P.x > (x+width-gap))  discard;
    if( P.y < (y+gap))        discard;
    if( P.y > (y+height-gap)) discard;

}
""")

rows, cols = 3, 3
window = app.Window(width=1024, height=1024, color=(0.30, 0.30, 0.35, 1.00))

# Build collection
dtype = [("position", np.float32, 3), ("normal", np.float32, 3),
         ("texcoord", np.float32, 2), ("color", np.float32, 4),
         ("index", np.float32, 1)]
cubes = BaseCollection(vtype=dtype, itype=np.uint32)
V, I = primitives.cube()
C = np.zeros(len(V), dtype=dtype)
for key in V.dtype.names:
    C[key] = V[key]
for i in range(rows * cols):
    C["index"] = i
    cubes.append(vertices=C, indices=I)
cubes._update()
V = cubes._vertices_buffer
I = cubes._indices_buffer


@window.event
def on_draw(dt):
    global phi, theta
    window.clear()
Esempio n. 5
0
        else:
            writer.close()
            writer = None

    # 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)


vertices, faces = primitives.cube()
cube = gloo.Program(vertex, fragment)
cube.bind(vertices)
view = np.eye(4, dtype=np.float32)
glm.translate(view, 0, 0, -3)
cube['view'] = view
cube['model'] = np.eye(4, dtype=np.float32)
cube['texture'] = data.checkerboard()
phi, theta = 0, 0

app.run(framerate=framerate)
Esempio n. 6
0
    gl.glEnable(gl.GL_DEPTH_TEST)


@window.event
def on_key_press(key, modifiers):
    global vertices, indices, index
    if key == ord(' '):
        index = (index + 1) % len(shapes)
        vertices, indices = shapes[index]
        program.bind(vertices)


index = 0
shapes = [
    primitives.plane(1.5),
    primitives.cube(1.5),
    primitives.sphere(),
    primitives.cubesphere(),
    primitives.cylinder(),
    primitives.torus(),
    primitives.cone(),
    primitives.pyramid(),
    primitives.teapot()
]
vertices, indices = shapes[index]

program = gloo.Program(vertex, fragment)
program.bind(vertices)
view = np.eye(4, dtype=np.float32)
model = np.eye(4, dtype=np.float32)
projection = np.eye(4, dtype=np.float32)