diff --git a/sim_scenes/interest/images/python.png b/sim_scenes/interest/images/python.png new file mode 100644 index 0000000000000000000000000000000000000000..4aed59e3d199b43035619ee30c4829e55179b733 Binary files /dev/null and b/sim_scenes/interest/images/python.png differ diff --git a/sim_scenes/interest/text_bodies.py b/sim_scenes/interest/text_bodies.py new file mode 100644 index 0000000000000000000000000000000000000000..24f06d853451f68c9ccecc313f77e2a6ebb417c8 --- /dev/null +++ b/sim_scenes/interest/text_bodies.py @@ -0,0 +1,48 @@ +# -*- coding:utf-8 -*- +# title :上帝之眼 +# description :上帝之眼 +# author :Python超人 +# date :2023-03-26 +# link :https://gitcode.net/pythoncr/ +# python_version :3.8 +# ============================================================================== +from bodies import Sun, Earth, Moon, FixedStar, Body +from common.consts import SECONDS_PER_HOUR, SECONDS_PER_HALF_DAY, SECONDS_PER_DAY, SECONDS_PER_WEEK +from sim_scenes.func import mayavi_run, ursina_run +from bodies.body import AU +import random +from sim_scenes.interest.utils.body_utils import gen_eye_bodies + + +def show_text_bodies(): + """ + 上帝之眼 + """ + D = 600 + mass = 0.5e25 + # camera_pos = 左-右+、上+下-、前+后- + camera_pos = (-100 * D, 0, -5000 * D) + + def get_position(pos, scale): + # [ 远+近- , 左+右- , 上+下-] + return pos[0] + (scale - 1.0) * 200 * (random.randint(90, 110)) * D, pos[1], pos[2] + # return pos[0], pos[1], pos[2] + + bodies: list = gen_eye_bodies(pixel_image="./images/python.png", + params={"D": D, "Body": Body, "mass": mass, + "get_position": get_position, + "camera_pos": camera_pos}) + face = FixedStar(name="bg", texture="fixed_star.png", mass=mass * 9000, color=(0xff, 0xf8, 0xd4), + init_position=[2000 * D, 260 * D, 100 * D], # [ 远+近- , 左+右- , 上+下-] + ignore_mass=True) + face.light_on = False + bodies.append(face) + + # 使用 ursina 查看的运行效果 + # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 + # position = 左-右+、上+下-、前+后- + ursina_run(bodies, SECONDS_PER_WEEK * 2, position=camera_pos) + + +if __name__ == '__main__': + show_text_bodies() diff --git a/sim_scenes/interest/the_eye_of_god.py b/sim_scenes/interest/the_eye_of_god.py index 524abf17aafc39861c5615c9899df61ec9bd4ce9..626f2cf17ab980b74f0b76247b4376ef29204a2f 100644 --- a/sim_scenes/interest/the_eye_of_god.py +++ b/sim_scenes/interest/the_eye_of_god.py @@ -30,7 +30,7 @@ def show_eye_of_god(): bodies: list = gen_eye_bodies( {"D": D, "Body": Body, "mass": mass, "get_position": get_position, "camera_pos": camera_pos}) face = FixedStar(name="face", texture="fixed_star.png", mass=mass * 3000, color=(0xff, 0xf8, 0xd4), - init_position=[2000 * D, 240 * D, -90 * D], # [ 远+近- , 左+右- , 上+下-] + init_position=[2000 * D, 200 * D, 100 * D], # [ 远+近- , 左+右- , 上+下-] ignore_mass=True) face.light_on = False bodies.append(face) @@ -75,7 +75,7 @@ def gen_eye_bodies(params): if pixel[0] >= 255 and pixel[1] >= 255 and pixel[1] >= 255: continue body_str = body_template % (f"星球{h}:{w}", pixel[0], pixel[1], pixel[2], scale, - w * interval_factor, -h * interval_factor, scale) + (width-w) * interval_factor, (height-h) * interval_factor, scale) bodies_str += body_str + ",\n" bodies_str += "]" diff --git a/sim_scenes/interest/utils/body_utils.py b/sim_scenes/interest/utils/body_utils.py index b8ceb08140348d1d5b5ad3e4ca79f38dcc493d24..1d35e25516e387518f41f35b24680d3474573f4e 100644 --- a/sim_scenes/interest/utils/body_utils.py +++ b/sim_scenes/interest/utils/body_utils.py @@ -44,7 +44,7 @@ def gen_eye_bodies(pixel_image, params, body_template=None): if pixel[0] >= 255 and pixel[1] >= 255 and pixel[1] >= 255: continue body_str = body_template % (f"星球{h}:{w}", pixel[0], pixel[1], pixel[2], scale, - w * interval_factor, -h * interval_factor, scale) + (width-w) * interval_factor, (height-h) * interval_factor, scale) bodies_str += body_str + ",\n" bodies_str += "]"