def makeFromDGI(self, dgi):
     DNANode.DNANode.makeFromDGI(self, dgi)
     self.code = DNAUtil.dgiExtractString8(dgi)
     self.color = DNAUtil.dgiExtractColor(dgi)
     self.width = dgi.getInt16() / 100.0
     self.height = dgi.getInt16() / 100.0
     self.bDefaultColor = dgi.getBool()
    def generateCogdoGeometry(self, storage, np, height, barrier):
        node = np.getParent().attachNewNode('cb' + self.id[2:])
        node.setTransform(np.getTransform())

        barrier.copyTo(node)

        block = DNAUtil.getBlockFromName(self.id)
        x = int(np.getX())
        y = int(np.getY())
        seed = block*1231 + x*83 + y

        codes = storage.getNumCatalogCodes('cogdo_wall')
        if codes != 0:
            wallCode = storage.getCatalogCode('cogdo_wall', seed%codes)
            wall = storage.findNode(wallCode)
        else:
            wall = None

        if wall:
            wallNode = wall.copyTo(node)
            wallNode.setScale(self.width, 1, height)

            for door in DNAUtil.getChildrenOfType(self, DNAFlatDoor):
                door.generateSuitGeometry(storage, wallNode)

        node.flattenStrong()
        node.stash()
示例#3
0
    def generateSuitGeometry(self, storage, np, height, barrier):
        node = np.getParent().attachNewNode('sb' + self.id[2:])
        node.setTransform(np.getTransform())

        barrier.copyTo(node)

        block = DNAUtil.getBlockFromName(self.id)
        x = int(np.getX())
        y = int(np.getY())
        seed = block * 1231 + x * 83 + y

        codes = storage.getNumCatalogCodes('suit_wall')
        if codes != 0:
            wallCode = storage.getCatalogCode('suit_wall', seed % codes)
            wall = storage.findNode(wallCode)
        else:
            wall = None

        if wall:
            wallNode = wall.copyTo(node)
            wallNode.setScale(self.width, 1, height)

            for door in DNAUtil.getChildrenOfType(self, DNAFlatDoor):
                door.generateSuitGeometry(storage, wallNode)

        node.flattenStrong()
        node.stash()
示例#4
0
 def makeFromDGI(self, dgi):
     DNANode.DNANode.makeFromDGI(self, dgi)
     self.code = DNAUtil.dgiExtractString8(dgi)
     self.wallColor = DNAUtil.dgiExtractColor(dgi)
     self.title = DNAUtil.dgiExtractString8(dgi)
     self.article = DNAUtil.dgiExtractString8(dgi)
     self.buildingType = DNAUtil.dgiExtractString8(dgi)
示例#5
0
 def makeFromDGI(self, dgi):
     DNANode.DNANode.makeFromDGI(self, dgi)
     self.code = DNAUtil.dgiExtractString8(dgi)
     self.wallColor = DNAUtil.dgiExtractColor(dgi)
     self.title = DNAUtil.dgiExtractString8(dgi)
     self.article = DNAUtil.dgiExtractString8(dgi)
     self.buildingType = DNAUtil.dgiExtractString8(dgi)
示例#6
0
 def makeFromDGI(self, dgi):
     DNANode.DNANode.makeFromDGI(self, dgi)
     self.code = DNAUtil.dgiExtractString8(dgi)
     self.color = DNAUtil.dgiExtractColor(dgi)
     self.width = dgi.getInt16() / 100.0
     self.height = dgi.getInt16() / 100.0
     self.bDefaultColor = dgi.getBool()
    def _postGenerate(self, storage, np):
        height = np.getPythonTag('wall_height') or 0.0
        np.clearPythonTag('wall_height')

        # First, set up collisions. We need a (self.width, height)-sized square.
        barrierNode = storage.findNode('wall_camera_barrier')
        if not barrierNode:
            raise DNAError('No wall_camera_barrier in storage.')

        barrier = barrierNode.copyTo(np)
        barrier.setScale(self.width, 1, height)

        type = DNAUtil.getBuildingClassFromName(self.id)
        if type == 'tb':
            self.generateSuitGeometry(storage, np, height, barrier)
            self.generateCogdoGeometry(storage, np, height, barrier)

        # We need to set collisions on all of our knock knock doors:
        block = DNAUtil.getBlockFromName(self.name)
        if block is not None:
            for collisionNP in np.findAllMatches('**/door_*/+CollisionNode'):
                collisionNP.setName('KnockKnockDoorSphere_%d' % block)

        # Finally, flatten down:
        np.flattenStrong()
示例#8
0
 def handleNode(self, dgi, target = None):
     if target is None:
         return
     numNodes = dgi.getUint16()
     for _ in xrange(numNodes):
         code = DNAUtil.dgiExtractString8(dgi)
         file = DNAUtil.dgiExtractString8(dgi)
         node = DNAUtil.dgiExtractString8(dgi)
         np = NodePath(loader.pdnaModel(file))
         if node:
             newNode = np.find('**/' + node).copyTo(NodePath())
             np.removeNode()
             np = newNode
         np.setTag('DNACode', code)
         np.setTag('DNARoot', node)
         target(np, code)
示例#9
0
    def _postGenerate(self, storage, np):
        height = np.getPythonTag('wall_height') or 0.0
        np.clearPythonTag('wall_height')
        barrierNode = storage.findNode('wall_camera_barrier')
        if not barrierNode:
            raise DNAError('No wall_camera_barrier in storage.')
        barrier = barrierNode.copyTo(np)
        barrier.setScale(self.width, 1, height)
        type = DNAUtil.getBuildingClassFromName(self.id)
        if type == 'tb':
            self.generateSuitGeometry(storage, np, height, barrier)
            self.generateCogdoGeometry(storage, np, height, barrier)
        block = DNAUtil.getBlockFromName(self.name)
        if block is not None:
            for collisionNP in np.findAllMatches('**/door_*/+CollisionNode'):
                collisionNP.setName('KnockKnockDoorSphere_%d' % block)

        np.flattenStrong()
        return
示例#10
0
 def makeFromDGI(self, dgi):
     DNANode.DNANode.makeFromDGI(self, dgi)
     self.code = DNAUtil.dgiExtractString8(dgi)
     self.streetTexture = DNAUtil.dgiExtractString8(dgi)
     self.sidewalkTexture = DNAUtil.dgiExtractString8(dgi)
     self.curbTexture = DNAUtil.dgiExtractString8(dgi)
     self.streetColor = DNAUtil.dgiExtractColor(dgi)
     self.sideWalkColor = DNAUtil.dgiExtractColor(dgi)
     self.curbColor = DNAUtil.dgiExtractColor(dgi)
示例#11
0
 def makeFromDGI(self, dgi):
     DNANode.DNANode.makeFromDGI(self, dgi)
     self.code = DNAUtil.dgiExtractString8(dgi)
     self.streetTexture = DNAUtil.dgiExtractString8(dgi)
     self.sidewalkTexture = DNAUtil.dgiExtractString8(dgi)
     self.curbTexture = DNAUtil.dgiExtractString8(dgi)
     self.streetColor = DNAUtil.dgiExtractColor(dgi)
     self.sideWalkColor = DNAUtil.dgiExtractColor(dgi)
     self.curbColor = DNAUtil.dgiExtractColor(dgi)
 def _makeNode(self, storage, parent):
     frontNode = parent.find('**/*building*_front')
     if frontNode.isEmpty():
         frontNode = parent.find('**/*_front')
     if not frontNode.getNode(0).isGeomNode():
         frontNode = frontNode.find('**/+GeomNode')
     frontNode.setEffect(DecalEffect.make())
     node = storage.findNode(self.code)
     if node is None:
         pass
     doorNode = node.copyTo(frontNode, 0)
     origin = parent.find('**/*door_origin')
     origin.node().setPreserveTransform(ModelNode.PTNet)
     self.setupDoor(doorNode, parent, origin, storage, DNAUtil.getBlockFromName(parent.getName()), self.getColor())
     return doorNode
示例#13
0
    def _postGenerate(self, storage, np):
        height = np.getPythonTag('wall_height') or 0.0
        np.clearPythonTag('wall_height')

        # First, set up collisions. We need a (self.width, height)-sized square.
        barrierNode = storage.findNode('wall_camera_barrier')
        if not barrierNode:
            raise DNAError('No wall_camera_barrier in storage.')

        barrier = barrierNode.copyTo(np)
        barrier.setScale(self.width, 1, height)

        type = DNAUtil.getBuildingClassFromName(self.id)
        if type == 'tb':
            self.generateSuitGeometry(storage, np, height, barrier)

        # We need to set collisions on all of our knock knock doors:
        block = DNAUtil.getBlockFromName(self.name)
        if block is not None:
            for collisionNP in np.findAllMatches('**/door_*/+CollisionNode'):
                collisionNP.setName('KnockKnockDoorSphere_%d' % block)

        # Finally, flatten down:
        np.flattenStrong()
示例#14
0
 def _makeNode(self, storage, parent):
     frontNode = parent.find("**/*building*_front")
     if frontNode.isEmpty():
         frontNode = parent.find("**/*_front")
     if not frontNode.getNode(0).isGeomNode():
         frontNode = frontNode.find("**/+GeomNode")
     frontNode.setEffect(DecalEffect.make())
     node = storage.findNode(self.code)
     if node is None:
         # raise DNAError('DNADoor code ' + self.code + ' not found in DNAStorage')
         # TODO: error message here
         pass
     doorNode = node.copyTo(frontNode, 0)
     origin = parent.find("**/*door_origin")
     origin.node().setPreserveTransform(ModelNode.PTNet)
     self.setupDoor(doorNode, parent, origin, storage, DNAUtil.getBlockFromName(parent.getName()), self.getColor())
     return doorNode
示例#15
0
    def setupSuitBuildingOrigin(self, nodePath):
        building = DNAUtil.getBuildingClassFromName(self.id)
        if building != 'tb':
            return

        name = 'sb' + self.id[2:]

        node = nodePath.find('**/*suit_building_origin')
        if node.isEmpty():
            #TODO: dna logging
            #print 'DNALandmarkBuilding ' + name + ' did not find **/*suit_building_origin'
            node = nodePath.attachNewNode(ModelNode(self.name))
        else:
            node.wrtReparentTo(nodePath)
            node.setName(name)

        node.node().setPreserveTransform(ModelNode.PTNet)
        node.hide()
    def setupSuitBuildingOrigin(self, nodePath):
        building = DNAUtil.getBuildingClassFromName(self.id)
        if building != 'tb':
            return

        name = 'sb' + self.id[2:]

        node = nodePath.find('**/*suit_building_origin')
        if node.isEmpty():
            #TODO: dna logging
            #print 'DNALandmarkBuilding ' + name + ' did not find **/*suit_building_origin'
            node = nodePath.attachNewNode(ModelNode(self.name))
        else:
            node.wrtReparentTo(nodePath)
            node.setName(name)

        node.node().setPreserveTransform(ModelNode.PTNet)
        node.hide()
示例#17
0
    def makeFromDGI(self, dgi, dnaStorage):
        DNAGroup.DNAGroup.makeFromDGI(self, dgi)

        numEdges = dgi.getUint16()
        for _ in xrange(numEdges):
            index = dgi.getUint16()
            endPoint = dgi.getUint16()
            self.addSuitEdge(dnaStorage.getSuitEdge(index, endPoint))

        numVisibles = dgi.getUint16()
        for _ in xrange(numVisibles):
            self.addVisible(DNAUtil.dgiExtractString8(dgi))

        numCells = dgi.getUint16()
        for _ in xrange(numCells):
            w = dgi.getUint8()
            h = dgi.getUint8()
            x, y, z = [dgi.getInt32() / 100.0 for i in xrange(3)]
            self.addBattleCell(DNABattleCell.DNABattleCell(w, h, LVector3f(x, y, z)))
示例#18
0
    def makeFromDGI(self, dgi, dnaStorage):
        DNAGroup.DNAGroup.makeFromDGI(self, dgi)
        numEdges = dgi.getUint16()
        for _ in xrange(numEdges):
            index = dgi.getUint16()
            endPoint = dgi.getUint16()
            self.addSuitEdge(dnaStorage.getSuitEdge(index, endPoint))

        numVisibles = dgi.getUint16()
        for _ in xrange(numVisibles):
            self.addVisible(DNAUtil.dgiExtractString8(dgi))

        numCells = dgi.getUint16()
        for _ in xrange(numCells):
            w = dgi.getUint8()
            h = dgi.getUint8()
            x, y, z = [dgi.getInt32() / 100.0 for i in xrange(3)]
            self.addBattleCell(
                DNABattleCell.DNABattleCell(w, h, LVector3f(x, y, z)))
示例#19
0
 def makeFromDGI(self, dgi):
     DNALandmarkBuilding.DNALandmarkBuilding.makeFromDGI(self, dgi)
     self.animName = DNAUtil.dgiExtractString8(dgi)
示例#20
0
    def handleStorageData(self, dgi):
        # Catalog Codes
        numRoots = dgi.getUint16()
        for _ in xrange(numRoots):
            root = DNAUtil.dgiExtractString8(dgi)
            numCodes = dgi.getUint8()
            for i in xrange(numCodes):
                code = DNAUtil.dgiExtractString8(dgi)
                self.dnaStorage.storeCatalogCode(root, code)

        # Textures
        numTextures = dgi.getUint16()
        for _ in xrange(numTextures):
            code = DNAUtil.dgiExtractString8(dgi)
            filename = DNAUtil.dgiExtractString8(dgi)
            self.dnaStorage.storeTexture(code, loader.pdnaTexture(filename, okMissing=True))

        # Fonts
        numFonts = dgi.getUint16()
        for _ in xrange(numFonts):
            code = DNAUtil.dgiExtractString8(dgi)
            filename = DNAUtil.dgiExtractString8(dgi)
            self.dnaStorage.storeFont(code, loader.pdnaFont(filename))

        # Nodes
        self.handleNode(dgi, target = self.dnaStorage.storeNode)
        self.handleNode(dgi, target = self.dnaStorage.storeHoodNode)
        self.handleNode(dgi, target = self.dnaStorage.storePlaceNode)

        # Blocks
        numBlocks = dgi.getUint16()
        for _ in xrange(numBlocks):
            number = dgi.getUint8()
            zone = dgi.getUint16()
            title = DNAUtil.dgiExtractString8(dgi)
            article = DNAUtil.dgiExtractString8(dgi)
            bldgType = DNAUtil.dgiExtractString8(dgi)
            self.dnaStorage.storeBlock(number, title, article, bldgType, zone)

        # Suit Points
        numPoints = dgi.getUint16()
        for _ in xrange(numPoints):
            index = dgi.getUint16()
            pointType = dgi.getUint8()
            x, y, z = (dgi.getInt32() / 100.0 for i in xrange(3))
            graph = dgi.getUint8()
            landmarkBuildingIndex = dgi.getInt8()
            self.dnaStorage.storeSuitPoint(DNASuitPoint.DNASuitPoint(index, pointType, LVector3f(x, y, z), landmarkBuildingIndex))

        # Suit Edges
        numEdges = dgi.getUint16()
        for _ in xrange(numEdges):
            index = dgi.getUint16()
            numPoints = dgi.getUint16()
            for i in xrange(numPoints):
                endPoint = dgi.getUint16()
                zoneId = dgi.getUint16()
                self.dnaStorage.storeSuitEdge(index, endPoint, zoneId)

        # Battle Cells
        numCells = dgi.getUint16()
        for _ in xrange(numCells):
            w = dgi.getUint8()
            h = dgi.getUint8()
            x, y, z = (dgi.getInt32() / 100.0 for i in xrange(3))
            self.dnaStorage.storeBattleCell(DNABattleCell.DNABattleCell(w, h, LVector3f(x, y, z)))
示例#21
0
 def makeFromDGI(self, dgi):
     DNAGroup.DNAGroup.makeFromDGI(self, dgi)
     self.code = DNAUtil.dgiExtractString8(dgi)
     self.color = DNAUtil.dgiExtractColor(dgi)
示例#22
0
文件: DNADoor.py 项目: nate97/src
 def makeFromDGI(self, dgi):
     DNAGroup.DNAGroup.makeFromDGI(self, dgi)
     self.code = DNAUtil.dgiExtractString8(dgi)
     self.color = DNAUtil.dgiExtractColor(dgi)
示例#23
0
 def makeFromDGI(self, dgi):
     DNALandmarkBuilding.DNALandmarkBuilding.makeFromDGI(self, dgi)
     self.animName = DNAUtil.dgiExtractString8(dgi)
示例#24
0
 def _storeData(self, data):
     block = data.getBlock(DNAUtil.getBlockFromName(self.id))
     block.title = self.getTitle()
     block.buildingType = self.type
     block.zone = self.getVisGroup().getZone()
     block.node = self
示例#25
0
 def makeFromDGI(self, dgi):
     self.name = DNAUtil.dgiExtractString8(dgi)
     DNAUtil.dgiExtractString8(dgi)
     DNAUtil.dgiExtractString8(dgi)
示例#26
0
 def makeFromDGI(self, dgi):
     DNAGroup.DNAGroup.makeFromDGI(self, dgi)
     self.code = DNAUtil.dgiExtractString8(dgi)
     self.color = DNAUtil.dgiExtractColor(dgi)
     self.windowCount = dgi.getUint8()
 def _storeData(self, data):
     block = data.getBlock(DNAUtil.getBlockFromName(self.id))
     block.title = self.getTitle()
     block.buildingType = self.type
     block.zone = self.getVisGroup().getZone()
     block.node = self
示例#28
0
 def makeFromDGI(self, dgi):
     self.name = DNAUtil.dgiExtractString8(dgi)
     DNAUtil.dgiExtractString8(dgi)
     DNAUtil.dgiExtractString8(dgi)