From d3ac3ff8215b46cf4fa9c7a670c225238360a6fe Mon Sep 17 00:00:00 2001 From: march3 Date: Thu, 16 Mar 2023 14:05:33 +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 --- scenes/solar_system_2.py | 2 +- simulators/mpl_simulator.py | 6 +++++- simulators/views/mayavi_view.py | 6 +++++- simulators/views/mpl_view.py | 6 ++++-- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/scenes/solar_system_2.py b/scenes/solar_system_2.py index 1a835d5..a268c18 100644 --- a/scenes/solar_system_2.py +++ b/scenes/solar_system_2.py @@ -28,7 +28,7 @@ if __name__ == '__main__': Mercury(size_scale=4e3, distance_scale=1.3), # 水星放大 4000 倍,距离放大 1.3 倍 Venus(size_scale=4e3, distance_scale=1.3), # 金星放大 4000 倍,距离放大 1.3 倍 Earth(size_scale=4e3, distance_scale=1.3), # 地球放大 4000 倍,距离放大 1.3 倍 - Asteroids(size_scale=3e2, parent=sun), # 小行星模拟 + Asteroids(size_scale=3e2, parent=sun), # 小行星模拟(仅 ursina 模拟器支持) Mars(size_scale=4e3, distance_scale=1.3), # 火星放大 4000 倍,距离放大 1.3 倍 Jupiter(size_scale=0.68e3, distance_scale=0.65), # 木星放大 680 倍,距离缩小到真实距离的 0.65 Saturn(size_scale=0.68e3, distance_scale=0.52), # 土星放大 680 倍,距离缩小到真实距离的 0.52 diff --git a/simulators/mpl_simulator.py b/simulators/mpl_simulator.py index 3b41e33..0357357 100644 --- a/simulators/mpl_simulator.py +++ b/simulators/mpl_simulator.py @@ -94,6 +94,10 @@ class MplSimulator(Simulator): update_ax(ax, styles) for idx, body in enumerate(bodies): + if hasattr(body, "torus_stars"): + # 暂不支持环状小行星群 + continue + if body.is_fixed_star: color = 'red' else: @@ -116,7 +120,7 @@ class MplSimulator(Simulator): ax.plot3D(_his_pos[0], _his_pos[1], _his_pos[2], color=color, alpha=0.5) z_range = ax.get_zlim()[1] - ax.get_zlim()[0] - ax.text(pos[0], pos[1], pos[2] + size*(z_range/5000), s=body.name, color=color, fontsize=12) + ax.text(pos[0], pos[1], pos[2] + size * (z_range / 5000), s=body.name, color=color, fontsize=12) if pause > 0: plt.pause(pause) diff --git a/simulators/views/mayavi_view.py b/simulators/views/mayavi_view.py index 8a78bbd..c0d0f9b 100644 --- a/simulators/views/mayavi_view.py +++ b/simulators/views/mayavi_view.py @@ -85,6 +85,10 @@ class MayaviView(BodyView): 天体显示的操作,比如:构建天体视图对象 :return: """ + if hasattr(self.body, "torus_stars"): + # 暂不支持环状小行星群 + return + if not hasattr(self, "sphere") or self.sphere is None: scale_factor = self.body.size_scale * self.body.diameter sphere = mlab.points3d(self.body.position[0], self.body.position[1], self.body.position[2], @@ -130,7 +134,7 @@ class MayaviView(BodyView): :param image_file: :return: """ - outfile = image_file.replace('.jpg', '_flipped.jpg') + outfile = image_file.replace('.jpg', '_flipped.jpg').replace('.png', '_flipped.jpg') if os.path.exists(outfile): image_file = outfile else: diff --git a/simulators/views/mpl_view.py b/simulators/views/mpl_view.py index 54555e5..7995577 100644 --- a/simulators/views/mpl_view.py +++ b/simulators/views/mpl_view.py @@ -23,7 +23,9 @@ class MplView(BodyView): pass def appear(self): - pass + if hasattr(self.body, "torus_stars"): + # 暂不支持环状小行星群 + return def disappear(self): - pass \ No newline at end of file + pass -- GitLab