Esempio n. 1
0
def main():
    args = sys.argv
    sphere_list = get_sphere_list(args[1])
    eye_point = data.Point(0.0, 0.0, -14.0)
    view = [-10.0, 10.0, -7.5, 7.5, 1024, 768]
    ambient_light = data.Color(1.0, 1.0, 1.0)
    light = data.Light(data.Point(-100.0, 100.0, -100.0),
                       data.Color(1.5, 1.5, 1.5))

    if len(args) > 2:
        try:
            for i in range(2, len(args)):
                if args[i] == "-eye":
                    l = args[i:i + 4]
                    eye_point = commandline.get_eye_point(l, [0.0, 0.0, -14.0])
                elif args[i] == "-view":
                    l = args[i:i + 7]
                    view = commandline.get_view(l, view)
                elif args[i] == "-light":
                    l = args[i:i + 7]
                    light = commandline.get_light(
                        l, [-100.0, 100.0, -100.0, 1.5, 1.5, 1.5])
                elif args[i] == "-ambient":
                    l = args[i:i + 4]
                    ambient_light = commandline.get_ambient_light(
                        l, [1.0, 1.0, 1.0])

        except:
            print "Something went horribly wrong"

    cast.cast_all_rays(view[0], view[1], view[2], view[3], view[4], view[5],
                       eye_point, sphere_list, ambient_light, light)
Esempio n. 2
0
def main(argv):
    view = commandline.get_view(argv)
    eye = commandline.get_eye(argv)
    light = commandline.get_light(argv)
    ambient = commandline.get_ambient(argv)
    sphere_list = commandline.get_sphere_list(argv[1])
    cast.cast_all_rays(view[0], view[1], view[2], view[3], int(view[4]), int(view[5]), eye, sphere_list, ambient, light)
Esempio n. 3
0
def main():
   args = sys.argv
   sphere_list = get_sphere_list(args[1])
   eye_point = data.Point(0.0,0.0,-14.0)
   view = [-10.0, 10.0, -7.5,7.5, 1024, 768]
   ambient_light = data.Color(1.0,1.0,1.0)
   light = data.Light(data.Point(-100.0, 100.0,-100.0), data.Color(1.5,1.5,1.5))

   if len(args) > 2: 
      try:
         for i in range(2,len(args)):
            if args[i] == "-eye":
               l = args[i:i+4]
               eye_point = commandline.get_eye_point(l, [0.0,0.0,-14.0])
            elif args[i] == "-view":
               l = args[i:i+7]
               view = commandline.get_view(l, view)
            elif args[i] == "-light":
               l = args[i:i+7]
               light = commandline.get_light(l, [-100.0,100.0,-100.0,1.5,1.5,1.5])
            elif args[i] == "-ambient":
               l = args[i:i+4]
               ambient_light = commandline.get_ambient_light(l, [1.0,1.0,1.0])
             
      except: 
         print "Something went horribly wrong"

   cast.cast_all_rays(view[0],view[1],view[2],view[3], view[4], view[5], eye_point, sphere_list, ambient_light, light)
Esempio n. 4
0
def main(argv):
    view = commandline.get_view(argv)
    eye = commandline.get_eye(argv)
    light = commandline.get_light(argv)
    ambient = commandline.get_ambient(argv)
    sphere_list = commandline.get_sphere_list(argv[1])
    cast.cast_all_rays(view[0], view[1], view[2], view[3], int(view[4]),
                       int(view[5]), eye, sphere_list, ambient, light)
Esempio n. 5
0
def main():
	sphere_list = []
	
	#try to open file or throw error
	try:
		input_file = open(argv[1], "r")
	except:
		print "Error: Filename not correctly specified"
		print "Usage: python ray_caster.py <filename> [-eye x y z] [-view min_x max_x min_y max_y width height"
		exit()
	
	#try to instantiate spheres from argv inputs or throw error
	line_count = 0
	for line in input_file:
		line_count += 1
		try:
			params = line.split()
			x = float(params[0])
			y = float(params[1])
			z = float(params[2])
			rad = float(params[3])
			r = float(params[4])
			g = float(params[5])
			b = float(params[6])
			amb = float(params[7])
			diff = float(params[8])
			spec = float(params[9])
			rough = float(params[10])
			sphere = Sphere(Point(x, y, z), rad, Color(r, g, b), Finish(amb, diff, spec, rough))
			sphere_list.append(sphere)
		except:
			print "malformed sphere on line {0} ... skipping".format(str(line_count))
	
	#initialize casting variables relative to argv inputs
	eye_point = get_eye_point(argv)
	view = get_view(argv)
	light = get_light(argv)
	ambient = get_ambient(argv)
	
	#write to image.ppm output image
	file = open("image.ppm", "w")
	file.write("P3\n")
	file.write("{0} {1}\n".format(str(view.width), str(view.height)))
	file.write("{0}\n".format(str(255)))
	cast_all_rays(view, eye_point, sphere_list, ambient, light, file)
	file.close()