Пример #1
0
 def _logClsend(self, senderId, dataStr):
     msgStream = StringStream()
     simbase.air.describeMessage(msgStream, '', dataStr)
     readableStr = msgStream.getData()
     sstream = StringStream()
     PyDatagram(dataStr).dumpHex(sstream)
     hexDump = sstream.getData()
     self.clsendNotify.info('%s [%s]: %s%s' % (self.doId, self._clsendCounter, readableStr, hexDump))
Пример #2
0
    def paintEvent(self,  event):

        screenData = StringStream() # Used to pass the data as a string
        screenImage = PNMImage() # Converts the texture data into a format usable with Qt

        if self.pandaTexture.hasRamImage():
            print "Should draw yes?"
            self.pandaTexture.store(screenImage)
            screenImage.write(screenData, "test.ppm")
            self.paintPixmap.loadFromData(screenData.getData())
            self.paintSurface.setPixmap(self.paintPixmap)
Пример #3
0
    def test_loader(self):
        store = DNAStorage()
        np = self.loader.loadDNAFile(store, Filename('test.pdna'))

        self.check_store(store)

        expected_repr = '''PandaNode dna
  PandaNode root
    PandaNode test
      PandaNode 1000
        PandaNode subgroup
          ModelNode prop_test T:(pos -12 5 7 hpr 180 15 0) S:(ColorScaleAttrib)
          PandaNode tb3:test_block [DNACode]
          PandaNode sb3:test_block'''
        ss = StringStream()
        np.ls(ss)
        self.assertEqual(ss.getData().strip(), expected_repr)
Пример #4
0
    def test_loader(self):
        store = DNAStorage()
        np = self.loader.loadDNAFile(store, Filename("test.pdna"))

        self.check_store(store)

        expected_repr = """PandaNode dna
  PandaNode root
    PandaNode test
      PandaNode 1000
        PandaNode subgroup
          ModelNode prop_test T:(pos -12 5 7 hpr 180 15 0) S:(ColorScaleAttrib)
          PandaNode tb3:test_block [DNACode]
          PandaNode sb3:test_block"""
        ss = StringStream()
        np.ls(ss)
        self.assertEqual(ss.getData().strip(), expected_repr)
Пример #5
0
 def _logClsend(self, senderId, dataStr):
     msgStream = StringStream()
     simbase.air.describeMessage(msgStream, '', dataStr)
     readableStr = msgStream.getData()
     sstream = StringStream()
     PyDatagram(dataStr).dumpHex(sstream)
     hexDump = sstream.getData()
     self.clsendNotify.info(
         '%s [%s]: %s%s' %
         (self.doId, self._clsendCounter, readableStr, hexDump))
Пример #6
0
    def load(self, container, name="New Region"):
        '''Loads a new region, usually from connecting to a server
        Or starting a new or previously saved region.
        '''
        import base64
        self.heightmap = PNMImage()
        imageString = base64.b64decode(container.heightmap)
        self.heightmap.read(StringStream(imageString))
        self.region_size = (self.heightmap.getXSize() - 1,
                            self.heightmap.getYSize() - 1)

        position = 0
        tileid = 0
        total_tiles = self.region_size[0] * self.region_size[1]
        ranges = []
        tiles = []

        for tile in container.tiles:
            tiles.append((tile.id, tile.cityid))
        for n in range(len(tiles)):
            try:
                ranges.append((tiles[n][0], tiles[n + 1][0] - 1, tiles[n][1]))
            except:
                ranges.append((tiles[n][0], total_tiles, tiles[n][1]))
        for r in ranges:
            for x in range(r[0], r[1] + 1):
                #print "r0, r1, x", r[0], r[1], x
                self.tiles.append(Tile(tileid, r[2]))
                #print "Len", len(self.tiles)
                tileid += 1

        position = 0
        for y in range(self.region_size[1]):
            for x in range(self.region_size[0]):
                self.tiles[position].coords = (x, y)
                position += 1

        for city in container.cities:
            self.newCity(city)
        messenger.send("generateRegion",
                       [self.heightmap, self.tiles, self.cities, container])