def __init__(self, x1, y1, x2, y2, z): Att_base.__init__(self, False, "Water1") # Water surface maker = CardMaker( 'water' ) maker.setFrame( x1, x2, y1, y2 ) self.waterNP = render.attachNewNode(maker.generate()) self.waterNP.setHpr(0,-90,0) self.waterNP.setPos(0,0,z) self.waterNP.setTransparency(TransparencyAttrib.MAlpha ) self.waterNP.setShader(loader.loadShader( 'Shaders/water1.sha' )) # Reflection plane self.waterPlane = Plane( Vec3( 0, 0, z+1 ), Point3( 0, 0, z ) ) planeNode = PlaneNode( 'waterPlane' ) planeNode.setPlane( self.waterPlane ) # Buffer and reflection camera self.buffer = base.win.makeTextureBuffer( 'waterBuffer', 512, 512 ) self.buffer.setClearColor( Vec4( 0, 0, 0, 1 ) ) cfa = CullFaceAttrib.makeReverse( ) rs = RenderState.make(cfa) self.watercamNP = base.makeCamera( self.buffer ) self.watercamNP.reparentTo(render) sa = ShaderAttrib.make() sa = sa.setShader(loader.loadShader('Shaders/splut3Clipped.sha') ) self.cam = self.watercamNP.node() self.cam.getLens( ).setFov( base.camLens.getFov( ) ) self.cam.getLens().setNear(1) self.cam.getLens().setFar(5000) self.cam.setInitialState( rs ) self.cam.setTagStateKey('Clipped') self.cam.setTagState('True', RenderState.make(sa)) # ---- water textures --------------------------------------------- # reflection texture, created in realtime by the 'water camera' tex0 = self.buffer.getTexture( ) tex0.setWrapU(Texture.WMClamp) tex0.setWrapV(Texture.WMClamp) ts0 = TextureStage( 'reflection' ) self.waterNP.setTexture( ts0, tex0 ) # distortion texture tex1 = loader.loadTexture('Textures/water.png') ts1 = TextureStage('distortion') self.waterNP.setTexture(ts1, tex1)
def makeWater(self): self.water = loader.loadModel("models/water.egg") self.water.setPos(0,0,1) self.water.setShader(loader.loadShader('shaders/water.sha')) self.water.setShaderInput('wateranim', Vec4(0.03, -0.015, 64.0, 0)) self.water.setShaderInput('waterdistort', Vec4(0.4, 4.0, 0.25, 0.45)) self.water.setShaderInput('time', 0) buffer = base.win.makeTextureBuffer('waterBuffer', 512, 512) #buffer.setClearColor(Vec4(0.3, 0.3, 1, 1)) cfa = CullFaceAttrib.makeReverse() rs = RenderState.make(cfa) self.watercamNP = base.makeCamera(buffer) self.watercamNP.reparentTo(render) cam = self.watercamNP.node() cam.getLens().setFov(base.camLens.getFov()) cam.getLens().setNear(1) cam.getLens().setFar(5000) cam.setInitialState(rs) self.waterPlane = Plane(Vec3(0, 0, 1), Point3(0, 0, 0)) planeNode = PlaneNode('waterPlane') planeNode.setPlane(self.waterPlane) #cam.lookAt(0,0,-1) cam.setTagStateKey('Clipped') tex0 = buffer.getTexture() tex0.setWrapU(Texture.WMClamp) tex0.setWrapV(Texture.WMClamp) ts0 = TextureStage('reflection') self.water.setTexture(ts0, tex0) tex1 = loader.loadTexture('texture/water.png') ts1 = TextureStage('distortion') self.water.setTexture(ts1, tex1) self.keyMap={}; self.keyMap["sit"]=0 self.keyMap["call"]=0 self.keyMap["left"]=0 self.keyMap["forward"]=0 self.keyMap["right"]=0 taskMgr.add(self.waterUpdate, "waterTask") taskMgr.add(self.cameraControl,"cameraControl") self.water.reparentTo(render)
def createGuiObjects(self): self.dayButton = DirectButton(parent=self.dayButtonLocator, image=self.selectedFrame, relief=None, command=self.__clickedOnDay, pressEffect=1, rolloverSound=None, clickSound=None) self.numberWidget = DirectLabel(parent=self.numberLocator, relief=None, text=str(self.myDate.day), text_scale=0.04, text_align=TextNode.ACenter, text_font=ToontownGlobals.getInterfaceFont(), text_fg=Vec4(110 / 255.0, 126 / 255.0, 255 / 255.0, 1)) self.attachMarker(self.numberLocator) self.listXorigin = 0 self.listFrameSizeX = self.scrollBottomRightLocator.getX() - self.scrollLocator.getX() self.scrollHeight = self.scrollLocator.getZ() - self.scrollBottomRightLocator.getZ() self.listZorigin = self.scrollBottomRightLocator.getZ() self.listFrameSizeZ = self.scrollLocator.getZ() - self.scrollBottomRightLocator.getZ() self.arrowButtonXScale = 1 self.arrowButtonZScale = 1 self.itemFrameXorigin = 0 self.itemFrameZorigin = 0 self.buttonXstart = self.itemFrameXorigin + 0.21 self.gui = loader.loadModel('phase_3.5/models/gui/friendslist_gui') buttonOffSet = -0.01 incButtonPos = (0.0, 0, 0) decButtonPos = (0.0, 0, 0) itemFrameMinZ = self.listZorigin itemFrameMaxZ = self.listZorigin + self.listFrameSizeZ arrowUp = self.find('**/downScroll_up') arrowDown = self.find('**/downScroll_down') arrowHover = self.find('**/downScroll_hover') self.scrollList = DirectScrolledList(parent=self.scrollLocator, relief=None, pos=(0, 0, 0), incButton_image=(arrowUp, arrowDown, arrowHover, arrowUp), incButton_relief=None, incButton_scale=(self.arrowButtonXScale, 1, self.arrowButtonZScale), incButton_pos=incButtonPos, incButton_image3_color=Vec4(1, 1, 1, 0.2), decButton_image=(arrowUp, arrowDown, arrowHover, arrowUp), decButton_relief=None, decButton_scale=(self.arrowButtonXScale, 1, -self.arrowButtonZScale), decButton_pos=decButtonPos, decButton_image3_color=Vec4(1, 1, 1, 0.2), itemFrame_pos=(self.itemFrameXorigin, 0, -0.03), numItemsVisible=4, incButtonCallback=self.scrollButtonPressed, decButtonCallback=self.scrollButtonPressed) itemFrameParent = self.scrollList.itemFrame.getParent() self.scrollList.incButton.reparentTo(self.scrollDownLocator) self.scrollList.decButton.reparentTo(self.scrollUpLocator) arrowUp.removeNode() arrowDown.removeNode() arrowHover.removeNode() clipper = PlaneNode('clipper') clipper.setPlane(Plane(Vec3(-1, 0, 0), Point3(0.23, 0, 0))) clipNP = self.scrollList.component('itemFrame').attachNewNode(clipper) self.scrollList.component('itemFrame').setClipPlane(clipNP) return
def load(self): CogdoGameMovie.load(self) self.toonDNA = ToonDNA.ToonDNA() self.toonDNA.newToonFromProperties('dss', 'ss', 'm', 'm', 2, 0, 2, 2, 1, 8, 1, 8, 1, 14) self.toonHead = Toon.Toon() self.toonHead.setDNA(self.toonDNA) self.toonHead.getGeomNode().setDepthWrite(1) self.toonHead.getGeomNode().setDepthTest(1) self.toonHead.loop('neutral') self.toonHead.setPosHprScale(-0.73, 0, -1.27, 180, 0, 0, 0.18, 0.18, 0.18) self.toonHead.reparentTo(hidden) self.toonHead.startBlink() self.cogHead = Suit.Suit() self.cogDNA = SuitDNA.SuitDNA() self.cogDNA.newSuit('le') self.cogHead.setDNA(self.cogDNA) self.cogHead.getGeomNode().setDepthWrite(1) self.cogHead.getGeomNode().setDepthTest(1) self.cogHead.loop('neutral') self.cogHead.setPosHprScale(-0.74, 0, -1.79, 180, 0, 0, 0.12, 0.14, 0.14) self.cogHead.reparentTo(hidden) self.cogHead.nametag.setNametag2d(None) self.cogHead.nametag.setNametag3d(None) self.clipPlane = self.toonHead.attachNewNode(PlaneNode('clip')) self.clipPlane.node().setPlane(Plane(0, 0, 1, 0)) self.clipPlane.setPos(0, 0, 2.45) audioMgr = base.cogdoGameAudioMgr self._cogDialogueSfx = audioMgr.createSfx('cogDialogue') self._toonDialogueSfx = audioMgr.createSfx('toonDialogue') def start(): camera.wrtReparentTo(render) self._startUpdateTask() def end(): self._stopUpdateTask() introDuration = Globals.Gameplay.IntroDurationSeconds dialogue = TTLocalizer.CogdoFlyingIntroMovieDialogue waitDur = introDuration / len(dialogue) flyDur = introDuration - waitDur * 0.5 flyThroughIval = Parallel( camera.posInterval(flyDur, self._exit.getPos(render) + Point3(0, -22, 1), blendType='easeInOut'), camera.hprInterval(flyDur, Point3(0, 5, 0), blendType='easeInOut')) self._ival = Sequence( Func(start), Parallel( flyThroughIval, Sequence( Func(self.displayLine, 'cog', self._getRandomLine(dialogue[0])), Wait(waitDur), Func(self.displayLine, 'toon', self._getRandomLine(dialogue[1])), Wait(waitDur), Func(self.displayLine, 'cog', self._getRandomLine(dialogue[2])), Wait(waitDur))), Func(end))
def createGuiObjects(self): self.dayButton = DirectButton(parent=self.dayButtonLocator, image=self.selectedFrame, relief=None, command=self.__clickedOnDay, pressEffect=1, rolloverSound=None, clickSound=None) self.numberWidget = DirectLabel( parent=self.numberLocator, relief=None, text=str(self.myDate.day), text_scale=0.04, text_align=TextNode.ACenter, text_font=ToontownGlobals.getInterfaceFont(), text_fg=Vec4(110 / 255.0, 126 / 255.0, 255 / 255.0, 1)) self.attachMarker(self.numberLocator) self.listXorigin = 0 self.listFrameSizeX = self.scrollBottomRightLocator.getX( ) - self.scrollLocator.getX() self.scrollHeight = self.scrollLocator.getZ( ) - self.scrollBottomRightLocator.getZ() self.listZorigin = self.scrollBottomRightLocator.getZ() self.listFrameSizeZ = self.scrollLocator.getZ( ) - self.scrollBottomRightLocator.getZ() self.arrowButtonXScale = 1 self.arrowButtonZScale = 1 self.itemFrameXorigin = 0 self.itemFrameZorigin = 0 self.buttonXstart = self.itemFrameXorigin + 0.21 self.gui = loader.loadModel('phase_3.5/models/gui/friendslist_gui') buttonOffSet = -0.01 incButtonPos = (0.0, 0, 0) decButtonPos = (0.0, 0, 0) itemFrameMinZ = self.listZorigin itemFrameMaxZ = self.listZorigin + self.listFrameSizeZ arrowUp = self.find('**/downScroll_up') arrowDown = self.find('**/downScroll_down') arrowHover = self.find('**/downScroll_hover') self.scrollList = DirectScrolledList( parent=self.scrollLocator, relief=None, pos=(0, 0, 0), incButton_image=(arrowUp, arrowDown, arrowHover, arrowUp), incButton_relief=None, incButton_scale=(self.arrowButtonXScale, 1, self.arrowButtonZScale), incButton_pos=incButtonPos, incButton_image3_color=Vec4(1, 1, 1, 0.2), decButton_image=(arrowUp, arrowDown, arrowHover, arrowUp), decButton_relief=None, decButton_scale=(self.arrowButtonXScale, 1, -self.arrowButtonZScale), decButton_pos=decButtonPos, decButton_image3_color=Vec4(1, 1, 1, 0.2), itemFrame_pos=(self.itemFrameXorigin, 0, -0.03), numItemsVisible=4, incButtonCallback=self.scrollButtonPressed, decButtonCallback=self.scrollButtonPressed) itemFrameParent = self.scrollList.itemFrame.getParent() self.scrollList.incButton.reparentTo(self.scrollDownLocator) self.scrollList.decButton.reparentTo(self.scrollUpLocator) arrowUp.removeNode() arrowDown.removeNode() arrowHover.removeNode() clipper = PlaneNode('clipper') clipper.setPlane(Plane(Vec3(-1, 0, 0), Point3(0.23, 0, 0))) clipNP = self.scrollList.component('itemFrame').attachNewNode(clipper) self.scrollList.component('itemFrame').setClipPlane(clipNP) return
def load(self): self.notify.debug('load()') CogdoGameMovie.load(self) backgroundGui = loader.loadModel( 'phase_5/models/cogdominium/tt_m_gui_csa_flyThru') self.bg = backgroundGui.find('**/background') self.chatBubble = backgroundGui.find('**/chatBubble') self.chatBubble.setScale(6.5, 6.5, 7.2999999999999998) self.chatBubble.setPos(0.32000000000000001, 0, -0.78000000000000003) self.bg.setScale(5.2000000000000002) self.bg.setPos(0.14000000000000001, 0, -0.66669999999999996) self.bg.reparentTo(aspect2d) self.chatBubble.reparentTo(aspect2d) self.frame = DirectFrame(geom=self.bg, relief=None, pos=(0.20000000000000001, 0, -0.66669999999999996)) self.bg.wrtReparentTo(self.frame) self.gameTitleText = DirectLabel( parent=self.frame, text=TTLocalizer.CogdoExecutiveSuiteTitle, scale=TTLocalizer.MRPgameTitleText * 0.80000000000000004, text_align=TextNode.ACenter, text_font=getSignFont(), text_fg=(1.0, 0.33000000000000002, 0.33000000000000002, 1.0), pos=TTLocalizer.MRgameTitleTextPos, relief=None) self.chatBubble.wrtReparentTo(self.frame) self.frame.hide() backgroundGui.removeNode() self.toonDNA = ToonDNA.ToonDNA() self.toonDNA.newToonFromProperties('dss', 'ss', 'm', 'm', 2, 0, 2, 2, 1, 8, 1, 8, 1, 14) self.toonHead = Toon.Toon() self.toonHead.setDNA(self.toonDNA) self.makeSuit('sc') self.toonHead.getGeomNode().setDepthWrite(1) self.toonHead.getGeomNode().setDepthTest(1) self.toonHead.loop('neutral') self.toonHead.setPosHprScale(-0.72999999999999998, 0, -1.27, 180, 0, 0, 0.17999999999999999, 0.17999999999999999, 0.17999999999999999) self.toonHead.reparentTo(hidden) self.toonHead.startBlink() self.clipPlane = self.toonHead.attachNewNode(PlaneNode('clip')) self.clipPlane.node().setPlane(Plane(0, 0, 1, 0)) self.clipPlane.setPos(0, 0, 2.4500000000000002) self._toonDialogueSfx = loader.loadSfx( 'phase_3.5/audio/dial/AV_dog_long.mp3') self._camHelperNode = NodePath('CamHelperNode') self._camHelperNode.reparentTo(render) dialogue = TTLocalizer.CogdoElevatorRewardLaff def start(): self.frame.show() base.setCellsAvailable( base.bottomCells + base.leftCells + base.rightCells, 0) def end(): self._dialogueLabel.reparentTo(hidden) self.toonHead.reparentTo(hidden) self.frame.hide() base.setCellsAvailable( base.bottomCells + base.leftCells + base.rightCells, 1) self._stopUpdateTask() self._ival = Sequence(Func(start), Func(self.displayLine, dialogue), Wait(self.elevatorDuration), Func(end)) self._startUpdateTask()
def load(self): CogdoGameMovie.load(self) self.toonDNA = ToonDNA.ToonDNA() self.toonDNA.newToonFromProperties('dss', 'ss', 'm', 'm', 2, 0, 2, 2, 1, 8, 1, 8, 1, 14) self.toonHead = Toon.Toon() self.toonHead.setDNA(self.toonDNA) self.makeSuit('sc') self.toonHead.getGeomNode().setDepthWrite(1) self.toonHead.getGeomNode().setDepthTest(1) self.toonHead.loop('neutral') self.toonHead.setPosHprScale(-0.73, 0, -1.27, 180, 0, 0, 0.18, 0.18, 0.18) self.toonHead.reparentTo(hidden) self.toonHead.startBlink() self.cogHead = Suit.Suit() self.cogDNA = SuitDNA.SuitDNA() self.cogDNA.newSuit('ms') self.cogHead.setDNA(self.cogDNA) self.cogHead.getGeomNode().setDepthWrite(1) self.cogHead.getGeomNode().setDepthTest(1) self.cogHead.loop('neutral') self.cogHead.setPosHprScale(-0.73, 0, -1.46, 180, 0, 0, 0.14, 0.14, 0.14) self.cogHead.reparentTo(hidden) self.clipPlane = self.toonHead.attachNewNode(PlaneNode('clip')) self.clipPlane.node().setPlane(Plane(0, 0, 1, 0)) self.clipPlane.setPos(0, 0, 2.45) audioMgr = base.cogdoGameAudioMgr self._cogDialogueSfx = audioMgr.createSfx('cogDialogue') self._toonDialogueSfx = audioMgr.createSfx('toonDialogue') suitData = Globals.SuitData[Globals.SuitTypes.Boss] bossSuit = Suit.Suit() d = SuitDNA.SuitDNA() d.newSuit(suitData['dnaName']) bossSuit.setDNA(d) bossSuit.setScale(suitData['scale']) bossSuit.loop('neutral') bossSuit.reparentTo(render) bossSuit.setPos(self._exit, -5, -5, 0) bossSuit.lookAt(self._exit) self._suits.append(bossSuit) self._camHelperNode = NodePath('CamHelperNode') self._camHelperNode.reparentTo(render) dialogue = TTLocalizer.CogdoMazeIntroMovieDialogue introDuration = Globals.IntroDurationSeconds waitDuration = introDuration / len(dialogue) def start(): camera.wrtReparentTo(render) self._exit.open(animate=False) def showBoss(): self._setCamTarget(bossSuit, 20, offset=Point3(0, 0, 7), angle=Point3(0, 15, 0)) bossSuit.loop('victory') self._state = 1 def showExit(): self._setCamTarget(self._exit, 10, offset=Point3(0, 0, 0), angle=Point3(0, 60, 0)) self._exit.close() self._state = 2 showExitIval = Parallel( camera.posInterval(waitDuration * 0.5, (10, -25, 20), other=self._exit, blendType='easeInOut'), Sequence( Wait(waitDuration * 0.25), Func(bossSuit.play, 'effort'), camera.hprInterval(waitDuration * 0.25, (30, -30, 0), blendType='easeInOut'), Func(self._exit.close), Wait(waitDuration * 0.5))) def showWaterCooler(): wc = self._maze.getWaterCoolers()[0] self._setCamTarget(wc, 25, angle=Point3(-30, 60, 0)) camera.wrtReparentTo(self._camHelperNode) self._state = 3 def end(): self._stopUpdateTask() self._ival = Sequence( Func(start), Func(self.displayLine, 'cog', self._getRandomLine(dialogue[0])), showExitIval, Func(showWaterCooler), Func(self.displayLine, 'toon', self._getRandomLine(dialogue[1])), Wait(waitDuration), Func(showBoss), bossSuit.hprInterval(1.0, bossSuit.getHpr() + Point3(180, 0, 0), blendType='easeInOut'), Func(self.displayLine, 'cog', self._getRandomLine(dialogue[2])), Wait(waitDuration - 1.0), Func(end)) self._startUpdateTask()
def load(self): self.notify.debug('load()') CogdoGameMovie.load(self) backgroundGui = loader.loadModel( 'phase_5/models/cogdominium/tt_m_gui_csa_flyThru') self.bg = backgroundGui.find('**/background') self.chatBubble = backgroundGui.find('**/chatBubble') self.chatBubble.setScale(6.5, 6.5, 7.3) self.chatBubble.setPos(0.32, 0, -0.78) self.bg.setScale(5.2) self.bg.setPos(0.14, 0, -0.6667) self.bg.reparentTo(aspect2d) self.chatBubble.reparentTo(aspect2d) self.frame = DirectFrame(geom=self.bg, relief=None, pos=(0.2, 0, -0.6667)) self.bg.wrtReparentTo(self.frame) self.gameTitleText = DirectLabel( parent=self.frame, text=TTLocalizer.CogdoExecutiveSuiteTitle, scale=TTLocalizer.MRPgameTitleText * 0.8, text_align=TextNode.ACenter, text_font=getSignFont(), text_fg=(1.0, 0.33, 0.33, 1.0), pos=TTLocalizer.MRgameTitleTextPos, relief=None) self.chatBubble.wrtReparentTo(self.frame) self.frame.hide() backgroundGui.removeNode() self.toonDNA = ToonDNA.ToonDNA() self.toonDNA.newToonFromProperties('dss', 'ss', 'm', 'm', 2, 0, 2, 2, 1, 8, 1, 8, 1, 14) self.toonHead = Toon.Toon() self.toonHead.setDNA(self.toonDNA) self.makeSuit('sc') self.toonHead.getGeomNode().setDepthWrite(1) self.toonHead.getGeomNode().setDepthTest(1) self.toonHead.loop('neutral') self.toonHead.setPosHprScale(-0.73, 0, -1.27, 180, 0, 0, 0.18, 0.18, 0.18) self.toonHead.reparentTo(hidden) self.toonHead.startBlink() self.clipPlane = self.toonHead.attachNewNode(PlaneNode('clip')) self.clipPlane.node().setPlane(Plane(0, 0, 1, 0)) self.clipPlane.setPos(0, 0, 2.45) self._toonDialogueSfx = loader.loadSfx( 'phase_3.5/audio/dial/AV_dog_long.ogg') self._camHelperNode = NodePath('CamHelperNode') self._camHelperNode.reparentTo(render) dialogue = TTLocalizer.CogdoExecutiveSuiteIntroMessage def start(): self.frame.show() base.setCellsAvailable( base.bottomCells + base.leftCells + base.rightCells, 0) def showShopOwner(): self._setCamTarget(self._shopOwner, -10, offset=Point3(0, 0, 5)) def end(): self._dialogueLabel.reparentTo(hidden) self.toonHead.reparentTo(hidden) self.frame.hide() base.setCellsAvailable( base.bottomCells + base.leftCells + base.rightCells, 1) self._stopUpdateTask() self._ival = Sequence( Func(start), Func(self.displayLine, dialogue), Func(showShopOwner), ParallelEndTogether( camera.posInterval(self.cameraMoveDuration, Point3(8, 0, 13), blendType='easeInOut'), camera.hprInterval(0.5, self._camHelperNode.getHpr(), blendType='easeInOut')), Wait(self.introDuration), Func(end)) self._startUpdateTask() return
def createGuiObjects(self): """Create the other gui objects in the month, assumes we have proper locators.""" # we create an invisible button so the day can be clicked on self.dayButton = DirectButton( parent=self.dayButtonLocator, image=self.selectedFrame, relief=None, command=self.__clickedOnDay, # next three settings are for debug pressEffect=1, rolloverSound=None, clickSound=None) self.numberWidget = DirectLabel( parent=self.numberLocator, relief=None, text=str(self.myDate.day), text_scale=0.04, text_align=TextNode.ACenter, text_font=ToontownGlobals.getInterfaceFont(), text_fg=Vec4(110 / 255.0, 126 / 255.0, 255 / 255.0, 1), ) self.attachMarker(self.numberLocator) self.listXorigin = 0 self.listFrameSizeX = self.scrollBottomRightLocator.getX( ) - self.scrollLocator.getX() self.scrollHeight = self.scrollLocator.getZ( ) - self.scrollBottomRightLocator.getZ() self.listZorigin = self.scrollBottomRightLocator.getZ() self.listFrameSizeZ = self.scrollLocator.getZ( ) - self.scrollBottomRightLocator.getZ() self.arrowButtonXScale = 1 self.arrowButtonZScale = 1 self.itemFrameXorigin = 0 self.itemFrameZorigin = 0 self.buttonXstart = self.itemFrameXorigin + 0.21 self.gui = loader.loadModel("phase_3.5/models/gui/friendslist_gui") buttonOffSet = -0.01 # these settings put the arrow buttons on the top incButtonPos = (0.0, 0, 0) decButtonPos = (0.0, 0, 0) # these settings put the arrow buttons on the right side # incButtonPos = (self.buttonXstart,0,self.listZorigin - buttonOffSet) # decButtonPos = (self.buttonXstart, 0, self.listZorigin + self.listFrameSizeZ + buttonOffSet) itemFrameMinZ = self.listZorigin itemFrameMaxZ = self.listZorigin + self.listFrameSizeZ arrowUp = self.find("**/downScroll_up") arrowDown = self.find("**/downScroll_down") arrowHover = self.find("**/downScroll_hover") self.scrollList = DirectScrolledList( parent=self.scrollLocator, relief=None, pos=(0, 0, 0), # inc and dec are DirectButtons # incButton is on the bottom of page, decButton is on the top! incButton_image=( arrowUp, arrowDown, arrowHover, arrowUp, ), incButton_relief=None, incButton_scale=(self.arrowButtonXScale, 1, self.arrowButtonZScale), incButton_pos=incButtonPos, # Make the disabled button fade out incButton_image3_color=Vec4(1, 1, 1, 0.2), decButton_image=( arrowUp, arrowDown, arrowHover, arrowUp, ), decButton_relief=None, decButton_scale=(self.arrowButtonXScale, 1, -self.arrowButtonZScale), decButton_pos=decButtonPos, # Make the disabled button fade out decButton_image3_color=Vec4(1, 1, 1, 0.2), # itemFrame is a DirectFrame, shift it down a bit to match top left scroll itemFrame_pos=(self.itemFrameXorigin, 0, -0.03), # each item is a button with text on it numItemsVisible=4, # so we select the day when we click on a scroll button incButtonCallback=self.scrollButtonPressed, decButtonCallback=self.scrollButtonPressed, ) # make sure the arrow buttons appear over item frame itemFrameParent = self.scrollList.itemFrame.getParent() self.scrollList.incButton.reparentTo(self.scrollDownLocator) self.scrollList.decButton.reparentTo(self.scrollUpLocator) arrowUp.removeNode() arrowDown.removeNode() arrowHover.removeNode() # Set up a clipping plane to truncate names that would extend # off the right end of the scrolled list. clipper = PlaneNode('clipper') clipper.setPlane(Plane(Vec3(-1, 0, 0), Point3(0.23, 0, 0))) clipNP = self.scrollList.component('itemFrame').attachNewNode(clipper) self.scrollList.component('itemFrame').setClipPlane(clipNP)
def load(self): self.notify.debug('load()') CogdoGameMovie.load(self) backgroundGui = loader.loadModel( 'phase_5/models/cogdominium/tt_m_gui_csa_flyThru') self.bg = backgroundGui.find('**/background') self.chatBubble = backgroundGui.find('**/chatBubble') self.chatBubble.setScale(6.5, 6.5, 7.3) self.chatBubble.setPos(0.32, 0, -0.78) self.bg.setScale(5.2) self.bg.setPos(0.14, 0, -0.6667) self.bg.reparentTo(aspect2d) self.chatBubble.reparentTo(aspect2d) self.frame = DirectFrame(geom=self.bg, relief=None, pos=(0.2, 0, -0.6667)) self.bg.wrtReparentTo(self.frame) self.gameTitleText = DirectLabel(parent=self.frame, text=TTLocalizer.CogdoBarrelRoomTitle, scale=TTLocalizer.MRPgameTitleText * 0.8, text_align=TextNode.ACenter, text_font=getSignFont(), text_fg=(1.0, 0.33, 0.33, 1.0), pos=TTLocalizer.MRgameTitleTextPos, relief=None) self.chatBubble.wrtReparentTo(self.frame) self.frame.hide() backgroundGui.removeNode() self.toonDNA = ToonDNA.ToonDNA() self.toonDNA.newToonFromProperties('dss', 'ss', 'm', 'm', 2, 0, 2, 2, 1, 8, 1, 8, 1, 14) self.toonHead = Toon.Toon() self.toonHead.setDNA(self.toonDNA) self.makeSuit('sc') self.toonHead.getGeomNode().setDepthWrite(1) self.toonHead.getGeomNode().setDepthTest(1) self.toonHead.loop('neutral') self.toonHead.setPosHprScale(-0.73, 0, -1.27, 180, 0, 0, 0.18, 0.18, 0.18) self.toonHead.reparentTo(hidden) self.toonHead.startBlink() self.clipPlane = self.toonHead.attachNewNode(PlaneNode('clip')) self.clipPlane.node().setPlane(Plane(0, 0, 1, 0)) self.clipPlane.setPos(0, 0, 2.45) self._toonDialogueSfx = loader.loadSfx( 'phase_3.5/audio/dial/AV_dog_long.ogg') self._camHelperNode = NodePath('CamHelperNode') self._camHelperNode.reparentTo(render) dialogue = TTLocalizer.CogdoBarrelIntroMovieDialogue def start(): self.frame.show() def end(): self._dialogueLabel.reparentTo(hidden) self.toonHead.reparentTo(hidden) self.frame.hide() self._stopUpdateTask() self._ival = Sequence( Func(start), Func(self.displayLine, dialogue), Wait(CogdoBarrelRoomConsts.BarrelRoomIntroTimeout), Func(end)) self._startUpdateTask()
def __init__(self, world, x1, y1, x2, y2, z): self.world = world logging.info(('setting up water plane at z=' + str(z))) # Water surface maker = CardMaker('water') maker.setFrame(x1, x2, y1, y2) self.waterNP = render.attachNewNode(maker.generate()) self.waterNP.setHpr(0, -90, 0) self.waterNP.setPos(0, 0, z) self.waterNP.setTransparency(TransparencyAttrib.MAlpha) self.waterNP.setShader(loader.loadShader('shaders/water.sha')) self.waterNP.setShaderInput('wateranim', Vec4(0.03, -0.015, 64.0, 0)) # vx, vy, scale, skip # offset, strength, refraction factor (0=perfect mirror, 1=total refraction), refractivity self.waterNP.setShaderInput('waterdistort', Vec4(0.4, 4.0, 0.25, 0.45)) self.waterNP.setShaderInput('time', 0) # Reflection plane self.waterPlane = Plane(Vec3(0, 0, z + 1), Point3(0, 0, z)) planeNode = PlaneNode('waterPlane') planeNode.setPlane(self.waterPlane) # Buffer and reflection camera buffer = base.win.makeTextureBuffer('waterBuffer', 512, 512) buffer.setClearColor(Vec4(0, 0, 0, 1)) cfa = CullFaceAttrib.makeReverse() rs = RenderState.make(cfa) self.watercamNP = base.makeCamera(buffer) self.watercamNP.reparentTo(render) #sa = ShaderAttrib.make() #sa = sa.setShader(loader.loadShader('shaders/splut3Clipped.sha') ) cam = self.watercamNP.node() cam.getLens().setFov(base.camLens.getFov()) cam.getLens().setNear(1) cam.getLens().setFar(5000) cam.setInitialState(rs) cam.setTagStateKey('Clipped') #cam.setTagState('True', RenderState.make(sa)) # ---- water textures ----------------------------------------------- #reflection texture, created in realtime by the 'water camera' tex0 = buffer.getTexture() tex0.setWrapU(Texture.WMClamp) tex0.setWrapV(Texture.WMClamp) ts0 = TextureStage('reflection') self.waterNP.setTexture(ts0, tex0) # distortion texture tex1 = loader.loadTexture('textures/water.png') ts1 = TextureStage('distortion') self.waterNP.setTexture(ts1, tex1) # ---- Fog --- broken min = Point3(x1, y1, -999.0) max = Point3(x2, y2, z) boundry = BoundingBox(min, max self.waterFog = Fog('waterFog') self.waterFog.setBounds(boundry) colour = (0.2, 0.5, 0.8) self.waterFog.setColor(*colour) self.waterFog.setExpDensity(0.05) render.attachNewNode(self.waterFog) #render.setFog(world.waterFog) taskMgr.add(self.update, "waterTask") def update(self, task): # update matrix of the reflection camera mc = base.camera.getMat() mf = self.waterPlane.getReflectionMat() self.watercamNP.setMat(mc * mf) self.waterNP.setShaderInput('time', task.time) self.waterNP.setX(self.world.ralph.getX()) self.waterNP.setY(self.world.ralph.getY()) return task.cont
def __init__(self, world, x1, y1, x2, y2, z): self.world = world logging.info(('setting up water plane at z=' + str(z))) # Water surface maker = CardMaker('water') maker.setFrame(x1, x2, y1, y2) self.waterNP = render.attachNewNode(maker.generate()) self.waterNP.setHpr(0, -90, 0) self.waterNP.setPos(0, 0, z) self.waterNP.setTransparency(TransparencyAttrib.MAlpha) self.waterNP.setShader(loader.loadShader('shaders/water.sha')) self.waterNP.setShaderInput('wateranim', Vec4(0.03, -0.015, 64.0, 0)) # vx, vy, scale, skip # offset, strength, refraction factor (0=perfect mirror, 1=total refraction), refractivity self.waterNP.setShaderInput('waterdistort', Vec4(0.4, 4.0, 0.25, 0.45)) self.waterNP.setShaderInput('time', 0) # Reflection plane self.waterPlane = Plane(Vec3(0, 0, z + 1), Point3(0, 0, z)) planeNode = PlaneNode('waterPlane') planeNode.setPlane(self.waterPlane) # Buffer and reflection camera buffer = base.win.makeTextureBuffer('waterBuffer', 512, 512) buffer.setClearColor(Vec4(0, 0, 0, 1)) cfa = CullFaceAttrib.makeReverse() rs = RenderState.make(cfa) self.watercamNP = base.makeCamera(buffer) self.watercamNP.reparentTo(render) #sa = ShaderAttrib.make() #sa = sa.setShader(loader.loadShader('shaders/splut3Clipped.sha') ) cam = self.watercamNP.node() cam.getLens().setFov(base.camLens.getFov()) cam.getLens().setNear(1) cam.getLens().setFar(5000) cam.setInitialState(rs) cam.setTagStateKey('Clipped') #cam.setTagState('True', RenderState.make(sa)) # ---- water textures --------------------------------------------- # reflection texture, created in realtime by the 'water camera' tex0 = buffer.getTexture() tex0.setWrapU(Texture.WMClamp) tex0.setWrapV(Texture.WMClamp) ts0 = TextureStage('reflection') self.waterNP.setTexture(ts0, tex0) # distortion texture tex1 = loader.loadTexture('textures/water.png') ts1 = TextureStage('distortion') self.waterNP.setTexture(ts1, tex1) # ---- Fog --- broken min = Point3(x1, y1, -999.0) max = Point3(x2, y2, z) boundry = BoundingBox(min, max) self.waterFog = Fog('waterFog') self.waterFog.setBounds(boundry) colour = (0.2, 0.5, 0.8) self.waterFog.setColor(*colour) self.waterFog.setExpDensity(0.05) render.attachNewNode(self.waterFog) #render.setFog(world.waterFog) taskMgr.add(self.update, "waterTask")
def __init__(self, manager, xml): self.surface = getWaterSurface(manager) self.surface.reparentTo(render) self.surface.hide( BitMask32.bit(1)) # Invisible to reflection camera (speedup) self.surface.hide(BitMask32.bit( 2)) # Invisible to volumetric lighting camera (speedup) self.surface.hide( BitMask32.bit(3)) # Invisible to shadow cameras (speedup) self.surface.setShader( loader.loadShader( manager.get('paths').getConfig().find('shaders').get('path') + '/water.cg')) self.surface.setShaderInput('time', 0.0, 0.0, 0.0, 0.0) ntex = loader.loadTexture( manager.get('paths').getConfig().find('textures').get('path') + '/water-normal.png') ntex.setMinfilter(Texture.FTLinearMipmapLinear) self.surface.setShaderInput('normal', ntex) self.surface.setShaderInput('camera', base.cam) self.surface.setTransparency(TransparencyAttrib.MDual, 10) self.surface.setTwoSided(True) self.surface.setShaderInput('waveInfo', Vec4(0.4, 0.4, 0.4, 0)) self.surface.setShaderInput('param2', Vec4(-0.015, 0.005, 0.05, 0.05)) self.surface.setShaderInput('param3', Vec4(0.7, 0.3, 0, 0)) self.surface.setShaderInput('param4', Vec4(2.0, 0.5, 0.5, 0.0)) #self.surface.setShaderInput('speed', Vec4(-.8, -.4, -.9, .3)) self.surface.setShaderInput('speed', Vec4(0.2, -1.2, -0.2, -0.7)) self.surface.setShaderInput('deepcolor', Vec4(0.0, 0.3, 0.5, 1.0)) self.surface.setShaderInput('shallowcolor', Vec4(0.0, 1.0, 1.0, 1.0)) self.surface.setShaderInput('reflectioncolor', Vec4(0.95, 1.0, 1.0, 1.0)) self.surface.hide() self.wbuffer = base.win.makeTextureBuffer('water', 512, 512) self.wbuffer.setClearColorActive(True) self.wbuffer.setClearColor(base.win.getClearColor()) self.wcamera = base.makeCamera(self.wbuffer) if manager.get('sky') != None and manager.get('sky').model != None: self.sky = manager.get('sky').model.copyTo(self.wcamera) self.sky.setTwoSided(True) self.sky.setSz(self.sky, -1) self.sky.setClipPlaneOff(1) self.sky.show() self.sky.hide(BitMask32.bit(0)) # Hide for normal camera self.sky.hide( BitMask32.bit(2)) # Hide for volumetric lighting camera self.sky.hide( BitMask32.bit(3)) # Hide for shadow camera(s), if any else: self.sky = None self.wcamera.reparentTo(render) self.wcamera.node().setLens(base.camLens) self.wcamera.node().setCameraMask(BitMask32.bit(1)) self.surface.hide(BitMask32.bit(1)) wtexture = self.wbuffer.getTexture() wtexture.setWrapU(Texture.WMClamp) wtexture.setWrapV(Texture.WMClamp) wtexture.setMinfilter(Texture.FTLinearMipmapLinear) self.surface.setShaderInput('reflection', wtexture) self.wplane = Plane(Vec3(0, 0, 1), Point3(0, 0, 0)) self.wplanenp = render.attachNewNode(PlaneNode('water', self.wplane)) tmpnp = NodePath('StateInitializer') tmpnp.setClipPlane(self.wplanenp) tmpnp.setAttrib(CullFaceAttrib.makeReverse()) self.wcamera.node().setInitialState(tmpnp.getState()) #self.fog = Fog('UnderwaterFog') #self.fog.setColor(0.0,0.3,0.5) self.fogEnabled = False