From 9ee3b1386ec53355cdd549e1734903cb460b3c45 Mon Sep 17 00:00:00 2001 From: march3 Date: Sun, 26 Mar 2023 21:30:56 +0800 Subject: [PATCH] =?UTF-8?q?Python=E8=B6=85=E4=BA=BA-=E5=AE=87=E5=AE=99?= =?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 --- bodies/earth.py | 2 +- sim_scenes/README.md | 39 ++++++++--------------------- sim_scenes/solar_system/hd_earth.py | 27 ++++++++++++++++++++ simulators/views/body_view.py | 6 +++-- 4 files changed, 42 insertions(+), 32 deletions(-) create mode 100644 sim_scenes/solar_system/hd_earth.py diff --git a/bodies/earth.py b/bodies/earth.py index 802cd3c..b847252 100644 --- a/bodies/earth.py +++ b/bodies/earth.py @@ -34,7 +34,7 @@ class Earth(Body): "init_position": init_position, "init_velocity": init_velocity, "density": 5507.85, - "color": (1, 89, 162), + "color": (7, 0, 162), "texture": texture, "size_scale": size_scale, "distance_scale": distance_scale, diff --git a/sim_scenes/README.md b/sim_scenes/README.md index dad2572..2ed08d2 100644 --- a/sim_scenes/README.md +++ b/sim_scenes/README.md @@ -8,38 +8,19 @@ **demo.py** * 演示入口,有详细的备注,大家可以在此基础上创建更多的模拟场景 -### 模拟三体场景 -**scenes/three_body_01.py** -* 3个太阳、1个地球(效果1) -**scenes/three_body_02.py** +### 科幻的场景模拟 +**sim_scenes/fiction** -* 3个太阳、1个地球(效果2) +### 有趣的场景模拟 +**sim_scenes/interest** -### 模拟太阳系场景 -**scenes/solar_system_1.py** +### 科学的场景模拟 +**sim_scenes/science** -* 展示的效果为太阳系真实的距离, -由于宇宙空间尺度非常大,如果按照实际的天体大小,则无法看到天体,因此需要对天体的尺寸进行放大 +### 太阳系场景模拟 +**sim_scenes/solar_system** -**scenes/solar_system_2.py** - -* 展示的效果非太阳系真实的距离和大小 -1. 由于宇宙空间尺度非常大,如果按照实际的天体大小,则无法看到天体,因此需要对天体的尺寸进行放大 -2. 为了达到最佳的显示效果,对每个行星天体的距离进行了缩放 - -**scenes/solar_system_3.py** - -* 展示的效果非太阳系真实的距离和大小 -1. 由于宇宙空间尺度非常大,按照实际的大小无法看到行星天体,因此需要对天体的尺寸进行放大 -2. 为了达到最佳的显示效果,对每个行星天体的距离进行了缩放 -3. 加入了小行星的演示效果** - - -**scenes/sun_earth.py** -* 太阳、地球运行效果 - - -**scenes/sun_earth_jupiter.py** -* 太阳、地球、木星运行效果 +### 三体的场景模拟 +**sim_scenes/tri_bodies** diff --git a/sim_scenes/solar_system/hd_earth.py b/sim_scenes/solar_system/hd_earth.py new file mode 100644 index 0000000..9d92e8e --- /dev/null +++ b/sim_scenes/solar_system/hd_earth.py @@ -0,0 +1,27 @@ +# -*- coding:utf-8 -*- +# title :高清地球模拟运行 +# description :高清地球模拟运行 +# author :Python超人 +# date :2023-02-11 +# link :https://gitcode.net/pythoncr/ +# python_version :3.8 +# ============================================================================== +from bodies import Earth +from common.consts import SECONDS_PER_HOUR, SECONDS_PER_DAY +from sim_scenes.func import ursina_run + +if __name__ == '__main__': + """ + 高清地球模拟运行 + """ + bodies = [ + Earth(texture="earth_hd.jpg", + init_position=[0, 0, 0], init_velocity=[0, 0, 0], + size_scale=100, show_name=True) + ] + # 使用 ursina 查看的运行效果 + # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 + # position = 左-右+、上+下-、前+后- + ursina_run(bodies, SECONDS_PER_HOUR, position=(0, 30000, -2000000), + # cosmic_bg="textures/cosmic1.jpg", + view_closely=True) diff --git a/simulators/views/body_view.py b/simulators/views/body_view.py index dd500a9..b6661ee 100644 --- a/simulators/views/body_view.py +++ b/simulators/views/body_view.py @@ -28,10 +28,12 @@ class BodyView(metaclass=ABCMeta): self.color = tuple(np.array(body.color) / 255) else: self.texture = self.__find_texture(self.body.texture) # 纹理 + self.color = tuple(np.array(body.color) / 255) if self.texture is None: - self.color = tuple(np.array(body.color) / 255) + self.texture_color = self.color else: - self.color = self.__get_texture_main_color(self.texture) + # self.color = self.__get_texture_main_color(self.texture) + self.texture_color = self.__get_texture_main_color(self.texture) self.appear() self.position = body.position self.name = body.name -- GitLab