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

Python超人-宇宙模拟器

上级 4cc9d074
......@@ -16,16 +16,18 @@ from sim_scenes.interest.utils.body_utils import gen_bodies_from_image
def show_text_bodies():
"""
显示文本的星球群
显示图片文本的星球群
"""
D = 6000
# camera_pos = 左-右+、上+下-、前+后-
D = 6000 # 基本距离单位:km(随意赋值)
# 观看摄像机的位置
# camera_pos = (左-右+, 上+下-, 前+后-)
camera_pos = (D, D, -7000 * D)
bodies: list = gen_bodies_from_image(pixel_image="./images/python.png", texture="color_body.png",
# 根据 pixel_image 指定图片(图片的像素不要太多)
bodies = gen_bodies_from_image(pixel_image="./images/python.png",
texture="color_body.png",
params={"camera_pos": camera_pos})
# 放一个恒星作为背景
bg = FixedStar(name="bg", texture="fixed_star.png", mass=2e32, color=(0xff, 0xf8, 0xd4),
bg = FixedStar(name="背景恒星", texture="fixed_star.png", mass=2e32, color=(0xff, 0xf8, 0xd4),
init_position=[-450 * D, 100 * D, 6000 * D], # [ 左-右+, 上+下-, 远+近- ]
ignore_mass=True)
......@@ -33,7 +35,7 @@ def show_text_bodies():
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
# position = camera_pos = (左-右+, 上+下-, 前+后-)
ursina_run(bodies, SECONDS_PER_WEEK * 2, position=camera_pos, view_closely=True)
......
......@@ -17,21 +17,23 @@ def show_eye_of_god():
"""
上帝之眼
"""
D = 6000
# camera_pos = 左-右+、上+下-、前+后-
D = 6000 # 基本距离单位:km(随意赋值)
# 观看摄像机的位置
# camera_pos = (左-右+, 上+下-, 前+后-)
camera_pos = (D, D, -7000 * D)
bodies: list = gen_bodies_from_image(pixel_image="./images/eye.png", texture="color_body.jpg",
bodies: list = gen_bodies_from_image(pixel_image="./images/eye.png",
texture="color_body.jpg",
params={"camera_pos": camera_pos})
# 放一个恒星作为背景
bg = FixedStar(name="bg", texture="fixed_star.png", mass=2e32, color=(0xff, 0xf8, 0xd4),
bg = FixedStar(name="背景恒星", texture="fixed_star.png", mass=2e32, color=(0xff, 0xf8, 0xd4),
init_position=[-400 * D, 100 * D, 6000 * D], # [ 左-右+, 上+下-, 远+近- ]
ignore_mass=True)
bodies.append(bg)
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
# position = camera_pos = (左-右+, 上+下-, 前+后-)
ursina_run(bodies, SECONDS_PER_WEEK * 2, position=camera_pos, view_closely=True)
......
......@@ -208,10 +208,16 @@ class UrsinaSimulator(Simulator):
if view_closely < 0.001:
view_closely = 0.001
camera.clip_plane_near = view_closely
if view_closely < 0.01:
# camera.fov = 60-0.01/view_closely
# camera.fov = 40
pass
else:
# 设置 camera 的裁剪面和位置
camera.clip_plane_near = 0.01
camera.fov = 60
camera.fov = 60
# UrsinaConfig.SCALE_FACTOR = UrsinaConfig.SCALE_FACTOR * math.ceil(0.01 / pow(camera.clip_plane_near,2))
# interval_fator 能让更新天体运行状态(位置、速度)更精确
# 设定时间间隔为0.01秒
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册