def drawTriangle(self, node, submap_center, submap_xel, triangle_index, nodes_ZTH, open_simplex): global god center_map = submap_xel for d in range(1, Map.radius + 1): # distance from center moving along triangle side t center_map = center_map.link[dirs[triangle_index]] tmp_map = center_map for n in range( 0, d ): # each cell from triangle_index triangle edge (included) to next triangle edge (excluded) if d == Map.radius and n == 0: cell_z = nodes_ZTH[0][triangle_index] cell_t = nodes_ZTH[1][triangle_index] cell_h = nodes_ZTH[2][triangle_index] else: interna = ((nodes_ZTH[0][6], nodes_ZTH[0][triangle_index], nodes_ZTH[0][(triangle_index + 1) % 6]), (nodes_ZTH[1][6], nodes_ZTH[1][triangle_index], nodes_ZTH[1][(triangle_index + 1) % 6]), (nodes_ZTH[2][6], nodes_ZTH[2][triangle_index], nodes_ZTH[2][(triangle_index + 1) % 6])) res = ExaRandom.interpolate( self, interna, Map.radius, (tmp_map.exa.e, tmp_map.exa.x, tmp_map.exa.a)) (cell_z, cell_t, cell_h) = res cell_z += open_simplex.noise2d(tmp_map.exa.x, tmp_map.exa.e) / 5 esterna = god.creation( submap_center, (tmp_map.exa.e, tmp_map.exa.x, tmp_map.exa.a), cell_t, cell_h) #animale, vegetale, terreno #load models dx, dy = submap_center (q, r) = tmp_map.exa.x, tmp_map.exa.e v_center = VBase2(s3 * q, v3s * 2 * (q / 2 + r)) if esterna[0] != None: self.model.loadAnimal(node, v_center[0] + dx, v_center[1] + dy, cell_z, esterna[0].nome) if esterna[1] != None: self.model.loadPlant(node, v_center[0] - side + dx, v_center[1] + dy, cell_z, esterna[1].nome) if esterna[2] != None: terrain_name = esterna[2].nome else: terrain_name = "rock" self.insertTile(node, submap_center, tmp_map, cell_z, terrain_name) tmp_map = tmp_map.link[dirs[(triangle_index + 2) % 6]]
def resetProperties(self): self.seaLevel = 0 self.center = 0 self.anchor = None self.overallSpeed = 0 self.uvSpeed = Vec2(0, 0) self.threshold = 0 self.radius = 0 self.uvScale = VBase2(0, 0) self.waveEnabled = 0 self.high = Vec4(0, 0, 0, 0) self.mid = VBase4(0, 0, 0, 0) self.low = Vec4(0, 0, 0, 0)
def __init__(self): self.seaLevel = 0 self.center = 0 self.anchor = None self.overallSpeed = 0 self.uvSpeed = Vec2(0, 0) self.thresfold = 0 self.radius = 0 self.uvScale = VBase2(0, 0) self.waveEnabled = 0 self.high = VBase4(0, 0, 0, 0) self.mid = VBase4(0, 0, 0, 0) self.low = VBase4(0, 0, 0, 0)
def insertTile(self, node, submap_center, xel: Xel.Xel, tile_z, terrain): dx, dy = submap_center (q, r) = xel.exa.x, xel.exa.e v_center = VBase2(s3 * q, v3s * 2 * (q / 2 + r)) tile_color = "rock" #TODO #if abs(q) == Map.radius or abs(r) == Map.radius or abs(xel.exa.a) == Map.radius: # tile_color = "yellow" #else: #temporary if terrain == "water": tile_z = 0 tile_color = terrain return self.model.loadExaTile(node, v_center[0] + dx, v_center[1] + dy, tile_z, tile_color)
def setup(self): # Store current values self.entry_background_color = VBase4(base.win.get_clear_color()) self.entry_cam_pos = VBase3(base.cam.get_pos()) self.entry_cam_hpr = VBase3(base.cam.get_hpr()) self.entry_cam_scale = VBase3(base.cam.get_scale()) self.entry_cam_fov = VBase2(base.cam.node().get_lens().get_fov()) # Set values for splash base.win.set_clear_color((0,0,0,1)) cam_dist = 2 base.cam.set_pos(0, -2.2 * cam_dist, 0) base.cam.set_hpr(0, 0, 0) base.cam.set_scale(1) base.cam.node().get_lens().set_fov(45/cam_dist) # Set up the splash itself self.logo_animation = Actor(asset_path / "panda3d_logo.bam") self.logo_animation.reparent_to(render) self.logo_animation.set_two_sided(True) shader = Shader.load( Shader.SL_GLSL, vertex=asset_path / "panda3d_logo.vert", fragment=asset_path / "panda3d_logo.frag", ) self.logo_animation.set_shader(shader) self.logo_animation.set_shader_input("fade", 0.0) self.logo_animation.set_shader_input("pattern", self.pattern.value) self.logo_animation.set_shader_input("colors", self.colors.value) self.logo_animation.set_shader_input("pattern_freq", self.pattern_freq) self.logo_animation.set_shader_input("cycle_freq", self.cycle_freq) self.logo_sound = base.loader.loadSfx(asset_path / "panda3d_logo.wav") # Build interval def shader_time(t): self.logo_animation.set_shader_input("time", t) def fade_background_to_white(t): base.win.set_clear_color((t,t,t,1)) self.logo_animation.set_shader_input("time", t/3.878) self.logo_animation.set_shader_input("fade", t) def fade_to_black(t): base.win.set_clear_color((1-t,1-t,1-t,1)) #self.logo_animation.set_shader_input("time", t/3.878) #self.logo_animation.set_shader_input("fade", t) # Timing: # 0.000 Start # 3.878 Logo is assembled, fade to black-on-whitey # 4.878 Black on white achieved # <+1.500> Begin fade to black # <+1.741> Black on black achieved # 8.119 Sound ends effects = Parallel( self.logo_animation.actorInterval( "splash", loop=False, ), SoundInterval( self.logo_sound, loop=False, ), Sequence( LerpFunc( shader_time, fromData=0, toData=1, duration=3.878, ), LerpFunc( fade_background_to_white, fromData=0, toData=1, duration=1.0, ), Wait(1.5), LerpFunc( fade_to_black, fromData=0, toData=1, duration=1.741, ), ), ) return effects
def obj_translate(self, value): self._obj_translate = VBase2(*value)