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

Python超人-宇宙模拟器

上级 6cb9d0a1
...@@ -34,7 +34,7 @@ class Earth(Body): ...@@ -34,7 +34,7 @@ class Earth(Body):
"init_position": init_position, "init_position": init_position,
"init_velocity": init_velocity, "init_velocity": init_velocity,
"density": 5507.85, "density": 5507.85,
"color": (1, 89, 162), "color": (7, 0, 162),
"texture": texture, "texture": texture,
"size_scale": size_scale, "size_scale": size_scale,
"distance_scale": distance_scale, "distance_scale": distance_scale,
......
...@@ -8,38 +8,19 @@ ...@@ -8,38 +8,19 @@
**demo.py** **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** ### 三体的场景模拟
**sim_scenes/tri_bodies**
* 展示的效果非太阳系真实的距离和大小
1. 由于宇宙空间尺度非常大,如果按照实际的天体大小,则无法看到天体,因此需要对天体的尺寸进行放大
2. 为了达到最佳的显示效果,对每个行星天体的距离进行了缩放
**scenes/solar_system_3.py**
* 展示的效果非太阳系真实的距离和大小
1. 由于宇宙空间尺度非常大,按照实际的大小无法看到行星天体,因此需要对天体的尺寸进行放大
2. 为了达到最佳的显示效果,对每个行星天体的距离进行了缩放
3. 加入了小行星的演示效果**
**scenes/sun_earth.py**
* 太阳、地球运行效果
**scenes/sun_earth_jupiter.py**
* 太阳、地球、木星运行效果
# -*- 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)
...@@ -28,10 +28,12 @@ class BodyView(metaclass=ABCMeta): ...@@ -28,10 +28,12 @@ class BodyView(metaclass=ABCMeta):
self.color = tuple(np.array(body.color) / 255) self.color = tuple(np.array(body.color) / 255)
else: else:
self.texture = self.__find_texture(self.body.texture) # 纹理 self.texture = self.__find_texture(self.body.texture) # 纹理
self.color = tuple(np.array(body.color) / 255)
if self.texture is None: if self.texture is None:
self.color = tuple(np.array(body.color) / 255) self.texture_color = self.color
else: 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.appear()
self.position = body.position self.position = body.position
self.name = body.name self.name = body.name
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册