From 1f81e3e704fea6ee79544ec00832c8ac93944518 Mon Sep 17 00:00:00 2001 From: march3 Date: Sat, 11 Mar 2023 21:41:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=AA=E9=98=B3=E7=B3=BB=E4=B8=89=E4=BD=93?= =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simulators/ursina_simulator.py | 16 +++++++++++++--- simulators/views/ursina_view.py | 4 ++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/simulators/ursina_simulator.py b/simulators/ursina_simulator.py index 09359f9..653c60c 100644 --- a/simulators/ursina_simulator.py +++ b/simulators/ursina_simulator.py @@ -7,7 +7,8 @@ # python_version :3.8 # ============================================================================== # pip install -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com ursina -from ursina import Ursina, window, Entity, Grid, Mesh, camera, Text, application, color, mouse, Vec2, Vec3, load_texture, held_keys +from ursina import Ursina, window, Entity, Grid, Mesh, camera, Text, application, color, mouse, Vec2, Vec3, \ + load_texture, held_keys from ursina.prefabs.first_person_controller import FirstPersonController from simulators.views.ursina_view import UrsinaView, UrsinaPlayer @@ -90,7 +91,16 @@ class UrsinaSimulator(Simulator): if kwargs["light"]: for v in self.ursina_views: if v.body.is_fixed_star: - v.light = PointLight(parent=v) + # v.light = PointLight(parent=v, intensity=10, range=10, color=color.white) + # v.light.brightness = 10 + lights = [] + for i in range(1): # 可以增加多个光源 + light = PointLight(parent=v, intensity=10, range=10, color=color.white) + light.brightness = 10 + lights.append(light) + v.lights = lights + pass + # PointLight(parent=camera, color=color.white, position=(0, 0, 0)) # AmbientLight(color=color.rgba(100, 100, 100, 0.1)) # DirectionalLight @@ -134,7 +144,7 @@ class UrsinaSimulator(Simulator): pause_handler.input = pause_handler_input # 加载中文字体文件 Text.default_font = 'simsun.ttc' - key_info_str = "方位控制[QWEASD + 鼠标] 暂停控制[空格] 移动速度[Tab]" + key_info_str = "方位控制[QWEASD + 鼠标] 暂停控制[空格] 摄像机移动速度[Tab]" key_info = Text(text=key_info_str, position=(-0.8, 0.5), origin=(-1, 1), background=True) self.app.run() diff --git a/simulators/views/ursina_view.py b/simulators/views/ursina_view.py index bae67a5..b887fb5 100644 --- a/simulators/views/ursina_view.py +++ b/simulators/views/ursina_view.py @@ -141,6 +141,10 @@ class UrsinaView(BodyView): self.planet.turn() if hasattr(self, "light"): self.light.position = Vec3(self.planet.x, self.planet.y, self.planet.z) + if hasattr(self, "lights"): + for light in self.lights: + light.position = Vec3(self.planet.x, self.planet.y, self.planet.z) + if hasattr(self, "ring"): self.ring.position = Vec3(self.planet.x, self.planet.y, self.planet.z) -- GitLab