def createSafeZone(self, dnaFile): if self.safeZoneStorageDNAFile: dnaBulk = DNABulkLoader(self.hood.dnaStore, (self.safeZoneStorageDNAFile, )) dnaBulk.loadDNAFiles() node = loader.loadDNAFile(self.hood.dnaStore, dnaFile) if node.getNumParents() == 1: self.geom = NodePath(node.getParent(0)) self.geom.reparentTo(hidden) self.geom.flattenLight() else: self.geom = hidden.attachNewNode(node) self.makeDictionaries(self.hood.dnaStore) self.createAnimatedProps(self.nodeList) self.holidayPropTransforms = {} npl = self.geom.findAllMatches('**/=DNARoot=holiday_prop') for i in range(npl.getNumPaths()): np = npl.getPath(i) np.setTag('transformIndex', ` i `) self.holidayPropTransforms[i] = np.getNetTransform() self.geom.flattenMedium() gsg = base.win.getGsg() if gsg: self.geom.prepareScene(gsg)
def createHood(self, dnaFile, loadStorage=1): # NJF if loadStorage: files = ('phase_5/dna/storage_town.pdna', self.townStorageDNAFile) dnaBulk = DNABulkLoader(self.hood.dnaStore, files) dnaBulk.loadDNAFiles() node = loader.loadDNAFile(self.hood.dnaStore, dnaFile) self.notify.debug('done loading %s' % dnaFile) if node.getNumParents() == 1: self.geom = NodePath(node.getParent(0)) self.geom.reparentTo(hidden) else: self.geom = hidden.attachNewNode(node) self.makeDictionaries(self.hood.dnaStore) self.reparentLandmarkBlockNodes() self.renameFloorPolys(self.nodeList) self.createAnimatedProps(self.nodeList) self.holidayPropTransforms = {} npl = self.geom.findAllMatches('**/=DNARoot=holiday_prop') for i in range(npl.getNumPaths()): np = npl.getPath(i) np.setTag('transformIndex', repr(i)) self.holidayPropTransforms[i] = np.getNetTransform() gsg = base.win.getGsg() if gsg: self.geom.prepareScene(gsg) self.geom.flattenLight() self.geom.setName('town_top_level')
def createHood(self, dnaFile, loadStorage = 1): if loadStorage: files = ('phase_5/dna/storage_town.pdna', self.townStorageDNAFile) dnaBulk = DNABulkLoader(self.hood.dnaStore, files) dnaBulk.loadDNAFiles() node = loader.loadDNAFile(self.hood.dnaStore, dnaFile) self.notify.debug('done loading %s' % dnaFile) if node.getNumParents() == 1: self.geom = NodePath(node.getParent(0)) self.geom.reparentTo(hidden) else: self.geom = hidden.attachNewNode(node) self.makeDictionaries(self.hood.dnaStore) self.reparentLandmarkBlockNodes() self.renameFloorPolys(self.nodeList) self.createAnimatedProps(self.nodeList) self.holidayPropTransforms = {} npl = self.geom.findAllMatches('**/=DNARoot=holiday_prop') for i in xrange(npl.getNumPaths()): np = npl.getPath(i) np.setTag('transformIndex', `i`) self.holidayPropTransforms[i] = np.getNetTransform() gsg = base.win.getGsg() if gsg: self.geom.prepareScene(gsg) self.geom.flattenLight() self.geom.setName('town_top_level')
def load(self): files = [] if self.storageDNAFile: files.append(self.storageDNAFile) newsManager = base.cr.newsManager if newsManager: holidayIds = base.cr.newsManager.getDecorationHolidayId() for holiday in holidayIds: if self.holidayStorageDNADict.get(holiday, []) != None: for storageFile in self.holidayStorageDNADict.get( holiday, []): files.append(storageFile) if (base.cr.newsManager.isHolidayRunning(TRICK_OR_TREAT) or base.cr.newsManager.isHolidayRunning(HALLOWEEN_PROPS) or base.cr.newsManager.isHolidayRunning(HALLOWEEN) ) and self.spookySkyFile: self.sky = loader.loadModel(self.spookySkyFile) self.sky.setTag('sky', 'Halloween') elif self.skyFile: self.sky = loader.loadModel(self.skyFile) self.sky.setTag('sky', 'Regular') self.sky.setScale(1.0) self.sky.setFogOff() else: if self.skyFile: self.sky = loader.loadModel(self.skyFile) self.sky.setTag('sky', 'Regular') self.sky.setScale(1.0) self.sky.setFogOff() dnaBulk = DNABulkLoader(self.dnaStore, tuple(files)) dnaBulk.loadDNAFiles() return
def loadDnaStore(self): if not hasattr(self, 'dnaStore'): self.dnaStore = DNAStorage() files = ('phase_4/dna/storage.jazz', 'phase_3.5/dna/storage_interior.jazz') dnaBulk = DNABulkLoader(self.dnaStore, files) dnaBulk.loadDNAFiles() self.dnaStore.storeFont('humanist', ToontownGlobals.getInterfaceFont()) self.dnaStore.storeFont('mickey', ToontownGlobals.getSignFont()) self.dnaStore.storeFont('suit', ToontownGlobals.getSuitFont())
def createPlayground(self, dnaFile): dnaBulk = DNABulkLoader(self.loader.dnaStore, (self.safeZoneStorageDNAFile,)) dnaBulk.loadDNAFiles() node = loader.loadDNAFile(self.loader.dnaStore, dnaFile) if node.getNumParents() == 1: self.geom = NodePath(node.getParent(0)) self.geom.reparentTo(hidden) else: self.geom = hidden.attachNewNode(node) self.makeDictionaries(self.loader.dnaStore) self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks(self, self.nodeList, self.zoneId) self.geom.flattenMedium() gsg = base.win.getGsg() if gsg: self.geom.prepareScene(gsg)
def loadDnaStoreTutorial(self): self.dnaStore = DNAStorage() files = ('phase_3.5/dna/storage_tutorial.jazz', 'phase_3.5/dna/storage_interior.jazz') dnaBulk = DNABulkLoader(self.dnaStore, files) dnaBulk.loadDNAFiles()
def loadUrbanTrack(self): self.dnaStore = DNAStorage() files = ('phase_4/dna/storage.jazz', 'phase_5/dna/storage_town.jazz', 'phase_4/dna/storage_TT.jazz', 'phase_5/dna/storage_TT_town.jazz', 'phase_8/dna/storage_BR.jazz', 'phase_8/dna/storage_BR_town.jazz', 'phase_8/dna/storage_DL.jazz', 'phase_8/dna/storage_DL_town.jazz') dnaBulk = DNABulkLoader(self.dnaStore, files) dnaBulk.loadDNAFiles() dnaFile = 'phase_6/dna/urban_track_town.jazz' if self.trackId in (RaceGlobals.RT_Urban_2, RaceGlobals.RT_Urban_2_rev): dnaFile = 'phase_6/dna/urban_track_town_B.jazz' node = loader.loadDNAFile(self.dnaStore, dnaFile) self.geomNode = node self.townGeom = self.geom.attachNewNode(node) self.townGeom.findAllMatches('**/+CollisionNode').stash() self.buildingGroups = {} self.currBldgInd = {} self.currBldgGroups = {} bgGeom = self.geom.find('**/polySurface8') if self.dummyNode: bgGeom.reparentTo(self.dummyNode) else: bgGeom.reparentTo(localAvatar) bgGeom.setScale(0.1) ce = CompassEffect.make(NodePath(), CompassEffect.PRot) bgGeom.node().setEffect(ce) bgGeom.setDepthTest(0) bgGeom.setDepthWrite(0) bgGeom.setBin('background', 102) bgGeom.setZ(-1) self.bgGeom = bgGeom l = self.geom.findAllMatches('**/+ModelNode') for n in l: n.node().setPreserveTransform(0) self.geom.flattenLight() maxNum = 0 for side in ['inner', 'outer']: self.buildingGroups[side] = [] self.currBldgInd[side] = None self.currBldgGroups[side] = None i = 0 while 1: bldgGroup = self.townGeom.find('**/Buildings_' + side + '-' + str(i)) if bldgGroup.isEmpty(): break l = bldgGroup.findAllMatches('**/+ModelNode') for n in l: n2 = n.getParent().attachNewNode(n.getName()) n.getChildren().reparentTo(n2) n.removeNode() bldgGroup.flattenStrong() if not bldgGroup.getNode(0).getBounds().isEmpty(): self.buildingGroups[side].append(bldgGroup) i += 1 if i > maxNum: maxNum = i for side in ['innersidest', 'outersidest']: self.buildingGroups[side] = [] self.currBldgInd[side] = None self.currBldgGroups[side] = None for i in xrange(maxNum): for barricade in ('innerbarricade', 'outerbarricade'): bldgGroup = self.townGeom.find('**/Buildings_' + side + '-' + barricade + '_' + str(i)) if bldgGroup.isEmpty(): continue l = bldgGroup.findAllMatches('**/+ModelNode') for n in l: n2 = n.getParent().attachNewNode(n.getName()) n.getChildren().reparentTo(n2) n.removeNode() self.buildingGroups[side].append(bldgGroup) treeNodes = self.townGeom.findAllMatches('**/prop_tree_*') for tree in treeNodes: tree.flattenStrong() snowTreeNodes = self.townGeom.findAllMatches('**/prop_snow_tree_*') for snowTree in snowTreeNodes: snowTree.flattenStrong() for side in ['inner', 'outer', 'innersidest', 'outersidest']: for grp in self.buildingGroups[side]: grp.stash() self.showBuildings(0) return