def generateToonMoveTrack(self, toon): node = NodePath('tempNode') displacement = Vec3(toon.getPos(render) - self.getPos(render)) displacement.setZ(0) displacement.normalize() movieDistance = self.movieNode.getDistance(self.rotateNode) displacement *= movieDistance node.reparentTo(render) node.setPos(displacement + self.getPos(render)) node.lookAt(self) heading = PythonUtil.fitDestAngle2Src(toon.getH(render), node.getH(render)) hpr = toon.getHpr(render) hpr.setX(heading) finalX = node.getX(render) finalY = node.getY(render) finalZ = node.getZ(render) node.removeNode() toonTrack = Sequence( Parallel( ActorInterval(toon, 'walk', loop=True, duration=1), Parallel( LerpPosInterval(toon, 1.0, Point3(finalX, finalY, toon.getZ(render)), fluid=True, bakeInStart=False)), LerpHprInterval(toon, 1.0, hpr=hpr)), Func(toon.loop, 'neutral')) return toonTrack
def enterBoarding(self, nodePath, side): camera.wrtReparentTo(nodePath) heading = PythonUtil.fitDestAngle2Src(camera.getH(nodePath), 90 * side) self.cameraBoardTrack = LerpPosHprInterval( camera, 1.5, Point3(14.4072 * side, 0, 3.8667), Point3(heading, -15, 0)) self.cameraBoardTrack.start() return None
def enterBoarding(self, nodePath): camera.wrtReparentTo(nodePath) heading = PythonUtil.fitDestAngle2Src(camera.getH(nodePath), 180) self.cameraBoardTrack = LerpPosHprInterval(camera, 1.5, Point3(0, 18, 8), Point3(heading, -10, 0)) self.cameraBoardTrack.start() return None
def enterBoarding(self, nodePath): camera.wrtReparentTo(nodePath) if self.reverseBoardingCamera: heading = PythonUtil.fitDestAngle2Src(camera.getH(nodePath), 180) self.cameraBoardTrack = LerpPosHprInterval(camera, 1.5, Point3(0, 18, 8), Point3(heading, -10, 0)) else: self.cameraBoardTrack = LerpPosHprInterval(camera, 1.5, Point3(0, -16, 5.5), Point3(0, 0, 0)) self.cameraBoardTrack.start()
def moveCamera(self, seatIndex): self.oldCameraPos = camera.getPos() self.oldCameraHpr = camera.getHpr() camera.wrtReparentTo(self.picnicTable) heading = PythonUtil.fitDestAngle2Src(camera.getH(), 90) if seatIndex < 3: self.cameraBoardTrack = LerpPosHprInterval(camera, 2.0, Point3(0, 0, 17), Point3(0, -90, 0)) elif camera.getH() < 0: self.cameraBoardTrack = LerpPosHprInterval(camera, 2.0, Point3(0, 0, 17), Point3(-180, -90, 0)) else: self.cameraBoardTrack = LerpPosHprInterval(camera, 2.0, Point3(0, 0, 17), Point3(180, -90, 0)) self.cameraBoardTrack.start()
def getJumpHpr(av = av, node = self.golfKart): hpr = Point3(0, 0, 0) if hasattr(self, 'golfKart') and self.golfKart: hpr = self.golfKart.getHpr(av.getParent()) if seatIndex < 2: hpr.setX(hpr.getX() + 180) else: hpr.setX(hpr.getX()) angle = PythonUtil.fitDestAngle2Src(av.getH(), hpr.getX()) hpr.setX(angle) else: self.notify.warning('getJumpHpr invalid golfKart, returning (0,0,0)') return hpr
def doDirectedAttack(self, avId, attackCode): toon = base.cr.doId2do.get(avId) if toon: gearRoot = self.rotateNode.attachNewNode('gearRoot') gearRoot.setZ(10) gearRoot.setTag('attackCode', str(attackCode)) gearModel = self.getGearFrisbee() gearModel.setScale(0.2) gearRoot.headsUp(toon) toToonH = PythonUtil.fitDestAngle2Src(0, gearRoot.getH() + 180) gearRoot.lookAt(toon) neutral = 'Fb_neutral' if not self.twoFaced: neutral = 'Ff_neutral' gearTrack = Parallel() for i in range(4): node = gearRoot.attachNewNode(str(i)) node.hide() node.setPos(0, 5.85, 4.0) gear = gearModel.instanceTo(node) x = random.uniform(-5, 5) z = random.uniform(-3, 3) h = random.uniform(-720, 720) gearTrack.append( Sequence( Wait(i * 0.15), Func(node.show), Parallel( node.posInterval(1, Point3(x, 50, z), fluid=1), node.hprInterval(1, VBase3(h, 0, 0), fluid=1)), Func(node.detachNode))) if not self.raised: neutral1Anim = self.getAnim('down2Up') self.raised = 1 else: neutral1Anim = ActorInterval(self, neutral, startFrame=48) throwAnim = self.getAnim('throw') neutral2Anim = ActorInterval(self, neutral) extraAnim = Sequence() if attackCode == ToontownGlobals.BossCogSlowDirectedAttack: extraAnim = ActorInterval(self, neutral) seq = Sequence( ParallelEndTogether( self.pelvis.hprInterval(1, VBase3(toToonH, 0, 0)), neutral1Anim), extraAnim, Parallel( Sequence(Wait(0.19), gearTrack, Func(gearRoot.detachNode), self.pelvis.hprInterval(0.2, VBase3(0, 0, 0))), Sequence(throwAnim, neutral2Anim))) self.doAnimate(seq, now=1, raised=1)
def generateToonMoveTrack(self): hpr = self.movieNode.getHpr(render) heading = PythonUtil.fitDestAngle2Src(self.av.getH(render), hpr[0]) hpr.setX(heading) self.av.setAnimState('run', 1.0) toonTrack = Sequence( Wait(0.5), Parallel( LerpPosInterval( self.av, 1.0, Point3(self.movieNode.getX(self.avParent), self.movieNode.getY(self.avParent), 0)), LerpHprInterval(self.av, 1.0, hpr=hpr, other=render)), Func(self.av.loop, 'neutral')) return toonTrack
def rollBossToPoint(self, fromPos, fromHpr, toPos, toHpr, reverse): vector = Vec3(toPos - fromPos) distance = vector.length() if toHpr == None: mat = Mat3(0, 0, 0, 0, 0, 0, 0, 0, 0) headsUp(mat, vector, CSDefault) scale = VBase3(0, 0, 0) shear = VBase3(0, 0, 0) toHpr = VBase3(0, 0, 0) decomposeMatrix(mat, scale, shear, toHpr, CSDefault) if fromHpr: newH = PythonUtil.fitDestAngle2Src(fromHpr[0], toHpr[0]) toHpr = VBase3(newH, 0, 0) else: fromHpr = toHpr turnTime = abs(toHpr[0] - fromHpr[0]) / ToontownGlobals.BossCogTurnSpeed if toHpr[0] < fromHpr[0]: leftRate = ToontownGlobals.BossCogTreadSpeed else: leftRate = -ToontownGlobals.BossCogTreadSpeed if reverse: rollTreadRate = -ToontownGlobals.BossCogTreadSpeed else: rollTreadRate = ToontownGlobals.BossCogTreadSpeed rollTime = distance / ToontownGlobals.BossCogRollSpeed deltaPos = toPos - fromPos track = Sequence( Func(self.setPos, fromPos), Func(self.headsUp, toPos), Parallel(self.hprInterval(turnTime, toHpr, fromHpr), self.rollLeftTreads(turnTime, leftRate), self.rollRightTreads(turnTime, -leftRate)), Parallel( LerpFunctionInterval(self.rollBoss, duration=rollTime, extraArgs=[fromPos, deltaPos]), self.rollLeftTreads(rollTime, rollTreadRate), self.rollRightTreads(rollTime, rollTreadRate))) return (track, toHpr)
def __startWalk(self): self.__stopWalk() if self.target: now = globalClock.getFrameTime() availableTime = self.arrivalTime - now if availableTime > 0: origH = self.getH() h = PythonUtil.fitDestAngle2Src(origH, self.targetH) delta = abs(h - origH) turnTime = delta / (self.velocity * 5) dist = Vec3(self.target - self.getPos()).length() walkTime = dist / self.velocity denom = turnTime + walkTime if denom != 0: timeCompress = availableTime / denom self.walkTrack = Sequence( self.hprInterval(turnTime * timeCompress, VBase3(h, 0, 0)), self.posInterval(walkTime * timeCompress, self.target)) self.walkTrack.start() else: self.setPos(self.target) self.setH(self.targetH)
def __chooseTarget(self, extraDelay=0): direction = self.__chooseDirection() if direction == None: self.target = None self.arrivalTime = None self.b_destroyGoon() return heading, dist = direction dist = min(dist, self.legLength) targetH = PythonUtil.reduceAngle(self.getH() + heading) origH = self.getH() h = PythonUtil.fitDestAngle2Src(origH, targetH) delta = abs(h - origH) turnTime = delta / (self.velocity * 5) walkTime = dist / self.velocity self.setH(targetH) self.target = self.boss.scene.getRelativePoint(self, Point3(0, dist, 0)) self.departureTime = globalClock.getFrameTime() self.arrivalTime = self.departureTime + turnTime + walkTime + extraDelay self.d_setTarget(self.target[0], self.target[1], h, globalClockDelta.localToNetworkTime(self.arrivalTime)) return
def getJumpHpr(av=av, node=destNode): hpr = node.getHpr(av.getParent()) hpr.setX(hpr.getX() + 180) angle = PythonUtil.fitDestAngle2Src(av.getH(), hpr.getX()) hpr.setX(angle) return hpr
def getJumpHpr(av=av, node=self.tablecloth): hpr = self.seats[seatIndex].getHpr(av.getParent()) angle = PythonUtil.fitDestAngle2Src(av.getH(), hpr.getX()) hpr.setX(angle) return hpr