提交 24ddb4bc 编写于 作者: 三月三net's avatar 三月三net

Python超人-宇宙模拟器

上级 f7b9372b
此差异已折叠。
...@@ -471,8 +471,8 @@ def create_line(from_pos, to_pos, parent=None, alpha=1.0, len_scale=1, set_light ...@@ -471,8 +471,8 @@ def create_line(from_pos, to_pos, parent=None, alpha=1.0, len_scale=1, set_light
return line return line
def create_circle(parent=None, pos=Vec3(0, 0, 0), thickness=1, scale=1, color=color.white, alpha=1): def create_circle(parent=None, pos=Vec3(0, 0, 0), thickness=1, scale=1, color=color.white, alpha=1, texture=None):
circle = Entity(parent=parent, model="circle", thickness=thickness, scale=scale, position=pos, circle = Entity(parent=parent, model="circle", texture=texture, thickness=thickness, scale=scale, position=pos,
color=color, alpha=alpha, double_sided=True) color=color, alpha=alpha, double_sided=True)
return circle return circle
......
...@@ -99,7 +99,7 @@ class UrsinaSimulator(Simulator): ...@@ -99,7 +99,7 @@ class UrsinaSimulator(Simulator):
c.enabled = False c.enabled = False
# Explosion animation # Explosion animation
def body_explode(target=None, scale=1, fps=6): def body_explode(target=None, scale=1, fps=6, explode_dir=None, explode_name="explosion"):
# from panda3d.core import GeomUtils # from panda3d.core import GeomUtils
if body.planet.enabled: if body.planet.enabled:
# TODO:下面代码保留,由于运行太快导致两个天体不是在表面碰撞,这样就要进行计算,希望在表面爆炸,但是需要耗费CPU资源,暂时注释 # TODO:下面代码保留,由于运行太快导致两个天体不是在表面碰撞,这样就要进行计算,希望在表面爆炸,但是需要耗费CPU资源,暂时注释
...@@ -120,8 +120,14 @@ class UrsinaSimulator(Simulator): ...@@ -120,8 +120,14 @@ class UrsinaSimulator(Simulator):
# 如果爆炸,则静止不动(停止并忽略引力) # 如果爆炸,则静止不动(停止并忽略引力)
body.stop_and_ignore_gravity() body.stop_and_ignore_gravity()
body.planet.enabled = False body.planet.enabled = False
explosion_file = find_file("images/explosion") if explode_dir is None:
explosion_file = os.path.join(explosion_file, "explosion") explode_dir = "images/explosion"
explosion_file = find_file(explode_dir)
if not os.path.exists(explosion_file):
return
explosion_file = os.path.join(explosion_file, explode_name)
# 获取体积数据(开三次方) # 获取体积数据(开三次方)
volume_scale = pow(body.planet.model.get_bounds().volume, 1 / 3) volume_scale = pow(body.planet.model.get_bounds().volume, 1 / 3)
# 根据体积、大小缩放判断爆炸的量 # 根据体积、大小缩放判断爆炸的量
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册