Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
d2d710b1
宇宙模拟器
项目概览
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看板
提交
d2d710b1
编写于
12月 07, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
e03e0272
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
32 addition
and
6 deletion
+32
-6
sim_lab/the_lost_planet.py
sim_lab/the_lost_planet.py
+32
-6
未找到文件。
sim_lab/the_lost_planet.py
浏览文件 @
d2d710b1
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
# link :https://gitcode.net/pythoncr/
# link :https://gitcode.net/pythoncr/
# python_version :3.9
# python_version :3.9
# ==============================================================================
# ==============================================================================
import
time
from
bodies
import
Sun
,
Mercury
,
Venus
,
Earth
,
Mars
,
Moon
,
Ceres
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
,
Asteroids
from
bodies
import
Sun
,
Mercury
,
Venus
,
Earth
,
Mars
,
Moon
,
Ceres
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
,
Asteroids
from
common.consts
import
SECONDS_PER_WEEK
,
SECONDS_PER_DAY
,
SECONDS_PER_MONTH
,
SECONDS_PER_YEAR
,
AU
from
common.consts
import
SECONDS_PER_WEEK
,
SECONDS_PER_DAY
,
SECONDS_PER_MONTH
,
SECONDS_PER_YEAR
,
AU
from
sim_scenes.func
import
mayavi_run
,
ursina_run
,
create_sphere_sky
from
sim_scenes.func
import
mayavi_run
,
ursina_run
,
create_sphere_sky
...
@@ -101,6 +103,10 @@ if __name__ == '__main__':
...
@@ -101,6 +103,10 @@ if __name__ == '__main__':
# camera.look_at(sun.planet)
# camera.look_at(sun.planet)
camera
.
rotation_z
-=
90
camera
.
rotation_z
-=
90
# for i in range(10):
# time.sleep(0.1)
# create_asteroid()
# UniverseSimScenes.show_grid_axises()
# UniverseSimScenes.show_grid_axises()
asteroids
.
planet
.
enabled
=
False
asteroids
.
planet
.
enabled
=
False
...
@@ -136,6 +142,25 @@ if __name__ == '__main__':
...
@@ -136,6 +142,25 @@ if __name__ == '__main__':
# ext_fun_for_method(planet, after_run_fun=alpha_animation)
# ext_fun_for_method(planet, after_run_fun=alpha_animation)
def
create_asteroid
():
from
ursina
import
Entity
,
color
,
Vec3
import
math
import
random
pos
=
moon
.
planet
.
position
# + Vec3()
radius
=
moon
.
planet
.
position
[
2
]
+
40
*
random
.
random
()
-
20
# * moon.distance_scale
asteroid
=
Entity
(
model
=
'sphere'
,
position
=
pos
,
color
=
color
.
white
,
scale
=
1.5
)
asteroid
.
s_angle
=
89.5
def
rotation
():
x
=
sun
.
planet
.
x
+
radius
*
math
.
cos
(
asteroid
.
s_angle
)
z
=
sun
.
planet
.
z
+
radius
*
math
.
sin
(
asteroid
.
s_angle
)
asteroid
.
position
=
(
x
,
10
*
random
.
random
()
-
5
,
z
)
speed
=
random
.
random
()
/
15
asteroid
.
s_angle
+=
speed
asteroid
.
update
=
rotation
#
#
# def after_ready():
# def after_ready():
# from ursina import camera, Vec3
# from ursina import camera, Vec3
...
@@ -158,11 +183,12 @@ if __name__ == '__main__':
...
@@ -158,11 +183,12 @@ if __name__ == '__main__':
set_alpha_animation
(
moon
,
0.0
,
1.0
,
0.005
)
set_alpha_animation
(
moon
,
0.0
,
1.0
,
0.005
)
setattr
(
moon
,
"years_6"
,
True
)
setattr
(
moon
,
"years_6"
,
True
)
elif
time_data
.
years
>
8
and
not
hasattr
(
asteroids
,
"years_8"
):
elif
time_data
.
years
>
8
and
not
hasattr
(
asteroids
,
"years_8"
):
set_alpha_animation
(
asteroids
,
0.0
,
1.0
,
0.01
)
# set_alpha_animation(asteroids, 0.0, 1.0, 0.01)
setattr
(
asteroids
,
"years_8"
,
True
)
for
i
in
range
(
3
):
create_asteroid
()
if
time_data
.
years
>
8
and
not
hasattr
(
moon
,
"years_8"
):
if
time_data
.
years
>
11
and
not
hasattr
(
moon
,
"mars_rotation"
):
setattr
(
asteroids
,
"years_8"
,
True
)
moon
.
planet
.
look_at
(
mars
.
planet
)
moon
.
planet
.
look_at
(
mars
.
planet
)
radius
=
12
radius
=
12
d
=
distance
(
moon
.
planet
,
mars
.
planet
.
position
)
d
=
distance
(
moon
.
planet
,
mars
.
planet
.
position
)
...
@@ -180,9 +206,9 @@ if __name__ == '__main__':
...
@@ -180,9 +206,9 @@ if __name__ == '__main__':
setattr
(
mars
,
"moon_angle"
,
moon_angle
+
0.08
)
setattr
(
mars
,
"moon_angle"
,
moon_angle
+
0.08
)
if
moon_angle
>=
110
:
if
moon_angle
>=
110
:
setattr
(
moon
,
"
years_8
"
,
True
)
setattr
(
moon
,
"
mars_rotation
"
,
True
)
print
(
"moon_angle"
,
moon_angle
)
print
(
"moon_angle"
,
moon_angle
)
elif
hasattr
(
mars
,
"moon_angle"
)
and
not
hasattr
(
moon
,
"earth_rotation"
):
elif
hasattr
(
mars
,
"moon_angle"
)
and
not
hasattr
(
moon
,
"earth_rotation"
):
earth_target
=
earth
.
planet
.
main_entity
earth_target
=
earth
.
planet
.
main_entity
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录