提交 7849c22e 编写于 作者: 三月三net's avatar 三月三net

Python超人-宇宙模拟器

上级 2a23da04
objs/textures/two_way_foil_circle.png

471.8 KB | W: | H:

objs/textures/two_way_foil_circle.png

23.6 KB | W: | H:

objs/textures/two_way_foil_circle.png
objs/textures/two_way_foil_circle.png
objs/textures/two_way_foil_circle.png
objs/textures/two_way_foil_circle.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -17,6 +17,7 @@ from objs import QuadObj, CircleObj, Obj ...@@ -17,6 +17,7 @@ from objs import QuadObj, CircleObj, Obj
from sim_scenes.func import camera_look_at, two_bodies_colliding from sim_scenes.func import camera_look_at, two_bodies_colliding
from sim_scenes.func import ursina_run, create_sphere_sky from sim_scenes.func import ursina_run, create_sphere_sky
from simulators.ursina.ursina_event import UrsinaEvent from simulators.ursina.ursina_event import UrsinaEvent
from simulators.func import ext_fun_for_method
class TwoWayFoilSim: class TwoWayFoilSim:
...@@ -45,15 +46,6 @@ class TwoWayFoilSim: ...@@ -45,15 +46,6 @@ class TwoWayFoilSim:
# endregion # endregion
init_bodies_pos_vels(self.bodies) init_bodies_pos_vels(self.bodies)
# # 获取模拟的初始位置和速度
# init_pos_vels = get_init_pos_vels()
#
# for body in self.bodies:
# pos_vels = init_pos_vels.get(type(body).__name__.lower(), None)
# if pos_vels is None:
# continue
# body.init_position = pos_vels['pos']
# body.init_velocity = pos_vels['vel']
def build_two_way_foil(self): def build_two_way_foil(self):
""" """
...@@ -94,6 +86,14 @@ class TwoWayFoilSim: ...@@ -94,6 +86,14 @@ class TwoWayFoilSim:
self.two_way_foil_circle.planet.rotation_x = 90 self.two_way_foil_circle.planet.rotation_x = 90
self.two_way_foil_circle.planet.enabled = False self.two_way_foil_circle.planet.enabled = False
def change_two_way_foil():
# 长方形膜状物,长八点五厘米,宽五点二厘米,比一张信用卡略大一些,极薄,看不出任何厚度。
# 封装状态下晶莹剔透、无色透明。待机模式下由于封装力场逐渐蒸发,会发出白光,使其表面呈纯白色,看上去就是一张纸条
self.two_way_foil.planet.scale_x = 8.5
self.two_way_foil.planet.scale_y = 5.2
ext_fun_for_method(self.two_way_foil.planet, after_run_fun=change_two_way_foil)
def flatten_animation(self, body): def flatten_animation(self, body):
""" """
天体二维化的动画 天体二维化的动画
......
...@@ -17,6 +17,7 @@ from objs import QuadObj, CircleObj, Obj ...@@ -17,6 +17,7 @@ from objs import QuadObj, CircleObj, Obj
from sim_scenes.func import camera_look_at, two_bodies_colliding from sim_scenes.func import camera_look_at, two_bodies_colliding
from sim_scenes.func import ursina_run, create_sphere_sky from sim_scenes.func import ursina_run, create_sphere_sky
from simulators.ursina.ursina_event import UrsinaEvent from simulators.ursina.ursina_event import UrsinaEvent
from simulators.func import ext_fun_for_method
class TwoWayFoilSim: class TwoWayFoilSim:
...@@ -94,6 +95,14 @@ class TwoWayFoilSim: ...@@ -94,6 +95,14 @@ class TwoWayFoilSim:
self.two_way_foil_circle.planet.rotation_x = 90 self.two_way_foil_circle.planet.rotation_x = 90
self.two_way_foil_circle.planet.enabled = False self.two_way_foil_circle.planet.enabled = False
def change_two_way_foil():
# 长方形膜状物,长八点五厘米,宽五点二厘米,比一张信用卡略大一些,极薄,看不出任何厚度。
# 封装状态下晶莹剔透、无色透明。待机模式下由于封装力场逐渐蒸发,会发出白光,使其表面呈纯白色,看上去就是一张纸条
self.two_way_foil.planet.scale_x = 8.5
self.two_way_foil.planet.scale_y = 5.2
ext_fun_for_method(self.two_way_foil.planet, after_run_fun=change_two_way_foil)
def flatten_animation(self, body): def flatten_animation(self, body):
""" """
天体二维化的动画 天体二维化的动画
......
...@@ -18,6 +18,7 @@ from objs import QuadObj, CircleObj, Obj ...@@ -18,6 +18,7 @@ from objs import QuadObj, CircleObj, Obj
from sim_scenes.func import camera_look_at, two_bodies_colliding from sim_scenes.func import camera_look_at, two_bodies_colliding
from sim_scenes.func import ursina_run, create_sphere_sky from sim_scenes.func import ursina_run, create_sphere_sky
from simulators.ursina.ursina_event import UrsinaEvent from simulators.ursina.ursina_event import UrsinaEvent
from simulators.func import ext_fun_for_method
class TwoWayFoilSim: class TwoWayFoilSim:
...@@ -86,6 +87,14 @@ class TwoWayFoilSim: ...@@ -86,6 +87,14 @@ class TwoWayFoilSim:
self.two_way_foil_circle.planet.rotation_x = 90 self.two_way_foil_circle.planet.rotation_x = 90
self.two_way_foil_circle.planet.enabled = False self.two_way_foil_circle.planet.enabled = False
def change_two_way_foil():
# 长方形膜状物,长八点五厘米,宽五点二厘米,比一张信用卡略大一些,极薄,看不出任何厚度。
# 封装状态下晶莹剔透、无色透明。待机模式下由于封装力场逐渐蒸发,会发出白光,使其表面呈纯白色,看上去就是一张纸条
self.two_way_foil.planet.scale_x = 8.5
self.two_way_foil.planet.scale_y = 5.2
ext_fun_for_method(self.two_way_foil.planet, after_run_fun=change_two_way_foil)
def gen_pixcel_image(self, planet): def gen_pixcel_image(self, planet):
""" """
将纹理图改为像素图片 将纹理图改为像素图片
...@@ -165,7 +174,7 @@ class TwoWayFoilSim: ...@@ -165,7 +174,7 @@ class TwoWayFoilSim:
self.two_way_foil.planet.enabled = False self.two_way_foil.planet.enabled = False
self.two_way_foil.init_velocity = [0, 0, 0] self.two_way_foil.init_velocity = [0, 0, 0]
# 圆形二向箔显示并设置透明度为0.9 # 圆形二向箔显示并设置透明度为0.9
self.two_way_foil_circle.planet.alpha = 0.9 self.two_way_foil_circle.planet.alpha = 0.8
self.two_way_foil_circle.planet.enabled = True self.two_way_foil_circle.planet.enabled = True
# 当前阶段为 stage_02:二向箔压平天体的阶段 # 当前阶段为 stage_02:二向箔压平天体的阶段
self.current_stage = self.stage_02 self.current_stage = self.stage_02
......
...@@ -17,6 +17,7 @@ from objs import QuadObj, CircleObj, Obj ...@@ -17,6 +17,7 @@ from objs import QuadObj, CircleObj, Obj
from sim_scenes.func import camera_look_at, two_bodies_colliding from sim_scenes.func import camera_look_at, two_bodies_colliding
from sim_scenes.func import ursina_run, create_sphere_sky from sim_scenes.func import ursina_run, create_sphere_sky
from simulators.ursina.ursina_event import UrsinaEvent from simulators.ursina.ursina_event import UrsinaEvent
from simulators.func import ext_fun_for_method
class TwoWayFoilSim: class TwoWayFoilSim:
...@@ -94,6 +95,14 @@ class TwoWayFoilSim: ...@@ -94,6 +95,14 @@ class TwoWayFoilSim:
self.two_way_foil_circle.planet.rotation_x = 90 self.two_way_foil_circle.planet.rotation_x = 90
self.two_way_foil_circle.planet.enabled = False self.two_way_foil_circle.planet.enabled = False
def change_two_way_foil():
# 长方形膜状物,长八点五厘米,宽五点二厘米,比一张信用卡略大一些,极薄,看不出任何厚度。
# 封装状态下晶莹剔透、无色透明。待机模式下由于封装力场逐渐蒸发,会发出白光,使其表面呈纯白色,看上去就是一张纸条
self.two_way_foil.planet.scale_x = 8.5
self.two_way_foil.planet.scale_y = 5.2
ext_fun_for_method(self.two_way_foil.planet, after_run_fun=change_two_way_foil)
def flatten_animation(self, body): def flatten_animation(self, body):
""" """
天体二维化的动画 天体二维化的动画
...@@ -194,6 +203,7 @@ class TwoWayFoilSim: ...@@ -194,6 +203,7 @@ class TwoWayFoilSim:
if self.two_way_foil.planet.enabled: if self.two_way_foil.planet.enabled:
self.two_way_foil.planet.rotation_x += 0.2 self.two_way_foil.planet.rotation_x += 0.2
self.two_way_foil.planet.rotation_y += 2 self.two_way_foil.planet.rotation_y += 2
# 摄像机始终看向二向箔 # 摄像机始终看向二向箔
camera_look_at(self.two_way_foil) camera_look_at(self.two_way_foil)
self.current_stage() self.current_stage()
......
...@@ -138,3 +138,28 @@ def update_ax_styles(ax, styles={}): ...@@ -138,3 +138,28 @@ def update_ax_styles(ax, styles={}):
ax.set_xlabel('X(天文单位:AU)', fontsize="18", color=fore_color) ax.set_xlabel('X(天文单位:AU)', fontsize="18", color=fore_color)
ax.set_ylabel('Y(天文单位:AU)', fontsize="18", color=fore_color) ax.set_ylabel('Y(天文单位:AU)', fontsize="18", color=fore_color)
ax.set_zlabel('Z(天文单位:AU)', fontsize="18", color=fore_color) ax.set_zlabel('Z(天文单位:AU)', fontsize="18", color=fore_color)
def ext_fun_for_method(obj, method_name='update', before_run_fun=None, after_run_fun=None):
"""
对方法进行扩展
@param obj:
@param method_name:
@param before_run_fun:
@param after_run_fun:
@return:
"""
if before_run_fun is None and after_run_fun is None:
return
obj.original_method = getattr(obj, method_name)
def new_method():
def warp():
if callable(before_run_fun):
before_run_fun()
obj.original_method()
if callable(after_run_fun):
after_run_fun()
return warp()
setattr(obj, method_name, new_method)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册