本文整理汇总了Python中World.add方法的典型用法代码示例。如果您正苦于以下问题:Python World.add方法的具体用法?Python World.add怎么用?Python World.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类World
的用法示例。
在下文中一共展示了World.add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Image
# 需要导入模块: import World [as 别名]
# 或者: from World import add [as 别名]
#lay the frame work for my image file
image = Image(500,400,'raytrace.ppm')
#initialize the world
world = World(depth)
#create all spheres with a random color
for offset in range(numSphere):
sphere = Sphere(Point(-6 + (offset* 4), 3.4+ (offset%2), -5+(offset * 5)), 2)
sphereColor = (
1/float(random.randrange(1,5+1)),
1/float(random.randrange(1,5+1)),
1/float(random.randrange(1,5+1))
)
mat = Material(sphereColor)
world.add(sphere, mat)
#add plane
world.add(Plane(), Material((0.1,0.3,0.4)))
#print welcome message
startingIntro(numSphere,depth, image.height, image.width, image.name, world.lightPoint)
gaze = reverseRay(world.position, world.eyeDirection - world.position)
cameraUP = gaze.vector.cross(Vector(0,1,0)).normalized()
cameraDir = cameraUP.cross(gaze.vector).normalized()
#compute field of view
ratio = float (image.height)/float(image.width)
#45 degree field of view