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

Python超人-宇宙模拟器

上级 99675402
...@@ -117,8 +117,10 @@ class HalleyCometSim: ...@@ -117,8 +117,10 @@ class HalleyCometSim:
@return: @return:
""" """
# 创建天空 # 创建天空
UrsinaConfig.trail_type = "line" # UrsinaConfig.trail_type = "line"
UrsinaConfig.trail_length = 91 # UrsinaConfig.trail_length = 91
UrsinaConfig.trail_type = "curve_line"
UrsinaConfig.trail_length = 420
# UrsinaConfig.trail_length = 1000 # UrsinaConfig.trail_length = 1000
UrsinaConfig.trail_thickness_factor = 3 UrsinaConfig.trail_thickness_factor = 3
# camera.clip_plane_near = 0.1 # camera.clip_plane_near = 0.1
......
...@@ -118,12 +118,20 @@ def create_trails(parent): ...@@ -118,12 +118,20 @@ def create_trails(parent):
# # 如果拖尾在天体的内部也不要生成 # # 如果拖尾在天体的内部也不要生成
# if self_pos_distance < self.scale_x + (self.trail_scale / 2): # if self_pos_distance < self.scale_x + (self.trail_scale / 2):
# pass # pass
# 如果位置比较近,就不创建拖尾了,保证拖尾间隔一定的距离 if UrsinaConfig.trail_type == "curve_line":
if last_pos_distance < parent.trail_scale * trail_int_scale: # 间隔距离不小于1.2倍的拖尾球体 # 如果位置比较近,就不创建拖尾了,保证拖尾间隔一定的距离
return # if last_pos_distance < parent.trail_scale * trail_int_scale / 5:
if last_pos_distance < 10:
return
else:
# 如果位置比较近,就不创建拖尾了,保证拖尾间隔一定的距离
if last_pos_distance < parent.trail_scale * trail_int_scale: # 间隔距离不小于1.2倍的拖尾球体
return
if UrsinaConfig.trail_type == "line": if UrsinaConfig.trail_type == "line":
trail = create_trail_line(parent, pos) # 拖尾为线条 trail = create_trail_line(parent, pos) # 拖尾为线条
elif UrsinaConfig.trail_type == "curve_line":
trail = create_trail_curve_line(parent, pos) # 拖尾为曲线条
else: else:
trail = create_trail_sphere(parent, pos) # 拖尾为球体 trail = create_trail_sphere(parent, pos) # 拖尾为球体
...@@ -247,6 +255,28 @@ def create_trail_line(parent, pos): ...@@ -247,6 +255,28 @@ def create_trail_line(parent, pos):
return trail return trail
def create_trail_curve_line(parent, pos):
"""
在天体当前的位置创建一个拖尾球体
@param pos:
@return:
"""
trail = None
if hasattr(parent, "trail_last_pos"):
trail_last_pos = parent.trail_last_pos
if distance(pos, trail_last_pos) > 0:
trail = Entity(model=Mesh(
vertices=((pos[0], pos[1], pos[2]), (trail_last_pos[0], trail_last_pos[1], trail_last_pos[2])),
mode='line',
thickness=UrsinaConfig.trail_thickness_factor),
color=parent.trail_color, alpha=0.5)
trail.set_light_off()
parent.last_trail = trail
parent.trail_last_pos = pos
return trail
def create_rings(parent): def create_rings(parent):
""" """
创建行星环(使用土星贴图) 创建行星环(使用土星贴图)
......
...@@ -42,8 +42,8 @@ class UrsinaConfig: ...@@ -42,8 +42,8 @@ class UrsinaConfig:
# 拖尾球体的数量 # 拖尾球体的数量
trail_length = 100 trail_length = 100
# 拖尾的类型(球体、线条) # 拖尾的类型(球体、线条、曲线条
trail_type = "sphere" # trail_type="line" or trail_type="sphere" trail_type = "sphere" # line sphere curve_line
# 默认秒数(0表示默认) # 默认秒数(0表示默认)
seconds_per = 0 seconds_per = 0
# # 控制摄像机动作速度(天体越大,速度越快,天体越小,速度越慢) # # 控制摄像机动作速度(天体越大,速度越快,天体越小,速度越慢)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册