コード例 #1
0
    def getIntroTrack(self):
        self.__cameraTask(None)
        origCamParent = camera.getParent()
        origCamPos = camera.getPos()
        origCamHpr = camera.getHpr()
        iCamParent = base.localAvatar.attachNewNode('iCamParent')
        iCamParent.setH(180)
        camera.reparentTo(iCamParent)
        toonHeight = base.localAvatar.getHeight()
        camera.setPos(0, -15, toonHeight * 3)
        camera.lookAt(0, 0, toonHeight / 2.0)
        iCamParent.wrtReparentTo(origCamParent)
        waitDur = 5.0
        lerpDur = 4.5
        lerpTrack = Parallel()
        startHpr = iCamParent.getHpr()
        startHpr.setX(PythonUtil.reduceAngle(startHpr[0]))
        lerpTrack.append(LerpPosHprInterval(iCamParent, lerpDur, pos=Point3(0, 0, 0), hpr=Point3(0, 0, 0), startHpr=startHpr, name=self.uniqueName('introLerpParent')))
        lerpTrack.append(LerpPosHprInterval(camera, lerpDur, pos=origCamPos, hpr=origCamHpr, blendType='easeInOut', name=self.uniqueName('introLerpCameraPos')))
        base.localAvatar.startLookAround()

        def cleanup(origCamParent = origCamParent, origCamPos = origCamPos, origCamHpr = origCamHpr, iCamParent = iCamParent):
            camera.reparentTo(origCamParent)
            camera.setPos(origCamPos)
            camera.setHpr(origCamHpr)
            iCamParent.removeNode()
            del iCamParent
            base.localAvatar.stopLookAround()

        return Sequence(Wait(waitDur),
                        lerpTrack,
                        Func(cleanup))
コード例 #2
0
 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