Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
19492412
宇宙模拟器
项目概览
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看板
提交
19492412
编写于
11月 14, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
8515a208
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
22 addition
and
6 deletion
+22
-6
objs/halley_comet.py
objs/halley_comet.py
+1
-1
simulators/ursina/entities/planet.py
simulators/ursina/entities/planet.py
+21
-5
未找到文件。
objs/halley_comet.py
浏览文件 @
19492412
...
@@ -50,7 +50,7 @@ class HalleComet(RockSnow):
...
@@ -50,7 +50,7 @@ class HalleComet(RockSnow):
super
().
__init__
(
**
params
)
super
().
__init__
(
**
params
)
# create_cone(radius, height, subdivisions, r=0.1)
# 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.07
,
0.20
,
2
,
10
0
)
self
.
comet_info
=
(
0.07
,
0.20
,
2
,
2
0
)
from
ursina.prefabs.primitives
import
Shader
from
ursina.prefabs.primitives
import
Shader
...
...
simulators/ursina/entities/planet.py
浏览文件 @
19492412
...
@@ -8,7 +8,8 @@
...
@@ -8,7 +8,8 @@
# ==============================================================================
# ==============================================================================
# pip install -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com ursina
# pip install -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com ursina
from
ursina
import
application
,
Entity
,
camera
,
color
,
Vec3
,
Text
,
load_texture
,
destroy
,
PointLight
from
ursina
import
application
,
Entity
,
camera
,
color
,
Vec3
,
Text
,
load_texture
,
destroy
,
PointLight
import
time
import
random
from
common.image_utils
import
find_texture
from
common.image_utils
import
find_texture
from
simulators.ursina.entities.entity_utils
import
create_name_text
,
create_trails
,
clear_trails
,
create_rings
,
\
from
simulators.ursina.entities.entity_utils
import
create_name_text
,
create_trails
,
clear_trails
,
create_rings
,
\
trail_init
,
create_fixed_star_lights
trail_init
,
create_fixed_star_lights
...
@@ -191,7 +192,7 @@ class Planet(Entity):
...
@@ -191,7 +192,7 @@ class Planet(Entity):
comet_num
=
2
comet_num
=
2
for
i
in
range
(
1
,
comet_num
):
for
i
in
range
(
1
,
comet_num
):
c
=
Entity
(
parent
=
self
.
comet_trail
,
model
=
create_comet_trail
(
*
comet_info
),
c
=
Entity
(
parent
=
self
.
comet_trail
,
model
=
create_comet_trail
(
*
comet_info
),
texture
=
texture
,
scale
=
1
+
i
*
0.0
1
,
texture
=
texture
,
scale
=
1
+
i
*
0.0
2
,
position
=
(
0
,
0
,
0
),
position
=
(
0
,
0
,
0
),
rotation
=
(
0
,
0
,
0
),
double_sided
=
True
,
alpha
=
1
)
rotation
=
(
0
,
0
,
0
),
double_sided
=
True
,
alpha
=
1
)
c
.
set_light_off
()
c
.
set_light_off
()
...
@@ -200,6 +201,11 @@ class Planet(Entity):
...
@@ -200,6 +201,11 @@ class Planet(Entity):
# self.comet_sphere = Entity(parent=self, model="sphere", texture="",
# self.comet_sphere = Entity(parent=self, model="sphere", texture="",
# color=color.white, scale=2.2, double_sided=True, alpha=0.6)
# color=color.white, scale=2.2, double_sided=True, alpha=0.6)
def
set_alpha
(
alpha
):
def
set_alpha
(
alpha
):
"""
设置尾巴的透明度
@param alpha:
@return:
"""
self
.
comet_trail
.
enabled
=
(
alpha
>
0.01
)
self
.
comet_trail
.
enabled
=
(
alpha
>
0.01
)
if
self
.
comet_trail
.
enabled
:
if
self
.
comet_trail
.
enabled
:
self
.
comet_trail
.
alpha
=
alpha
/
2
self
.
comet_trail
.
alpha
=
alpha
/
2
...
@@ -210,17 +216,27 @@ class Planet(Entity):
...
@@ -210,17 +216,27 @@ class Planet(Entity):
# self.comet_sphere.alpha = alpha
# self.comet_sphere.alpha = alpha
def
comet_trail_update
():
def
comet_trail_update
():
import
random
"""
通过更新尾巴的旋转值,模拟尾巴的动画
@return:
"""
if
application
.
paused
:
return
# 1秒钟更新一次,效果就可以了
if
time
.
time
()
-
comet_trail_update
.
last_time
>=
1
:
comet_trail_update
.
last_time
=
time
.
time
()
# self.comet_trail.rotation_x += 1
# self.comet_trail.rotation_x += 1
for
c
in
self
.
comet_trail
.
children
:
for
c
in
self
.
comet_trail
.
children
:
c
.
rotation_y
+=
(
random
.
randint
(
-
20
,
20
)
/
10
)
c
.
rotation_y
+=
(
random
.
randint
(
-
20
,
20
)
/
10
)
self
.
comet_trail
.
set_alpha
=
set_alpha
self
.
comet_trail
.
set_alpha
=
set_alpha
self
.
comet_trail
.
update
=
comet_trail_update
self
.
comet_trail
.
update
=
comet_trail_update
# set_alpha(0.8)
comet_trail_update
.
last_time
=
time
.
time
()
# 设置行星环不受灯光影响,否则看不清行星环
# 设置行星环不受灯光影响,否则看不清行星环
self
.
comet_trail
.
set_light_off
()
self
.
comet_trail
.
set_light_off
()
# self.comet_sphere.set_light_off()
def
create_rotate_entity
(
self
):
def
create_rotate_entity
(
self
):
"""
"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录