def fixEffects(self): nodes = self.getNodePaths() for curNode in nodes: mf = curNode.find('**/*mesh_front*') sign_joint = curNode.find('**/sign_origin_joint') if not sign_joint.isEmpty(): self.notify.debug('I found sign_origin_joint 1') if not mf.isEmpty(): sign = mf.find('**/sign') mf.clearEffect(DecalEffect.getClassType()) if not sign.isEmpty(): sign.setDepthWrite(1, 1) sign.setEffect(DecalEffect.make()) sign_joint = curNode.find('**/sign_origin_joint') allSignJoints = curNode.findAllMatches( '**/sign_origin_joint') num = allSignJoints.getNumPaths() if num: sign_joint = allSignJoints.getPath(num - 1) if not sign_joint.isEmpty(): self.notify.debug('I found sign_origin_joint 2') sign.wrtReparentTo(sign_joint)
def replaceDecalEffectsWithDepthOffsetAttrib(node): for np in node.findAllMatches("**"): if np.hasEffect(DecalEffect.getClassType()): np.clearEffect(DecalEffect.getClassType()) np.setDepthOffset(1)
def makeDictionaries(self, dnaStore): self.nodeDict = {} self.zoneDict = {} self.zoneVisDict = {} self.nodeList = [] self.fadeInDict = {} self.fadeOutDict = {} a1 = Vec4(1, 1, 1, 1) a0 = Vec4(1, 1, 1, 0) numVisGroups = dnaStore.getNumDNAVisGroupsAI() for i in xrange(numVisGroups): groupFullName = dnaStore.getDNAVisGroupName(i) visGroup = dnaStore.getDNAVisGroupAI(i) groupName = base.cr.hoodMgr.extractGroupName(groupFullName) zoneId = int(groupName) zoneId = ZoneUtil.getTrueZoneId(zoneId, self.zoneId) groupNode = self.geom.find('**/' + groupFullName) if groupNode.isEmpty(): continue else: if ':' in groupName: groupName = '%s%s' % (zoneId, groupName[groupName.index(':'):]) else: groupName = '%s' % zoneId groupNode.setName(groupName) CIGlobals.replaceDecalEffectsWithDepthOffsetAttrib(groupNode) #group all the flat walls block2flatwall = {} flatwalls = groupNode.findAllMatches("**/tb*:*_DNARoot;+s") for flatwall in flatwalls: if "toon_landmark" in flatwall.getName(): print "Skipping", flatwall.getName() continue if flatwall.hasTag("DNACode") and flatwall.hasMat(): continue block = int(flatwall.getName().split(":")[0][2:]) if not block2flatwall.has_key(block): block2flatwall[block] = groupNode.attachNewNode( ModelNode('toonBuildingsBlock' + str(block))) flatwall.wrtReparentTo(block2flatwall[block]) for node in block2flatwall.values(): for child in node.findAllMatches("**"): child.clearEffect(DecalEffect.getClassType()) child.clearTag("DNACode") child.clearTag("cam") CIGlobals.clearModelNodesBelow(node) node.flattenStrong() flattenGroup = groupNode.attachNewNode('optim') flattens = ['street*_DNARoot'] removes = ['interactive_prop*_DNARoot'] for remove in removes: for np in groupNode.findAllMatches("**/" + remove): np.removeNode() for flatten in flattens: for np in groupNode.findAllMatches("**/" + flatten): if np.hasTag("DNACode") and np.hasMat(): continue for child in np.findAllMatches("**"): child.clearEffect(DecalEffect.getClassType()) child.clearTag("DNACode") child.clearTag("cam") np.wrtReparentTo(flattenGroup) flattenGroup.clearModelNodes() flattenGroup.flattenStrong() CIGlobals.flattenModelNodes(groupNode) groupNode.flattenStrong() #groupNode.ls() self.nodeDict[zoneId] = [] self.nodeList.append(groupNode) self.zoneDict[zoneId] = groupNode visibles = [] for i in xrange(visGroup.getNumVisibles()): visibles.append(int(visGroup.get_visible(i))) visibles.append(ZoneUtil.getBranchZone(zoneId)) self.zoneVisDict[zoneId] = visibles fadeDuration = 0.5 self.fadeOutDict[groupNode] = Sequence( Func(groupNode.setTransparency, 1), LerpColorScaleInterval(groupNode, fadeDuration, a0, startColorScale=a1), Func(groupNode.clearColorScale), Func(groupNode.clearTransparency), Func(groupNode.stash), Func(base.disablePhysicsNodes, groupNode), name='fadeZone-' + str(zoneId), autoPause=1) self.fadeInDict[groupNode] = Sequence( Func(base.enablePhysicsNodes, groupNode), Func(groupNode.unstash), Func(groupNode.setTransparency, 1), LerpColorScaleInterval(groupNode, fadeDuration, a1, startColorScale=a0), Func(groupNode.clearColorScale), Func(groupNode.clearTransparency), name='fadeZone-' + str(zoneId), autoPause=1) for i in xrange(numVisGroups): groupFullName = dnaStore.getDNAVisGroupName(i) zoneId = int(base.cr.hoodMgr.extractGroupName(groupFullName)) zoneId = ZoneUtil.getTrueZoneId(zoneId, self.zoneId) for j in xrange(dnaStore.getNumVisiblesInDNAVisGroup(i)): visName = dnaStore.getVisibleName(i, j) groupName = base.cr.hoodMgr.extractGroupName(visName) nextZoneId = int(groupName) nextZoneId = ZoneUtil.getTrueZoneId(nextZoneId, self.zoneId) visNode = self.zoneDict[nextZoneId] self.nodeDict[zoneId].append(visNode) self.hood.dnaStore.resetPlaceNodes() self.hood.dnaStore.resetDNAGroups() self.hood.dnaStore.resetDNAVisGroups() self.hood.dnaStore.resetDNAVisGroupsAI()