Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
4336543d
宇宙模拟器
项目概览
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看板
提交
4336543d
编写于
11月 13, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
ce5702ba
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
61 addition
and
5 deletion
+61
-5
objs/halley_comet.py
objs/halley_comet.py
+2
-1
objs/textures/comet_trail.png
objs/textures/comet_trail.png
+0
-0
simulators/ursina/entities/planet.py
simulators/ursina/entities/planet.py
+3
-4
simulators/ursina/ursina_mesh.py
simulators/ursina/ursina_mesh.py
+56
-0
textures/grid.png
textures/grid.png
+0
-0
textures/grid_r.png
textures/grid_r.png
+0
-0
未找到文件。
objs/halley_comet.py
浏览文件 @
4336543d
...
...
@@ -49,7 +49,8 @@ class HalleComet(RockSnow):
}
super
().
__init__
(
**
params
)
# create_cone(radius, height, subdivisions, r=0.1)
self
.
comet_info
=
(
0.18
,
2.0
,
100
,
0.2
)
# self.comet_info = (0.18, 2.0, 100, 0.2)
self
.
comet_info
=
(
0.03
,
0.18
,
1.5
,
100
)
from
ursina.prefabs.primitives
import
Shader
...
...
objs/textures/comet_trail.png
查看替换文件 @
ce5702ba
浏览文件 @
4336543d
432.3 KB
|
W:
|
H:
383.2 KB
|
W:
|
H:
2-up
Swipe
Onion skin
simulators/ursina/entities/planet.py
浏览文件 @
4336543d
...
...
@@ -18,7 +18,7 @@ from common.color_utils import adjust_brightness, conv_to_vec4_color, get_invers
from
common.func
import
find_file
from
simulators.views.body_view
import
BodyView
from
simulators.ursina.ursina_mesh
import
create_sphere
,
create_torus
,
create_arrow_line
,
create_line
,
create_label
,
\
create_cone
create_cone
,
create_frustum
import
math
...
...
@@ -182,10 +182,9 @@ class Planet(Entity):
create_rings
(
self
)
def
create_comet_trail
(
self
,
comet_info
):
# cone = create_cone(0.25, 1.5, 100, 0.18)
cone
=
create_cone
(
*
comet_info
)
comet_mesh
=
create_frustum
(
*
comet_info
)
texture
=
find_texture
(
"comet_trail.png"
)
self
.
comet_trail
=
Entity
(
parent
=
self
,
model
=
co
ne
,
texture
=
texture
,
scale
=
20
,
self
.
comet_trail
=
Entity
(
parent
=
self
,
model
=
co
met_mesh
,
texture
=
texture
,
scale
=
20
,
position
=
(
0
,
0
,
0
),
rotation
=
(
0
,
90
,
90
),
double_sided
=
True
,
alpha
=
0.8
)
...
...
simulators/ursina/ursina_mesh.py
浏览文件 @
4336543d
...
...
@@ -116,6 +116,62 @@ def create_cone(radius, height, subdivisions, r=0.1):
return
Mesh
(
vertices
=
verts
,
triangles
=
tris
,
normals
=
normals
,
uvs
=
uvs
,
mode
=
'triangle'
)
import
math
def
create_frustum
(
bottom_radius
,
top_radius
,
height
,
subdivisions
):
"""
创建一个圆台
@param bottom_radius: 圆台底部的半径
@param top_radius: 圆台顶部的半径
@param height: 圆台的高度
@param subdivisions: 细分数,用于控制圆台的光滑度
@return: Mesh对象,表示创建的圆台
"""
verts
=
[]
# 顶点列表
tris
=
[]
# 三角面索引列表
normals
=
[]
# 法线列表
uvs
=
[]
# UV坐标列表
# 生成圆台底部的顶点和UV坐标
for
i
in
range
(
subdivisions
):
angle
=
2
*
math
.
pi
*
i
/
subdivisions
x
=
bottom_radius
*
math
.
cos
(
angle
)
z
=
bottom_radius
*
math
.
sin
(
angle
)
verts
.
append
(
Vec3
(
x
,
0
,
z
))
uvs
.
append
(
Vec2
(
i
/
subdivisions
,
0
))
# 生成圆台顶部的顶点和UV坐标
for
i
in
range
(
subdivisions
):
angle
=
2
*
math
.
pi
*
i
/
subdivisions
x
=
top_radius
*
math
.
cos
(
angle
)
z
=
top_radius
*
math
.
sin
(
angle
)
verts
.
append
(
Vec3
(
x
,
height
,
z
))
uvs
.
append
(
Vec2
(
i
/
subdivisions
,
1
))
# 生成圆台侧面的顶点、法线和三角面
for
i
in
range
(
subdivisions
):
# 底部顶点索引
bottom_index
=
i
# 顶部顶点索引
top_index
=
i
+
subdivisions
# 下一个底部顶点索引
next_bottom_index
=
(
i
+
1
)
%
subdivisions
# 下一个顶部顶点索引
next_top_index
=
(
i
+
1
)
%
subdivisions
+
subdivisions
# 侧面三角形
tris
.
append
((
bottom_index
,
next_bottom_index
,
top_index
))
tris
.
append
((
next_bottom_index
,
next_top_index
,
top_index
))
# 侧面法线
normal
=
(
verts
[
top_index
]
-
verts
[
bottom_index
]).
cross
(
verts
[
next_bottom_index
]
-
verts
[
bottom_index
]).
normalized
()
normals
.
append
(
normal
)
normals
.
append
(
normal
)
return
Mesh
(
vertices
=
verts
,
triangles
=
tris
,
normals
=
normals
,
uvs
=
uvs
,
mode
=
'triangle'
)
def
create_cylinder
(
radius
,
height
,
subdivisions
):
"""
创建一个圆柱体
...
...
textures/grid.png
0 → 100644
浏览文件 @
4336543d
153 字节
textures/grid_r.png
0 → 100644
浏览文件 @
4336543d
297 字节
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录