Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
2285f601
宇宙模拟器
项目概览
Python_超人
/
宇宙模拟器
通知
19
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
宇宙模拟器
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
2285f601
编写于
4月 16, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
给天体增加了倾斜参数,地球进行了修改,由于增加了一个倾斜的parent entity,所以,改动比较大。
上级
2c8eb08f
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
30 addition
and
14 deletion
+30
-14
sim_scenes/science/free_fall_of_ball.py
sim_scenes/science/free_fall_of_ball.py
+1
-1
simulators/ursina/entities/entity_utils.py
simulators/ursina/entities/entity_utils.py
+2
-2
simulators/ursina/entities/planet.py
simulators/ursina/entities/planet.py
+27
-11
未找到文件。
sim_scenes/science/free_fall_of_ball.py
浏览文件 @
2285f601
...
...
@@ -6,7 +6,7 @@
# link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
bodies
import
Moon
,
Earth
,
Body
from
bodies
import
Earth
,
Body
from
objs
import
Football
from
common.consts
import
SECONDS_PER_HOUR
,
SECONDS_PER_MINUTE
from
sim_scenes.func
import
ursina_run
...
...
simulators/ursina/entities/entity_utils.py
浏览文件 @
2285f601
...
...
@@ -39,7 +39,7 @@ def create_name_text(parent):
return
name_text
def
trail_init
(
parent
):
def
trail_init
(
parent
,
scale
):
"""
拖尾球体的初始化
@return:
...
...
@@ -52,7 +52,7 @@ def trail_init(parent):
trail_color
=
adjust_brightness
(
trail_color
,
0.4
)
parent
.
trail_color
=
color
.
rgba
(
trail_color
[
0
],
trail_color
[
1
],
trail_color
[
2
],
0.6
)
# 拖尾球体的大小为该天体的 1/5
parent
.
trail_scale
=
parent
.
scale_x
/
5
parent
.
trail_scale
=
scale
/
5
if
parent
.
trail_scale
<
1
:
# 如果太小,则
pass
...
...
simulators/ursina/entities/planet.py
浏览文件 @
2285f601
...
...
@@ -36,6 +36,7 @@ class Planet(Entity):
if
hasattr
(
self
.
body
,
"rotation_speed"
):
self
.
rotation_speed
=
self
.
body
.
rotation_speed
self
.
rotMode
=
'x'
# random.choice(["x", "y", "z"])
self
.
name
=
body_view
.
name
pos
=
body_view
.
position
*
self
.
body
.
distance_scale
*
UrsinaConfig
.
SCALE_FACTOR
...
...
@@ -97,6 +98,21 @@ class Planet(Entity):
rotation
=
rotation
,
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"
):
# 星环小天体群(主要模拟小行星群,非一个天体)
...
...
@@ -105,7 +121,7 @@ class Planet(Entity):
else
:
# 一个天体
# 拖尾球体的初始化
trail_init
(
self
)
trail_init
(
self
.
main_entity
,
self
.
scale_x
)
if
hasattr
(
self
.
body
,
"is_fixed_star"
):
if
self
.
body
.
is_fixed_star
:
...
...
@@ -141,9 +157,9 @@ class Planet(Entity):
# self.x = -pos[1]
# self.y = pos[2]
# self.z = pos[0]
self
.
x
=
pos
[
0
]
self
.
y
=
pos
[
1
]
self
.
z
=
pos
[
2
]
self
.
main_entity
.
x
=
pos
[
0
]
self
.
main_entity
.
y
=
pos
[
1
]
self
.
main_entity
.
z
=
pos
[
2
]
else
:
self
.
follow_parent
()
...
...
@@ -183,9 +199,9 @@ class Planet(Entity):
if
UrsinaConfig
.
show_trail
:
# 有时候第一个位置不正确,所以判断一下有历史记录后在创建
if
len
(
self
.
body
.
his_position
())
>
1
:
create_trails
(
self
)
create_trails
(
self
.
main_entity
)
else
:
clear_trails
(
self
)
clear_trails
(
self
.
main_entity
)
if
hasattr
(
self
,
"name_text"
):
d
=
(
camera
.
world_position
-
self
.
name_text
.
world_position
).
length
()
...
...
@@ -213,18 +229,18 @@ class Planet(Entity):
# self.x = -pos[1]
# self.y = pos[2]
# self.z = pos[0]
self
.
x
=
pos
[
0
]
self
.
y
=
pos
[
1
]
self
.
z
=
pos
[
2
]
self
.
main_entity
.
x
=
pos
[
0
]
self
.
main_entity
.
y
=
pos
[
1
]
self
.
main_entity
.
z
=
pos
[
2
]
def
destroy_all
(
self
):
# 从天体系统中移除自己(TODO:暂时还不能移除)
# self.body_view.bodies_system.bodies.remove(self.body)
# 删除拖尾
clear_trails
(
self
)
clear_trails
(
self
.
main_entity
)
# 如果有行星环,则删除行星环
if
hasattr
(
self
,
"ring"
):
destroy
(
self
.
ring
)
destroy
(
self
.
main_entity
.
ring
)
self
.
body
.
appeared
=
False
self
.
body_view
.
appeared
=
False
# 最后删除自己
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录