本文整理汇总了Python中World.addLight方法的典型用法代码示例。如果您正苦于以下问题:Python World.addLight方法的具体用法?Python World.addLight怎么用?Python World.addLight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类World
的用法示例。
在下文中一共展示了World.addLight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Regular
# 需要导入模块: import World [as 别名]
# 或者: from World import addLight [as 别名]
sampler = Regular(25, 83)
texture = ImageTexture(texels, sphere_map, image.size[0], image.size[1])
t_mat = Matte(0.75, 0.75, texture, sampler)
t_s = Sphere(Point(0, 0, -5), 8.0, t_mat)
world.addObject(t_s)
#area Light
intensity = 10.0
emissive = Emissive(intensity, white)
p0 = Point(-5, 20, -12)
a = Vector(10.0, 0, 0)
b = Vector(0, 10.0, 0)
sampler = Regular(25, 83)
rectangle = Rectangle(p0, a, b, emissive, sampler)
world.addObject(rectangle)
area_light = AreaLight(rectangle)
world.addLight(area_light)
"""
#Bunny
vertices, faces = world.OBJLoad("bunny.obj")
for f in faces:
t = Triangle(vertices[f[0]-1], vertices[f[1]-1], vertices[f[2]-1], phong)
world.addObject(t)
"""
start_time = time.time()
world.renderScene()
print("Time elapsed: {0}".format(time.time() - start_time))
print("with {0} rays shot".format(world.rays))
示例2: _RGB
# 需要导入模块: import World [as 别名]
# 或者: from World import addLight [as 别名]
class Window:
@staticmethod
def _RGB(r, g, b):
color = '#%02x%02x%02x' % (r, g, b)
return color
# Default values
_menuWidth=200
_menuHeight=600
_menuColor = _RGB.__func__(240,240,240)
_canvasColor = _RGB.__func__(218,218,218)
_frequency = 20
# Window constructor
def __init__(self, w=800, h=600):
self._root = Tk()
self._root.title("Braitenberg Vehicles")
self._root.resizable(width=FALSE, height=FALSE)
self._canvas = Canvas(self._root,
width=w,
height=h,
bd=1,
relief=SUNKEN,
background=self._canvasColor,
)
self._menu = Frame(self._root,
width=self._menuWidth,
height=self._menuHeight,
bd=1,
relief=SUNKEN,
bg=self._menuColor,
)
self._canvas.grid(row=0, column=0, sticky=N+W, padx=2, pady=2)
self._canvas.grid_propagate(False)
self._menu.grid(row=0, column=1, sticky=N+W, padx=2, pady=2)
self._menu.grid_propagate(False)
self._k11 = StringVar()
self._k12 = StringVar()
self._k21 = StringVar()
self._k22 = StringVar()
self._bx = StringVar()
self._by = StringVar()
self._bs = StringVar() #this is added for the size of the bot
self._lx = StringVar()
self._ly = StringVar()
self._world = World()
self._initMenu()
self._isRunning = False
# Place objects into window
def _initMenu(self):
self._menu.columnconfigure(0, weight=1)
self._menu.columnconfigure(1, weight=1)
stepButton = Button(self._menu, text="Step", command=self._step)
quitButton = Button(self._menu, text="Quit", command=exit)
simButton = Button(self._menu, text="Start Simulation", command=self._sim)
self._simButton = simButton
matrixLabel = Label(self._menu, text="K Matrix:")
k11 = Entry(self._menu, justify=RIGHT, textvariable=self._k11)
k12 = Entry(self._menu, justify=RIGHT, textvariable=self._k12)
k21 = Entry(self._menu, justify=RIGHT, textvariable=self._k21)
k22 = Entry(self._menu, justify=RIGHT, textvariable=self._k22)
self._k11.set("1")
self._k12.set("0")
self._k21.set("0")
self._k22.set("1")
botPositionLabel = Label(self._menu, text="Position:")
botXLabel = Label(self._menu, text="X:")
botYLabel = Label(self._menu, text="Y:")
botSizeLabel = Label(self._menu, text="Size:") #this is added for the size
bx = Entry(self._menu, justify=RIGHT, textvariable=self._bx)
by = Entry(self._menu, justify=RIGHT, textvariable=self._by)
bs = Entry(self._menu, justify=RIGHT, textvariable=self._bs) #this is added for the size
self._bx.set("0")
self._by.set("0")
self._bs.set("1") #this is added for the size
addBotButton = Button(self._menu, text="Add Bot", command=self._addBot)
lightPositionLabel = Label(self._menu, text="Position:")
lightXLabel = Label(self._menu, text="X:")
lightYLabel = Label(self._menu, text="Y:")
lx = Entry(self._menu, justify=RIGHT, textvariable=self._lx)
ly = Entry(self._menu, justify=RIGHT, textvariable=self._ly)
self._lx.set("0")
self._ly.set("0")
addLightButton = Button(self._menu, text="Add Light", command=self._addLight)
# attach objects to menu in position
stepButton.grid(row=0, column=0, sticky=N)
quitButton.grid(row=0, column=1, sticky=N)
simButton.grid(row=1, column=0, columnspan=2, sticky=N)
matrixLabel.grid(row=2, column=0, columnspan=2, sticky=N)
k11.grid(row=3, column=0, sticky=N)
k12.grid(row=3, column=1, sticky=N)
k21.grid(row=4, column=0, sticky=N)
k22.grid(row=4, column=1, sticky=N)
botPositionLabel.grid(row=5, column=0, columnspan=2, sticky=N)
#.........这里部分代码省略.........