def __init__(self):
		self.ticks=0

		base.setBackgroundColor(224.0/255.0, 188.0/255.0, 112.0/255.0)
		base.camera.setPos(100,100,100)
		self.correctAspectRatio()
		self.titleScreenTrack=loader.loadModel("models/titlescreentrack")
		self.titleScreenTrack.setScale(1.0)
		self.titleScreenTrack.reparentTo(render)
		self.titleScreenTrack.setPos(0.0,-10,-2.5)
		self.trackRotation=0

		self.titleScreenTitle=loader.loadModel("models/gridleader")
		self.titleScreenTitle.setScale(1.0)
		self.titleScreenTitle.setH(180.0)
		self.titleScreenTitle.reparentTo(render)
		self.titleScreenTitle.setPos(0.0,-10,0.3)

		self.titleScreenText=TitleScreenText()

		startLineCm=CardMaker('card')
		# left, right, top, bottom
		startLineCm.setFrame(0,2.25,0,0.6)
		startLineNode=self.titleScreenTrack.attachNewNode(startLineCm.generate())
		startLineNode.setTwoSided(True)
		startLineNode.setBillboardAxis()
		startLineNode.setTransparency(TransparencyAttrib.MAlpha)
		tex=loader.loadTexture('textures/titlestartline.png')
		tex.setWrapU(Texture.WMClamp)
		tex.setWrapV(Texture.WMClamp)
		startLineNode.setTexture(tex)
		startLineNode.setPos(-0.202,1.521,0)
		self.startLineNode=startLineNode

		base.accept('aspectRatioChanged',self.correctAspectRatio)
Exemplo n.º 2
0
    def setupRightTexture(self):
        cm = CardMaker('quadMaker')
        cm.setColor(1.0, 1.0, 1.0, 1.0)

        aspect = base.camLens.getAspectRatio()
        htmlWidth = 2.0 * aspect * WEB_WIDTH / float(WIN_WIDTH)
        htmlHeight = 2.0 * float(WEB_HEIGHT) / float(WIN_HEIGHT)

        # the html area will be center aligned and vertically top aligned
        #cm.setFrame(-htmlWidth/2.0, htmlWidth/2.0, 1.0 - htmlHeight, 1.0)
        cm.setFrame(0, htmlWidth / 2.0, -htmlHeight / 2.0, htmlHeight / 2.0)
        card = cm.generate()
        self.rightQuad = NodePath(card)
        self.rightQuad.reparentTo(self.parent)

        self.rightGuiTex = Texture("guiTex")
        self.rightGuiTex.setupTexture(Texture.TT2dTexture, WEB_HALF_WIDTH,
                                      WEB_HEIGHT, 1, Texture.TUnsignedByte,
                                      Texture.FRgba)
        self.rightGuiTex.setKeepRamImage(True)
        self.rightGuiTex.makeRamImage()
        self.rightGuiTex.setWrapU(Texture.WMClamp)
        self.rightGuiTex.setWrapV(Texture.WMClamp)

        ts = TextureStage('rightWebTS')
        self.rightQuad.setTexture(ts, self.rightGuiTex)
        self.rightQuad.setTexScale(ts, 1.0, -1.0)

        self.rightQuad.setTransparency(0)
        self.rightQuad.setTwoSided(True)
        self.rightQuad.setColor(1.0, 1.0, 1.0, 1.0)
 def _initModel(self):
     baseName = '**/tt_t_gui_cmg_miniMap_'
     cardModel = CogdoUtil.loadMazeModel('miniMap_cards', group='gui')
     cm = CardMaker('bg')
     cm.setFrame(-1.1, 1.1, -1.1, 1.1)
     bg = self.attachNewNode(cm.generate())
     bg.setColor(*self._bgColor)
     bg.setBin('fixed', 0)
     frame = cardModel.find(baseName + 'frame')
     frame.reparentTo(self)
     frame.setScale(2.5)
     frame.setPos(0.01, 0, -0.01)
     self._entrance = cardModel.find(baseName + 'entrance')
     self._entrance.reparentTo(self)
     self._entrance.setScale(0.35)
     self._entrance.hide()
     self._exit = NodePath('exit')
     self._exit.setScale(0.35)
     self._exit.reparentTo(self)
     self._exitOpen = cardModel.find(baseName + 'exitOpen')
     self._exitOpen.reparentTo(self._exit)
     self._exitClosed = cardModel.find(baseName + 'exitClosed')
     self._exitClosed.reparentTo(self._exit)
     self._suitMarkerTemplate = cardModel.find(baseName + 'cogIcon')
     self._suitMarkerTemplate.detachNode()
     self._suitMarkerTemplate.setScale(0.225)
     self._waterCoolerTemplate = cardModel.find(baseName + 'waterDrop')
     self._waterCoolerTemplate.detachNode()
     self._waterCoolerTemplate.setScale(0.225)
     self._exit.hide()
     cardModel.removeNode()
Exemplo n.º 4
0
    def __init__(self, av, **kw):
        DirectFrame.__init__(self, relief=None, sortOrder=50)
        self.initialiseoptions(QuestMap)
        self.container = DirectFrame(parent=self, relief=None)
        self.marker = DirectFrame(parent=self.container, relief=None)
        self.cogInfoFrame = DirectFrame(parent=self.container, relief=None)
        cm = CardMaker('bg')
        cm.setFrame(-0.5, 0.5, -0.5, 0.5)
        bg = self.cogInfoFrame.attachNewNode(cm.generate())
        bg.setTransparency(1)
        bg.setColor(0.5, 0.5, 0.5, 0.5)
        bg.setBin('fixed', 0)
        self.cogInfoFrame['geom'] = bg
        self.cogInfoFrame['geom_pos'] = (0, 0, 0)
        self.cogInfoFrame['geom_scale'] = (6, 1, 2)
        self.cogInfoFrame.setScale(0.05)
        self.cogInfoFrame.setPos(0, 0, 0.6)
        self.buildingMarkers = []
        self.av = av
        self.wantToggle = base.config.GetBool('want-toggle-quest-map', True)
        self.updateMarker = True
        self.cornerPosInfo = None
        self.hqPosInfo = None
        self.fishingSpotInfo = None
        self.load()
        self.setScale(1.5)
        bg.removeNode()
        self.hoodId = None
        self.zoneId = None
        self.suitPercentage = {}
        for currHoodInfo in SuitPlannerBase.SuitPlannerBase.SuitHoodInfo:
            tracks = currHoodInfo[SuitPlannerBase.SuitPlannerBase.SUIT_HOOD_INFO_TRACK]
            self.suitPercentage[currHoodInfo[SuitPlannerBase.SuitPlannerBase.SUIT_HOOD_INFO_ZONE]] = tracks

        return
Exemplo n.º 5
0
 def setupTexture(self):
     cm = CardMaker('quadMaker')
     cm.setColor(1.0, 1.0, 1.0, 1.0)
     aspect = base.camLens.getAspectRatio()
     htmlWidth = 2.0 * aspect * WEB_WIDTH_PIXELS / float(WIN_WIDTH)
     htmlHeight = 2.0 * float(WEB_HEIGHT_PIXELS) / float(WIN_HEIGHT)
     cm.setFrame(-htmlWidth / 2.0, htmlWidth / 2.0, -htmlHeight / 2.0, htmlHeight / 2.0)
     bottomRightX = WEB_WIDTH_PIXELS / float(WEB_WIDTH + 1)
     bottomRightY = WEB_HEIGHT_PIXELS / float(WEB_HEIGHT + 1)
     cm.setUvRange(Point2(0, 1 - bottomRightY), Point2(bottomRightX, 1))
     card = cm.generate()
     self.quad = NodePath(card)
     self.quad.reparentTo(self.parent)
     self.guiTex = Texture('guiTex')
     self.guiTex.setupTexture(Texture.TT2dTexture, WEB_WIDTH, WEB_HEIGHT, 1, Texture.TUnsignedByte, Texture.FRgba)
     self.guiTex.setMinfilter(Texture.FTLinear)
     self.guiTex.setKeepRamImage(True)
     self.guiTex.makeRamImage()
     self.guiTex.setWrapU(Texture.WMRepeat)
     self.guiTex.setWrapV(Texture.WMRepeat)
     ts = TextureStage('webTS')
     self.quad.setTexture(ts, self.guiTex)
     self.quad.setTexScale(ts, 1.0, -1.0)
     self.quad.setTransparency(0)
     self.quad.setTwoSided(True)
     self.quad.setColor(1.0, 1.0, 1.0, 1.0)
     self.calcMouseLimits()
Exemplo n.º 6
0
    def _createMapTextureCard(self):
        mapImage = PNMImage(MAP_RESOLUTION, MAP_RESOLUTION)
        mapImage.fill(*self._bgColor)
        fgColor = VBase4D(*self._fgColor)
        for x in xrange(self._mazeHeight):
            for y in xrange(self._mazeWidth):
                if self._mazeCollTable[y][x] == 1:
                    ax = float(x) / self._mazeWidth * MAP_RESOLUTION
                    invertedY = self._mazeHeight - 1 - y
                    ay = float(invertedY) / self._mazeHeight * MAP_RESOLUTION
                    self._drawSquare(mapImage, int(ax), int(ay), 10, fgColor)

        mapTexture = Texture('mapTexture')
        mapTexture.setupTexture(Texture.TT2dTexture, self._maskResolution, self._maskResolution, 1, Texture.TUnsignedByte, Texture.FRgba)
        mapTexture.setMinfilter(Texture.FTLinear)
        mapTexture.load(mapImage)
        mapTexture.setWrapU(Texture.WMClamp)
        mapTexture.setWrapV(Texture.WMClamp)
        mapImage.clear()
        del mapImage
        cm = CardMaker('map_cardMaker')
        cm.setFrame(-1.0, 1.0, -1.0, 1.0)
        map = self.attachNewNode(cm.generate())
        map.setTexture(mapTexture, 1)
        return map
Exemplo n.º 7
0
    def __init__( self, *args, **kwargs ):
        colour = kwargs.pop( 'colour', (1, 1, 1, .2) )
        p3d.SingleTask.__init__( self, *args, **kwargs )

        # Create a card maker
        cm = CardMaker( self.name )
        cm.setFrame( 0, 1, 0, 1 )
        
        # Init the node path, wrapping the card maker to make a rectangle
        NodePath.__init__( self, cm.generate() )
        self.setColor( colour )
        self.setTransparency( 1 )
        self.reparentTo( self.root2d )
        self.hide()
        
        # Create the rectangle border
        ls = LineSegs()
        ls.moveTo( 0, 0, 0 )
        ls.drawTo( 1, 0, 0 )
        ls.drawTo( 1, 0, 1 )
        ls.drawTo( 0, 0, 1 )
        ls.drawTo( 0, 0, 0 )
        
        # Attach border to rectangle
        self.attachNewNode( ls.create() )
Exemplo n.º 8
0
 def genArrow(self, pos, hpr, id):
     factory = CardMaker('factory')
     factory.setFrame(-0.5, 0.5, -0.5, 0.5)
     arrowNode = factory.generate()
     arrowRoot = NodePath('root')
     baseArrow = NodePath(arrowNode)
     baseArrow.setTransparency(1)
     baseArrow.setTexture(self.boostArrowTexture)
     baseArrow.reparentTo(arrowRoot)
     arrow2 = baseArrow.copyTo(baseArrow)
     arrow2.setPos(0, 0, 1)
     arrow3 = arrow2.copyTo(arrow2)
     arrowRoot.setPos(*pos)
     arrowRoot.setHpr(*hpr)
     baseArrow.setHpr(0, -90, 0)
     baseArrow.setScale(24)
     arrowRoot.reparentTo(self.geom)
     trigger = 'boostArrow' + str(id)
     cs = CollisionTube(Point3(0.6, -6, 0), Point3(0.6, 54, 0), 4.8)
     cs.setTangible(0)
     triggerEvent = 'imIn-' + trigger
     cn = CollisionNode(trigger)
     cn.addSolid(cs)
     cn.setIntoCollideMask(BitMask32(32768))
     cn.setFromCollideMask(BitMask32(32768))
     cnp = NodePath(cn)
     cnp.reparentTo(arrowRoot)
     self.accept(triggerEvent, self.hitBoostArrow)
     arrowVec = arrow2.getPos(self.geom) - baseArrow.getPos(self.geom)
     arrowVec.normalize()
     idStr = str(id)
     cnp.setTag('boostId', idStr)
     self.boostDir[idStr] = arrowVec
     base.arrows.append(arrowRoot)
Exemplo n.º 9
0
 def loadFlatQuad(self, fullFilename):
     cm = CardMaker("cm-%s" % fullFilename)
     cm.setColor(1.0, 1.0, 1.0, 1.0)
     aspect = base.camLens.getAspectRatio()
     htmlWidth = 2.0 * aspect * WEB_WIDTH_PIXELS / float(WIN_WIDTH)
     htmlHeight = 2.0 * float(WEB_HEIGHT_PIXELS) / float(WIN_HEIGHT)
     cm.setFrame(-htmlWidth / 2.0, htmlWidth / 2.0, -htmlHeight / 2.0, htmlHeight / 2.0)
     bottomRightX = WEB_WIDTH_PIXELS / float(WEB_WIDTH + 1)
     bottomRightY = WEB_HEIGHT_PIXELS / float(WEB_HEIGHT + 1)
     cm.setUvRange(Point2(0, 1 - bottomRightY), Point2(bottomRightX, 1))
     card = cm.generate()
     quad = NodePath(card)
     jpgFile = PNMImage(WEB_WIDTH, WEB_HEIGHT)
     smallerJpgFile = PNMImage()
     readFile = smallerJpgFile.read(Filename(fullFilename))
     if readFile:
         jpgFile.copySubImage(smallerJpgFile, 0, 0)
         guiTex = Texture("guiTex")
         guiTex.setupTexture(Texture.TT2dTexture, WEB_WIDTH, WEB_HEIGHT, 1, Texture.TUnsignedByte, Texture.FRgba)
         guiTex.setMinfilter(Texture.FTLinear)
         guiTex.load(jpgFile)
         guiTex.setWrapU(Texture.WMClamp)
         guiTex.setWrapV(Texture.WMClamp)
         ts = TextureStage("webTS")
         quad.setTexture(ts, guiTex)
         quad.setTransparency(0)
         quad.setTwoSided(True)
         quad.setColor(1.0, 1.0, 1.0, 1.0)
         result = quad
     else:
         result = None
     Texture.setTexturesPower2(1)
     return result
Exemplo n.º 10
0
 def _initModel(self):
     baseName = '**/tt_t_gui_cmg_miniMap_'
     cardModel = CogdoUtil.loadMazeModel('miniMap_cards', group='gui')
     cm = CardMaker('bg')
     cm.setFrame(-1.1, 1.1, -1.1, 1.1)
     bg = self.attachNewNode(cm.generate())
     bg.setColor(*self._bgColor)
     bg.setBin('fixed', 0)
     frame = cardModel.find(baseName + 'frame')
     frame.reparentTo(self)
     frame.setScale(2.5)
     frame.setPos(0.01, 0, -0.01)
     self._entrance = cardModel.find(baseName + 'entrance')
     self._entrance.reparentTo(self)
     self._entrance.setScale(0.35)
     self._entrance.hide()
     self._exit = NodePath('exit')
     self._exit.setScale(0.35)
     self._exit.reparentTo(self)
     self._exitOpen = cardModel.find(baseName + 'exitOpen')
     self._exitOpen.reparentTo(self._exit)
     self._exitClosed = cardModel.find(baseName + 'exitClosed')
     self._exitClosed.reparentTo(self._exit)
     self._suitMarkerTemplate = cardModel.find(baseName + 'cogIcon')
     self._suitMarkerTemplate.detachNode()
     self._suitMarkerTemplate.setScale(0.225)
     self._waterCoolerTemplate = cardModel.find(baseName + 'waterDrop')
     self._waterCoolerTemplate.detachNode()
     self._waterCoolerTemplate.setScale(0.225)
     self._exit.hide()
     cardModel.removeNode()
Exemplo n.º 11
0
    def _createMaskTextureCard(self):
        """
        This will return a NodePath with a card textured with the map mask.  It
        also creates several other members that re needed to change the mask.
        """
        # create and fill empty mask image
        self._maskImage = PNMImage(self._maskResolution, self._maskResolution, 4)
        for x in range(self._maskResolution):
            for y in range(self._maskResolution):
                #maskImage.setXel(x,y,mapImage.getRed(x/13,y/10),mapImage.getGreen(x/13,y/10),mapImage.getBlue(x/13,y/10))
                self._maskImage.setXelA(x,y,0,0,0,1)

        # create the texture for the mask
        self.maskTexture = Texture("maskTexture")
        self.maskTexture.setupTexture(Texture.TT2dTexture, self._maskResolution, self._maskResolution, 1, Texture.TUnsignedByte, Texture.FRgba)
        self.maskTexture.setMinfilter(Texture.FTLinear)
        self.maskTexture.setWrapU(Texture.WMClamp)
        self.maskTexture.setWrapV(Texture.WMClamp)

        self.maskTexture.load(self._maskImage)
        base.graphicsEngine.renderFrame()

        # put the mask texture on a card and return it
        cm = CardMaker("mask_cardMaker")
        cm.setFrame(-1.0,1.0,-1.0,1.0)
        mask = self.attachNewNode(cm.generate())
        mask.setTexture(self.maskTexture, 1)
        mask.setTransparency(1)
        return mask
Exemplo n.º 12
0
 def loadFlatQuad(self, fullFilename):
     cm = CardMaker('cm-%s' % fullFilename)
     cm.setColor(1.0, 1.0, 1.0, 1.0)
     aspect = base.camLens.getAspectRatio()
     htmlWidth = 2.0 * aspect * WEB_WIDTH_PIXELS / float(WIN_WIDTH)
     htmlHeight = 2.0 * float(WEB_HEIGHT_PIXELS) / float(WIN_HEIGHT)
     cm.setFrame(-htmlWidth / 2.0, htmlWidth / 2.0, -htmlHeight / 2.0,
                 htmlHeight / 2.0)
     bottomRightX = WEB_WIDTH_PIXELS / float(WEB_WIDTH + 1)
     bottomRightY = WEB_HEIGHT_PIXELS / float(WEB_HEIGHT + 1)
     cm.setUvRange(Point2(0, 1 - bottomRightY), Point2(bottomRightX, 1))
     card = cm.generate()
     quad = NodePath(card)
     jpgFile = PNMImage(WEB_WIDTH, WEB_HEIGHT)
     smallerJpgFile = PNMImage()
     readFile = smallerJpgFile.read(Filename(fullFilename))
     if readFile:
         jpgFile.copySubImage(smallerJpgFile, 0, 0)
         guiTex = Texture('guiTex')
         guiTex.setupTexture(Texture.TT2dTexture, WEB_WIDTH, WEB_HEIGHT, 1,
                             Texture.TUnsignedByte, Texture.FRgba)
         guiTex.setMinfilter(Texture.FTLinear)
         guiTex.load(jpgFile)
         guiTex.setWrapU(Texture.WMClamp)
         guiTex.setWrapV(Texture.WMClamp)
         ts = TextureStage('webTS')
         quad.setTexture(ts, guiTex)
         quad.setTransparency(0)
         quad.setTwoSided(True)
         quad.setColor(1.0, 1.0, 1.0, 1.0)
         result = quad
     else:
         result = None
     Texture.setTexturesPower2(1)
     return result
Exemplo n.º 13
0
	def __init__(self, name, nrplates, width, height, shaderfile, texturefile, uvlist, jitter=-1):
		self.name = name
		self.texturefile = texturefile
		self.shaderfile = shaderfile
		
		self.np = NodePath('leaf')
		
		self.tex = loader.loadTexture('textures/' + texturefile)
		self.tex.setMinfilter(Texture.FTLinearMipmapLinear)
		self.tex.setMagfilter(Texture.FTLinearMipmapLinear)
		self.tex.setAnisotropDegree(2)
		self.np.setTexture(self.tex)
		self.np.setTwoSided(True)
		self.np.setTransparency(TransparencyAttrib.MAlpha)
		self.np.setDepthWrite(False)
		
		maker = CardMaker('leaf')
		maker.setFrame(-width/2.0, width/2.0, 0, height)
		#maker.setFrame(0,1,0,1)
		for i in range(nrplates):
			if uvlist != None:
				maker.setUvRange(uvlist[i][0], uvlist[i][1])
			else:
				maker.setUvRange(Point2(0,0), Point2(1,0.98))
			node = self.np.attachNewNode(maker.generate())
			#node.setTwoSided(True)
			node.setHpr(i * 180.0 / nrplates,0,0)
		self.np.flattenStrong()
		#np.flattenLight()
		#np.setTwoSided(True)
		
		if jitter == -1:
			self.jitter = height/width/2
		else:
			self.jitter = jitter
Exemplo n.º 14
0
 def setupTexture(self):
     cm = CardMaker('quadMaker')
     cm.setColor(1.0, 1.0, 1.0, 1.0)
     aspect = base.camLens.getAspectRatio()
     htmlWidth = 2.0 * aspect * WEB_WIDTH_PIXELS / float(WIN_WIDTH)
     htmlHeight = 2.0 * float(WEB_HEIGHT_PIXELS) / float(WIN_HEIGHT)
     cm.setFrame(-htmlWidth / 2.0, htmlWidth / 2.0, -htmlHeight / 2.0,
                 htmlHeight / 2.0)
     bottomRightX = WEB_WIDTH_PIXELS / float(WEB_WIDTH + 1)
     bottomRightY = WEB_HEIGHT_PIXELS / float(WEB_HEIGHT + 1)
     cm.setUvRange(Point2(0, 1 - bottomRightY), Point2(bottomRightX, 1))
     card = cm.generate()
     self.quad = NodePath(card)
     self.quad.reparentTo(self.parent)
     self.guiTex = Texture('guiTex')
     self.guiTex.setupTexture(Texture.TT2dTexture, WEB_WIDTH, WEB_HEIGHT, 1,
                              Texture.TUnsignedByte, Texture.FRgba)
     self.guiTex.setMinfilter(Texture.FTLinear)
     self.guiTex.setKeepRamImage(True)
     self.guiTex.makeRamImage()
     self.guiTex.setWrapU(Texture.WMRepeat)
     self.guiTex.setWrapV(Texture.WMRepeat)
     ts = TextureStage('webTS')
     self.quad.setTexture(ts, self.guiTex)
     self.quad.setTexScale(ts, 1.0, -1.0)
     self.quad.setTransparency(0)
     self.quad.setTwoSided(True)
     self.quad.setColor(1.0, 1.0, 1.0, 1.0)
     self.calcMouseLimits()
Exemplo n.º 15
0
    def _createMapTextureCard(self):
        mapImage = PNMImage(MAP_RESOLUTION, MAP_RESOLUTION)
        mapImage.fill(*self._bgColor)
        fgColor = VBase4D(*self._fgColor)
        for x in range(self._mazeHeight):
            for y in range(self._mazeWidth):
                if self._mazeCollTable[y][x] == 1:
                    ax = float(x) / self._mazeWidth * MAP_RESOLUTION
                    invertedY = self._mazeHeight - 1 - y
                    ay = float(invertedY) / self._mazeHeight * MAP_RESOLUTION
                    self._drawSquare(mapImage, int(ax), int(ay), 10, fgColor)

        mapTexture = Texture('mapTexture')
        mapTexture.setupTexture(Texture.TT2dTexture, self._maskResolution,
                                self._maskResolution, 1, Texture.TUnsignedByte,
                                Texture.FRgba)
        mapTexture.setMinfilter(Texture.FTLinear)
        mapTexture.load(mapImage)
        mapTexture.setWrapU(Texture.WMClamp)
        mapTexture.setWrapV(Texture.WMClamp)
        mapImage.clear()
        del mapImage
        cm = CardMaker('map_cardMaker')
        cm.setFrame(-1.0, 1.0, -1.0, 1.0)
        map = self.attachNewNode(cm.generate())
        map.setTexture(mapTexture, 1)
        return map
Exemplo n.º 16
0
 def __init__(self, av, **kw):
     DirectFrame.__init__(self, relief=None, sortOrder=50)
     self.initialiseoptions(QuestMap)
     self.container = DirectFrame(parent=self, relief=None)
     self.marker = DirectFrame(parent=self.container, relief=None)
     self.cogInfoFrame = DirectFrame(parent=self.container, relief=None)
     cm = CardMaker('bg')
     cm.setFrame(-0.5, 0.5, -0.5, 0.5)
     bg = self.cogInfoFrame.attachNewNode(cm.generate())
     bg.setTransparency(1)
     bg.setColor(0.5, 0.5, 0.5, 0.5)
     bg.setBin('fixed', 0)
     self.cogInfoFrame['geom'] = bg
     self.cogInfoFrame['geom_pos'] = (0, 0, 0)
     self.cogInfoFrame['geom_scale'] = (6, 1, 2)
     self.cogInfoFrame.setScale(0.05)
     self.cogInfoFrame.setPos(0, 0, 0.6)
     self.buildingMarkers = []
     self.av = av
     self.updateMarker = True
     self.cornerPosInfo = None
     self.hqPosInfo = None
     self.fishingSpotInfo = None
     self.load()
     self.setScale(1.5)
     bg.removeNode()
     self.hoodId = None
     self.zoneId = None
     self.suitPercentage = {}
     for currHoodInfo in SuitPlannerBase.SuitPlannerBase.SuitHoodInfo:
         tracks = currHoodInfo[
             SuitPlannerBase.SuitPlannerBase.SUIT_HOOD_INFO_TRACK]
         self.suitPercentage[currHoodInfo[
             SuitPlannerBase.SuitPlannerBase.SUIT_HOOD_INFO_ZONE]] = tracks
Exemplo n.º 17
0
 def _createSimpleMarker(self, size, color=(1, 1, 1)):
     halfSize = size * 0.5
     cm = CardMaker('mazemap_simple_marker')
     cm.setFrame(-halfSize, halfSize, -halfSize, halfSize)
     markerNP = self.maskedLayer.attachNewNode(cm.generate())
     markerNP.setColor(*color)
     return markerNP
 def genArrow(self, pos, hpr, id):
     factory = CardMaker('factory')
     factory.setFrame(-.5, 0.5, -.5, 0.5)
     arrowNode = factory.generate()
     arrowRoot = NodePath('root')
     baseArrow = NodePath(arrowNode)
     baseArrow.setTransparency(1)
     baseArrow.setTexture(self.boostArrowTexture)
     baseArrow.reparentTo(arrowRoot)
     arrow2 = baseArrow.copyTo(baseArrow)
     arrow2.setPos(0, 0, 1)
     arrow3 = arrow2.copyTo(arrow2)
     arrowRoot.setPos(*pos)
     arrowRoot.setHpr(*hpr)
     baseArrow.setHpr(0, -90, 0)
     baseArrow.setScale(24)
     arrowRoot.reparentTo(self.geom)
     trigger = 'boostArrow' + str(id)
     cs = CollisionTube(Point3(0.6, -6, 0), Point3(0.6, 54, 0), 4.8)
     cs.setTangible(0)
     triggerEvent = 'imIn-' + trigger
     cn = CollisionNode(trigger)
     cn.addSolid(cs)
     cn.setIntoCollideMask(BitMask32(32768))
     cn.setFromCollideMask(BitMask32(32768))
     cnp = NodePath(cn)
     cnp.reparentTo(arrowRoot)
     self.accept(triggerEvent, self.hitBoostArrow)
     arrowVec = arrow2.getPos(self.geom) - baseArrow.getPos(self.geom)
     arrowVec.normalize()
     idStr = str(id)
     cnp.setTag('boostId', idStr)
     self.boostDir[idStr] = arrowVec
     base.arrows.append(arrowRoot)
Exemplo n.º 19
0
 def _createSimpleMarker(self, size, color = (1, 1, 1)):
     halfSize = size * 0.5
     cm = CardMaker('mazemap_simple_marker')
     cm.setFrame(-halfSize, halfSize, -halfSize, halfSize)
     markerNP = self.maskedLayer.attachNewNode(cm.generate())
     markerNP.setColor(*color)
     return markerNP
Exemplo n.º 20
0
    def __init__(self, name, inclination, baseDimension):
        #public props
        self.baseDimension = baseDimension

        tex = loader.loadTexture(resourceManager.getResource(name) + '.png')

        xscaled = tex.getOrigFileXSize() / self.baseDimension
        yscaled = tex.getOrigFileYSize() / self.baseDimension

        cm = CardMaker("unscrollobject")
        cm.setFrame(0, xscaled, 0, yscaled)

        ts = TextureStage('ts')
        ts.setMode(TextureStage.MDecal)

        uvscroll = UvScrollNode("uvscrollnode", 1, 0.0, 0.0, 0.0)

        uvscroll.addChild(cm.generate())

        self.node = NodePath(uvscroll)
        self.node.setTwoSided(True)

        self.node.setX((-xscaled / 2) + 0.5)
        self.node.setP(-(360 - int(inclination)))
        self.node.setTexture(tex)
        self.node.setTransparency(TransparencyAttrib.MAlpha)
        self.node.reparentTo(render)
Exemplo n.º 21
0
    def __init__(self, player):

        self.player = player

        self.root = NodePath("CogdoFlyingGui")
        self.root.reparentTo(aspect2d)

        self.fuelMeter = NodePath("scrubMeter")
        self.fuelMeter.reparentTo(self.root)
        self.fuelMeter.setPos(1.1, 0.0, -0.7)
        self.fuelMeter.setSz(2.0)

        cm = CardMaker('card')
        cm.setFrame(-0.07, 0.07, 0.0, 0.75)
        self.fuelMeterBar = self.fuelMeter.attachNewNode(cm.generate())
        self.fuelMeterBar.setColor(0.95, 0.95, 0.0, 1.0)

        self.fuelLabel = DirectLabel(
            parent=self.root,
            relief=None,
            pos=(1.1, 0, -0.8),
            scale=0.075,
            text="Fuel",
            text_fg=(0.95, 0.95, 0, 1),
            text_shadow=(0, 0, 0, 1),
            text_font=ToontownGlobals.getInterfaceFont(),
        )

        self.messageLabel = DirectLabel(
            parent=self.root,
            relief=None,
            pos=(0.0, 0.0, -0.9),
            scale=0.1,
            text="                ",
            text_align=TextNode.ACenter,
            text_fg=(0.95, 0.95, 0, 1),
            text_shadow=(0, 0, 0, 1),
            text_font=ToontownGlobals.getInterfaceFont(),
            textMayChange=1,
        )
        self.messageLabel.stash()

        self.winLabel = DirectLabel(
            parent=self.root,
            relief=None,
            pos=(0.0, 0.0, 0.0),
            scale=0.25,
            text="You win!",
            text_align=TextNode.ACenter,
            text_fg=(0.95, 0.95, 0, 1),
            text_shadow=(0, 0, 0, 1),
            text_font=ToontownGlobals.getInterfaceFont(),
        )
        self.winLabel.stash()

        self.refuelLerp = LerpFunctionInterval(self.fuelMeterBar.setSz,
                                               fromData=0.0,
                                               toData=1.0,
                                               duration=2.0)
 def __init__(self,table=None,mask=None):
     """
     @keyword table: filename of a table texture. See table_template.psd. Either
                     paint anywhere inside the mask for a complete background
                     or turn off the pads and spinner and paint in the table circle
                     for just a table texture that will have spinners and pads
                     put on top of it.
     @type mask: str
     @keyword mask: filename of a mask texture of the non-Jam-o-Drum area. probably
                    jod_mask.png that comes with the Jam-o-Drum library.
     @type mask: str
     """
     NodePath.__init__(self,"JamoDrum")
     
     totalHeight = max(1.0,math.sqrt(2)/4.0+SPINNER_RADIUS)*2
     
     cm = CardMaker("card")
     cm.setFrame(-1,1,-1,1)
     self.tableCard = self.attachNewNode(cm.generate())
     self.tableCard.setP(-90)
     self.tableCard.setScale(4.0/3.0)
     self.tableCard.setLightOff()
     self.tableCard.setBin("background",0)
     self.tableCard.setDepthTest(0)
     self.tableCard.setDepthWrite(0)
     self.tableCard.hide()
     
     if (table):
         self.setTableTexture(loader.loadTexture(table))
                    
     
     if (mask):
         cm = CardMaker("JOD Mask")
         cm.setFrame(-4.0/3.0,4.0/3.0,-4.0/3.0,4.0/3.0)
         self.mask = aspect2d.attachNewNode(cm.generate())
         #self.mask.setP(-90)
         self.mask.setTexture(loader.loadTexture(mask),1)
         self.mask.setTransparency(1)
         self.mask.setDepthTest(0)
     else:
         self.mask = None
     
     self.stations = []
     for i in range(4):
         station = Station(self,i)
         station.reparentTo(self)
         self.stations.append(station)
     
     self.reparentTo(render)
     base.disableMouse()
     self.lens = OrthographicLens()
     self.lens.setFilmSize(totalHeight*base.getAspectRatio(),totalHeight)
     base.cam.node().setLens(self.lens)
     camera.setPosHpr(0,0,10.0, 0,-90,0)
     base.setBackgroundColor(0,0,0)
     
     self.audio3d = Audio3DManager(base.sfxManagerList[0],self)
     self.audio3d.setDropOffFactor(0)
Exemplo n.º 23
0
    def __init__(self, table=None, mask=None):
        """
        @keyword table: filename of a table texture. See table_template.psd. Either
                        paint anywhere inside the mask for a complete background
                        or turn off the pads and spinner and paint in the table circle
                        for just a table texture that will have spinners and pads
                        put on top of it.
        @type mask: str
        @keyword mask: filename of a mask texture of the non-Jam-o-Drum area. probably
                       jod_mask.png that comes with the Jam-o-Drum library.
        @type mask: str
        """
        NodePath.__init__(self, "JamoDrum")

        totalHeight = max(1.0, math.sqrt(2) / 4.0 + SPINNER_RADIUS) * 2

        cm = CardMaker("card")
        cm.setFrame(-1, 1, -1, 1)
        self.tableCard = self.attachNewNode(cm.generate())
        self.tableCard.setP(-90)
        self.tableCard.setScale(4.0 / 3.0)
        self.tableCard.setLightOff()
        self.tableCard.setBin("background", 0)
        self.tableCard.setDepthTest(0)
        self.tableCard.setDepthWrite(0)
        self.tableCard.hide()

        if (table):
            self.setTableTexture(loader.loadTexture(table))

        if (mask):
            cm = CardMaker("JOD Mask")
            cm.setFrame(-4.0 / 3.0, 4.0 / 3.0, -4.0 / 3.0, 4.0 / 3.0)
            self.mask = aspect2d.attachNewNode(cm.generate())
            #self.mask.setP(-90)
            self.mask.setTexture(loader.loadTexture(mask), 1)
            self.mask.setTransparency(1)
            self.mask.setDepthTest(0)
        else:
            self.mask = None

        self.stations = []
        for i in range(4):
            station = Station(self, i)
            station.reparentTo(self)
            self.stations.append(station)

        self.reparentTo(render)
        base.disableMouse()
        self.lens = OrthographicLens()
        self.lens.setFilmSize(totalHeight * base.getAspectRatio(), totalHeight)
        base.cam.node().setLens(self.lens)
        camera.setPosHpr(0, 0, 10.0, 0, -90, 0)
        base.setBackgroundColor(0, 0, 0)

        self.audio3d = Audio3DManager(base.sfxManagerList[0], self)
        self.audio3d.setDropOffFactor(0)
Exemplo n.º 24
0
    def loadFlatQuad(self, fullFilename):
        """Load the flat jpg into a quad."""
        assert self.notify.debugStateCall(self)
        #Texture.setTexturesPower2(AutoTextureScale.ATSUp)
        #Texture.setTexturesPower2(2)
        
        cm = CardMaker('cm-%s'%fullFilename)
        cm.setColor(1.0, 1.0, 1.0, 1.0)
        aspect = base.camLens.getAspectRatio()
        htmlWidth = 2.0*aspect * WEB_WIDTH_PIXELS / float(WIN_WIDTH)		
        htmlHeight = 2.0*float(WEB_HEIGHT_PIXELS) / float(WIN_HEIGHT) 

        # the html area will be center aligned and vertically top aligned
        #cm.setFrame(-htmlWidth/2.0, htmlWidth/2.0, 1.0 - htmlHeight, 1.0)
        cm.setFrame(-htmlWidth/2.0, htmlWidth/2.0, - htmlHeight / 2.0, htmlHeight / 2.0)

        bottomRightX = (WEB_WIDTH_PIXELS) / float( WEB_WIDTH +1)
        bottomRightY = WEB_HEIGHT_PIXELS / float (WEB_HEIGHT+1)

        #cm.setUvRange(Point2(0,0), Point2(bottomRightX, bottomRightY))
        cm.setUvRange(Point2(0,1-bottomRightY), Point2(bottomRightX,1))
        
        card = cm.generate()
        quad = NodePath(card)
        #quad.reparentTo(self.parent)

        jpgFile = PNMImage(WEB_WIDTH, WEB_HEIGHT)
        smallerJpgFile = PNMImage()
        readFile = smallerJpgFile.read(Filename(fullFilename))
        if readFile:
            jpgFile.copySubImage(smallerJpgFile, 0, 0)

            guiTex = Texture("guiTex")
            guiTex.setupTexture(Texture.TT2dTexture, WEB_WIDTH, WEB_HEIGHT, 1, Texture.TUnsignedByte, Texture.FRgba)
            guiTex.setMinfilter(Texture.FTLinear)
            guiTex.load(jpgFile)
            #guiTex.setKeepRamImage(True)		
            #guiTex.makeRamImage()				
            guiTex.setWrapU(Texture.WMClamp)
            guiTex.setWrapV(Texture.WMClamp)

            ts = TextureStage('webTS')
            quad.setTexture(ts, guiTex)
            #quad.setTexScale(ts, 1.0, -1.0)

            quad.setTransparency(0)
            quad.setTwoSided(True)
            quad.setColor(1.0, 1.0, 1.0, 1.0)
            result= quad
        else:
            # if we have an error loading the file, return None to signify an error
            result = None

        #Texture.setTexturesPower2(AutoTextureScale.ATSDown)
        Texture.setTexturesPower2(1)
        return result
Exemplo n.º 25
0
 def _initGUI(self):
     base.loadingScreen.beginStep('init Gui', 4, 55)
     cm = CardMaker('PotionBackground')
     cm.setFrame(-10, 10, -10, 10)
     cm.setColor(0, 0, 0, 1)
     self.background = NodePath(cm.generate())
     self.background.reparentTo(aspect2d)
     self.background.setBin('background', -100)
     self.xpBackground = NodePath('PotionXPBackground')
     self.xpBackground.reparentTo(aspect2d)
     self.xpBackground.setBin('background', -95)
     base.loadingScreen.tick()
     self.dialogs = NodePath('DialogBackground')
     self.dialogs.reparentTo(aspect2d)
     self.dialogs.setBin('background', -70)
     self.buttonsBackground = NodePath('PotionButtonBackground')
     self.buttonsBackground.reparentTo(base.a2dBottomRight)
     self.buttonsBackground.setBin('background', -90)
     textureCard = loader.loadModel('models/minigames/pir_m_gui_pot_textureCard')
     self.stretchedBackgroundTextureCard = textureCard.find('**/pir_t_gui_pot_background')
     self.stretchedBackgroundTextureCard.reparentTo(self.background)
     self.stretchedBackgroundTextureCard.setScale(3.3999999999999999, 1.0, 3.3999999999999999)
     self.stretchedBackgroundTextureCard.setPos(0.0, 20.0, 0.0)
     fadecm = CardMaker('card')
     fadecm.setFrameFullscreenQuad()
     self.fadeIn = render2d.attachNewNode(fadecm.generate())
     self.fadeIn.setBin('background', -50)
     self.fadeIn.setPos(0.0, -30.0, 0.0)
     self.fadeIn.setColor(0, 0, 0, 1.0)
     self.fadeIn.setTransparency(True)
     base.loadingScreen.tick()
     cm = CardMaker('card')
     cm.setFrame(0, 1, 0.01, 0.01)
     self.foregroundLayer = aspect2d.attachNewNode(cm.generate())
     self.foregroundTextureCard = textureCard.find('**/pir_t_gui_pot_foreground')
     self.foregroundTextureCard.setScale(0.80000000000000004, 1.0, 0.40000000000000002)
     self.foregroundTextureCard.setPos(-0.69999999999999996, -20.0, 0.80000000000000004)
     self.foregroundTextureCard.setBin('background', -80)
     self.foregroundTextureCard.copyTo(self.foregroundLayer)
     self.repMeter = ReputationMeter.ReputationMeter(InventoryType.PotionsRep, width = 0.56000000000000005)
     inv = localAvatar.getInventory()
     self.repMeter.reparentTo(self.xpBackground)
     self.repMeter.setPos(0, 0, -0.94999999999999996)
     self.repMeter.update(inv.getAccumulator(InventoryType.PotionsRep))
     localAvatar.guiMgr.registerReputationHandler(self.updateRepMeter)
     base.loadingScreen.tick()
     self.closeButton = GuiButton.GuiButton(image = (textureCard.find('**/pir_t_gui_pot_escape'), textureCard.find('**/pir_t_gui_pot_escapeOn'), textureCard.find('**/pir_t_gui_pot_escapeOn'), textureCard.find('**/pir_t_gui_pot_escape')), image_scale = (0.10000000000000001, 0.10000000000000001, 0.10000000000000001), image_pos = (0.074999999999999997, 0, 0.080000000000000002), hotkeys = [
         'Escape'], hotkeyLabel = PLocalizer.PotionGui['ExitButton'], pos = (-0.40000000000000002, 0.0, 0.01), text0_fg = PotionGlobals.TextColor, text1_fg = PiratesGuiGlobals.TextFG0, text2_fg = PiratesGuiGlobals.TextFG15, text3_fg = PotionGlobals.TextColorDisabled, parent = self.buttonsBackground, command = self.confirmQuit)
     self.returnButton = GuiButton.GuiButton(text = (PLocalizer.PotionGui['SwitchRecipe'], PLocalizer.PotionGui['SwitchRecipe'], PLocalizer.PotionGui['SwitchRecipe'], PLocalizer.PotionGui['SwitchRecipe']), pos = (-0.57999999999999996, 0.0, -0.62), text_scale = PiratesGuiGlobals.TextScaleExtraLarge, text_shadow = None, image = (None, None, None, None), text0_fg = PotionGlobals.TextColor, text1_fg = PiratesGuiGlobals.TextFG0, text2_fg = PiratesGuiGlobals.TextFG15, text3_fg = PotionGlobals.TextColorDisabled, parent = self.background, command = self.confirmReturn)
     self.returnButton.stash()
     self.hintsButton = GuiButton.GuiButton(text = (PLocalizer.PotionGui['ShowTutorial'], PLocalizer.PotionGui['ShowTutorial'], PLocalizer.PotionGui['ShowTutorial'], PLocalizer.PotionGui['ShowTutorial']), text_scale = PiratesGuiGlobals.TextScaleSmall, image_scale = (0.25, 0.10000000000000001, 0.17999999999999999), image_pos = (0, 0, 0), pos = (-0.53000000000000003, 0.0, 0.074999999999999997), parent = self.buttonsBackground, command = self.showLastHint)
     self.InfoButton = GuiButton.GuiButton(text = (PLocalizer.PotionGui['IngredientList'], PLocalizer.PotionGui['IngredientList'], PLocalizer.PotionGui['IngredientList'], PLocalizer.PotionGui['IngredientList']), text_scale = PiratesGuiGlobals.TextScaleSmall, image_scale = (0.29999999999999999, 0.10000000000000001, 0.17999999999999999), image_pos = (0, 0, 0), pos = (-0.83999999999999997, 0.0, 0.074999999999999997), parent = self.buttonsBackground, command = self.showInfo)
     textureCard.removeNode()
     base.loadingScreen.endStep('init Gui')
Exemplo n.º 26
0
 def _initGUI(self):
     base.loadingScreen.beginStep('init Gui', 4, 55)
     cm = CardMaker('PotionBackground')
     cm.setFrame(-10, 10, -10, 10)
     cm.setColor(0, 0, 0, 1)
     self.background = NodePath(cm.generate())
     self.background.reparentTo(aspect2d)
     self.background.setBin('background', -100)
     self.xpBackground = NodePath('PotionXPBackground')
     self.xpBackground.reparentTo(aspect2d)
     self.xpBackground.setBin('background', -95)
     base.loadingScreen.tick()
     self.dialogs = NodePath('DialogBackground')
     self.dialogs.reparentTo(aspect2d)
     self.dialogs.setBin('background', -70)
     self.buttonsBackground = NodePath('PotionButtonBackground')
     self.buttonsBackground.reparentTo(base.a2dBottomRight)
     self.buttonsBackground.setBin('background', -90)
     textureCard = loader.loadModel('models/minigames/pir_m_gui_pot_textureCard')
     self.stretchedBackgroundTextureCard = textureCard.find('**/pir_t_gui_pot_background')
     self.stretchedBackgroundTextureCard.reparentTo(self.background)
     self.stretchedBackgroundTextureCard.setScale(3.3999999999999999, 1.0, 3.3999999999999999)
     self.stretchedBackgroundTextureCard.setPos(0.0, 20.0, 0.0)
     fadecm = CardMaker('card')
     fadecm.setFrameFullscreenQuad()
     self.fadeIn = render2d.attachNewNode(fadecm.generate())
     self.fadeIn.setBin('background', -50)
     self.fadeIn.setPos(0.0, -30.0, 0.0)
     self.fadeIn.setColor(0, 0, 0, 1.0)
     self.fadeIn.setTransparency(True)
     base.loadingScreen.tick()
     cm = CardMaker('card')
     cm.setFrame(0, 1, 0.01, 0.01)
     self.foregroundLayer = aspect2d.attachNewNode(cm.generate())
     self.foregroundTextureCard = textureCard.find('**/pir_t_gui_pot_foreground')
     self.foregroundTextureCard.setScale(0.80000000000000004, 1.0, 0.40000000000000002)
     self.foregroundTextureCard.setPos(-0.69999999999999996, -20.0, 0.80000000000000004)
     self.foregroundTextureCard.setBin('background', -80)
     self.foregroundTextureCard.copyTo(self.foregroundLayer)
     self.repMeter = ReputationMeter.ReputationMeter(InventoryType.PotionsRep, width = 0.56000000000000005)
     inv = localAvatar.getInventory()
     self.repMeter.reparentTo(self.xpBackground)
     self.repMeter.setPos(0, 0, -0.94999999999999996)
     self.repMeter.update(inv.getAccumulator(InventoryType.PotionsRep))
     localAvatar.guiMgr.registerReputationHandler(self.updateRepMeter)
     base.loadingScreen.tick()
     self.closeButton = GuiButton.GuiButton(image = (textureCard.find('**/pir_t_gui_pot_escape'), textureCard.find('**/pir_t_gui_pot_escapeOn'), textureCard.find('**/pir_t_gui_pot_escapeOn'), textureCard.find('**/pir_t_gui_pot_escape')), image_scale = (0.10000000000000001, 0.10000000000000001, 0.10000000000000001), image_pos = (0.074999999999999997, 0, 0.080000000000000002), hotkeys = [
         'Escape'], hotkeyLabel = PLocalizer.PotionGui['ExitButton'], pos = (-0.40000000000000002, 0.0, 0.01), text0_fg = PotionGlobals.TextColor, text1_fg = PiratesGuiGlobals.TextFG0, text2_fg = PiratesGuiGlobals.TextFG15, text3_fg = PotionGlobals.TextColorDisabled, parent = self.buttonsBackground, command = self.confirmQuit)
     self.returnButton = GuiButton.GuiButton(text = (PLocalizer.PotionGui['SwitchRecipe'], PLocalizer.PotionGui['SwitchRecipe'], PLocalizer.PotionGui['SwitchRecipe'], PLocalizer.PotionGui['SwitchRecipe']), pos = (-0.57999999999999996, 0.0, -0.62), text_scale = PiratesGuiGlobals.TextScaleExtraLarge, text_shadow = None, image = (None, None, None, None), text0_fg = PotionGlobals.TextColor, text1_fg = PiratesGuiGlobals.TextFG0, text2_fg = PiratesGuiGlobals.TextFG15, text3_fg = PotionGlobals.TextColorDisabled, parent = self.background, command = self.confirmReturn)
     self.returnButton.stash()
     self.hintsButton = GuiButton.GuiButton(text = (PLocalizer.PotionGui['ShowTutorial'], PLocalizer.PotionGui['ShowTutorial'], PLocalizer.PotionGui['ShowTutorial'], PLocalizer.PotionGui['ShowTutorial']), text_scale = PiratesGuiGlobals.TextScaleSmall, image_scale = (0.25, 0.10000000000000001, 0.17999999999999999), image_pos = (0, 0, 0), pos = (-0.53000000000000003, 0.0, 0.074999999999999997), parent = self.buttonsBackground, command = self.showLastHint)
     self.InfoButton = GuiButton.GuiButton(text = (PLocalizer.PotionGui['IngredientList'], PLocalizer.PotionGui['IngredientList'], PLocalizer.PotionGui['IngredientList'], PLocalizer.PotionGui['IngredientList']), text_scale = PiratesGuiGlobals.TextScaleSmall, image_scale = (0.29999999999999999, 0.10000000000000001, 0.17999999999999999), image_pos = (0, 0, 0), pos = (-0.83999999999999997, 0.0, 0.074999999999999997), parent = self.buttonsBackground, command = self.showInfo)
     textureCard.removeNode()
     base.loadingScreen.endStep('init Gui')
Exemplo n.º 27
0
    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)
Exemplo n.º 28
0
 def make_vertical_wall(self, pos):
     x, y = pos
     cm = CardMaker("wall")
     cm.setFrame(0, 1, 0, 2)
     front_card = cm.generate()
     front = self.render.attachNewNode(front_card)
     front.setH(0)
     front.setPos(x,y,0)
     back_card = cm.generate()
     back = self.render.attachNewNode(back_card)
     back.setH(180)
     back.setPos(x+1,y,0)
	def makeCard(self, color, width, height, i, j, divisions):
		divisions = float(divisions)
		x = i / divisions
		y = j / divisions
		d = 1 / divisions

		card = CardMaker("wall")
		card.setColor(*color)
		card.setFrame(width*(x*2-1), width*((x+d)*2-1), height*(y*2-1), height*((y+d)*2-1))
		card.setUvRange(Point2(width*x, height*y), Point2(width*(x+d), height*(y+d)))
		card.setHasUvs(True)
		card.setHasNormals(True)
		node = self.node.attachNewNode(card.generate())
 def _initVisuals(self):
     RepairMincroGame._initVisuals(self)
     self.model = loader.loadModel('models/gui/pir_m_gui_srp_pumping_main')
     self.visual = self.attachNewNode('visual')
     self.visual.setPos(-0.25, 0.0, 0.074999999999999997)
     goalTopLoc = self.model.find('**/locator_top')
     goalTopLoc.reparentTo(self.visual)
     goalBottomLoc = self.model.find('**/locator_bottom')
     goalBottomLoc.reparentTo(self.visual)
     self.goalPositions = (goalBottomLoc.getPos(self), goalTopLoc.getPos(self))
     self.greatLabel = DirectLabel(text = PLocalizer.Minigame_Repair_Pumping_Great, text_fg = (0.20000000000000001, 0.80000000000000004, 0.29999999999999999, 1.0), text_pos = (0.0, 0.59999999999999998), text_align = TextNode.ACenter, text_font = PiratesGlobals.getPirateFont(), relief = None, text_shadow = (0.0, 0.0, 0.0, 1.0), scale = (0.080000000000000002, 0.080000000000000002, 0.080000000000000002), pos = (-0.46500000000000002, 0.0, 0.0), parent = self)
     self.failLabel = DirectLabel(text = PLocalizer.Minigame_Repair_Pumping_Fail, text_fg = (0.80000000000000004, 0.20000000000000001, 0.29999999999999999, 1.0), text_pos = (0.0, 0.59999999999999998), text_align = TextNode.ARight, text_font = PiratesGlobals.getPirateFont(), text_shadow = (0.0, 0.0, 0.0, 1.0), relief = None, scale = (0.080000000000000002, 0.080000000000000002, 0.080000000000000002), pos = (-0.625, 0.0, 0.0), parent = self)
     self.shipBackground = self.model.find('**/static_ship_background')
     self.shipBackground.reparentTo(self.visual)
     self.waterMeter = self.model.find('**/sprite_waterBottom')
     self.waterMeter.reparentTo(self.visual)
     self.waterTop = self.model.find('**/sprite_waterTop')
     self.waterTop.reparentTo(self.visual)
     self.waterMeterTopLoc = self.waterMeter.find('**/locator_topOfShipWater')
     self.pumpBackground = self.model.find('**/pumpBackground')
     self.pumpBackground.reparentTo(self.visual)
     self.pumpWaterTop = self.model.find('**/sprite_pumpWaterTop')
     self.pumpWaterTop.reparentTo(self.visual)
     self.pumpWaterBottom = self.model.find('**/sprite_pumpWaterBottom')
     self.pumpWaterBottom.reparentTo(self.visual)
     self.pumpWaterTopLoc = self.pumpWaterBottom.find('**/locator_topOfPumpWater')
     self.pumpHandle = self.model.find('**/sprite_handle')
     self.pumpHandle.reparentTo(self.visual)
     self.pumpBar = self.model.find('**/static_pump')
     self.pumpBar.reparentTo(self.visual)
     self.goalBox = self.model.find('**/sprite_clickField')
     self.goalBox.reparentTo(self.visual)
     self.goalBox.setTransparency(1)
     self.enableGoalBox()
     self.pumpLine = self.model.find('**/sprite_bar')
     self.pumpLine.reparentTo(self.visual)
     self.ghostLine = self.visual.attachNewNode('ghostLine')
     self.pumpLine.getChild(0).copyTo(self.ghostLine)
     self.ghostLine.setScale(self.pumpLine.getScale())
     self.ghostLine.setColor(1.0, 0.20000000000000001, 0.20000000000000001, 1.0)
     self.shipForground = self.model.find('**/static_ship_foreground')
     self.shipForground.reparentTo(self.visual)
     cm = CardMaker('cardMaker')
     cm.setFrame(-0.33000000000000002, 0.33000000000000002, 0.0, 1.0)
     self.goalBox.setZ(self.goalPositions[TOP].getZ())
     self.goalBoxStartScale = self.goalBox.getSz()
     self.enableGoalBox()
     self.pumpWaterUpLerp = LerpFunc(self.setPumpWater, fromData = -0.10000000000000001, toData = 1.0, duration = 0.5)
     self.pumpWaterDownLerp = LerpFunc(self.setPumpWater, fromData = 1.0, toData = -0.10000000000000001, duration = 0.5)
     self.model.removeNode()
     del self.model
Exemplo n.º 31
0
 def _initVisuals(self):
     RepairMincroGame._initVisuals(self)
     self.model = loader.loadModel('models/gui/pir_m_gui_srp_pumping_main')
     self.visual = self.attachNewNode('visual')
     self.visual.setPos(-0.25, 0.0, 0.074999999999999997)
     goalTopLoc = self.model.find('**/locator_top')
     goalTopLoc.reparentTo(self.visual)
     goalBottomLoc = self.model.find('**/locator_bottom')
     goalBottomLoc.reparentTo(self.visual)
     self.goalPositions = (goalBottomLoc.getPos(self), goalTopLoc.getPos(self))
     self.greatLabel = DirectLabel(text = PLocalizer.Minigame_Repair_Pumping_Great, text_fg = (0.20000000000000001, 0.80000000000000004, 0.29999999999999999, 1.0), text_pos = (0.0, 0.59999999999999998), text_align = TextNode.ACenter, text_font = PiratesGlobals.getPirateFont(), relief = None, text_shadow = (0.0, 0.0, 0.0, 1.0), scale = (0.080000000000000002, 0.080000000000000002, 0.080000000000000002), pos = (-0.46500000000000002, 0.0, 0.0), parent = self)
     self.failLabel = DirectLabel(text = PLocalizer.Minigame_Repair_Pumping_Fail, text_fg = (0.80000000000000004, 0.20000000000000001, 0.29999999999999999, 1.0), text_pos = (0.0, 0.59999999999999998), text_align = TextNode.ARight, text_font = PiratesGlobals.getPirateFont(), text_shadow = (0.0, 0.0, 0.0, 1.0), relief = None, scale = (0.080000000000000002, 0.080000000000000002, 0.080000000000000002), pos = (-0.625, 0.0, 0.0), parent = self)
     self.shipBackground = self.model.find('**/static_ship_background')
     self.shipBackground.reparentTo(self.visual)
     self.waterMeter = self.model.find('**/sprite_waterBottom')
     self.waterMeter.reparentTo(self.visual)
     self.waterTop = self.model.find('**/sprite_waterTop')
     self.waterTop.reparentTo(self.visual)
     self.waterMeterTopLoc = self.waterMeter.find('**/locator_topOfShipWater')
     self.pumpBackground = self.model.find('**/pumpBackground')
     self.pumpBackground.reparentTo(self.visual)
     self.pumpWaterTop = self.model.find('**/sprite_pumpWaterTop')
     self.pumpWaterTop.reparentTo(self.visual)
     self.pumpWaterBottom = self.model.find('**/sprite_pumpWaterBottom')
     self.pumpWaterBottom.reparentTo(self.visual)
     self.pumpWaterTopLoc = self.pumpWaterBottom.find('**/locator_topOfPumpWater')
     self.pumpHandle = self.model.find('**/sprite_handle')
     self.pumpHandle.reparentTo(self.visual)
     self.pumpBar = self.model.find('**/static_pump')
     self.pumpBar.reparentTo(self.visual)
     self.goalBox = self.model.find('**/sprite_clickField')
     self.goalBox.reparentTo(self.visual)
     self.goalBox.setTransparency(1)
     self.enableGoalBox()
     self.pumpLine = self.model.find('**/sprite_bar')
     self.pumpLine.reparentTo(self.visual)
     self.ghostLine = self.visual.attachNewNode('ghostLine')
     self.pumpLine.getChild(0).copyTo(self.ghostLine)
     self.ghostLine.setScale(self.pumpLine.getScale())
     self.ghostLine.setColor(1.0, 0.20000000000000001, 0.20000000000000001, 1.0)
     self.shipForground = self.model.find('**/static_ship_foreground')
     self.shipForground.reparentTo(self.visual)
     cm = CardMaker('cardMaker')
     cm.setFrame(-0.33000000000000002, 0.33000000000000002, 0.0, 1.0)
     self.goalBox.setZ(self.goalPositions[TOP].getZ())
     self.goalBoxStartScale = self.goalBox.getSz()
     self.enableGoalBox()
     self.pumpWaterUpLerp = LerpFunc(self.setPumpWater, fromData = -0.10000000000000001, toData = 1.0, duration = 0.5)
     self.pumpWaterDownLerp = LerpFunc(self.setPumpWater, fromData = 1.0, toData = -0.10000000000000001, duration = 0.5)
     self.model.removeNode()
     del self.model
Exemplo n.º 32
0
	def __init__(self, listConsideration=[]):
		
		z = -0.05
		self.plane = Plane(Vec3(0, 0, 1), Point3(0, 0, z)) 
		cm = CardMaker("blah") 
		cm.setFrame(-100, 100, -100, 100) 
		render.attachNewNode(cm.generate()).lookAt(0, 0, -1) 
		
		#Create a selection window using cardmaker 
		#We will use the setScale function to dynamically scale the quad to the appropriate size in UpdateSelRect 
		temp = CardMaker('') 
		temp.setFrame(0, 1, 0, 1) 
		#self.npSelRect is the actual selection rectangle that we dynamically hide/unhide and change size 
		self.npSelRect = render2d.attachNewNode(temp.generate()) 
		self.npSelRect.setColor(0.5,1,0,.3) 
		self.npSelRect.setTransparency(1) 
		self.npSelRect.hide() 
		LS = LineSegs() 
		LS.setColor(0.5,1,0,1)
		LS.moveTo(0,0,0) 
		LS.drawTo(1,0,0) 
		LS.drawTo(1,0,1) 
		LS.drawTo(0,0,1) 
		LS.drawTo(0,0,0) 
		self.npSelRect.attachNewNode(LS.create()) 
		self.listConsideration = listConsideration 
		self.listSelected = [] 
		self.listLastSelected = [] 
		 
		self.pt2InitialMousePos = (-12, -12) 
		self.pt2LastMousePos = (-12, -12) 
		 
		####----Used to differentiate between group selections and point selections 
		#self.booMouseMoved  = False 
		self.fFovh, self.fFovv = base.camLens.getFov() 
		 
		####--Used to control how frequently update_rect is updated; 
		self.fTimeLastUpdateSelRect = 0 
		self.fTimeLastUpdateSelected = 0 
		self.UpdateTimeSelRect = 0.015 
		self.UpdateTimeSelected = 0.015 
		 
		####------Register the left-mouse-button to start selecting 
		self.accept("mouse1", self.OnStartSelect) 
		self.accept("control-mouse1", self.OnStartSelect) 
		self.accept("mouse1-up", self.OnStopSelect) 
		self.taskUpdateSelRect = 0 
		
		####------otherThings
		self.booSelecting = False
Exemplo n.º 33
0
    def __init__(self,width,height,texture,scale):
        self.width = width*scale
        self.height = height*scale
        print texture
        self.texture = loader.loadTexture(texture)

        cm = CardMaker("CardMaker")
        cm.setFrame((self.width/2,self.height/2,0),(-self.width/2,self.height/2,0),(-self.width/2,-self.height/2,0),(self.width/2,-self.height/2,0))
        card = render.attachNewNode(cm.generate())
        card.clearColor()
        card.setBin("background", 10)
        card.setHpr(180,0,0)
        card.setTransparency(TransparencyAttrib.MAlpha)

        card.setTexture(self.texture)
Exemplo n.º 34
0
    def makeCard(self, color, width, height, i, j, divisions):
        divisions = float(divisions)
        x = i / divisions
        y = j / divisions
        d = 1 / divisions

        card = CardMaker("wall")
        card.setColor(*color)
        card.setFrame(width * (x * 2 - 1), width * ((x + d) * 2 - 1),
                      height * (y * 2 - 1), height * ((y + d) * 2 - 1))
        card.setUvRange(Point2(width * x, height * y),
                        Point2(width * (x + d), height * (y + d)))
        card.setHasUvs(True)
        card.setHasNormals(True)
        node = self.node.attachNewNode(card.generate())
Exemplo n.º 35
0
def setSky(directory, ext=".jpg"):
    """Sets up a skybox. 'directory' is the directory whitch contains 6
    pictures with the names right.ext, left.ext and so on (see template).
    ext is the extension the pictures have (with dot).
    """
    #TODO: accept all supported image file extensions without the need for an
    #      extra argument

    # remove the old sky first when loading a new one
    # TODO: get this working...
    #oldsky = render.find("*sky*")
    #print oldsky
    #for child in render.getChildren():
    #    child.remove()

    sky = NodePath().attachNewNode("sky")
    sides = {
        "right":  ( 1,  0,  0, -90,   0,  0),
        "left":   (-1,  0,  0,  90,   0,  0),
        "top":    ( 0,  0,  1,   0,  90,  0),
        "bottom": ( 0,  0, -1,  180,  -90,  0),
        "front":  ( 0,  1,  0,   0,   0,  0),
        "back":   ( 0, -1,  0, 180,   0,  0)
        }
    for name, poshpr in sides.iteritems():

        c = CardMaker(name)
        c.setFrame(-1, 1, -1, 1)
        card = c.generate()
        cardnode = sky.attachNewNode(card)
        cardnode.setPosHpr(*poshpr)
        tex = loader.loadTexture("skyboxes/" + directory + "/" + name + ext)
        tex.setWrapV(tex.WMClamp)
        tex.setMagfilter(tex.FTNearestMipmapNearest)
        tex.setMinfilter(tex.FTNearestMipmapNearest)
        cardnode.setTexture(tex)

    sky.flattenStrong()
    sky.setScale(10, 10, 10)
    sky.setCompass()
    sky.setBin('background', 0)
    sky.setDepthTest(False)
    sky.setDepthWrite(False)
    sky.setLightOff()
    sky.reparentTo(camera)

    geom = sky.getChild(0).node()
    geom.setName("cube")
 def __init__(self, potionGame):
     self.numColumns = 8
     self.numRows = 10
     DirectFrame.__init__(self, parent = potionGame.background, relief = None)
     cm = CardMaker('card')
     cm.setFrame(0, 0, 1.0, 1.0)
     self.background = self.attachNewNode(cm.generate())
     self.background.setColor(0.20000000000000001, 0.20000000000000001, 0.20000000000000001, 1)
     self.potionGame = potionGame
     self.pieceDropped = False
     self.pieceFlipped = False
     self.pieceNotDropped = False
     self.delayDropped = False
     self.experementMatched = False
     self.experementFailed = False
     self.initBoard()
Exemplo n.º 37
0
 def createSprite(self,filename, x, z, sx, sz, transparent = 1):
     
     cm = CardMaker('spritesMaker') 
     cm.setFrame(-0.5, 0.5, -0.5, 0.5) 
     sprite = cm.generate()    
     
     tex = loader.loadTexture(filename) 
     
     spriteNP = NodePath(sprite)    
     
     spriteNP.setTexture(tex) 
     spriteNP.setPos(x, 0, z) 
     spriteNP.setScale(sx, 1.0, sz) 
     spriteNP.setTransparency(transparent)
      
     return spriteNP
Exemplo n.º 38
0
        def __init__(self, scale=1, value=1, r=1, g=0, b=0):
                NodePath.__init__(self, 'healthbar')

                self.scale = scale
                cmfg = CardMaker('fg')
                cmfg.setFrame(- scale,  scale, -0.1 * scale, 0.1 * scale)
                self.fg = self.attachNewNode(cmfg.generate())

                cmbg = CardMaker('bg') 
                cmbg.setFrame(- scale, scale, -0.1 * scale, 0.1 * scale) 
                self.bg = self.attachNewNode(cmbg.generate()) 

                self.fg.setColor(r, g, b, 1) 
                self.bg.setColor(0.2, 0.2, 0.2, 1) 

                self.setValue(value) 
Exemplo n.º 39
0
    def _createMapTextureCard(self):
        """
        This will return a NodePath with a card textured with the minimap.  The
        minimap texture is dynamically created from the map data.
        """
        # create and fill empty map image
        mapImage = PNMImage(MAP_RESOLUTION, MAP_RESOLUTION)
        blockFiles = []
        for i in range(5):
            blockFiles.append(PNMImage())
            #blockFiles[i].read(Filename("mapBlock%i.jpg"%(i+1)))
            # TODO:maze either reference a set of textures for each piece or fill with color
            blockFiles[i].read(Filename('phase_4/maps/male_sleeve4New.jpg'))
        mapImage.fill(0.8, 0.8, 0.8)

        # iterate through the map data and place a block in the map image where appropriate
        for x in range( len(self._mazeLayout[0]) ):
            for y in range( len(self._mazeLayout) ):
                if self._mazeLayout[y][x]:
                    ax = float(x)/len(self._mazeLayout[0]) * MAP_RESOLUTION
                    ay = float(y)/len(self._mazeLayout) * MAP_RESOLUTION

                    #TODO:maze use different blocks for different wall types or items
                    #mapImage.copySubImage(random.choice(blockFiles), int(ax), int(ay), 20, 20, 32, 32)

                    #TODO:maze find the ideal block texture size for the map so we dont
                    #          have to do this strange offset
                    #mapImage.copySubImage(blockFiles[0], int(ax), int(ay), 0, 0, 32, 32)
                    self._drawSquare(mapImage, int(ax), int(ay), 10, VBase4D(0.5, 0.5, 0.5, 1.0))

        # create a texture from the map image
        mapTexture = Texture("mapTexture")
        mapTexture.setupTexture(Texture.TT2dTexture, self._maskResolution, self._maskResolution, 1, Texture.TUnsignedByte, Texture.FRgba)
        mapTexture.setMinfilter(Texture.FTLinear)
        mapTexture.load(mapImage)
        mapTexture.setWrapU(Texture.WMClamp)
        mapTexture.setWrapV(Texture.WMClamp)

        mapImage.clear()
        del mapImage

        # put the texture on a card and return it
        cm = CardMaker("map_cardMaker")
        cm.setFrame(-1.0,1.0,-1.0,1.0)
        map = self.attachNewNode(cm.generate())
        map.setTexture(mapTexture, 1)
        return map
Exemplo n.º 40
0
class BulletHoles:
    """The name says it all."""
    def __init__(self, manager, xml):
        self.texture = loader.loadTexture('data/textures/bullet-hole.png')
        self.texture.setMinfilter(Texture.FTLinearMipmapLinear)
        self.container = render.attachNewNode(ModelRoot('bullet-holes'))
        self.card = CardMaker('bullet-hole')
        s = BULLETHOLE_SIZE * 0.5
        self.card.setFrame(-s, s, -s, s)
        self.card.setUvRange(Point2(0, 0), Point2(1, 1))

    def makeNew(self, pos, nor, parent=None):
        """Makes a new bullet hole."""
        if parent == None:
            parent = self.container
        else:
            # Add a subnode to the parent, if it's not already there
            child = parent.find('bullet-holes')
            if child.isEmpty():
                parent = parent.attachNewNode('bullet-holes')
            else:
                parent = child
        newhole = NodePath(self.card.generate())
        newhole.reparentTo(parent)
        newhole.lookAt(render, Point3(newhole.getPos(render) - nor))
        newhole.setR(newhole, random() * 360.0)
        newhole.setPos(render, pos)
        # Offset it a little to avoid z-fighting
        # Increase this value if you still see it.
        newhole.setY(newhole, -.001 - random() * 0.01)
        del newhole
        # We don't want one batch per bullet hole, so flatten it.
        # This could be made smarter to preserve culling, but
        # I have yet to see a performance loss.
        # The clearTexture() is a necessary hack.
        parent.clearTexture()
        parent.flattenStrong()
        parent.setTexture(self.texture)
        parent.setTransparency(TransparencyAttrib.MDual)
        parent.setShaderOff(1)
        parent.hide(BitMask32.bit(
            2))  # Invisible to volumetric lighting camera (speedup)
        parent.hide(BitMask32.bit(3))  # Invisible to shadow cameras (speedup)

    def destroy(self):
        self.container.removeNode()
Exemplo n.º 41
0
 def __init__(self, potionGame):
     self.numColumns = 8
     self.numRows = 10
     DirectFrame.__init__(self, parent=potionGame.background, relief=None)
     cm = CardMaker('card')
     cm.setFrame(0, 0, 1.0, 1.0)
     self.background = self.attachNewNode(cm.generate())
     self.background.setColor(0.2, 0.2, 0.2, 1)
     self.potionGame = potionGame
     self.pieceDropped = False
     self.pieceFlipped = False
     self.pieceNotDropped = False
     self.delayDropped = False
     self.experementMatched = False
     self.experementFailed = False
     self.initBoard()
     return
Exemplo n.º 42
0
    def load_floor(self):
        cm = CardMaker("floor")
        cm.setFrame(0, 1, 0, 1)
        card = cm.generate()

        grass_texture = self.loader.loadTexture(os.path.join("data", "images", "grass.png"))
        wood_texture = self.loader.loadTexture(os.path.join("data", "images", "floor_wood_0.png"))
        
        for x, row in enumerate(self.floor_data.layout):
            for y, tile in enumerate(row):
                floor = self.render.attachNewNode(cm.generate())
                floor.setP(270)
                floor.setPos(x,y,0)                
                if tile == floor_layout.GRASS:
                    floor.setTexture(grass_texture)
                elif tile == floor_layout.WOOD:
                    floor.setTexture(wood_texture)
Exemplo n.º 43
0
 def create_floor(self, size_x_axis, size_y_axis, texture):
     
     card_maker = CardMaker('')
     card_maker.setFrame(0,size_x_axis,0,size_y_axis)
     '''
     for y in range(size_y_axis):
         for x in range(size_x_axis):
             new_node = self.floorNode.attachNewNode(card_maker.generate())
             new_node.setP(-90)
             new_node.setPos(x, y, 0)
     '''
     new_node = self.floor_node.attachNewNode(card_maker.generate())
     new_node.setP(-90)
     new_node.setPos(0, 0, 0)
     new_node.setTexture(textures[texture])    
     
     self.floor_node.flattenStrong()
Exemplo n.º 44
0
class BulletHoles:
  """The name says it all."""
  def __init__(self,manager,xml):
    self.texture = loader.loadTexture('data/textures/bullet-hole.png')
    self.texture.setMinfilter(Texture.FTLinearMipmapLinear)
    self.container = render.attachNewNode(ModelRoot('bullet-holes'))
    self.card = CardMaker('bullet-hole')
    s = BULLETHOLE_SIZE * 0.5
    self.card.setFrame(-s, s, -s, s)
    self.card.setUvRange(Point2(0, 0), Point2(1, 1))

  def makeNew(self, pos, nor, parent = None):
    """Makes a new bullet hole."""
    if parent == None:
      parent = self.container
    else:
      # Add a subnode to the parent, if it's not already there
      child = parent.find('bullet-holes')
      if child.isEmpty():
        parent = parent.attachNewNode('bullet-holes')
      else:
        parent = child
    newhole = NodePath(self.card.generate())
    newhole.reparentTo(parent)
    newhole.lookAt(render, Point3(newhole.getPos(render) - nor))
    newhole.setR(newhole, random() * 360.0)
    newhole.setPos(render, pos)
    # Offset it a little to avoid z-fighting
    # Increase this value if you still see it.
    newhole.setY(newhole, -.001 - random() * 0.01)
    del newhole
    # We don't want one batch per bullet hole, so flatten it.
    # This could be made smarter to preserve culling, but
    # I have yet to see a performance loss.
    # The clearTexture() is a necessary hack.
    parent.clearTexture()
    parent.flattenStrong()
    parent.setTexture(self.texture)
    parent.setTransparency(TransparencyAttrib.MDual)
    parent.setShaderOff(1)
    parent.hide(BitMask32.bit(2)) # Invisible to volumetric lighting camera (speedup)
    parent.hide(BitMask32.bit(3)) # Invisible to shadow cameras (speedup)

  def destroy(self):
    self.container.removeNode()
    def __init__(self,
                 name,
                 nrplates,
                 width,
                 height,
                 shaderfile,
                 texturefile,
                 uvlist,
                 jitter=-1):
        #print name, nrplates, width, height, shaderfile, texturefile, uvlist, jitter
        self.name = name
        self.texturefile = texturefile
        self.shaderfile = shaderfile

        self.np = NodePath('leaf')

        self.tex = loader.loadTexture('textures/' + texturefile)
        self.tex.setMinfilter(Texture.FTLinearMipmapLinear)
        self.tex.setMagfilter(Texture.FTLinearMipmapLinear)
        self.tex.setAnisotropicDegree(2)
        self.np.setTexture(self.tex)
        self.np.setTwoSided(True)
        self.np.setTransparency(TransparencyAttrib.MAlpha)
        #self.np.setTransparency( TransparencyAttrib.MMultisample )
        self.np.setDepthWrite(False)

        maker = CardMaker('leaf')
        maker.setFrame(-width / 2.0, width / 2.0, 0, height)
        #maker.setFrame( 0,1,0,1)
        for i in range(nrplates):
            if uvlist != None:
                maker.setUvRange(uvlist[i][0], uvlist[i][1])
            else:
                maker.setUvRange(Point2(0, 0), Point2(1, 0.98))
            node = self.np.attachNewNode(maker.generate())
            #node.setTwoSided( True )
            node.setHpr(i * 180.0 / nrplates, 0, 0)
        self.np.flattenStrong()
        #np.flattenLight()
        #np.setTwoSided( True )

        if jitter == -1:
            self.jitter = height / width / 2
        else:
            self.jitter = jitter
Exemplo n.º 46
0
    def __init__(self, width, height, texture, scale):
        self.width = width * scale
        self.height = height * scale
        self.texture = loader.loadTexture(
            texture)  #"textures/map/"+texture+".jpg")

        cm = CardMaker("CardMaker")
        cm.setFrame((self.width / 2, self.height / 2, 0),
                    (-self.width / 2, self.height / 2, 0),
                    (-self.width / 2, -self.height / 2, 0),
                    (self.width / 2, -self.height / 2, 0))
        card = render.attachNewNode(cm.generate())
        card.clearColor()
        card.setBin("background", 10)
        card.setHpr(180, 0, 0)
        card.setTransparency(TransparencyAttrib.MAlpha)

        card.setTexture(self.texture)
 def __setupEnvironment(self):
     cm = CardMaker("ground")
     size = 200
     cm.setFrame(-size, size, -size, size)
     environment = render.attachNewNode(cm.generate())
     environment.lookAt(0, 0, -1)
     environment.setPos(100, -100, 0)
     environment.setCollideMask(BitMask32.allOn())
     environment.reparentTo(render)
     
     texture = loader.loadTexture("textures/ground.png")
     
     # This is so the textures can look better from a distance
     texture.setMinfilter(Texture.FTLinearMipmapLinear)
     
     environment.setTexGen(TextureStage.getDefault(), TexGenAttrib.MWorldPosition) 
     environment.setTexScale(TextureStage.getDefault(), 0.02, 0.02)
     environment.setTexture(texture, 1)
Exemplo n.º 48
0
    def addLock(self, x, y, color):
        """
        Adds a lock to the minimap.  This will add a colored dot to the map
        that represents a lock.
        --- This is subject to change pending a new player-lock data system. ---
        """
        assert self.notify.debugCall()

        x, y = self._tileToActualPosition(x, y)

        # TODO:maze: replace with lock model / texture
        cm = CardMaker("lock_cardMaker")
        cm.setFrame(-0.04,0.04,-0.04,0.04)
        lock = self.maskedLayer.attachNewNode(cm.generate())

        lock.setColor(color)
        lock.setPos(x/self._maskResolution*2.0 - 0.97, 0, y/self._maskResolution*-2.0 + 1.02)

        self._locks.append(lock)
Exemplo n.º 49
0
 def createImageSprite3D(resources, sprite, parent=None):
     """
     Creates a node responsible for rendering a sprite whose visual representation consists of a single image.
     
     We use the CardMaker in order to generate a quad where the image will be applied as a texture.        
     
     Returns: the NodePath for the created node.
     """
     tex = resources.loadTexture(sprite.image)
     cm = CardMaker(sprite.name)
     cm.setFrame(-0.5, 0.5, -0.5, 0.5)
     cm.setColor(1, 1, 1, 1)
     if parent is not None:
         card = parent.attachNewNode(cm.generate())
     else:
         card = NodePath(cm.generate())
     card.setTexture(tex)
     card.setPythonTag('sprite', sprite)
     return card
    def __setupEnvironment(self):
        cm = CardMaker("ground")
        size = 100
        cm.setFrame(-size, size, -size, size)
        environment = render.attachNewNode(cm.generate())
        environment.lookAt(0, 0, -1)
        environment.setPos(0, 0, 0)
        environment.setCollideMask(BitMask32.allOn())
        environment.reparentTo(render)

        texture = loader.loadTexture("textures/ground.png")

        # This is so the textures can look better from a distance
        texture.setMinfilter(Texture.FTLinearMipmapLinear)

        environment.setTexGen(TextureStage.getDefault(),
                              TexGenAttrib.MWorldPosition)
        environment.setTexScale(TextureStage.getDefault(), 0.02, 0.02)
        environment.setTexture(texture, 1)
Exemplo n.º 51
0
    def _createMaskTextureCard(self):
        self._maskImage = PNMImage(self._maskResolution, self._maskResolution, 4)
        for x in xrange(self._maskResolution):
            for y in xrange(self._maskResolution):
                self._maskImage.setXelA(x, y, 0, 0, 0, 1)

        self.maskTexture = Texture('maskTexture')
        self.maskTexture.setupTexture(Texture.TT2dTexture, self._maskResolution, self._maskResolution, 1, Texture.TUnsignedByte, Texture.FRgba)
        self.maskTexture.setMinfilter(Texture.FTLinear)
        self.maskTexture.setWrapU(Texture.WMClamp)
        self.maskTexture.setWrapV(Texture.WMClamp)
        self.maskTexture.load(self._maskImage)
        base.graphicsEngine.renderFrame()
        cm = CardMaker('mask_cardMaker')
        cm.setFrame(-1.1, 1.1, -1.1, 1.1)
        mask = self.attachNewNode(cm.generate())
        mask.setTexture(self.maskTexture, 1)
        mask.setTransparency(1)
        return mask
Exemplo n.º 52
0
    def _createMaskTextureCard(self):
        self._maskImage = PNMImage(self._maskResolution, self._maskResolution, 4)
        for x in range(self._maskResolution):
            for y in range(self._maskResolution):
                self._maskImage.setXelA(x, y, 0, 0, 0, 1)

        self.maskTexture = Texture('maskTexture')
        self.maskTexture.setupTexture(Texture.TT2dTexture, self._maskResolution, self._maskResolution, 1, Texture.TUnsignedByte, Texture.FRgba)
        self.maskTexture.setMinfilter(Texture.FTLinear)
        self.maskTexture.setWrapU(Texture.WMClamp)
        self.maskTexture.setWrapV(Texture.WMClamp)
        self.maskTexture.load(self._maskImage)
        base.graphicsEngine.renderFrame()
        cm = CardMaker('mask_cardMaker')
        cm.setFrame(-1.1, 1.1, -1.1, 1.1)
        mask = self.attachNewNode(cm.generate())
        mask.setTexture(self.maskTexture, 1)
        mask.setTransparency(1)
        return mask
Exemplo n.º 53
0
        def __init__(self, scale=1.2):
                NodePath.__init__(self, 'healthbar')

                self.scale = scale
                cmfg = CardMaker('fg')
                cmfg.setFrame(- scale,  scale, -0.1 * scale, 0.1 * scale)
                self.fg = self.attachNewNode(cmfg.generate())

                cmbg = CardMaker('bg')
                cmbg.setFrame(- scale, scale, -0.1 * scale, 0.1 * scale)
                self.bg = self.attachNewNode(cmbg.generate())

                #cmbd = CardMaker('bd')
                #cmbd.setFrame(- scale * 1.3, scale * 1.3, -.2 * scale, .2 * scale)
                #self.bd = self.attachNewNode(cmbd.generate())

                self.fg.setColor(1, 0, 0, 1)
                self.bg.setColor(0.2, 0.2, 0.2, 1)

                self.setValue(1)
Exemplo n.º 54
0
 def __init__( self ):
   # disable the default camera control
   base.disableMouse()
   
   # create the aiming cross
   cm = CardMaker('aim-cross')
   cm.setFrame(-AIMCROSSWIDTH,AIMCROSSWIDTH,-AIMCROSSHEIGHT,AIMCROSSHEIGHT)
   cross = cm.generate()
   self.aimingCross = NodePath(cross)
   # set texture to cross
   tex = loader.loadTexture(CROSSTEXTURE)
   self.aimingCross.setTexture(tex)
   # enable transparency on the aiming cross
   self.aimingCross.setTransparency(TransparencyAttrib.MAlpha)
   self.aimingCross.detachNode()
   
   # enable this class functions
   self.enable()
   
   self.accept( 'space', self.toggle )
Exemplo n.º 55
0
    def __init__(self,pickableList = []):
        self.pickable = pickableList
        tempCard = CardMaker('')
        tempCard.setFrame(0,1,0,1)

        #Lets render our frame so we can hide / show /resize it as needed        
        self.selectFrame = render2d.attachNewNode(tempCard.generate())
        self.selectFrame.setColor(1,1,0,.2)
        self.selectFrame.setTransparency(1)
        self.selectFrame.hide()
        
        #Set up our line segmants for a border 
        ls = LineSegs()
        ls.moveTo(0,0,0)
        ls.drawTo(1,0,0)
        ls.drawTo(1,0,1)
        ls.drawTo(0,0,1)
        ls.drawTo(0,0,0)
        
        self.selectFrame.attachNewNode(ls.create())
        
        self.selected = []
        self.previousSelect = []
        self.selectable = []
        
        #Init our mouse locations
        self.pt2InitMousePos = (-1,-1)
        self.pt2LastMousePos = (-1,-1)
        self.fFovh , self.fFovv = base.camLens.getFov()
        
        self.fTimeLastUpdateRect = 0
        self.fTimeLastUpdateSelected = 0
        self.UpdateTimeRect = 0.015
        self.UpdateTimeSelected = 0.015
        
        print "Running Select Tools"
        
        self.accept("mouse1",self.OnStartSelect)
        self.accept("control-mouse1",self.OnStartSelect)
        self.accept("mouse1-up",self.OnMouseRelease)
        self.taskUpdateSelectRect = 0
 def __setupPreview(self):
   """Creates the preview."""
   if not self.previewCheck.Value: return
   if self.preview != None:
     self.__destroyPreview()
   self.preview = wx.StaticBitmap(self, style = wx.SUNKEN_BORDER, size = PREVIEW_SIZE)
   self.sizer.Add(self.preview, 0, wx.ADJUST_MINSIZE | wx.ALIGN_CENTER, 0)
   cm = CardMaker("preview")
   cm.setFrame(-1, 1, -1, 1)
   cm.setUvRange(Point2(0, 0), Point2(1, 1))
   self.previewTexture = Texture()
   self.previewBuffer = WindowManager.windows[0].win.makeTextureBuffer("preview", *PREVIEW_SIZE)
   self.previewBuffer.setClearColor(Vec4(1, 1, 1, 1))
   self.previewCamera = base.makeCamera2d(self.previewBuffer)
   self.previewPlane = NodePath(cm.generate())
   self.previewPlane.setFogOff(1000)
   self.previewPlane.setLightOff(1000)
   self.previewCamera.node().setScene(self.previewPlane)
   self.previewBuffer.addRenderTexture(self.previewTexture, GraphicsOutput.RTMCopyRam)
   self.previewCamera.node().setActive(texturePainter.texturePainterStatus == TEXTURE_PAINTER_STATUS_ENABLED)
   self.Layout()