示例#1
0
def on_draw():

    a = 1.6
    b = a * sqrt(3) / 3
    r = sqrt(1 - b*b)
    R = Vector3(a, a, a).normalized() * b
    cs = Matrix4.new_translate(R[0], R[1], R[2]) * Matrix4.new_look_at(Vector3(0, 0, 0), R, Vector3(0, 1, 0))

    glDisable(GL_DEPTH_TEST)
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    glLoadIdentity()
    draw_coords(Matrix4.new_identity(), 2)
    draw_line((0, 0, 0), R, (1, 1, 0))
    draw_coords(cs, r, 3)
    glEnable(GL_DEPTH_TEST)
    draw_triangle((a, 0, 0), (0, a, 0), (0, 0, a), (.5, .5, 1), .2)
    draw_sphere(1, (1, .5, .5), .2)
示例#2
0
def on_draw():

    a = 1.6
    b = a * sqrt(3) / 3
    r = sqrt(1 - b * b)
    R = Vector3(a, a, a).normalized() * b
    cs = Matrix4.new_translate(R[0], R[1], R[2]) * Matrix4.new_look_at(
        Vector3(0, 0, 0), R, Vector3(0, 1, 0))

    glDisable(GL_DEPTH_TEST)
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    glLoadIdentity()
    draw_coords(Matrix4.new_identity(), 2)
    draw_line((0, 0, 0), R, (1, 1, 0))
    draw_coords(cs, r, 3)
    glEnable(GL_DEPTH_TEST)
    draw_triangle((a, 0, 0), (0, a, 0), (0, 0, a), (.5, .5, 1), .2)
    draw_sphere(1, (1, .5, .5), .2)
示例#3
0
        glUniform1i(l,self.idx);

        glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, vIndices)

slots = []

def matToList(m):
	m = m.transposed()
	return [m.a,m.b,m.c,m.d, m.e,m.f,m.g,m.h,
		m.i,m.j,m.k,m.l, m.m,m.n,m.o,m.p]

translation = Vector3()

zstamp = time.time()

invrots = [Matrix4.new_identity(),
                  Matrix4.new_rotatex(pi/2),
                  Matrix4.new_rotatex(-pi/2),
                  Matrix4.new_rotatey(pi/2),
                  Matrix4.new_rotatey(-pi/2),
                  Matrix4.new_rotatez(pi/2),
                  Matrix4.new_rotatex(pi)]

def add_flat_tri(p, vertices, normals, indices):
        n = (p[1]-p[0]).cross(p[2]-p[0]).normalize()
        for i in range(3):
                vertices += array('f',[p[i].x, p[i].y, p[i].z])
                normals += array('f',[n.x, n.y, n.z])
        next = len(indices)
        indices += array('H',[next, next+1, next+2])