Exemple #1
0
 def startEffects(self):
     if not self.fireflies:
         self.fireflies = Fireflies()
     
     if self.fireflies and hasattr(base, 'cr'):
         self.fireflies.reparentTo(base.localAvatar)
         self.fireflies.startLoop()
     
     base.ambientMgr.requestFadeIn(SoundGlobals.AMBIENT_JUNGLE, duration = 10, finalVolume = PiratesGlobals.DEFAULT_AMBIENT_VOLUME, priority = 1)
     self.swamp_water = None
     reflection = Reflection.getGlobalReflection()
     if 'jungle_a' in self.modelPrefix:
         if base.config.GetBool('want-shaders', 1) and base.win and base.win.getGsg() and base.win.getGsg().getShaderModel() >= GraphicsStateGuardian.SM20:
             water_color = Vec4(13, 15, 21, 255.0)
             self.water = Swamp(self.modelPrefix + 'water', self.parent, reflection, None, None, water_color)
             self.water.reflection_factor = 0.29999999999999999
             self.water.set_reflection_parameters_np()
         else:
             water = loader.loadModel(self.modelPrefix + 'water')
             water.reparentTo(self.parent)
             color = Vec4(0)
             water.setColorScale(color)
             mask = 0xFFFFFFFFL
             stencil = StencilAttrib.make(1, StencilAttrib.SCFAlways, StencilAttrib.SOKeep, StencilAttrib.SOKeep, StencilAttrib.SOReplace, 1, mask, mask)
             water.setAttrib(stencil)
             water.setBin('water', 0)
             self.reflection = reflection
             taskMgr.add(self.camTask, 'jungleEffectsCamTask-' + str(id(self)), priority = 49)
             water.setFogOff()
     
     for file in self.randomAnimalSoundFiles:
         sfx = loadSfx(file)
         self.randomSfx.append(sfx)
     
     taskMgr.doMethodLater(self.RANDOM_SOUND_PERIOD, self.checkForRandomSound, name = 'checkForRandomSound-' + str(id(self)))
    def startEffects(self):
        if not self.fireflies:
            self.fireflies = Fireflies()
        if self.fireflies:
            if hasattr(base, 'cr'):
                self.fireflies.reparentTo(base.localAvatar)
                self.fireflies.startLoop()
            base.ambientMgr.requestFadeIn(SoundGlobals.AMBIENT_JUNGLE, duration=10, finalVolume=PiratesGlobals.DEFAULT_AMBIENT_VOLUME, priority=1)
            self.swamp_water = None
            reflection = Reflection.getGlobalReflection()
            if 'jungle_a' in self.modelPrefix:
                water_color = base.config.GetBool('want-shaders', 1) and base.win and base.win.getGsg() and base.win.getGsg().getShaderModel() >= GraphicsStateGuardian.SM20 and Vec4(13, 15, 21, 255.0)
                self.water = Swamp(self.modelPrefix + 'water', self.parent, reflection, None, None, water_color)
                self.water.reflection_factor = 0.3
                self.water.set_reflection_parameters_np()
            else:
                water = loader.loadModel(self.modelPrefix + 'water')
                water.reparentTo(self.parent)
                color = Vec4(0)
                water.setColorScale(color)
                mask = 4294967295L
                stencil = StencilAttrib.make(1, StencilAttrib.SCFAlways, StencilAttrib.SOKeep, StencilAttrib.SOKeep, StencilAttrib.SOReplace, 1, mask, mask)
                water.setAttrib(stencil)
                water.setBin('water', 0)
                self.reflection = reflection
                taskMgr.add(self.camTask, 'jungleEffectsCamTask-' + str(id(self)), priority=49)
                water.setFogOff()
        for file in self.randomAnimalSoundFiles:
            sfx = loadSfx(file)
            self.randomSfx.append(sfx)

        taskMgr.doMethodLater(self.RANDOM_SOUND_PERIOD, self.checkForRandomSound, name='checkForRandomSound-' + str(id(self)))
        return
    def startEffects(self):
        self.swamp_water = None
        if base.config.GetBool(
                'want-shaders',
                1) and base.win and base.win.getGsg() and base.win.getGsg(
                ).getShaderModel() >= GraphicsStateGuardian.SM20:
            reflection = Reflection.getGlobalReflection()
            self.swamp_water = Swamp(self.modelPath + '_water', self.parent,
                                     reflection)
        else:
            self.water = loader.loadModel(self.modelPath + '_water')
            self.water.reparentTo(self.parent)
            self.water.setTransparency(TransparencyAttrib.MNone, 100)
            alpha_test_attrib = AlphaTestAttrib.make(RenderAttrib.MAlways, 0)
            self.water.setAttrib(alpha_test_attrib, 100)
        if not self.fireflies:
            self.fireflies = Fireflies()

        if self.fireflies and hasattr(base, 'cr'):
            self.fireflies.reparentTo(base.localAvatar)
            self.fireflies.startLoop()

        if not self.groundFog:
            self.groundFog = GroundFog()

        if self.groundFog and hasattr(base, 'options'):
            if base.options.getSpecialEffectsSetting(
            ) >= base.options.SpecialEffectsMedium:
                self.groundFog.reparentTo(base.localAvatar)
                self.groundFog.startLoop(
                    base.options.getSpecialEffectsSetting())

        if hasattr(base, 'cr') and not hasattr(base.cr, 'isFake'):
            taskMgr.add(self.adjustGroundFogZ,
                        self.parent.uniqueName('groundFogZTask'))

        base.ambientMgr.requestFadeIn(
            SoundGlobals.AMBIENT_SWAMP,
            duration=10,
            finalVolume=PiratesGlobals.DEFAULT_AMBIENT_VOLUME,
            priority=1)
        for file in self.randomAnimalSoundFiles:
            sfx = loadSfx(file)
            self.randomSfx.append(sfx)

        taskMgr.doMethodLater(self.RANDOM_SOUND_PERIOD,
                              self.checkForRandomSound,
                              name='checkForRandomSound-' + str(id(self)))
 def startEffects(self):
     reflection = Reflection.getGlobalReflection()
     non_shader_water_color = Vec4(0.0, 1.0 / 255.0, 4.0 / 255.0, 1.0)
     shader_water_color = Vec4(0.0, 1.0, 4.0, 255.0)
     if self.parent.uniqueId in self.WaterCaves:
         if base.config.GetBool('want-shaders', 1) and base.win and base.win.getGsg() and base.win.getGsg().getShaderModel() >= GraphicsStateGuardian.SM20:
             self.water = Swamp('models/caves/cave_a_water', self.parent, reflection, None, None, shader_water_color)
             self.water.reflection_factor = 0.29999999999999999
             self.water.set_reflection_parameters_np()
         else:
             water = loader.loadModel('models/caves/cave_a_water')
             water.reparentTo(self.parent)
             color = non_shader_water_color
             water.setColorScale(color)
             water.setTextureOff(1)
             mask = 0xFFFFFFFFL
             stencil = StencilAttrib.make(1, StencilAttrib.SCFAlways, StencilAttrib.SOKeep, StencilAttrib.SOKeep, StencilAttrib.SOReplace, 1, mask, mask)
             water.setAttrib(stencil)
             water.setBin('water', 0)
             self.reflection = reflection
             taskMgr.add(self.camTask, 'caveEffectsCamTask-' + str(id(self)), priority = 49)
             water.setFogOff()
     elif self.parent.uniqueId in self.LavaCaves:
         if base.config.GetBool('want-shaders', 1) and base.win and base.win.getGsg() and base.win.getGsg().getShaderModel() >= GraphicsStateGuardian.SM20:
             self.water = Swamp(self.modelPrefix + 'lava', self.parent, reflection, None, None, shader_water_color)
             l1 = LerpScaleInterval(self.water.seamodel, 2, Vec3(1.006, 1.006, 1.0), Vec3(1.0, 1.0, 1.0), blendType = 'easeInOut')
             l2 = LerpScaleInterval(self.water.seamodel, 2, Vec3(1.0, 1.0, 1.0), Vec3(1.006, 1.006, 1.0), blendType = 'easeInOut')
             seq = Sequence(l1, l2)
             seq.loop()
             self.water.reflection_factor = 0.29999999999999999
             self.water.set_reflection_parameters_np()
         else:
             water = loader.loadModel(self.modelPrefix + 'lava')
             water.reparentTo(self.parent)
             water.setFogOff()
     
     base.ambientMgr.requestFadeIn(SoundGlobals.AMBIENT_CAVE, duration = 10, finalVolume = PiratesGlobals.DEFAULT_AMBIENT_VOLUME, priority = 1)
     if self.water:
         self.water.supports_sky_only = self.supports_sky_only
     
     if reflection:
         if base.options.reflection >= 1:
             reflection.reflectShowThroughOnly(False)
             reflection.enable(True)
 def startEffects(self):
     reflection = Reflection.getGlobalReflection()
     non_shader_water_color = Vec4(0.0, 1.0 / 255.0, 4.0 / 255.0, 1.0)
     shader_water_color = Vec4(0.0, 1.0, 4.0, 255.0)
     if self.parent.uniqueId in self.WaterCaves:
         if base.config.GetBool('want-shaders', 1) and base.win and base.win.getGsg() and base.win.getGsg().getShaderModel() >= GraphicsStateGuardian.SM20:
             self.water = Swamp('models/caves/cave_a_water', self.parent, reflection, None, None, shader_water_color)
             self.water.reflection_factor = 0.3
             self.water.set_reflection_parameters_np()
         else:
             water = loader.loadModel('models/caves/cave_a_water')
             water.reparentTo(self.parent)
             color = non_shader_water_color
             water.setColorScale(color)
             water.setTextureOff(1)
             mask = 4294967295L
             stencil = StencilAttrib.make(1, StencilAttrib.SCFAlways, StencilAttrib.SOKeep, StencilAttrib.SOKeep, StencilAttrib.SOReplace, 1, mask, mask)
             water.setAttrib(stencil)
             water.setBin('water', 0)
             self.reflection = reflection
             taskMgr.add(self.camTask, 'caveEffectsCamTask-' + str(id(self)), priority=49)
             water.setFogOff()
     elif self.parent.uniqueId in self.LavaCaves:
         if base.config.GetBool('want-shaders', 1) and base.win and base.win.getGsg() and base.win.getGsg().getShaderModel() >= GraphicsStateGuardian.SM20:
             self.water = Swamp(self.modelPrefix + 'lava', self.parent, reflection, None, None, shader_water_color)
             l1 = LerpScaleInterval(self.water.seamodel, 2, Vec3(1.006, 1.006, 1.0), Vec3(1.0, 1.0, 1.0), blendType='easeInOut')
             l2 = LerpScaleInterval(self.water.seamodel, 2, Vec3(1.0, 1.0, 1.0), Vec3(1.006, 1.006, 1.0), blendType='easeInOut')
             seq = Sequence(l1, l2)
             seq.loop()
             self.water.reflection_factor = 0.3
             self.water.set_reflection_parameters_np()
         else:
             water = loader.loadModel(self.modelPrefix + 'lava')
             water.reparentTo(self.parent)
             water.setFogOff()
     base.ambientMgr.requestFadeIn(SoundGlobals.AMBIENT_CAVE, duration=10, finalVolume=PiratesGlobals.DEFAULT_AMBIENT_VOLUME, priority=1)
     if self.water:
         self.water.supports_sky_only = self.supports_sky_only
     if reflection:
         if base.options.reflection >= 1:
             reflection.reflectShowThroughOnly(False)
             reflection.enable(True)
     return
Exemple #6
0
 def startEffects(self):
     self.swamp_water = None
     if base.config.GetBool('want-shaders', 1) and base.win and base.win.getGsg() and base.win.getGsg().getShaderModel() >= GraphicsStateGuardian.SM20:
         reflection = Reflection.getGlobalReflection()
         self.swamp_water = Swamp(self.modelPath + '_water', self.parent, reflection)
     else:
         self.water = loader.loadModel(self.modelPath + '_water')
         self.water.reparentTo(self.parent)
         self.water.setTransparency(TransparencyAttrib.MNone, 100)
         alpha_test_attrib = AlphaTestAttrib.make(RenderAttrib.MAlways, 0)
         self.water.setAttrib(alpha_test_attrib, 100)
     if not self.fireflies:
         self.fireflies = Fireflies()
     
     if self.fireflies and hasattr(base, 'cr'):
         self.fireflies.reparentTo(base.localAvatar)
         self.fireflies.startLoop()
     
     if not self.groundFog:
         self.groundFog = GroundFog()
     
     if self.groundFog and hasattr(base, 'options'):
         if base.options.getSpecialEffectsSetting() >= base.options.SpecialEffectsMedium:
             self.groundFog.reparentTo(base.localAvatar)
             self.groundFog.startLoop(base.options.getSpecialEffectsSetting())
         
     
     if hasattr(base, 'cr') and not hasattr(base.cr, 'isFake'):
         taskMgr.add(self.adjustGroundFogZ, self.parent.uniqueName('groundFogZTask'))
     
     base.ambientMgr.requestFadeIn(SoundGlobals.AMBIENT_SWAMP, duration = 10, finalVolume = PiratesGlobals.DEFAULT_AMBIENT_VOLUME, priority = 1)
     for file in self.randomAnimalSoundFiles:
         sfx = loadSfx(file)
         self.randomSfx.append(sfx)
     
     taskMgr.doMethodLater(self.RANDOM_SOUND_PERIOD, self.checkForRandomSound, name = 'checkForRandomSound-' + str(id(self)))
 def initializeIslandWaterParameters(self, reference):
     debug = False
     island_water_parameters = IslandWaterParameters()
     world_position = self.getPos(render)
     world_x_offset = world_position[0]
     world_y_offset = world_position[1]
     world_z_offset = world_position[2]
     if debug:
         print self, '=', self.getName()
         print 'GAME AREA X OFF, Y OFF, Z OFF = ', world_x_offset, world_y_offset, world_z_offset
     self.swampAreaNode = reference.find('**/ocean')
     model = reference.find('**/water_color')
     if model:
         if debug:
             print 'WATER COLOR X OFF, Y OFF, Z OFF = ', world_x_offset, world_y_offset, world_z_offset
         model.hide()
         min_point = Point3(0)
         max_point = Point3(0)
         model.calcTightBounds(min_point, max_point)
         size = max_point - min_point
         if self.getH() == 180 or self.getH() == -180:
             x = -min_point[0] + world_x_offset
             y = -min_point[1] + world_y_offset
             x_size = -size[0]
             y_size = -size[1]
         else:
             x = min_point[0] + world_x_offset
             y = min_point[1] + world_y_offset
             x_size = size[0]
             y_size = size[1]
         island_water_parameters.map_x_origin = x
         island_water_parameters.map_y_origin = y
         island_water_parameters.map_x_scale = x_size
         island_water_parameters.map_y_scale = y_size
         if debug:
             print 'X, Y, X SIZE, Y SIZE = ', min_point[0], min_point[
                 1], x_size, y_size
         texture = model.findTexture('*')
         if texture:
             island_water_parameters.water_color_texture = texture
             if debug:
                 print 'WATER COLOR TEXTURE', texture
     elif debug:
         print '*** water_color NODE NOT FOUND'
     model = reference.find('**/water_alpha')
     if model:
         if debug:
             print 'WATER ALPHA X OFF, Y OFF, Z OFF = ', world_x_offset, world_y_offset, world_z_offset
         model.hide()
         min_point = Point3(0)
         max_point = Point3(0)
         model.calcTightBounds(min_point, max_point)
         size = max_point - min_point
         if self.getH() == 180 or self.getH() == -180:
             x = -min_point[0] + world_x_offset
             y = -min_point[1] + world_y_offset
             x_size = -size[0]
             y_size = -size[1]
         else:
             x = min_point[0] + world_x_offset
             y = min_point[1] + world_y_offset
             x_size = size[0]
             y_size = size[1]
         island_water_parameters.alpha_map_x_origin = x
         island_water_parameters.alpha_map_y_origin = y
         island_water_parameters.alpha_map_x_scale = x_size
         island_water_parameters.alpha_map_y_scale = y_size
         if debug:
             print 'ALPHA X, Y, X SIZE, Y SIZE = ', min_point[0], min_point[
                 1], x_size, y_size
         texture = model.findTexture('*')
         if texture:
             island_water_parameters.water_alpha_texture = texture
             if debug:
                 print 'WATER ALPHA TEXTURE', texture
     elif debug:
         print '*** water_alpha NODE NOT FOUND'
     use_shader = False
     if base.config.GetBool(
             'want-shaders',
             1) and base.win and base.win.getGsg() and base.win.getGsg(
             ).getShaderModel() >= GraphicsStateGuardian.SM20:
         use_shader = True
     model_ns = reference.find('**/water_swamp_ns')
     if model_ns:
         if use_shader:
             model_ns.hide()
         else:
             model_ns.show()
             model = model_ns
             model.setBin('water', 1)
             parent = model.getParent()
             model.detachNode()
             stencil_one_node_path = NodePath('stencil_one')
             stencil_one_node_path.reparentTo(parent)
             model.instanceTo(stencil_one_node_path)
             mask = 4294967295L
             stencil_one = StencilAttrib.make(1, StencilAttrib.SCFEqual,
                                              StencilAttrib.SOKeep,
                                              StencilAttrib.SOKeep,
                                              StencilAttrib.SOKeep, 1, mask,
                                              mask)
             stencil_one_node_path.setAttrib(stencil_one, 100)
             stencil_one_node_path.setDepthTest(0)
             if not base.useStencils:
                 stencil_one_node_path.hide()
     model_alpha_texture = None
     model_alpha = reference.find('**/water_alpha_swamp')
     if model_alpha:
         model_alpha_texture = model_alpha.findTexture('*')
         model_alpha.hide()
         if debug:
             print 'model_alpha_texture', model_alpha_texture
         if False:
             texture = model_alpha_texture
             card_x_size = 0.5
             card_y_size = 0.5
             card = CardMaker('test_texture_card')
             card.setFrame(-card_x_size, card_x_size, -card_y_size,
                           card_y_size)
             card_node_path = NodePath(card.generate())
             card_node_path.setTexture(texture, 1)
             card_node_path.node().setBounds(OmniBoundingVolume())
             card_node_path.node().setFinal(1)
             card_node_path.reparentTo(render2d)
     else:
         model_alpha = None
     model = reference.find('**/water_color_swamp')
     if model:
         if use_shader:
             model.show()
             model_texture = model.findTexture('*')
             if debug:
                 print 'WATER COLOR SWAMP X OFF, Y OFF, Z OFF = ', world_x_offset, world_y_offset, world_z_offset
             parent = model.getParent()
             model.detachNode()
             stencil_one_node_path = NodePath('stencil_one')
             stencil_one_node_path.reparentTo(parent)
             model.instanceTo(stencil_one_node_path)
             mask = 4294967295L
             stencil_one = StencilAttrib.make(1, StencilAttrib.SCFEqual,
                                              StencilAttrib.SOKeep,
                                              StencilAttrib.SOKeep,
                                              StencilAttrib.SOKeep, 1, mask,
                                              mask)
             stencil_one_node_path.setAttrib(stencil_one, 100)
             stencil_one_node_path.setDepthTest(0)
             if not base.useStencils:
                 stencil_one_node_path.hide()
             min_point = Point3(0)
             max_point = Point3(0)
             model.calcTightBounds(min_point, max_point)
             size = max_point - min_point
             if self.getH() == 180 or self.getH() == -180:
                 x = -min_point[0] + world_x_offset
                 y = -min_point[1] + world_y_offset
                 x_size = -size[0]
                 y_size = -size[1]
             else:
                 x = min_point[0] + world_x_offset
                 y = min_point[1] + world_y_offset
                 x_size = size[0]
                 y_size = size[1]
             if debug:
                 print 'min_point', min_point
                 print 'max_point', max_point
                 print 'size', size
                 print 'x y', x, y
             island_water_parameters.swamp_map_x_origin = x
             island_water_parameters.swamp_map_y_origin = y
             island_water_parameters.swamp_map_x_scale = x_size
             island_water_parameters.swamp_map_y_scale = y_size
             if debug:
                 print 'X, Y, X SIZE, Y SIZE = ', min_point[0], min_point[
                     1], x_size, y_size
             texture = model.findTexture('*')
             if texture:
                 island_water_parameters.swamp_water_color_texture = texture
                 if debug:
                     print 'SWAMP WATER COLOR TEXTURE', texture
             water_color_file_path = island_water_parameters.default_water_color_file_path
             alpha_texture_file_path = island_water_parameters.default_water_alpha_file_path
             opacity_texture_file_path = None
             shader_file_path = 'models/swamps/cuba_swamp001_2X.cg'
             reflection = Reflection.getGlobalReflection()
             self.swamp_water = Swamp(None, None, reflection, model,
                                      shader_file_path)
             island_water_parameters.swamp_water = self.swamp_water
             unload_previous_texture = True
             self.swamp_water.set_water_color_texture(
                 water_color_file_path, unload_previous_texture,
                 model_texture)
             self.swamp_water.set_water_alpha_texture(
                 alpha_texture_file_path, unload_previous_texture,
                 model_alpha_texture)
             self.swamp_water.set_wrap_or_clamp(True)
             r = 37.0
             g = 62.0
             b = 40.0
             self.swamp_water.water_r = r
             self.swamp_water.water_g = g
             self.swamp_water.water_b = b
             island_water_parameters.swamp_color_r = r
             island_water_parameters.swamp_color_g = g
             island_water_parameters.swamp_color_b = b
             x = 0.0
             y = 1.0
             speed = 3.2
             island_water_parameters.swamp_direction_x = x
             island_water_parameters.swamp_direction_y = y
             island_water_parameters.swamp_speed = speed
             self.swamp_water.update_water_direction_and_speed(x, y, speed)
         else:
             model.hide()
     elif debug:
         print '*** water_color_swamp NODE NOT FOUND'
     self.islandWaterParameters = island_water_parameters
     return
    def startCustomEffects(self, interior=True, loadIslandMusic=False):
        if self.envEffects:
            self.envEffects.delete()
            self.envEffects = None
        if self.environment == 'Swamp':
            self.envEffects = SwampEffects.SwampEffects(self, self.modelPath)
            base.musicMgr.requestCurMusicFadeOut(removeFromPlaylist=False)
            base.musicMgr.request(SoundGlobals.MUSIC_SWAMP,
                                  priority=1,
                                  volume=0.6)
        elif self.environment == 'Jungle':
            self.envEffects = ForestEffects.ForestEffects(self, self.modelPath)
            base.musicMgr.requestCurMusicFadeOut(removeFromPlaylist=False)
            base.musicMgr.request(SoundGlobals.MUSIC_JUNGLE,
                                  priority=1,
                                  volume=0.6)
        elif self.environment == 'Cave':
            self.envEffects = CaveEffects.CaveEffects(self, self.modelPath)
            base.musicMgr.requestCurMusicFadeOut(removeFromPlaylist=False)
            if self.uniqueId == LocationIds.RAVENS_COVE_MINE:
                base.musicMgr.request(SoundGlobals.getMainMusic(self.uniqueId),
                                      priority=1,
                                      volume=0.6)
            else:
                base.musicMgr.request(SoundGlobals.MUSIC_CAVE,
                                      priority=1,
                                      volume=0.6)
        elif self.uniqueId in ('1189479168.0sdnaik0', '1150922126.8akelts'):
            r = Reflection.getGlobalReflection()
            water = SeaPatch(self, reflection=r)
            water.loadSeaPatchFile('out.spf')
            self.water = water
            self.initializeIslandWaterParameters(self.geom)
        else:
            self.envEffects = EnvironmentEffects(self, self.modelPath)
            if interior:
                pass
        if loadIslandMusic:
            if not base.localAvatar.isInInvasion():
                base.musicMgr.requestFadeOut(SoundGlobals.MUSIC_TORMENTA)
                base.musicMgr.requestFadeOut(
                    SoundGlobals.MUSIC_TORMENTA_COMBAT)

            def getCurrentIslandMusic():
                priZeros = []
                for music in base.musicMgr.playlist:
                    if music.priority == 0:
                        priZeros.append(music)

                return priZeros

            def changeMusic(music, pri):
                for priZero in getCurrentIslandMusic():
                    base.musicMgr.requestFadeOut(priZero.name,
                                                 removeFromPlaylist=True)

                base.musicMgr.request(music, priority=0, volume=0.6)

            mainMusic = SoundGlobals.getMainMusic(self.uniqueId)
            altMusic = SoundGlobals.getAltMusic(self.uniqueId)
            if mainMusic and altMusic:
                base.musicMgr.requestCurMusicFadeOut(removeFromPlaylist=True)
                todMgr = base.cr.timeOfDayManager
                todMgr.addTimeOfDayToggle('Day-Night Area Music', 6.0, 20.0,
                                          changeMusic, [mainMusic, 0],
                                          changeMusic, [altMusic, 0])
            elif mainMusic:
                base.musicMgr.requestCurMusicFadeOut(removeFromPlaylist=True)
                base.musicMgr.request(mainMusic, volume=0.6)
            elif altMusic:
                base.musicMgr.requestCurMusicFadeOut(removeFromPlaylist=True)
                base.musicMgr.request(altMusic, volume=0.6)
        self.builder.initEffects()
        return
Exemple #9
0
 def setupWater(self):
     r = Reflection.getGlobalReflection()
     water = SeaPatch(self, reflection=r)
     water.loadSeaPatchFile('out.spf')
     self.water = water
 def setupWater(self):
     r = Reflection.getGlobalReflection()
     water = SeaPatch(self, reflection = r)
     water.loadSeaPatchFile('out.spf')
     self.water = water
 def initializeIslandWaterParameters(self, reference):
     debug = False
     island_water_parameters = IslandWaterParameters()
     world_position = self.getPos(render)
     world_x_offset = world_position[0]
     world_y_offset = world_position[1]
     world_z_offset = world_position[2]
     if debug:
         print self, '=', self.getName()
         print 'GAME AREA X OFF, Y OFF, Z OFF = ', world_x_offset, world_y_offset, world_z_offset
     
     self.swampAreaNode = reference.find('**/ocean')
     model = reference.find('**/water_color')
     if model:
         if debug:
             print 'WATER COLOR X OFF, Y OFF, Z OFF = ', world_x_offset, world_y_offset, world_z_offset
         
         model.hide()
         min_point = Point3(0)
         max_point = Point3(0)
         model.calcTightBounds(min_point, max_point)
         size = max_point - min_point
         if self.getH() == 180 or self.getH() == -180:
             x = -min_point[0] + world_x_offset
             y = -min_point[1] + world_y_offset
             x_size = -size[0]
             y_size = -size[1]
         else:
             x = min_point[0] + world_x_offset
             y = min_point[1] + world_y_offset
             x_size = size[0]
             y_size = size[1]
         island_water_parameters.map_x_origin = x
         island_water_parameters.map_y_origin = y
         island_water_parameters.map_x_scale = x_size
         island_water_parameters.map_y_scale = y_size
         if debug:
             print 'X, Y, X SIZE, Y SIZE = ', min_point[0], min_point[1], x_size, y_size
         
         texture = model.findTexture('*')
         if texture:
             island_water_parameters.water_color_texture = texture
             if debug:
                 print 'WATER COLOR TEXTURE', texture
             
         
     elif debug:
         print '*** water_color NODE NOT FOUND'
     
     model = reference.find('**/water_alpha')
     if model:
         if debug:
             print 'WATER ALPHA X OFF, Y OFF, Z OFF = ', world_x_offset, world_y_offset, world_z_offset
         
         model.hide()
         min_point = Point3(0)
         max_point = Point3(0)
         model.calcTightBounds(min_point, max_point)
         size = max_point - min_point
         if self.getH() == 180 or self.getH() == -180:
             x = -min_point[0] + world_x_offset
             y = -min_point[1] + world_y_offset
             x_size = -size[0]
             y_size = -size[1]
         else:
             x = min_point[0] + world_x_offset
             y = min_point[1] + world_y_offset
             x_size = size[0]
             y_size = size[1]
         island_water_parameters.alpha_map_x_origin = x
         island_water_parameters.alpha_map_y_origin = y
         island_water_parameters.alpha_map_x_scale = x_size
         island_water_parameters.alpha_map_y_scale = y_size
         if debug:
             print 'ALPHA X, Y, X SIZE, Y SIZE = ', min_point[0], min_point[1], x_size, y_size
         
         texture = model.findTexture('*')
         if texture:
             island_water_parameters.water_alpha_texture = texture
             if debug:
                 print 'WATER ALPHA TEXTURE', texture
             
         
     elif debug:
         print '*** water_alpha NODE NOT FOUND'
     
     use_shader = False
     if base.config.GetBool('want-shaders', 1) and base.win and base.win.getGsg() and base.win.getGsg().getShaderModel() >= GraphicsStateGuardian.SM20:
         use_shader = True
     
     model_ns = reference.find('**/water_swamp_ns')
     if model_ns:
         if use_shader:
             model_ns.hide()
         else:
             model_ns.show()
             model = model_ns
             model.setBin('water', 1)
             parent = model.getParent()
             model.detachNode()
             stencil_one_node_path = NodePath('stencil_one')
             stencil_one_node_path.reparentTo(parent)
             model.instanceTo(stencil_one_node_path)
             mask = 0xFFFFFFFFL
             stencil_one = StencilAttrib.make(1, StencilAttrib.SCFEqual, StencilAttrib.SOKeep, StencilAttrib.SOKeep, StencilAttrib.SOKeep, 1, mask, mask)
             stencil_one_node_path.setAttrib(stencil_one, 100)
             stencil_one_node_path.setDepthTest(0)
             if not base.useStencils:
                 stencil_one_node_path.hide()
             
     
     model_alpha_texture = None
     model_alpha = reference.find('**/water_alpha_swamp')
     if model_alpha:
         model_alpha_texture = model_alpha.findTexture('*')
         model_alpha.hide()
         if debug:
             print 'model_alpha_texture', model_alpha_texture
         
         if False:
             texture = model_alpha_texture
             card_x_size = 0.5
             card_y_size = 0.5
             card = CardMaker('test_texture_card')
             card.setFrame(-card_x_size, card_x_size, -card_y_size, card_y_size)
             card_node_path = NodePath(card.generate())
             card_node_path.setTexture(texture, 1)
             card_node_path.node().setBounds(OmniBoundingVolume())
             card_node_path.node().setFinal(1)
             card_node_path.reparentTo(render2d)
         
     else:
         model_alpha = None
     model = reference.find('**/water_color_swamp')
     if model:
         if use_shader:
             model.show()
             model_texture = model.findTexture('*')
             if debug:
                 print 'WATER COLOR SWAMP X OFF, Y OFF, Z OFF = ', world_x_offset, world_y_offset, world_z_offset
             
             parent = model.getParent()
             model.detachNode()
             stencil_one_node_path = NodePath('stencil_one')
             stencil_one_node_path.reparentTo(parent)
             model.instanceTo(stencil_one_node_path)
             mask = 0xFFFFFFFFL
             stencil_one = StencilAttrib.make(1, StencilAttrib.SCFEqual, StencilAttrib.SOKeep, StencilAttrib.SOKeep, StencilAttrib.SOKeep, 1, mask, mask)
             stencil_one_node_path.setAttrib(stencil_one, 100)
             stencil_one_node_path.setDepthTest(0)
             if not base.useStencils:
                 stencil_one_node_path.hide()
             
             min_point = Point3(0)
             max_point = Point3(0)
             model.calcTightBounds(min_point, max_point)
             size = max_point - min_point
             if self.getH() == 180 or self.getH() == -180:
                 x = -min_point[0] + world_x_offset
                 y = -min_point[1] + world_y_offset
                 x_size = -size[0]
                 y_size = -size[1]
             else:
                 x = min_point[0] + world_x_offset
                 y = min_point[1] + world_y_offset
                 x_size = size[0]
                 y_size = size[1]
             if debug:
                 print 'min_point', min_point
                 print 'max_point', max_point
                 print 'size', size
                 print 'x y', x, y
             
             island_water_parameters.swamp_map_x_origin = x
             island_water_parameters.swamp_map_y_origin = y
             island_water_parameters.swamp_map_x_scale = x_size
             island_water_parameters.swamp_map_y_scale = y_size
             if debug:
                 print 'X, Y, X SIZE, Y SIZE = ', min_point[0], min_point[1], x_size, y_size
             
             texture = model.findTexture('*')
             if texture:
                 island_water_parameters.swamp_water_color_texture = texture
                 if debug:
                     print 'SWAMP WATER COLOR TEXTURE', texture
                 
             
             water_color_file_path = island_water_parameters.default_water_color_file_path
             alpha_texture_file_path = island_water_parameters.default_water_alpha_file_path
             opacity_texture_file_path = None
             shader_file_path = 'models/swamps/cuba_swamp001_2X.cg'
             reflection = Reflection.getGlobalReflection()
             self.swamp_water = Swamp(None, None, reflection, model, shader_file_path)
             island_water_parameters.swamp_water = self.swamp_water
             unload_previous_texture = True
             self.swamp_water.set_water_color_texture(water_color_file_path, unload_previous_texture, model_texture)
             self.swamp_water.set_water_alpha_texture(alpha_texture_file_path, unload_previous_texture, model_alpha_texture)
             self.swamp_water.set_wrap_or_clamp(True)
             r = 37.0
             g = 62.0
             b = 40.0
             self.swamp_water.water_r = r
             self.swamp_water.water_g = g
             self.swamp_water.water_b = b
             island_water_parameters.swamp_color_r = r
             island_water_parameters.swamp_color_g = g
             island_water_parameters.swamp_color_b = b
             x = 0.0
             y = 1.0
             speed = 3.2000000000000002
             island_water_parameters.swamp_direction_x = x
             island_water_parameters.swamp_direction_y = y
             island_water_parameters.swamp_speed = speed
             self.swamp_water.update_water_direction_and_speed(x, y, speed)
         else:
             model.hide()
     elif debug:
         print '*** water_color_swamp NODE NOT FOUND'
     
     self.islandWaterParameters = island_water_parameters
    def startCustomEffects(self, interior = True, loadIslandMusic = False):
        if self.envEffects:
            self.envEffects.delete()
            self.envEffects = None
        
        if self.environment == 'Swamp':
            self.envEffects = SwampEffects.SwampEffects(self, self.modelPath)
            base.musicMgr.requestCurMusicFadeOut(removeFromPlaylist = False)
            base.musicMgr.request(SoundGlobals.MUSIC_SWAMP, priority = 1, volume = 0.59999999999999998)
        elif self.environment == 'Jungle':
            self.envEffects = ForestEffects.ForestEffects(self, self.modelPath)
            base.musicMgr.requestCurMusicFadeOut(removeFromPlaylist = False)
            base.musicMgr.request(SoundGlobals.MUSIC_JUNGLE, priority = 1, volume = 0.59999999999999998)
        elif self.environment == 'Cave':
            self.envEffects = CaveEffects.CaveEffects(self, self.modelPath)
            base.musicMgr.requestCurMusicFadeOut(removeFromPlaylist = False)
            if self.uniqueId == LocationIds.RAVENS_COVE_MINE:
                base.musicMgr.request(SoundGlobals.getMainMusic(self.uniqueId), priority = 1, volume = 0.59999999999999998)
            else:
                base.musicMgr.request(SoundGlobals.MUSIC_CAVE, priority = 1, volume = 0.59999999999999998)
        elif self.uniqueId in ('1189479168.0sdnaik0', '1150922126.8akelts'):
            r = Reflection.getGlobalReflection()
            water = SeaPatch(self, reflection = r)
            water.loadSeaPatchFile('out.spf')
            self.water = water
            self.initializeIslandWaterParameters(self.geom)
        else:
            self.envEffects = EnvironmentEffects(self, self.modelPath)
            if interior:
                pass
            
        if loadIslandMusic:
            if not base.localAvatar.isInInvasion():
                base.musicMgr.requestFadeOut(SoundGlobals.MUSIC_TORMENTA)
                base.musicMgr.requestFadeOut(SoundGlobals.MUSIC_TORMENTA_COMBAT)
            
            
            def getCurrentIslandMusic():
                priZeros = []
                for music in base.musicMgr.playlist:
                    if music.priority == 0:
                        priZeros.append(music)
                        continue
                
                return priZeros

            
            def changeMusic(music, pri):
                for priZero in getCurrentIslandMusic():
                    base.musicMgr.requestFadeOut(priZero.name, removeFromPlaylist = True)
                
                base.musicMgr.request(music, priority = 0, volume = 0.59999999999999998)

            mainMusic = SoundGlobals.getMainMusic(self.uniqueId)
            altMusic = SoundGlobals.getAltMusic(self.uniqueId)
            if mainMusic and altMusic:
                base.musicMgr.requestCurMusicFadeOut(removeFromPlaylist = True)
                todMgr = base.cr.timeOfDayManager
                todMgr.addTimeOfDayToggle('Day-Night Area Music', 6.0, 20.0, changeMusic, [
                    mainMusic,
                    0], changeMusic, [
                    altMusic,
                    0])
            elif mainMusic:
                base.musicMgr.requestCurMusicFadeOut(removeFromPlaylist = True)
                base.musicMgr.request(mainMusic, volume = 0.59999999999999998)
            elif altMusic:
                base.musicMgr.requestCurMusicFadeOut(removeFromPlaylist = True)
                base.musicMgr.request(altMusic, volume = 0.59999999999999998)
            
        
        self.builder.initEffects()