예제 #1
0
ntracer = NTracer(args.dimension)

if args.file:
    if ntracer.dimension != 3:
        sys.exit('a file can only be displayed with a dimensionality of 3')

    try:
        triangles = wavefront_obj.load_obj(args.file)
    except Exception as e:
        if args.debug:
            raise
        sys.exit('could not load file: ' + str(e))
        
    scene = ntracer.build_composite_scene(triangles)
else:
    scene = ntracer.BoxScene()

pygame.display.init()
pygame.font.init()

pygame.display.set_caption('ntracer')
screen = pygame.display.set_mode((640,480),pygame.RESIZABLE)

current_img = pygame.Surface(screen.get_size())
next_img = pygame.Surface(screen.get_size())

started = False

def translate(d):
    def inner(t):
        global started
예제 #2
0
        self.frame += 1
        if self.frame >= args.frames: return False
            
        a2 = camera.axes[0]*self.h + camera.axes[1]*self.h
        for i in range(nt.dimension-3): a2 += camera.axes[i+3]*self.h
        camera.transform(nt.Matrix.rotation(camera.axes[2],a2,self.incr))
        camera.normalize()
        camera.origin = camera.axes[2] * cam_distance
        scene.set_camera(camera)
        
        return True


if nt.dimension >= 3 and args.schlafli[0] == 4 and all(c == 3 for c in args.schlafli[1:]):
    cam_distance = -math.sqrt(nt.dimension) * args.cam_dist
    scene = nt.BoxScene()
else:
    print('building geometry...')
    timing = timer()
    
    p = Polygon(args.schlafli[0])
    for i,s in enumerate(args.schlafli[1:]):
        p = compose(p,i+2,s)

    hull = p.hull()
    timing = timer() - timing
    print('done in {0} seconds'.format(timing))

    cam_distance = -math.sqrt(p.circumradius_square()) * args.cam_dist

    print('partitioning scene...')