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)
 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 __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)
Пример #5
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()
Пример #6
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)
Пример #7
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!")
Пример #8
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)
Пример #9
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()
Пример #10
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')
Пример #11
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')