Ejemplo n.º 1
0
def testSurfaceDisplayWithSphere2():
    """ Create and display a cube with surfaces. """

    resolution = 30
    viewer = wd.WireframeViewer(600, 400)
    viewer.addWireframe(
        'sphere',
        shape.Spheroid((300, 200, 20), (160, 160, 160), resolution=resolution))

    # Colour ball
    faces = viewer.wireframes['sphere'].faces
    for i in range(resolution / 4):
        for j in range(resolution * 2 - 4):
            f = i * (resolution * 4 - 8) + j
            faces[f][1][1] = 0
            faces[f][1][2] = 0

    # Colour with lattitude
    #for (face, colour) in faces[::2]:
    #    colour[1] = 0
    #    colour[2] = 0

    print "Create a sphere with %d faces." % len(
        viewer.wireframes['sphere'].faces)
    viewer.displayEdges = False
    viewer.run()
Ejemplo n.º 2
0
def testSurfaceDisplayWithSphere():
    """ Create and display a cube with surfaces. """

    viewer = wd.WireframeViewer(600, 400)
    viewer.addWireframe(
        'sphere', shape.Spheroid((200, 200, 20), (160, 160, 160),
                                 resolution=30))
    print "Create a sphere with %d faces." % len(
        viewer.wireframes['sphere'].faces)
    viewer.displayEdges = False
    viewer.run()
Ejemplo n.º 3
0
def testWireframeDisplay3():
    """ Create display with two cuboids, a plane and spheroid. """

    viewer = wd.WireframeViewer(600, 400)
    viewer.addWireframe('grid',
                        shape.HorizontalGrid((20, 400, 0), (40, 30), (14, 20)))
    viewer.addWireframe('cube1', shape.Cuboid((200, 100, 400), (20, 30, 40)))
    viewer.addWireframe('cube2', shape.Cuboid((100, 360, 20), (10, 40, 20)))
    viewer.addWireframe('sphere', shape.Spheroid((250, 300, 100),
                                                 (20, 30, 40)))
    viewer.run()
Ejemplo n.º 4
0
Archivo: lab8.py Proyecto: jtreim/cs355
                elif event.type == pygame.KEYDOWN:
                    key_down = event.key
                elif event.type == pygame.KEYUP:
                    key_down = None

            if key_down:
                self.keyEvent(key_down)

            self.display()
            self.update()

        pygame.quit()


resolution = 52
viewer = WireframeViewer(600, 400)
viewer.addWireframe(
    'sphere',
    shape.Spheroid((300, 200, 20), (160, 160, 160), resolution=resolution))

# Colour ball
faces = viewer.wireframes['sphere'].faces
for i in range(int(resolution / 4)):
    for j in range(resolution * 2 - 4):
        f = i * (resolution * 4 - 8) + j
        faces[f][1][1] = 0
        faces[f][1][2] = 0

viewer.displayEdges = False
viewer.run()
Ejemplo n.º 5
0
	return np.array([cx / norm, cy / norm, cz / norm])


def clamp(x, low, high):
	return min(max(x, low), high)


def fast_clip(a, low, high):
	x, y, z = a
	return ([
		min(max(x, low), high),
		min(max(y, low), high),
		min(max(z, low), high),
	])


resolution = 52
viewer = WireframeViewer(600, 400)
viewer.addWireframe('sphere', shape.Spheroid((300, 200, 20), (160, 160, 160), resolution=resolution))

# Colour ball
faces = viewer.wireframes['sphere'].faces
for i in range(int(resolution / 4)):
	for j in range(resolution * 2 - 4):
		f = i * (resolution * 4 - 8) + j
		faces[f][1][1] = 0
		faces[f][1][2] = 0

viewer.displayEdges = False
viewer.run()