提交 19492412 编写于 作者: 三月三net's avatar 三月三net

Python超人-宇宙模拟器

上级 8515a208
......@@ -50,7 +50,7 @@ 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.07, 0.20, 2, 100)
self.comet_info = (0.07, 0.20, 2, 20)
from ursina.prefabs.primitives import Shader
......
......@@ -8,7 +8,8 @@
# ==============================================================================
# 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
import time
import random
from common.image_utils import find_texture
from simulators.ursina.entities.entity_utils import create_name_text, create_trails, clear_trails, create_rings, \
trail_init, create_fixed_star_lights
......@@ -191,7 +192,7 @@ class Planet(Entity):
comet_num = 2
for i in range(1, comet_num):
c = Entity(parent=self.comet_trail, model=create_comet_trail(*comet_info),
texture=texture, scale=1 + i * 0.01,
texture=texture, scale=1 + i * 0.02,
position=(0, 0, 0),
rotation=(0, 0, 0), double_sided=True, alpha=1)
c.set_light_off()
......@@ -200,6 +201,11 @@ class Planet(Entity):
# self.comet_sphere = Entity(parent=self, model="sphere", texture="",
# color=color.white, scale=2.2, double_sided=True, alpha=0.6)
def set_alpha(alpha):
"""
设置尾巴的透明度
@param alpha:
@return:
"""
self.comet_trail.enabled = (alpha > 0.01)
if self.comet_trail.enabled:
self.comet_trail.alpha = alpha / 2
......@@ -210,17 +216,27 @@ class Planet(Entity):
# self.comet_sphere.alpha = alpha
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
for c in self.comet_trail.children:
c.rotation_y += (random.randint(-20, 20) / 10)
self.comet_trail.set_alpha = set_alpha
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_sphere.set_light_off()
def create_rotate_entity(self):
"""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册