def createWake(self):
     if self.owner:
         ownerId = self.owner.doId
     else:
         ownerId = None
     if not base.cr.activeWorld:
         self.notify.warning('Ship %s is trying to create a wake without an active world.' % (ownerId,))
         return None
     
     if not base.cr.activeWorld.getWater():
         self.notify.warning('Ship %s is trying to create a wake without an ocean. (world: %s)' % (ownerId, base.cr.activeWorld))
         return None
     
     if self.WantWake and base.cr.wantSpecialEffects and self.owner:
         self.removeWake()
         if base.options.getSpecialEffectsSetting() >= base.options.SpecialEffectsMedium:
             if not hasattr(base.cr.activeWorld.getWater(), 'patch'):
                 self.notify.error("Ship %s is in location %s,%s (%s[%s]).\nThis causes Attribute Error: 'NoneType' object has no attribute 'patch'\n" % (ownerId, self.getLocation()[0], self.getLocation()[1], type(self.getParentObj()), safeRepr(self.getParentObj())))
             
             self.wake = Wake.getEffect()
             if self.wake:
                 self.wake.attachToShip(self.owner)
                 compassFX = CompassEffect.make(render)
                 self.wake.setEffect(compassFX)
                 self.wake.startAnimate(self.owner)
Пример #2
0
    def createEnvironment(self):
        # Fog to hide a performance tweak:
        colour = (0.0, 0.0, 0.0)
        expfog = Fog("scene-wide-fog")
        expfog.setColor(*colour)
        expfog.setExpDensity(0.001)  # original : 0.004
        render.setFog(expfog)
        base.setBackgroundColor(*colour)

        # Our sky
        skydome = loader.loadModel('sky.egg')
        skydome.setEffect(CompassEffect.make(self.render))
        skydome.setScale(self.maxdistance / 2)  # bit less than "far"
        skydome.setZ(-65)  # sink it
        # NOT render - you'll fly through the sky!:
        skydome.reparentTo(self.camera)

        # Our lighting
        ambientLight = AmbientLight("ambientLight")
        ambientLight.setColor(Vec4(.6, .6, .6, 1))
        directionalLight = DirectionalLight("directionalLight")
        directionalLight.setDirection(Vec3(0, -10, -10))
        directionalLight.setColor(Vec4(1, 1, 1, 1))
        directionalLight.setSpecularColor(Vec4(1, 1, 1, 1))
        render.setLight(render.attachNewNode(ambientLight))
        render.setLight(render.attachNewNode(directionalLight))
Пример #3
0
 def playStormEffect(self):
     if not self.stormEffect:
         self.stormEffect = DarkMaelstrom(self.shipRoot)
         self.stormEffect.setZ(50)
         self.stormEffect.loop()
         compassFX = CompassEffect.make(render)
         self.stormEffect.setEffect(compassFX)
Пример #4
0
    def createWake(self):
        if self.owner:
            ownerId = self.owner.doId
        else:
            ownerId = None
        if not base.cr.activeWorld:
            self.notify.warning(
                'Ship %s is trying to create a wake without an active world.' %
                (ownerId, ))
            return None

        if not base.cr.activeWorld.getWater():
            self.notify.warning(
                'Ship %s is trying to create a wake without an ocean. (world: %s)'
                % (ownerId, base.cr.activeWorld))
            return None

        if self.WantWake and base.cr.wantSpecialEffects and self.owner:
            self.removeWake()
            if base.options.getSpecialEffectsSetting(
            ) >= base.options.SpecialEffectsMedium:
                if not hasattr(base.cr.activeWorld.getWater(), 'patch'):
                    self.notify.error(
                        "Ship %s is in location %s,%s (%s[%s]).\nThis causes Attribute Error: 'NoneType' object has no attribute 'patch'\n"
                        % (ownerId, self.getLocation()[0],
                           self.getLocation()[1], type(self.getParentObj()),
                           safeRepr(self.getParentObj())))

                self.wake = Wake.getEffect()
                if self.wake:
                    self.wake.attachToShip(self.owner)
                    compassFX = CompassEffect.make(render)
                    self.wake.setEffect(compassFX)
                    self.wake.startAnimate(self.owner)
 def playStormEffect(self):
     if not self.stormEffect:
         self.stormEffect = DarkMaelstrom(self.shipRoot)
         self.stormEffect.setZ(50)
         self.stormEffect.loop()
         compassFX = CompassEffect.make(render)
         self.stormEffect.setEffect(compassFX)
Пример #6
0
 def __init__(self):
     self.sky = loader.loadModel('models/sky')
     tex = loader.loadTexture('models/tex/space.jpg')
     self.sky.setTexture(tex)
     self.sky.setEffect(CompassEffect.make(render))
     self.sky.setScale(500)
     self.sky.setZ(-65)
     self.sky.reparentTo(base.camera)
 def __init__(self):
     universeBackground = loader.loadModel('models/sky')
     tex = loader.loadTexture('models/tex/space.jpg')
     universeBackground.setTexture(tex)
     universeBackground.setEffect(CompassEffect.make(render))
     universeBackground.setScale(500)
     universeBackground.setZ(-65)
     universeBackground.reparentTo(base.camera)
 def __init__(self):
     self.sky = loader.loadModel('models/sky')
     tex = loader.loadTexture('models/tex/space.jpg')
     self.sky.setTexture(tex)
     self.sky.setEffect(CompassEffect.make(render))
     self.sky.setScale(500)
     self.sky.setZ(-65)
     self.sky.reparentTo(base.camera)
Пример #9
0
 def __init__(self, base):
     self.timeOfDay = "morning"
     #self.skysphere = base.loader.loadModel('models/blue-sky-sphere')
     self.skysphere = base.loader.loadModel('models/farmsky')
     self.skysphere.setEffect(CompassEffect.make(base.render))
     self.skysphere.setScale(1.0)
     self.skysphere.setPos(0.0, 0.0, -100.0)
     self.skysphere.reparentTo(base.render)
     self.initialize_lighting()
Пример #10
0
 def __init__(self, base):
     self.timeOfDay = "morning"
     #self.skysphere = base.loader.loadModel('models/blue-sky-sphere')
     self.skysphere = base.loader.loadModel('models/farmsky')
     self.skysphere.setEffect(CompassEffect.make(base.render))
     self.skysphere.setScale(1.0)
     self.skysphere.setPos(0.0,0.0,-100.0)
     self.skysphere.reparentTo(base.render) 
     self.initialize_lighting()
Пример #11
0
    def createEnvironment(self):
        # Fog to hide a performance tweak
        exp_fog = Fog("scene-wide-fog")
        exp_fog.setColor(1, 0.8, 0.8)
        exp_fog.setExpDensity(0.002)
        render.setFog(exp_fog)
        # base.setBackgroundColor(*colour)

        # Sky Dome
        '''
        sky_dome = loader.loadModel("models/sky")      # sky_sphere.egg by default
        sky_dome.setEffect(CompassEffect.make(self.render))
        sky_dome.setScale(self.max_distance / 2)
        sky_dome.setZ(-65)  # sink it
        # NOT render - you'll fly through the sky!
        sky_dome.reparentTo(self.camera)
        '''

        # Sky Sphere
        sky_sphere = self.loader.loadModel("models/sky_sphere")
        sky_sphere.setEffect(CompassEffect.make(self.render))
        sky_sphere.setScale(0.08)
        sky_sphere.reparentTo(self.camera)

        # Lighting
        ambient_light = AmbientLight("ambientLight")
        ambient_colour = Vec4(0.6, 0.6, 0.6, 1)
        ambient_light.setColor(ambient_colour)
        self.render.setLight(self.render.attachNewNode(ambient_light))

        directional_light = DirectionalLight("directionalLight")
        # direction = Vec3(0, -10, -10)
        # directional_light.setDirection(direction)
        directional_colour = Vec4(0.8, 0.8, 0.5, 1)
        directional_light.setColor(directional_colour)

        # directional_specular = Vec4(1, 1, 1, 1)
        # directional_light.setSpecularColor(directional_specular)

        dir_light_np = self.render.attachNewNode(directional_light)
        dir_light_np.setPos(0, 0, 260)
        dir_light_np.lookAt(self.player)
        self.render.setLight(dir_light_np)

        # Water
        self.water = self.loader.loadModel("models/square")
        self.water.setSx(self.world_size*2)
        self.water.setSy(self.world_size*2)
        self.water.setPos(self.world_size/2, self.world_size/2, 25)   # z is sea level
        self.water.setTransparency(TransparencyAttrib.MAlpha)
        newTS = TextureStage("1")
        self.water.setTexture(newTS, self.loader.loadTexture("models/water.png"))
        self.water.setTexScale(newTS, 4)
        self.water.reparentTo(self.render)
        LerpTexOffsetInterval(self.water, 200, (1,0), (0,0), textureStage=newTS).loop()
Пример #12
0
	def __init__(self, vehicleNode, distance):
		'''
		Constructor
		'''
		self.enabled = False
		
		self.vehicleNode = vehicleNode
		self.centerNode = NodePath("centerNode")
		self.camNode = NodePath("cameraNode")
		self.centerNode.reparentTo(vehicleNode)
		self.camNode.reparentTo(vehicleNode)
		compass = CompassEffect.make(render)
		self.centerNode.setEffect(compass)
		self.camNode.setPos(self.centerNode, distance)
		self.camNode.lookAt(self.centerNode)
Пример #13
0
def startCloudSky(hood, parent=camera, effects=CompassEffect.PRot | CompassEffect.PZ):
    hood.sky.reparentTo(parent)
    hood.sky.setDepthTest(0)
    hood.sky.setDepthWrite(0)
    hood.sky.setBin("background", 100)
    hood.sky.find("**/Sky").reparentTo(hood.sky, -1)
    hood.sky.reparentTo(parent)
    hood.sky.setZ(0.0)
    hood.sky.setHpr(0.0, 0.0, 0.0)
    ce = CompassEffect.make(NodePath(), effects)
    hood.sky.node().setEffect(ce)
    skyTrackTask = Task(hood.skyTrack)
    skyTrackTask.h = 0
    skyTrackTask.cloud1 = hood.sky.find("**/cloud1")
    skyTrackTask.cloud2 = hood.sky.find("**/cloud2")
    if not skyTrackTask.cloud1.isEmpty() and not skyTrackTask.cloud2.isEmpty():
        taskMgr.add(skyTrackTask, "skyTrack")
    else:
        notify.warning("Couldn't find clouds!")
Пример #14
0
    def createEnvironment(self):
        # Fog to hide a performance tweak:
        colour = (0.5, 0.5, 0.5)
        expfog = Fog("scene-wide-fog")
        expfog.setColor(*colour)
        expfog.setExpDensity(0.001)  # original : 0.004
        render.setFog(expfog)
        base.setBackgroundColor(*colour)

        # Our sky
        skysphere = self.loader.loadModel('blue-sky-sphere')
        skysphere.setEffect(CompassEffect.make(self.render))
        skysphere.setScale(0.08)

        # NOT render or you'll fly through the sky!:
        skysphere.reparentTo(self.camera)

        # Our lighting
        ambientLight = AmbientLight("ambientLight")
        ambientLight.setColor(Vec4(.6, .6, .6, 1))
        self.render.setLight(self.render.attachNewNode(ambientLight))

        directionalLight = DirectionalLight("directionalLight")
        directionalLight.setColor(VBase4(0.8, 0.8, 0.5, 1))
        dlnp = self.render.attachNewNode(directionalLight)
        dlnp.setPos(0, 0, 260)
        dlnp.lookAt(self.player)
        self.render.setLight(dlnp)

        # water
        self.water = self.loader.loadModel('square.egg')
        self.water.setSx(self.worldsize * 2)
        self.water.setSy(self.worldsize * 2)
        self.water.setPos(self.worldsize / 2, self.worldsize / 2,
                          2)  # sea level
        self.water.setTransparency(TransparencyAttrib.MAlpha)
        newTS = TextureStage('1')
        self.water.setTexture(newTS, self.loader.loadTexture('water.png'))
        self.water.setTexScale(newTS, 4)
        self.water.reparentTo(self.render)
        LerpTexOffsetInterval(self.water,
                              200, (1, 0), (0, 0),
                              textureStage=newTS).loop()
Пример #15
0
    def __createEnvironment(self):
        # Fog
        expfog = Fog("scene-wide-fog")
        expfog.setColor(0.5, 0.5, 0.5)
        expfog.setExpDensity(0.002)
        self.render.setFog(expfog)

        # Our sky
        skysphere = self.loader.loadModel('volume1/models/blue-sky-sphere')
        skysphere.setEffect(CompassEffect.make(self.render))
        skysphere.setScale(0.08)
        # NOT render or you'll fly through the sky!:
        skysphere.reparentTo(self.camera)

        # Our lighting
        ambientLight = AmbientLight("ambientLight")
        ambientLight.setColor(Vec4(.6, .6, .6, 1))
        self.render.setLight(self.render.attachNewNode(ambientLight))

        directionalLight = DirectionalLight("directionalLight")
        directionalLight.setColor(VBase4(0.8, 0.8, 0.5, 1))
        dlnp = self.render.attachNewNode(directionalLight)
        dlnp.setPos(0, 0, 260)
        dlnp.setHpr(225, -60, 0)  #lookAt(self.player)
        self.render.setLight(dlnp)

        # water
        self.water = self.loader.loadModel('volume1/models/square.egg')
        self.water.setSx(self.worldsize * 2)
        self.water.setSy(self.worldsize * 2)
        self.water.setPos(self.worldsize / 2, self.worldsize / 2,
                          18)  # sea level
        self.water.setTransparency(TransparencyAttrib.MAlpha)
        nTS = TextureStage('1')
        self.water.setTexture(
            nTS, self.loader.loadTexture('volume1/models/water.png'))
        self.water.setTexScale(nTS, 4)
        self.water.reparentTo(self.render)
        LerpTexOffsetInterval(self.water,
                              200, (1, 0), (0, 0),
                              textureStage=nTS).loop()
def startCloudSky(hood,
                  parent=camera,
                  effects=CompassEffect.PRot | CompassEffect.PZ):
    hood.sky.reparentTo(parent)
    hood.sky.setDepthTest(0)
    hood.sky.setDepthWrite(0)
    hood.sky.setBin('background', 100)
    hood.sky.find('**/Sky').reparentTo(hood.sky, -1)
    hood.sky.reparentTo(parent)
    hood.sky.setZ(0.0)
    hood.sky.setHpr(0.0, 0.0, 0.0)
    ce = CompassEffect.make(NodePath(), effects)
    hood.sky.node().setEffect(ce)
    skyTrackTask = Task(hood.skyTrack)
    skyTrackTask.h = 0
    skyTrackTask.cloud1 = hood.sky.find('**/cloud1')
    skyTrackTask.cloud2 = hood.sky.find('**/cloud2')
    if not skyTrackTask.cloud1.isEmpty() and not skyTrackTask.cloud2.isEmpty():
        taskMgr.add(skyTrackTask, 'skyTrack')
    else:
        notify.warning("Couldn't find clouds!")
Пример #17
0
 def __init__( self ):
   # --- create a compass ---
   # load a plane
   self.compassNp = loader.loadModelCopy( "data/models/plane.egg" )
   self.compassNp.setColor( 1,1,1,1 )
   self.compassNp.setLightOff()
   self.compassNp.setScale( 0.25 )
   self.compassNp.setHpr( 0, 270,0 )
   
   # assign texture
   self.tex0 = loader.loadTexture( 'data/textures/kompass.png' )
   self.compassNp.setTexture( self.tex0, 0 )
   self.compassNp.setTransparency(1)
   
   # create position node for the compass
   self.compassPositionNp = NodePath( "CompassPositionNp" )
   self.compassPositionNp.reparentTo( base.camera )
   self.compassPositionNp.setPos( 0.0, 0.8, -0.5 )
   self.compassNp.reparentTo( self.compassPositionNp )
   
   # assign CompassEffect
   Effect=CompassEffect.make(render)
   self.compassNp.node().setEffect(Effect)
Пример #18
0
    def createEnvironment(self):
        # Fog
        expfog = Fog("scene-wide-fog")
        expfog.setColor(0.5, 0.5, 0.5)
        expfog.setExpDensity(0.002)
        self.render.setFog(expfog)

        # Sky
        skysphere = self.loader.loadModel("assets/blue-sky-sphere")
        skysphere.setEffect(CompassEffect.make(self.render))
        skysphere.setScale(0.08)
        skysphere.reparentTo(self.camera)

        # Lights
        ambientLight = AmbientLight("ambientLight")
        ambientLight.setColor(Vec4(0.6, 0.6, 0.6, 1))
        self.render.setLight(self.render.attachNewNode(ambientLight))

        directionalLight = DirectionalLight("directionalLight")
        directionalLight.setColor(VBase4(0.8, 0.8, 0.5, 1))
        dlnp = self.render.attachNewNode(directionalLight)
        dlnp.setPos(0, 0, 260)
        dlnp.lookAt(self.player)
        self.render.setLight(dlnp)

        # Water
        self.water = self.loader.loadModel("assets/square.egg")
        self.water.setSx(self.worldsize * 2)
        self.water.setSy(self.worldsize * 2)
        self.water.setPos(self.worldsize / 2, self.worldsize / 2, 25)
        self.water.setTransparency(TransparencyAttrib.MAlpha)
        newTS = TextureStage("1")
        self.water.setTexture(newTS, self.loader.loadTexture("assets/water.png"))
        self.water.setTexScale(newTS, 4)
        self.water.reparentTo(self.render)
        LerpTexOffsetInterval(self.water, 200, (1, 0), (0, 0), textureStage=newTS).loop()
Пример #19
0
    def init_nodepath(self):


        # Load the environment model.
        self.environ = loader.loadModel("models/env03")

        # water
        self.water = loader.loadModel('models/square')
        self.water.setSx(400*2)
        self.water.setSy(400*2)
        self.water.setPos(0, 80, -1)  # sea level
        self.water.setTransparency(TransparencyAttrib.MAlpha)
        newTS = TextureStage('1')
        self.water.setTexture(newTS, loader.loadTexture('models/water.png'))
        self.water.setTexScale(newTS, 4)
        self.water.reparentTo(render)
        LerpTexOffsetInterval(self.water, 50, (1, 0), (0, 0), textureStage=newTS).loop()

        # Our sky
        self.skysphere = loader.loadModel('models/blue-sky-sphere')
        self.skysphere.setEffect(CompassEffect.make(render))
        self.skysphere.setScale(0.05)

        # NOT render or you'll fly through the sky!:
        self.skysphere.reparentTo(base.camera)

        # Reparent the model to render.
        self.environ.reparentTo(render)

        # Apply scale and position transforms on the model.
        self.environ.setScale(1, 1, 1)
        self.environ.setPos(37, 48, 0)
        self.environ.setHpr(270, 0, 0)
        self.environ.setTwoSided(True)

        # fog
        colour = (0.1, 0.1, 0.1)
        expfog = Fog("scene-wide-fog")
        expfog.setColor(*colour)
        expfog.setExpDensity(0.01)
        render.setFog(expfog)

        # Set Rain Boundaries
        mapCollision = CollisionNode('mapcnode')
        mapCollision.setTag('INTO', 'map')

        self.pt1, self.pt2 = self.environ.getTightBounds()
        self.deltaX = self.pt2.x - self.pt1.x
        self.deltaY = self.pt2.y - self.pt1.y
        self.deltaZ = 1000

        # Set up rain effect initialization
        self.spawnEveryXSeconds = .001
        self.spawnXDrops = 4
        self.dropDuration = .2
        self.percentChanceOfImpactCircle = .8
        self.percentChanceOfImpactFog = .5
        self.percentChanceOfDoubleDrop = .8
        self.percentChanceOfTripleDrop = .2

        # base.setBackgroundColor(*colour)

        self.nodePath = render.attachNewNode('World')
        self.init_lights()
        self.init_camera()
        self.terrain.init_nodepath()
        for team in self.teams:
            for character in team.characters:
                character.init_nodepath()

        # create rain
        taskMgr.doMethodLater(0, self.makeItRain, 'make-it-rain')
Пример #20
0
    def init_nodepath(self):

        # Load the environment model.
        self.environ = loader.loadModel("models/env03")

        # water
        self.water = loader.loadModel('models/square')
        self.water.setSx(400 * 2)
        self.water.setSy(400 * 2)
        self.water.setPos(0, 80, -1)  # sea level
        self.water.setTransparency(TransparencyAttrib.MAlpha)
        newTS = TextureStage('1')
        self.water.setTexture(newTS, loader.loadTexture('models/water.png'))
        self.water.setTexScale(newTS, 4)
        self.water.reparentTo(render)
        LerpTexOffsetInterval(self.water,
                              50, (1, 0), (0, 0),
                              textureStage=newTS).loop()

        # Our sky
        self.skysphere = loader.loadModel('models/blue-sky-sphere')
        self.skysphere.setEffect(CompassEffect.make(render))
        self.skysphere.setScale(0.05)

        # NOT render or you'll fly through the sky!:
        self.skysphere.reparentTo(base.camera)

        # Reparent the model to render.
        self.environ.reparentTo(render)

        # Apply scale and position transforms on the model.
        self.environ.setScale(1, 1, 1)
        self.environ.setPos(37, 48, 0)
        self.environ.setHpr(270, 0, 0)
        self.environ.setTwoSided(True)

        # fog
        colour = (0.1, 0.1, 0.1)
        expfog = Fog("scene-wide-fog")
        expfog.setColor(*colour)
        expfog.setExpDensity(0.01)
        render.setFog(expfog)

        # Set Rain Boundaries
        mapCollision = CollisionNode('mapcnode')
        mapCollision.setTag('INTO', 'map')

        self.pt1, self.pt2 = self.environ.getTightBounds()
        self.deltaX = self.pt2.x - self.pt1.x
        self.deltaY = self.pt2.y - self.pt1.y
        self.deltaZ = 1000

        # Set up rain effect initialization
        self.spawnEveryXSeconds = .001
        self.spawnXDrops = 4
        self.dropDuration = .2
        self.percentChanceOfImpactCircle = .8
        self.percentChanceOfImpactFog = .5
        self.percentChanceOfDoubleDrop = .8
        self.percentChanceOfTripleDrop = .2

        # base.setBackgroundColor(*colour)

        self.nodePath = render.attachNewNode('World')
        self.init_lights()
        self.init_camera()
        self.terrain.init_nodepath()
        for team in self.teams:
            for character in team.characters:
                character.init_nodepath()

        # create rain
        taskMgr.doMethodLater(0, self.makeItRain, 'make-it-rain')