Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
f2d7524a
宇宙模拟器
项目概览
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看板
提交
f2d7524a
编写于
11月 14, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
3df3827c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
10 deletion
+32
-10
sim_scenes/func.py
sim_scenes/func.py
+31
-10
sim_scenes/solar_system/halley_comet_sim.py
sim_scenes/solar_system/halley_comet_sim.py
+1
-0
未找到文件。
sim_scenes/func.py
浏览文件 @
f2d7524a
...
@@ -799,6 +799,31 @@ def get_run_speed_factor(run_speed_factor=1 / 8):
...
@@ -799,6 +799,31 @@ def get_run_speed_factor(run_speed_factor=1 / 8):
return
run_speed_factor
*
control_speed_factor
return
run_speed_factor
*
control_speed_factor
def
camera_to_target
(
info
):
from
ursina
import
camera
,
Vec3
,
lerp
,
slerp
,
time
import
inspect
t
=
info
.
get
(
"to"
)
ct_id
=
t
[
"ct_id"
]
from
objs
import
CameraTarget
ct
=
CameraTarget
.
targets
.
get
(
ct_id
,
None
)
if
ct
is
None
:
print
(
"没有发现 CameraTarget ct_id = "
,
ct_id
)
return
target_position
=
ct
.
planet
.
position
direction
=
(
target_position
-
camera
.
position
).
normalized
()
# 计算摄像机移动的方向
distance
=
(
target_position
-
camera
.
position
).
length
()
# 计算摄像机到目标位置的距离
if
distance
>
0
:
# 如果摄像机还没有到达目标位置
camera
.
position
+=
direction
*
t
.
get
(
"t"
,
0.1
)
*
time
.
dt
# 让摄像机匀速移动
else
:
print
(
"摄像机已到达目标位置"
)
# camera_position = lerp(camera.position, ct.planet.position, t.get("t", 0.1))
# camera.look_at(ct.planet)
# camera.position = camera_position # Vec3(camera_position[0],camera_position[1], 0)
print
(
"camera_to_target"
,
ct
.
planet
.
position
,
camera
.
position
,
t
)
# camera.position = p
def
camera_move_control
(
camera_move_infos
,
cond_cb
,
value_conv
=
None
,
smooth
=
None
):
def
camera_move_control
(
camera_move_infos
,
cond_cb
,
value_conv
=
None
,
smooth
=
None
):
"""
"""
...
@@ -835,7 +860,13 @@ def camera_move_control(camera_move_infos, cond_cb, value_conv=None, smooth=None
...
@@ -835,7 +860,13 @@ def camera_move_control(camera_move_infos, cond_cb, value_conv=None, smooth=None
next_cond
=
camera_move_infos
[
idx
+
1
][
0
]
next_cond
=
camera_move_infos
[
idx
+
1
][
0
]
next_info
=
camera_move_infos
[
idx
+
1
][
1
]
next_info
=
camera_move_infos
[
idx
+
1
][
1
]
cond_cb_params
=
{
"cond"
:
cond
,
"next_cond"
:
next_cond
,
"idx"
:
idx
,
"info"
:
info
,
"next_info"
:
next_info
}
cond_cb_params
=
{
"cond"
:
cond
,
"next_cond"
:
next_cond
,
"idx"
:
idx
,
"info"
:
info
,
"next_info"
:
next_info
}
if
cond_cb
(
cond_cb_params
):
if
cond_cb
(
cond_cb_params
):
t
=
info
.
get
(
"to"
,
None
)
if
t
is
not
None
:
camera_to_target
(
info
)
continue
p
=
camera
.
position
p
=
camera
.
position
x
,
y
,
z
=
[
info
.
get
(
"x"
,
0
),
info
.
get
(
"y"
,
0
),
info
.
get
(
"z"
,
0
)]
x
,
y
,
z
=
[
info
.
get
(
"x"
,
0
),
info
.
get
(
"y"
,
0
),
info
.
get
(
"z"
,
0
)]
mis
=
[
info
.
get
(
"f"
,
0
),
info
.
get
(
"b"
,
0
),
info
.
get
(
"l"
,
0
),
info
.
get
(
"r"
,
0
),
\
mis
=
[
info
.
get
(
"f"
,
0
),
info
.
get
(
"b"
,
0
),
info
.
get
(
"l"
,
0
),
info
.
get
(
"r"
,
0
),
\
...
@@ -867,16 +898,6 @@ def camera_move_control(camera_move_infos, cond_cb, value_conv=None, smooth=None
...
@@ -867,16 +898,6 @@ def camera_move_control(camera_move_infos, cond_cb, value_conv=None, smooth=None
if
abs
(
diff
[
_i
+
3
])
<
0.05
:
if
abs
(
diff
[
_i
+
3
])
<
0.05
:
mis
[
_i
]
=
round
(
last_move_ps
[
_i
+
3
]
-
diff
[
_i
+
3
]
/
100
,
2
)
mis
[
_i
]
=
round
(
last_move_ps
[
_i
+
3
]
-
diff
[
_i
+
3
]
/
100
,
2
)
# print(f"{dns[_i]}", mis[_i])
# print(f"{dns[_i]}", mis[_i])
# if diff[4] != 0:
# mis[1] = 0
# if diff[5] != 0:
# z = 0
# if diff[6] != 0:
# x = 0
# if diff[7] != 0:
# y = 0
# if diff[8] != 0:
# z = 0
if
x
!=
0
or
y
!=
0
or
z
!=
0
:
if
x
!=
0
or
y
!=
0
or
z
!=
0
:
p
+=
Vec3
(
conv_val
(
x
,
"x"
),
conv_val
(
y
,
"y"
),
conv_val
(
z
,
"z"
))
p
+=
Vec3
(
conv_val
(
x
,
"x"
),
conv_val
(
y
,
"y"
),
conv_val
(
z
,
"z"
))
...
...
sim_scenes/solar_system/halley_comet_sim.py
浏览文件 @
f2d7524a
...
@@ -215,6 +215,7 @@ class HalleyCometSim(HalleyCometSimBase):
...
@@ -215,6 +215,7 @@ class HalleyCometSim(HalleyCometSimBase):
# 按坐标系方向移动 x:右+左-, y:升+降-, z:前+(接近太阳)后-(远离太阳)
# 按坐标系方向移动 x:右+左-, y:升+降-, z:前+(接近太阳)后-(远离太阳)
# 以摄像机视角移动 f:前 b:后 l:左 r:右 u:上 d:下
# 以摄像机视角移动 f:前 b:后 l:左 r:右 u:上 d:下
(
1982
,
{
"x"
:
2
,
"y"
:
1
}),
(
1982
,
{
"x"
:
2
,
"y"
:
1
}),
# (1983, {"to": {"ct_id": 1, "t": 10}}),
(
1986
,
{
"x"
:
2
,
"y"
:
-
2
,
"z"
:
-
15
}),
(
1986
,
{
"x"
:
2
,
"y"
:
-
2
,
"z"
:
-
15
}),
(
1987
,
{
"y"
:
-
6
,
"z"
:
-
12
}),
(
1987
,
{
"y"
:
-
6
,
"z"
:
-
12
}),
(
1988
,
{
"y"
:
-
3
,
"z"
:
-
12
}),
(
1988
,
{
"y"
:
-
3
,
"z"
:
-
12
}),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录