Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
50d20da6
宇宙模拟器
项目概览
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看板
提交
50d20da6
编写于
11月 17, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
81cbd6e3
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
50 addition
and
3 deletion
+50
-3
common/color_utils.py
common/color_utils.py
+31
-0
sim_scenes/solar_system/solar_system_reality.py
sim_scenes/solar_system/solar_system_reality.py
+1
-1
simulators/ursina/entities/entity_utils.py
simulators/ursina/entities/entity_utils.py
+17
-1
simulators/ursina/ursina_mesh.py
simulators/ursina/ursina_mesh.py
+1
-1
textures/fixed_star_glow.png
textures/fixed_star_glow.png
+0
-0
未找到文件。
common/color_utils.py
浏览文件 @
50d20da6
...
...
@@ -34,6 +34,15 @@ def conv_to_vec4_color(colour: tuple, alpha=1):
# color = ursina_color.rgba(r, g, b, a)
def
white_brightest
(
color
,
min_value
=
220
):
# x = y/255*(255-min_value) + min_value
r
,
g
,
b
=
color
r
=
min
(
255
,
int
(
r
/
255
*
(
255
-
min_value
)
+
min_value
))
g
=
min
(
255
,
int
(
g
/
255
*
(
255
-
min_value
)
+
min_value
))
b
=
min
(
255
,
int
(
b
/
255
*
(
255
-
min_value
)
+
min_value
))
return
r
,
g
,
b
def
brightest
(
color
):
if
isinstance
(
color
,
tuple
):
r
,
g
,
b
=
color
...
...
@@ -51,6 +60,28 @@ def brightest(color):
return
[
r
,
g
,
b
]
def
fixed_star_color_brightest
(
c
,
ursina_color
=
False
):
if
c
is
None
:
bc
=
(
255
,
255
,
255
)
else
:
bc
=
white_brightest
(
c
)
if
ursina_color
:
return
conv_to_vec4_color
(
bc
)
return
bc
def
brightest_color
(
c
,
ursina_color
=
False
):
if
c
is
None
:
bc
=
(
255
,
255
,
255
)
else
:
bc
=
brightest
(
c
)
if
ursina_color
:
return
conv_to_vec4_color
(
bc
)
return
bc
def
trail_color_brightest
(
bodies
):
"""
天体尾巴最亮
...
...
sim_scenes/solar_system/solar_system_reality.py
浏览文件 @
50d20da6
...
...
@@ -192,7 +192,7 @@ class SolarSystemRealitySim:
# 创建太阳系天体
self
.
create_bodies
()
# glows = (glow_num:10, glow_scale:1.03 glow_alpha:0.1~1)
self
.
sun
.
glows
=
(
80
,
1.005
,
0.0
1
)
self
.
sun
.
glows
=
(
4
,
1.005
,
0.
1
)
# 对地球进行初始化
self
.
init_earth
()
...
...
simulators/ursina/entities/entity_utils.py
浏览文件 @
50d20da6
...
...
@@ -11,10 +11,12 @@ from ursina import Ursina, window, Entity, Mesh, SmoothFollow, Texture, clamp, t
camera
,
color
,
mouse
,
Vec2
,
Vec3
,
Vec4
,
Text
,
\
load_texture
,
held_keys
,
destroy
,
PointLight
,
DirectionalLight
,
distance
from
common
import
color_utils
from
common.image_utils
import
find_texture
from
simulators.ursina.entities.body_trail
import
BodyTrail
,
BodyTrailLine
from
simulators.ursina.ursina_config
import
UrsinaConfig
from
common.color_utils
import
adjust_brightness
,
conv_to_vec4_color
,
get_inverse_color
from
simulators.ursina.ursina_mesh
import
create_torus
from
simulators.ursina.ursina_mesh
import
create_torus
,
create_circle
from
common.func
import
find_file
import
math
import
numpy
as
np
...
...
@@ -356,10 +358,24 @@ def create_fixed_star_lights(fixed_star):
# _color = color.white
_color
=
fixed_star
.
body_view
.
body
.
color
_color
=
color
.
rgba
(
_color
[
0
]
/
255
,
_color
[
1
]
/
255
,
_color
[
2
]
/
255
,
1
)
for
i
in
range
(
glow_num
):
glow_entity
=
Entity
(
parent
=
fixed_star
,
model
=
'sphere'
,
color
=
_color
,
scale
=
math
.
pow
(
glow_scale
,
i
+
1
),
alpha
=
glow_alpha
)
if
glow_num
<
5
:
bright_color
=
color_utils
.
fixed_star_color_brightest
(
fixed_star
.
body_view
.
body
.
color
,
True
)
glow_circle
=
create_circle
(
parent
=
None
,
pos
=
fixed_star
.
position
,
scale
=
fixed_star
.
scale
*
1.8
)
glow_circle
.
texture
=
find_texture
(
"fixed_star_glow.png"
)
glow_circle
.
color
=
bright_color
glow_circle
.
set_light_off
(
True
)
def
glow_circle_update
():
# from ursina import camera
glow_circle
.
look_at
(
camera
)
glow_circle
.
update
=
glow_circle_update
if
hasattr
(
fixed_star
.
body_view
.
body
,
"light_on"
):
if
fixed_star
.
body_view
.
body
.
light_on
:
for
i
in
range
(
2
):
...
...
simulators/ursina/ursina_mesh.py
浏览文件 @
50d20da6
...
...
@@ -473,7 +473,7 @@ def create_line(from_pos, to_pos, parent=None, alpha=1.0, len_scale=1, set_light
def
create_circle
(
parent
=
None
,
pos
=
Vec3
(
0
,
0
,
0
),
thickness
=
1
,
scale
=
1
,
color
=
color
.
white
,
alpha
=
1
):
circle
=
Entity
(
parent
=
parent
,
model
=
"circle"
,
thickness
=
thickness
,
scale
=
scale
,
position
=
pos
,
color
=
color
,
alpha
=
alpha
)
color
=
color
,
alpha
=
alpha
,
double_sided
=
True
)
return
circle
...
...
textures/fixed_star_glow.png
0 → 100644
浏览文件 @
50d20da6
248.0 KB
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录