diff --git a/objs/halley_comet.py b/objs/halley_comet.py index 04478d3530c26caa869a02aa26eb9c1f293e4c63..c20c63d0a9900a633dd1cd1332a390c229feb68b 100644 --- a/objs/halley_comet.py +++ b/objs/halley_comet.py @@ -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 diff --git a/simulators/ursina/entities/planet.py b/simulators/ursina/entities/planet.py index df3db8658791f8a11584fae51cc8ee7eb4663d3a..7e31b69b883e22aa027210474d3e5d416230f90a 100644 --- a/simulators/ursina/entities/planet.py +++ b/simulators/ursina/entities/planet.py @@ -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): """