def findSomethingToLookAt(self): toons = [] if hasattr(self, 'doId'): for key in self.cr.doId2do.keys(): val = self.cr.doId2do[key] if not val.doId == self.doId: if CIGlobals.isSuit(val) or CIGlobals.isToon( val) or CIGlobals.isDisneyChar(val): if self.eyeLensNP.node().isInView( val.getPos(self.eyeLensNP)): if CIGlobals.isToon(val): toons.append(val.getPart('head')) elif CIGlobals.isSuit(val): toons.append(val.headModel) elif CIGlobals.isDisneyChar(val): toons.append(val.headNode) decision = random.randint(0, 3) if toons == [] or decision == 3: return self.randomLookSpot() else: startH = self.getPart('head').getH() startP = self.getPart('head').getP() startR = self.getPart('head').getR() toon = random.randint(0, len(toons) - 1) if toons[toon]: self.getPart('head').lookAt(toons[toon], 0, 0, -0.75) else: self.notify.warning( 'toons[toon] is None -- I cannot look at nothing.') endH = self.getPart('head').getH() endP = self.getPart('head').getP() endR = self.getPart('head').getR() self.getPart('head').setHpr(startH, startP, startR) return (endH, endP, endR)
def getToonsFlydownTrack(): offset = 0.0 track = Parallel() localAvCannon = None for toon in self.cr.doId2do.values(): if not CIGlobals.isToon(toon): continue tCannon = None for cannon in self.cannons: if cannon.getOwner() == toon.doId: if toon.doId == base.localAvatar.doId: self.cannonId = cannon.doId self.cannon = cannon tCannon = cannon break if tCannon: propeller = loader.loadModel( "phase_5/models/cogdominium/tt_m_ara_cfg_toonPropeller.bam" ) torso = toon.getPart("torso") bp = torso.attachNewNode('backpackInstance') animal = toon.getAnimal() bodyScale = ToonGlobals.BodyScales[animal] bpHeight = ToonGlobals.TorsoHeightDict[ toon.getTorso()] * bodyScale - 0.5 bp.setPos(0, -0.325, bpHeight) pInst = bp.attachNewNode("propellerInstance") pInst.setPos(0, 0, 0) pInst.setHpr(0, 20, 0) pInst.setScale(1.0, 1.0, 1.25) propeller.instanceTo(pInst) ival = LerpHprInterval(propeller, duration=0.35, hpr=(360, 0, 0), startHpr=(0, 0, 0)) ival.loop() toon.stopSmooth() toon.loop('jump') toon.wrtReparentTo(cannon) toon.hide() toon.setH(0) track.append( Sequence( Wait(offset), Func(toon.show), Parallel( Sequence(Wait(3.5), Func(ival.pause), ActorInterval(toon, "zend"), Func(toon.loop, "neutral")), LerpPosInterval(toon, duration=4.0, pos=(5, 0, 0), startPos=(5, 0, 20), blendType='easeOut')), Func(propeller.removeNode), Func(pInst.removeNode), Func(bp.removeNode), Func(toon.wrtReparentTo, render))) offset += 0.5 return track