def readLights(self,light_data): self.lights = [] i = 0 for light in light_data: name = '%s light %d' % (light['type'], i ) pl = None if light['type'] == 'point': pl = PointLight( name ) pl.setPoint(Point3(*light['pos'])) pl.setColor(Vec4(*light['color']) ) elif light['type'] == 'directional': pl = DirectionalLight( name ) pl.setColor(Vec4(*light['color']) ) elif light['type'] == 'ambient': pl = AmbientLight( name ) pl.setColor(Vec4(*light['color']) ) #not implemented #elif light['type'] == 'spotlight': # pl = Spotlight( name ) #if it's allright if pl != None: self.lights.append(NodePath(pl)) i += 1
def activateStar(self, player): ''' Activates a constructed dead star object, starting the lifetime counter with the assigned default value while the Game Engine calls the graphic engine to display the corresponding animation. @param player, the player who has activated the star ''' self.lifetime = LIFETIME self.stage = 1 self.activated = True self.radius = MAX_STAR_RADIUS self.player = player self.timer_task = taskMgr.doMethodLater(1, self.trackStarLife, 'starLifeTick') player.selected_star = self # point_light = PointLight("starLight") # point_light.setColor(Vec4(1.0, 1.0, 1.0, 1.0)) # pt_node = render.attachNewNode(point_light) ## pt_node.setHpr(60, 0, 90) # pt_node.setPos(Vec3(0, 0, -40.0)) # render.setLight(pt_node) point_light = PointLight("starLight") point_light.setColor(Vec4(1.0, 1.0, 1.0, 1.0)) point_light.setPoint(Point3(0, 0, 0)) pt_node = self.point_path.attachNewNode(point_light) # pt_node.setHpr(60, 0, 90) render.setLight(pt_node) '''TODO : display star birth animation ''' star_created_sound = base.loader.loadSfx("sound/effects/star/starCreation1.wav") star_created_sound.setVolume(0.6) star_created_sound.play() # base.sfxManagerList[0].update() # SphericalBody.star_created_sound1.play() #SphericalBody.star_created_sound2.play() self.radius = MAX_STAR_RADIUS self.model_path.setScale(self.radius) self.model_path.setTexture(self.flare_ts, SphericalBody.star_stage1_tex) self._activateSunflare()