提交 0ad66e87 编写于 作者: 三月三net's avatar 三月三net

Python超人-宇宙模拟器

上级 04e0b284
...@@ -88,7 +88,7 @@ if __name__ == '__main__': ...@@ -88,7 +88,7 @@ if __name__ == '__main__':
def on_ready(): def on_ready():
# 运行前触发 # 运行前触发
# 为了较好的立体效果,可以增加太阳光线,光线指向木星(target=jupiter) # 为了较好的立体效果,可以增加太阳光线,光线指向木星(target=jupiter)
create_directional_light(position=(200, 0, -300), target=jupiter) create_directional_light(position=(200, 0, -300), light_num=3, target=jupiter)
# 摄像机看向木星 # 摄像机看向木星
camera_look_at(jupiter, rotation_z=0) camera_look_at(jupiter, rotation_z=0)
......
...@@ -167,7 +167,7 @@ def create_trail_sphere(parent, pos): ...@@ -167,7 +167,7 @@ def create_trail_sphere(parent, pos):
# return value, direction # return value, direction
def create_directional_light(position, target=None, shadows=False, light_color=None): def create_directional_light(position, target=None, shadows=False, light_num=1, light_color=None):
""" """
创建平行光(DirectionalLight) 创建平行光(DirectionalLight)
@param position: 光源位置 @param position: 光源位置
...@@ -194,19 +194,24 @@ def create_directional_light(position, target=None, shadows=False, light_color=N ...@@ -194,19 +194,24 @@ def create_directional_light(position, target=None, shadows=False, light_color=N
else: else:
light_color = color.rgba(light_color[0] / 255, light_color[1] / 255, light_color[2] / 255, 1) light_color = color.rgba(light_color[0] / 255, light_color[1] / 255, light_color[2] / 255, 1)
light = DirectionalLight(position=position, intensity=10, range=10, color=light_color) lights = []
for i in range(light_num):
light = DirectionalLight(position=position, intensity=10, range=10, color=light_color)
lights.append(light)
if shadows: if shadows:
light.shadows = lit_with_shadows_shader for light in lights:
light.shadows = lit_with_shadows_shader
if target is not None: if target is not None:
if hasattr(target, "planet"): for light in lights:
if hasattr(target.planet, "main_entity"): if hasattr(target, "planet"):
light.look_at(target.planet.main_entity) if hasattr(target.planet, "main_entity"):
light.look_at(target.planet.main_entity)
else:
light.look_at(target.planet)
else: else:
light.look_at(target.planet) light.look_at(target)
else:
light.look_at(target)
if shadows: if shadows:
return lit_with_shadows_shader return lit_with_shadows_shader
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册