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

Python超人-宇宙模拟器

上级 17fc08ca
...@@ -37,10 +37,10 @@ class ControlHandler(EventHandler): ...@@ -37,10 +37,10 @@ class ControlHandler(EventHandler):
background=True) background=True)
self.camera_info = Text(text="", scale=0.8, position=(0, -0.45), origin=(0, 1), self.camera_info = Text(text="", scale=0.8, position=(0, -0.45), origin=(0, 1),
background=True) background=False)
def camera_update(self): def camera_update(self):
pos = camera.position # WS => [2] pos = camera.position # WS => [2]
w_pos = camera.world_rotation # 鼠标右键 w_pos = camera.world_rotation # 鼠标右键
# rot = camera.rotation # rot = camera.rotation
wt = camera.world_transform # QE[0,1,2] AD [0 , 2] 鼠标右键 wt = camera.world_transform # QE[0,1,2] AD [0 , 2] 鼠标右键
...@@ -50,11 +50,12 @@ class ControlHandler(EventHandler): ...@@ -50,11 +50,12 @@ class ControlHandler(EventHandler):
# print(camera.left,camera.forward,camera.back,camera.right,camera.scale,camera.aspect_ratio,camera.down,camera.up,camera.world_scale,camera.world_rotation) # print(camera.left,camera.forward,camera.back,camera.right,camera.scale,camera.aspect_ratio,camera.down,camera.up,camera.world_scale,camera.world_rotation)
# fw = camera.forward # fw = camera.forward
# self.camera_info.text = "pos:[%.2f,%.2f,%.2f] w_pos:[%.2f,%.2f,%.2f] rot:[%.2f,%.2f,%.2f] wt:[%s,%s,%s]" % \ # self.camera_info.text = "pos:[%.2f,%.2f,%.2f] w_pos:[%.2f,%.2f,%.2f] rot:[%.2f,%.2f,%.2f] wt:[%s,%s,%s]" % \
self.camera_info.text = "pos:[%.2f,%.2f,%.2f] w_pos:[%.2f,%.2f,%.2f] wt:[%s,%s]" % \ if hasattr(self, "camera_info"):
(pos[0], pos[1], pos[2], self.camera_info.text = "pos:[%.2f,%.2f,%.2f] w_pos:[%.2f,%.2f,%.2f] wt:[%s,%s]" % \
w_pos[0], w_pos[1], w_pos[2], (pos[0], pos[1], pos[2],
# rot[0], rot[1], rot[2], w_pos[0], w_pos[1], w_pos[2],
wt[0], wt[1]) # , wt[2] # rot[0], rot[1], rot[2],
wt[0], wt[1]) # , wt[2]
def sec_per_time_switch_changed(self): def sec_per_time_switch_changed(self):
""" """
......
...@@ -29,7 +29,7 @@ class UiSlider(Slider): ...@@ -29,7 +29,7 @@ class UiSlider(Slider):
max=max, max=max,
default=default, default=default,
color=color.rgba(0.0, 0.0, 0.0, 0.5), color=color.rgba(0.0, 0.0, 0.0, 0.5),
ignore_paused=False, ignore_paused=True,
dynamic=True) dynamic=True)
# self.label.scale *= 8/10 # self.label.scale *= 8/10
self.label.font = UrsinaConfig.CN_FONT self.label.font = UrsinaConfig.CN_FONT
...@@ -88,5 +88,5 @@ class UiButton(Button): ...@@ -88,5 +88,5 @@ class UiButton(Button):
def __init__(self, text, on_click): def __init__(self, text, on_click):
super(UiButton, self).__init__(text=text, origin=(0, 0), y=2, super(UiButton, self).__init__(text=text, origin=(0, 0), y=2,
on_click=on_click, color=color.rgba(0.0, 0.0, 0.0, 0.5), on_click=on_click, color=color.rgba(0.0, 0.0, 0.0, 0.5),
ignore_paused=False) ignore_paused=True)
self.text_entity.font = UrsinaConfig.CN_FONT self.text_entity.font = UrsinaConfig.CN_FONT
...@@ -164,9 +164,14 @@ class UrsinaSimulator(Simulator): ...@@ -164,9 +164,14 @@ class UrsinaSimulator(Simulator):
:return: :return:
""" """
# Add skybox # Add skybox
if camera.clip_plane_near >= 0.01:
sky_scale = 50000
else:
sky_scale = 500000 * camera.clip_plane_near
from ursina import Sky from ursina import Sky
sky_scale = 50000
sky = Sky(texture=texture) sky = Sky(texture=texture)
sky.scale = sky_scale sky.scale = sky_scale
# sky.set_shader_input('texture_scale', Vec2(20, 20)) # sky.set_shader_input('texture_scale', Vec2(20, 20))
...@@ -191,8 +196,11 @@ class UrsinaSimulator(Simulator): ...@@ -191,8 +196,11 @@ class UrsinaSimulator(Simulator):
if view_closely: if view_closely:
# 近距离查看 # 近距离查看
# 设置 camera 的裁剪面和位置 if isinstance(view_closely, float):
camera.clip_plane_near = 0.01 camera.clip_plane_near = view_closely
else:
# 设置 camera 的裁剪面和位置
camera.clip_plane_near = 0.01
camera.fov = 60 camera.fov = 60
# interval_fator 能让更新天体运行状态(位置、速度)更精确 # interval_fator 能让更新天体运行状态(位置、速度)更精确
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册