Beispiel #1
0
def testSurfaceDisplayWithCube():
    """ Create and display a cube with surfaces. """

    viewer = wd.WireframeViewer(600, 400)
    viewer.addWireframe('cube', shape.Cuboid((225, 100, 0), (200, 200, 200)))
    viewer.displayEdges = False
    viewer.run()
Beispiel #2
0
def testWireframeDisplay():
    """ Create and display a wireframe cube. """

    viewer = wd.WireframeViewer(600, 400)
    viewer.addWireframe('cube', shape.Cuboid((80, 150, 0), (200, 200, 200)))
    viewer.displayFaces = False
    viewer.run()
Beispiel #3
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()
Beispiel #4
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()
Beispiel #5
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()
Beispiel #6
0
import wireframe as wf
import wireframeDisplay as wd

class AnimatedWireframe(wf.Wireframe):
    def update(self):
        self.translate([0,1,0])

ball = wf.getSpheroid((200,200,300), (30,30,30), 16)
animated_ball = AnimatedWireframe()
animated_ball.nodes = ball.nodes
animated_ball.edges = ball.edges

width, height = 600, 400
viewer = wd.WireframeViewer(width, height)
viewer.addWireframe('floor', wf.getHorizontalGrid((0,height,0), (50,50), (12,12)))
viewer.addWireframe('ball', animated_ball)

# Eye starts at (width/2, height/2, 0). Move to (width/2, height-50, 0)
viewer.translate([0,-150,0])

# Change depending on screen size and now much the eye can fit in view
field_of_view = 0.25
viewer.scale(1/field_of_view)

#viewer.perspective = False

viewer.run()