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

给天体增加了倾斜参数,地球进行了修改,由于增加了一个倾斜的parent entity,所以,改动比较大。

上级 2c8eb08f
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
# link :https://gitcode.net/pythoncr/ # link :https://gitcode.net/pythoncr/
# python_version :3.8 # python_version :3.8
# ============================================================================== # ==============================================================================
from bodies import Moon, Earth, Body from bodies import Earth, Body
from objs import Football from objs import Football
from common.consts import SECONDS_PER_HOUR, SECONDS_PER_MINUTE from common.consts import SECONDS_PER_HOUR, SECONDS_PER_MINUTE
from sim_scenes.func import ursina_run from sim_scenes.func import ursina_run
......
...@@ -39,7 +39,7 @@ def create_name_text(parent): ...@@ -39,7 +39,7 @@ def create_name_text(parent):
return name_text return name_text
def trail_init(parent): def trail_init(parent, scale):
""" """
拖尾球体的初始化 拖尾球体的初始化
@return: @return:
...@@ -52,7 +52,7 @@ def trail_init(parent): ...@@ -52,7 +52,7 @@ def trail_init(parent):
trail_color = adjust_brightness(trail_color, 0.4) trail_color = adjust_brightness(trail_color, 0.4)
parent.trail_color = color.rgba(trail_color[0], trail_color[1], trail_color[2], 0.6) parent.trail_color = color.rgba(trail_color[0], trail_color[1], trail_color[2], 0.6)
# 拖尾球体的大小为该天体的 1/5 # 拖尾球体的大小为该天体的 1/5
parent.trail_scale = parent.scale_x / 5 parent.trail_scale = scale / 5
if parent.trail_scale < 1: if parent.trail_scale < 1:
# 如果太小,则 # 如果太小,则
pass pass
......
...@@ -36,6 +36,7 @@ class Planet(Entity): ...@@ -36,6 +36,7 @@ class Planet(Entity):
if hasattr(self.body, "rotation_speed"): if hasattr(self.body, "rotation_speed"):
self.rotation_speed = self.body.rotation_speed self.rotation_speed = self.body.rotation_speed
self.rotMode = 'x' # random.choice(["x", "y", "z"]) self.rotMode = 'x' # random.choice(["x", "y", "z"])
self.name = body_view.name self.name = body_view.name
pos = body_view.position * self.body.distance_scale * UrsinaConfig.SCALE_FACTOR pos = body_view.position * self.body.distance_scale * UrsinaConfig.SCALE_FACTOR
...@@ -97,6 +98,21 @@ class Planet(Entity): ...@@ -97,6 +98,21 @@ class Planet(Entity):
rotation=rotation, rotation=rotation,
double_sided=True double_sided=True
) )
if hasattr(self.body, "rotate_angle"):
if self.body.rotate_angle != 0:
self.rotate_angle = self.body.rotate_angle
self.main_entity = Entity()
self.main_entity.rotation_x = self.rotate_angle
self.main_entity.body_view = self.body_view
self.main_entity.body = self.body
self.parent = self.main_entity
self.position = [0, 0, 0]
else:
self.rotate_angle = 0
self.main_entity = self
else:
self.rotate_angle = 0
self.main_entity = self
if hasattr(self.body, "torus_stars"): if hasattr(self.body, "torus_stars"):
# 星环小天体群(主要模拟小行星群,非一个天体) # 星环小天体群(主要模拟小行星群,非一个天体)
...@@ -105,7 +121,7 @@ class Planet(Entity): ...@@ -105,7 +121,7 @@ class Planet(Entity):
else: else:
# 一个天体 # 一个天体
# 拖尾球体的初始化 # 拖尾球体的初始化
trail_init(self) trail_init(self.main_entity, self.scale_x)
if hasattr(self.body, "is_fixed_star"): if hasattr(self.body, "is_fixed_star"):
if self.body.is_fixed_star: if self.body.is_fixed_star:
...@@ -141,9 +157,9 @@ class Planet(Entity): ...@@ -141,9 +157,9 @@ class Planet(Entity):
# self.x = -pos[1] # self.x = -pos[1]
# self.y = pos[2] # self.y = pos[2]
# self.z = pos[0] # self.z = pos[0]
self.x = pos[0] self.main_entity.x = pos[0]
self.y = pos[1] self.main_entity.y = pos[1]
self.z = pos[2] self.main_entity.z = pos[2]
else: else:
self.follow_parent() self.follow_parent()
...@@ -183,9 +199,9 @@ class Planet(Entity): ...@@ -183,9 +199,9 @@ class Planet(Entity):
if UrsinaConfig.show_trail: if UrsinaConfig.show_trail:
# 有时候第一个位置不正确,所以判断一下有历史记录后在创建 # 有时候第一个位置不正确,所以判断一下有历史记录后在创建
if len(self.body.his_position()) > 1: if len(self.body.his_position()) > 1:
create_trails(self) create_trails(self.main_entity)
else: else:
clear_trails(self) clear_trails(self.main_entity)
if hasattr(self, "name_text"): if hasattr(self, "name_text"):
d = (camera.world_position - self.name_text.world_position).length() d = (camera.world_position - self.name_text.world_position).length()
...@@ -213,18 +229,18 @@ class Planet(Entity): ...@@ -213,18 +229,18 @@ class Planet(Entity):
# self.x = -pos[1] # self.x = -pos[1]
# self.y = pos[2] # self.y = pos[2]
# self.z = pos[0] # self.z = pos[0]
self.x = pos[0] self.main_entity.x = pos[0]
self.y = pos[1] self.main_entity.y = pos[1]
self.z = pos[2] self.main_entity.z = pos[2]
def destroy_all(self): def destroy_all(self):
# 从天体系统中移除自己(TODO:暂时还不能移除) # 从天体系统中移除自己(TODO:暂时还不能移除)
# self.body_view.bodies_system.bodies.remove(self.body) # self.body_view.bodies_system.bodies.remove(self.body)
# 删除拖尾 # 删除拖尾
clear_trails(self) clear_trails(self.main_entity)
# 如果有行星环,则删除行星环 # 如果有行星环,则删除行星环
if hasattr(self, "ring"): if hasattr(self, "ring"):
destroy(self.ring) destroy(self.main_entity.ring)
self.body.appeared = False self.body.appeared = False
self.body_view.appeared = False self.body_view.appeared = False
# 最后删除自己 # 最后删除自己
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册