Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
37a66502
宇宙模拟器
项目概览
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看板
提交
37a66502
编写于
7月 16, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
bd2ea340
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
80 addition
and
17 deletion
+80
-17
sim_scenes/earth/earth_3d.py
sim_scenes/earth/earth_3d.py
+45
-17
simulators/ursina/entities/camera3d.py
simulators/ursina/entities/camera3d.py
+35
-0
textures/earth_hd_trans.png
textures/earth_hd_trans.png
+0
-0
未找到文件。
sim_scenes/earth/earth_3d.py
浏览文件 @
37a66502
...
...
@@ -7,17 +7,23 @@
# python_version :3.8
# ==============================================================================
from
bodies
import
Earth
from
common.consts
import
SECONDS_PER_HOUR
,
SECONDS_PER_DAY
from
sim_scenes.func
import
ursina_run
,
camera_look_at
from
common.consts
import
SECONDS_PER_HOUR
,
SECONDS_PER_DAY
,
AU
from
sim_scenes.func
import
ursina_run
,
camera_look_at
,
create_3d_card
from
simulators.ursina.entities.body_timer
import
TimeData
from
simulators.ursina.entities.camera3d
import
Camera3d
from
simulators.ursina.ursina_config
import
UrsinaConfig
from
simulators.ursina.ursina_event
import
UrsinaEvent
from
ursina
import
camera
if
__name__
==
'__main__'
:
"""
地球3D效果
# sim_video_3d_cap.bat earth earth_3d
"""
# 创建带有云层的地球
earth
=
Earth
(
texture
=
"earth_hd_trans.png"
,
earth
=
Earth
(
# texture="earth_hd.jpg",
texture
=
"earth_hd_trans.png"
,
rotate_angle
=-
23.44
,
init_position
=
[
0
,
0
,
0
],
init_velocity
=
[
0
,
0
,
0
],
...
...
@@ -28,29 +34,51 @@ if __name__ == '__main__':
size_scale
=
1.001
,
parent
=
earth
)
bodies
=
[
earth
,
clouds
]
# camera.camera_pos = "right"
# camera_l2r = 0.002 * AU * UrsinaConfig.SCALE_FACTOR
#
#
# def switch_position():
# if camera.camera_pos == "right": # 摄像机右眼
# camera.world_position[0] -= 2 * camera_l2r
# camera.camera_pos = "left"
# elif camera.camera_pos == "left": # 摄像机左眼
# camera.world_position[0] += 2 * camera_l2r
# camera.camera_pos = "right"
#
#
# camera.switch_position = switch_position
def
on_ready
():
from
ursina
import
camera
earth
.
camera3d
=
Camera3d
()
earth
.
camera3d
.
position
=
(
1.45
*
earth
.
radius
*
UrsinaConfig
.
SCALE_FACTOR
,
0
,
-
30000
*
UrsinaConfig
.
SCALE_FACTOR
)
# camera_look_at(earth, rotation_z=0)
# camera.fov = 40
earth
.
_3d_card
=
create_3d_card
()
def
on_before_evolving
(
evolve_args
):
earth
.
_3d_card
.
switch_color
()
earth
.
camera3d
.
switch_position
()
if
earth
.
_3d_card
.
switch_flag
==
1
:
evolve_args
[
"evolve_dt"
]
=
0.0
def
on_timer_changed
(
time_data
:
TimeData
):
pass
# 订阅事件后,上面的函数功能才会起作用
# 运行前会触发 on_ready
UrsinaEvent
.
on_ready_subscription
(
on_ready
)
# 订阅事件后,上面的函数功能才会起作用
# 运行中,每时每刻都会触发 on_timer_changed
UrsinaEvent
.
on_timer_changed_subscription
(
on_timer_changed
)
UrsinaEvent
.
on_before_evolving_subscription
(
on_before_evolving
)
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
ursina_run
(
bodies
,
SECONDS_PER_HOUR
/
2
,
position
=
(
1.2
*
earth
.
radius
,
0
,
-
30000
),
ursina_run
(
bodies
,
SECONDS_PER_HOUR
,
# position=(1.2 * earth.radius, 0, -30000),
position
=
(
0
,
0
,
0
),
show_grid
=
False
,
show_camera_info
=
False
,
show_control_info
=
False
,
cosmic_bg
=
"none"
,
view_closely
=
0.001
)
# 近距离观看 view_closely=True或0.001
simulators/ursina/entities/camera3d.py
0 → 100644
浏览文件 @
37a66502
# -*- coding:utf-8 -*-
# title :创建一个宇宙网格对象
# description :创建一个宇宙网格对象
# author :Python超人
# date :2023-02-11
# link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
ursina
import
Entity
,
camera
from
common.consts
import
AU
from
simulators.ursina.ursina_config
import
UrsinaConfig
class
Camera3d
(
Entity
):
def
__init__
(
self
,
**
kwargs
):
super
().
__init__
()
for
key
,
value
in
kwargs
.
items
():
setattr
(
self
,
key
,
value
)
camera
.
parent
=
self
self
.
camera_pos
=
"right"
# self.camera_l2r = 0.002 * AU * UrsinaConfig.SCALE_FACTOR
self
.
camera_l2r
=
0.0005
def
switch_position
(
self
):
if
self
.
camera_pos
==
"right"
:
# 摄像机右眼
self
.
x
-=
2
*
self
.
camera_l2r
self
.
camera_pos
=
"left"
elif
self
.
camera_pos
==
"left"
:
# 摄像机左眼
self
.
x
+=
2
*
self
.
camera_l2r
self
.
camera_pos
=
"right"
def
update
(
self
):
pass
textures/earth_hd_trans.png
0 → 100644
浏览文件 @
37a66502
因为 它太大了无法显示 image diff 。你可以改为
查看blob
。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录