Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
cce82fd6
宇宙模拟器
项目概览
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看板
提交
cce82fd6
编写于
4月 01, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
d159c082
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
77 addition
and
6 deletion
+77
-6
simulators/ursina/entities/body_trail.py
simulators/ursina/entities/body_trail.py
+66
-1
simulators/ursina/entities/planet.py
simulators/ursina/entities/planet.py
+2
-0
simulators/ursina_simulator.py
simulators/ursina_simulator.py
+9
-5
未找到文件。
simulators/ursina/entities/body_trail.py
浏览文件 @
cce82fd6
...
...
@@ -7,7 +7,7 @@
# python_version :3.8
# ==============================================================================
# pip install -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com ursina
from
ursina
import
Entity
,
Mesh
,
Text
,
color
,
destroy
from
ursina
import
Entity
,
Mesh
,
Text
,
color
,
destroy
,
Vec3
from
simulators.ursina.ursina_config
import
UrsinaConfig
...
...
@@ -48,10 +48,16 @@ class BodyTrail(Entity):
verts_acc
=
[(
0
,
0
,
0
),
tuple
(
acc_direction
)]
verts_vel
=
[(
0
,
0
,
0
),
tuple
(
vel_direction
)]
# acc_arrow = Arrow(parent=self,from_pos=Vec3((0, 0, 0)), to_pos=Vec3(tuple(acc_direction)),color=color.yellow, alpha=0.5)
# acc_arrow.set_light_off()
acc_line
=
Entity
(
parent
=
self
,
model
=
Mesh
(
vertices
=
verts_acc
,
mode
=
'line'
,
thickness
=
3
),
color
=
color
.
yellow
,
alpha
=
0.5
)
acc_line
.
set_light_off
()
# vel_arrow = Arrow(parent=self,from_pos=Vec3((0, 0, 0)), to_pos=Vec3(tuple(vel_direction)),color=color.red, alpha=0.5)
# vel_arrow.set_light_off()
vel_line
=
Entity
(
parent
=
self
,
model
=
Mesh
(
vertices
=
verts_vel
,
mode
=
'line'
,
thickness
=
3
),
color
=
color
.
red
,
alpha
=
0.5
)
vel_line
.
set_light_off
()
...
...
@@ -65,3 +71,62 @@ class BodyTrail(Entity):
font
=
UrsinaConfig
.
CN_FONT
,
background
=
False
,
color
=
color
.
yellow
,
position
=
acc_position
,
alpha
=
0.5
)
acc_text
.
set_light_off
()
class
Arrow
(
Entity
):
def
__init__
(
self
,
parent
,
from_pos
=
(
0
,
0
,
0
),
to_pos
=
(
1
,
0
,
0
),
**
kwargs
):
from_pos
=
to_pos
/
2
super
().
__init__
(
parent
=
parent
,
model
=
'arrow'
,
position
=
from_pos
,
**
kwargs
)
# self.x = -pos[1]
# self.y = pos[2]
# self.z = pos[0]
to_pos
=
1000
*
to_pos
# to_pos = -to_pos[2],-to_pos[1],to_pos[0]
# to_pos = -to_pos[2],-to_pos[0],to_pos[1]
# to_pos = to_pos[0],to_pos[2],to_pos[1]
# to_pos = -to_pos[0],to_pos[1],to_pos[2]
# to_pos = to_pos[1], -to_pos[0], -to_pos[2]
# to_pos = to_pos[1], -to_pos[0], -to_pos[2]
self
.
rotation
=
(
0
,
0
,
0
)
self
.
look_at
(
to_pos
)
print
(
self
.
rotation
)
# self.model = Mesh(vertices=[
# from_pos,
# from_pos + (to_pos - from_pos) * 0.9,
# from_pos + (to_pos - from_pos) * 0.9 + Vec3(0, 0.1, 0),
# to_pos,
# from_pos + (to_pos - from_pos) * 0.9 - Vec3(0, 0.1, 0),
# from_pos + (to_pos - from_pos) * 0.9
# ], mode='triangle', thickness=thickness)
#
# self.color = color
# self.look_at(to_pos)
# self.scale_z = (to_pos - from_pos).length()
# class Arrow(Entity):
# def __init__(self,parent, from_pos, to_pos, **kwargs):
# super().__init__(parent=parent, model='arrow', **kwargs)
# self.position = from_pos
# self.look_at(to_pos)
# import numpy as np
# def draw_arrow(parent, from_pos, to_pos, color, alpha):
# # 计算方向向量和长度
# p1 = np.array(from_pos)
# p2 = np.array(to_pos)
# direction = p2 - p1
# length = np.linalg.norm(direction)
#
# # 创建箭头实体
# arrow = Entity(parent=parent, model="arrow", scale=(1, 1, length),color=color,alpha=alpha)
#
# # 设置箭头位置和方向
# arrow_position = p1 + direction/2
# arrow.position = arrow_position
# arrow.look_at(p2)
#
# return arrow
\ No newline at end of file
simulators/ursina/entities/planet.py
浏览文件 @
cce82fd6
...
...
@@ -109,6 +109,7 @@ class Planet(Entity):
pos
=
self
.
body_view
.
position
*
UrsinaConfig
.
SCALE_FACTOR
if
self
.
body
.
parent
is
None
:
# TODO: ????????
self
.
x
=
-
pos
[
1
]
self
.
y
=
pos
[
2
]
self
.
z
=
pos
[
0
]
...
...
@@ -175,6 +176,7 @@ class Planet(Entity):
self
.
f_parent
=
b
break
pos
=
self
.
f_parent
.
position
*
UrsinaConfig
.
SCALE_FACTOR
# TODO: ????????
self
.
x
=
-
pos
[
1
]
self
.
y
=
pos
[
2
]
self
.
z
=
pos
[
0
]
...
...
simulators/ursina_simulator.py
浏览文件 @
cce82fd6
...
...
@@ -40,13 +40,17 @@ class WorldGrid(Entity):
s
=
100
grid
=
Entity
(
model
=
Grid
(
s
,
s
),
scale
=
s
*
20
,
color
=
color
.
rgba
(
255
,
255
,
255
,
20
),
rotation_x
=
90
,
position
=
(
0
,
-
80
,
0
))
# 坐标轴
# vertsx = ((0, 0, 0), (10, 0, 0))
# Entity(model=Mesh(vertices=vertsx, mode='line', thickness=3), color=color.cyan).set_light_off()
# vertsyz = [(0, 0, 0), (0, 10, 0), (0, 0, 0), (0, 0, 10)]
# Entity(model=Mesh(vertices=vertsyz, mode='line', thickness=3), color=color.yellow).set_light_off()
grid
.
set_light_off
()
# 坐标轴
# vertsx = ((0, 0, 0), (10, 0, 0))
# Entity(model=Mesh(vertices=vertsx, mode='line', thickness=3), color=color.red).set_light_off()
#
# vertsy = [(0, 0, 0), (0, 10, 0)]
# Entity(model=Mesh(vertices=vertsy, mode='line', thickness=3), color=color.green).set_light_off()
#
# vertsz = [(0, 0, 0), (0, 0, 10)]
# Entity(model=Mesh(vertices=vertsz, mode='line', thickness=3), color=color.blue).set_light_off()
class
UrsinaSimulator
(
Simulator
):
"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录