def announceGenerate(self): # TODO - for some reason this is getting called hundreds of times when there are multiple districts DistributedObject.DistributedObject.announceGenerate(self) self.sendUpdate("enteredParty", []) globalClock.syncFrameTime() self.startPartyClock() base.localAvatar.chatMgr.chatInputSpeedChat.addInsidePartiesMenu() self.spawnTitleText() messenger.send(self.generatedEvent) if config.GetBool("show-debug-party-grid", 0): self.testGrid = NodePath("test_grid") self.testGrid.reparentTo(base.cr.playGame.hood.loader.geom) for i in xrange(len(self.grid)): for j in xrange(len(self.grid[i])): cm = CardMaker("gridsquare") np = NodePath(cm.generate()) np.setScale(12) np.setP(-90.0) np.setPos( PartyUtils.convertDistanceFromPartyGrid(j, 0) - 6.0, PartyUtils.convertDistanceFromPartyGrid(i, 1) - 6.0, 0.1, ) np.reparentTo(self.testGrid) if self.grid[i][j]: np.setColorScale(0.0, 1.0, 0.0, 1.0) else: np.setColorScale(1.0, 0.0, 0.0, 1.0)
def announceGenerate(self): assert (self.notify.debug("announceGenerate()")) DistributedObject.DistributedObject.announceGenerate(self) self.sendUpdate("avIdEnteredParty", [base.localAvatar.doId]) # we probably just spent a lot of time loading, so # tell globalClock to update the frame timestamp globalClock.syncFrameTime() self.startPartyClock() base.localAvatar.chatMgr.chatInputSpeedChat.addInsidePartiesMenu() self.spawnTitleText() if config.GetBool('show-debug-party-grid', 0): # Debug grid self.testGrid = NodePath("test_grid") self.testGrid.reparentTo(base.cr.playGame.hood.loader.geom) for i in range(len(self.grid)): for j in range(len(self.grid[i])): cm = CardMaker("gridsquare") np = NodePath(cm.generate()) np.setScale(12) np.setP(-90.0) np.setPos( PartyUtils.convertDistanceFromPartyGrid(j, 0) - 6.0, PartyUtils.convertDistanceFromPartyGrid(i, 1) - 6.0, 0.1) np.reparentTo(self.testGrid) if self.grid[i][j]: np.setColorScale(0.0, 1.0, 0.0, 1.0) else: np.setColorScale(1.0, 0.0, 0.0, 1.0)
def announceGenerate(self): #TODO - for some reason this is getting called hundreds of times when there are multiple districts DistributedObject.DistributedObject.announceGenerate(self) self.sendUpdate('enteredParty', []) globalClock.syncFrameTime() self.startPartyClock() base.localAvatar.chatMgr.chatInputSpeedChat.addInsidePartiesMenu() self.spawnTitleText() messenger.send(self.generatedEvent) if config.GetBool('show-debug-party-grid', 0): self.testGrid = NodePath('test_grid') self.testGrid.reparentTo(base.cr.playGame.hood.loader.geom) for i in xrange(len(self.grid)): for j in xrange(len(self.grid[i])): cm = CardMaker('gridsquare') np = NodePath(cm.generate()) np.setScale(12) np.setP(-90.0) np.setPos( PartyUtils.convertDistanceFromPartyGrid(j, 0) - 6.0, PartyUtils.convertDistanceFromPartyGrid(i, 1) - 6.0, 0.1) np.reparentTo(self.testGrid) if self.grid[i][j]: np.setColorScale(0.0, 1.0, 0.0, 1.0) else: np.setColorScale(1.0, 0.0, 0.0, 1.0)
def loadModelCopy(parent, path, name, size = None, pos = None, color = None, tex = None): # New models are loaded in a non-standard way to allow flattenStrong to work effectively over them. modelRoot = base.loader.loadModelCopy(path) model = NodePath(name) modelRoot.getChildren().reparentTo(model) model.reparentTo(parent) #model aditional transformations if size != None: resizeToUnit(model, size) if pos != None: model.setPos(pos[0], pos[1], pos[2]) if color != None: model.setColorScale(color[0], color[1], color[2], color[3]) if tex != None: tx = base.loader.loadTexture(tex) model.setTexture(tx) return model
def announceGenerate(self): DistributedObject.DistributedObject.announceGenerate(self) self.sendUpdate('enteredParty', []) globalClock.syncFrameTime() self.startPartyClock() base.localAvatar.chatMgr.chatInputSpeedChat.addInsidePartiesMenu() self.spawnTitleText() messenger.send(self.generatedEvent) if config.GetBool('show-debug-party-grid', 0): self.testGrid = NodePath('test_grid') self.testGrid.reparentTo(base.cr.playGame.hood.loader.geom) for i in range(len(self.grid)): for j in range(len(self.grid[i])): cm = CardMaker('gridsquare') np = NodePath(cm.generate()) np.setScale(12) np.setP(-90.0) np.setPos(PartyUtils.convertDistanceFromPartyGrid(j, 0) - 6.0, PartyUtils.convertDistanceFromPartyGrid(i, 1) - 6.0, 0.1) np.reparentTo(self.testGrid) if self.grid[i][j]: np.setColorScale(0.0, 1.0, 0.0, 1.0) else: np.setColorScale(1.0, 0.0, 0.0, 1.0)
def __init__(self, manager, xml): self.updateTask = None self.sun = base.cam.attachNewNode('sun') loader.loadModel( manager.get('paths').getConfig().find('misc').get('path') + '/sphere').reparentTo(self.sun) self.sun.setScale(0.1) self.sun.setTwoSided(True) self.sun.setColorScale(10.0, 10.0, 10.0, 1.0, 10001) self.sun.setLightOff(1) self.sun.setShaderOff(1) self.sun.setFogOff(1) self.sun.setCompass() self.sun.setBin('background', 10) self.sun.setDepthWrite(False) self.sun.setDepthTest(False) # Workaround an annoyance in Panda. No idea why it's needed. self.sun.node().setBounds(OmniBoundingVolume()) isa = xml.find('isa') inst = xml.find('instance') if isa != None or inst != None: if inst != None: orig = Vec3(float(inst.get('x', '0')), float(inst.get('y', '0')), float(inst.get('z', '0'))) else: level = manager.get(isa.get('source')) orig = Vec3(level.getByIsA(isa.get('name'))[0].getPos(render)) orig.normalize() self.sun.setPos(orig) godrays = xml.find('godrays') if godrays != None: self.vlbuffer = base.win.makeTextureBuffer('volumetric-lighting', base.win.getXSize() / 2, base.win.getYSize() / 2) self.vlbuffer.setClearColor(Vec4(0, 0, 0, 1)) cam = base.makeCamera(self.vlbuffer) cam.node().setLens(base.camLens) cam.reparentTo(base.cam) initstatenode = NodePath('InitialState') initstatenode.setColorScale(0, 0, 0, 1, 10000) initstatenode.setShaderOff(10000) initstatenode.setLightOff(10000) initstatenode.setMaterialOff(10000) initstatenode.setTransparency(TransparencyAttrib.MBinary, 10000) cam.node().setCameraMask(BitMask32.bit(2)) cam.node().setInitialState(initstatenode.getState()) self.vltexture = self.vlbuffer.getTexture() self.vltexture.setWrapU(Texture.WMClamp) self.vltexture.setWrapV(Texture.WMClamp) card = CardMaker('VolumetricLightingCard') card.setFrameFullscreenQuad() self.finalQuad = render2d.attachNewNode(card.generate()) self.finalQuad.setAttrib( ColorBlendAttrib.make(ColorBlendAttrib.MAdd, ColorBlendAttrib.OIncomingColor, ColorBlendAttrib.OFbufferColor)) self.finalQuad.setShader( Shader.load( posixpath.join( manager.get('paths').getConfig().find('shaders').get( 'path'), 'filter-vlight.cg'))) self.finalQuad.setShaderInput('src', self.vltexture) self.finalQuad.setShaderInput( 'vlparams', 32, 0.9 / 32.0, 0.97, 0.5 ) # Note - first 32 is now hardcoded into shader for cards that don't support variable sized loops. self.finalQuad.setShaderInput('casterpos', 0.5, 0.5, 0, 0) # Last parameter to vlcolor is the exposure vlcolor = Vec4(float(godrays.get('r', '1')), float(godrays.get('g', '1')), float(godrays.get('b', '1')), 0.04) self.finalQuad.setShaderInput('vlcolor', vlcolor) else: self.finalQuad = None
def __init__(self, filters): self.filters = filters self.updateTask = None self.finalQuad = None self.sun = base.cam.attachNewNode('sun') loader.loadModel("models/sphere").reparentTo(self.sun) self.sun.setScale(0.08) self.sun.setTwoSided(True) self.sun.setColorScale(1.0, 1.0, 1.0, 1.0, 10001) self.sun.setLightOff(1) self.sun.setShaderOff(1) self.sun.setFogOff(1) self.sun.setCompass() self.sun.setBin('background', 2) self.sun.setDepthWrite(False) self.sun.setDepthTest(False) # Workaround an annoyance in Panda. No idea why it's needed. self.sun.node().setBounds(OmniBoundingVolume()) direct = Vec4(2.0, 1.9, 1.8, 1) #bright for hdr #direct = Vec4(0.7, 0.65, 0.6, 1) self.dlight = DirectionalLight('dlight') self.dlight.setColor(direct) dlnp = self.sun.attachNewNode(self.dlight) render.setLight(dlnp) render.setShaderInput('dlight0', dlnp) self.setTime(700.0) pandaVolumetricLighting = False if pandaVolumetricLighting: self.filters.setVolumetricLighting( dlnp ) else: self.vlbuffer = base.win.makeTextureBuffer('volumetric-lighting', base.win.getXSize() / 2, base.win.getYSize() / 2) self.vlbuffer.setClearColor(Vec4(0, 0, 0, 1)) cam = base.makeCamera(self.vlbuffer) cam.node().setLens(base.camLens) cam.reparentTo(base.cam) initstatenode = NodePath('InitialState') initstatenode.setColorScale(0, 0, 0, 1, 10000) initstatenode.setShaderOff(10000) initstatenode.setFogOff(1) initstatenode.setLightOff(10000) initstatenode.setMaterialOff(10000) initstatenode.setTransparency(TransparencyAttrib.MBinary, 10000) cam.node().setCameraMask(BitMask32.bit(2)) cam.node().setInitialState(initstatenode.getState()) self.vltexture = self.vlbuffer.getTexture() self.vltexture.setWrapU(Texture.WMClamp) self.vltexture.setWrapV(Texture.WMClamp) card = CardMaker('VolumetricLightingCard') card.setFrameFullscreenQuad() self.finalQuad = render2d.attachNewNode(card.generate()) self.finalQuad.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd, ColorBlendAttrib.OIncomingColor, ColorBlendAttrib.OFbufferColor)) self.finalQuad.setShader(Shader.load("shaders/filter-vlight.cg")) self.finalQuad.setShaderInput('src', self.vltexture) self.finalQuad.setShaderInput('vlparams', 32, 0.95 / 32.0, 0.985, 0.5) # Note - first 32 is now hardcoded into shader for cards that don't support variable sized loops. self.finalQuad.setShaderInput('casterpos', 0.5, 0.5, 0, 0) # Last parameter to vlcolor is the exposure vlcolor = Vec4(1, 0.99, 0.80, 0.03) self.finalQuad.setShaderInput('vlcolor', vlcolor) self.start()
def __init__(self, manager, xml): self.updateTask = None self.sun = base.cam.attachNewNode("sun") loader.loadModel(manager.get("paths").getConfig().find("misc").get("path") + "/sphere").reparentTo(self.sun) self.sun.setScale(0.1) self.sun.setTwoSided(True) self.sun.setColorScale(10.0, 10.0, 10.0, 1.0, 10001) self.sun.setLightOff(1) self.sun.setShaderOff(1) self.sun.setFogOff(1) self.sun.setCompass() self.sun.setBin("background", 10) self.sun.setDepthWrite(False) self.sun.setDepthTest(False) # Workaround an annoyance in Panda. No idea why it's needed. self.sun.node().setBounds(OmniBoundingVolume()) isa = xml.find("isa") inst = xml.find("instance") if isa != None or inst != None: if inst != None: orig = Vec3(float(inst.get("x", "0")), float(inst.get("y", "0")), float(inst.get("z", "0"))) else: level = manager.get(isa.get("source")) orig = Vec3(level.getByIsA(isa.get("name"))[0].getPos(render)) orig.normalize() self.sun.setPos(orig) godrays = xml.find("godrays") if godrays != None: self.vlbuffer = base.win.makeTextureBuffer( "volumetric-lighting", base.win.getXSize() / 2, base.win.getYSize() / 2 ) self.vlbuffer.setClearColor(Vec4(0, 0, 0, 1)) cam = base.makeCamera(self.vlbuffer) cam.node().setLens(base.camLens) cam.reparentTo(base.cam) initstatenode = NodePath("InitialState") initstatenode.setColorScale(0, 0, 0, 1, 10000) initstatenode.setShaderOff(10000) initstatenode.setLightOff(10000) initstatenode.setMaterialOff(10000) initstatenode.setTransparency(TransparencyAttrib.MBinary, 10000) cam.node().setCameraMask(BitMask32.bit(2)) cam.node().setInitialState(initstatenode.getState()) self.vltexture = self.vlbuffer.getTexture() self.vltexture.setWrapU(Texture.WMClamp) self.vltexture.setWrapV(Texture.WMClamp) card = CardMaker("VolumetricLightingCard") card.setFrameFullscreenQuad() self.finalQuad = render2d.attachNewNode(card.generate()) self.finalQuad.setAttrib( ColorBlendAttrib.make( ColorBlendAttrib.MAdd, ColorBlendAttrib.OIncomingColor, ColorBlendAttrib.OFbufferColor ) ) self.finalQuad.setShader( Shader.load( posixpath.join(manager.get("paths").getConfig().find("shaders").get("path"), "filter-vlight.cg") ) ) self.finalQuad.setShaderInput("src", self.vltexture) self.finalQuad.setShaderInput( "vlparams", 32, 0.9 / 32.0, 0.97, 0.5 ) # Note - first 32 is now hardcoded into shader for cards that don't support variable sized loops. self.finalQuad.setShaderInput("casterpos", 0.5, 0.5, 0, 0) # Last parameter to vlcolor is the exposure vlcolor = Vec4( float(godrays.get("r", "1")), float(godrays.get("g", "1")), float(godrays.get("b", "1")), 0.04 ) self.finalQuad.setShaderInput("vlcolor", vlcolor) else: self.finalQuad = None