示例#1
0
 def getToonPullingLeverInterval(self, toon):
     walkTime = 0.2
     reach = ActorInterval(toon, 'leverReach', playRate=2.0)
     pull = ActorInterval(toon, 'leverPull', startFrame=6)
     origPos = toon.getPos(render)
     origHpr = toon.getHpr(render)
     newPos = self.lever.getPos(render)
     newHpr = self.lever.getHpr(render)
     origHpr.setX(PythonUtil.fitSrcAngle2Dest(origHpr[0], newHpr[0]))
     toon.setPosHpr(origPos, origHpr)
     reachAndPull = Sequence(
         ActorInterval(toon,
                       'walk',
                       loop=True,
                       duration=walkTime - reach.getDuration()), reach,
         pull)
     leverSeq = Sequence(
         Wait(walkTime + reach.getDuration() - 0.1),
         self.stick.hprInterval(0.55, Point3(0.0, 25.0, 0.0),
                                Point3(0.0, 0.0, 0.0)), Wait(0.3),
         self.stick.hprInterval(0.4, Point3(0.0, 0.0, 0.0),
                                Point3(0.0, 25.0, 0.0)))
     returnSeq = Sequence(
         Parallel(toon.posInterval(walkTime, newPos, origPos),
                  toon.hprInterval(walkTime, newHpr, origHpr), leverSeq,
                  reachAndPull))
     return returnSeq
示例#2
0
    def getThrowInterval(self, gag, x, y, z, h, p, r):
        toon = self.toon
        flyGag = self.createThrowGag(gag)
        throwSoundIval = self._throwSfx
        if throwSoundIval.isPlaying():
            throwSoundIval.finish()
        throwSoundIval.node = toon
        toonThrowIval1 = ActorInterval(
            toon,
            "throw",
            startFrame=Globals.ThrowStartFrame,
            endFrame=Globals.ThrowEndFrame,
            playRate=Globals.ThrowPlayRate,
            partName="torso",
        )
        toss = Track(
            (
                0,
                Sequence(
                    Func(toon.setPosHpr, x, y, z, h, p, r),
                    Func(gag.reparentTo, toon.rightHand),
                    Func(gag.setPosHpr, 0, 0, 0, 0, 0, 0),
                    toonThrowIval1,
                ),
            ),
            (
                toonThrowIval1.getDuration(),
                Parallel(
                    Func(gag.detachNode),
                    Sequence(
                        ActorInterval(
                            toon,
                            "throw",
                            startFrame=Globals.ThrowEndFrame + 1,
                            playRate=Globals.ThrowPlayRate,
                            partName="torso",
                        ),
                        Func(self.completeThrow),
                    ),
                ),
            ),
        )

        def getEndPos(toon=toon):
            return render.getRelativePoint(toon, Point3(0, Globals.ThrowDistance, 0))

        fly = Track(
            (0, throwSoundIval),
            (
                toonThrowIval1.getDuration(),
                Sequence(
                    Func(flyGag.reparentTo, render),
                    Func(flyGag.setPosHpr, toon, 0.52, 0.97, 2.24, 0, -45, 0),
                    ProjectileInterval(flyGag, endPos=getEndPos, duration=Globals.ThrowDuration),
                    Func(flyGag.detachNode),
                ),
            ),
        )
        return (toss, fly, flyGag)
示例#3
0
 def doActivity(self):
     pr = 5.0
     jump = ActorInterval(self.avatar,
                          'land',
                          startFrame=50,
                          endFrame=20,
                          playRate=pr * 2)
     jumpDur = jump.getDuration()
     curr = self.avatar.getPos(render)
     return Sequence(
         ActorInterval(self.avatar,
                       'land',
                       startFrame=60,
                       endFrame=50,
                       playRate=pr),
         Parallel(
             Sequence(
                 LerpPosInterval(self.avatar, jumpDur / 2, curr + (0, 0, 1),
                                 curr),
                 LerpPosInterval(self.avatar, jumpDur / 2, curr,
                                 curr + (0, 0, 1))), jump),
         ActorInterval(self.avatar,
                       'land',
                       startFrame=20,
                       endFrame=60,
                       playRate=pr))
示例#4
0
    def getThrowInterval(self, gag, x, y, z, h, p, r):
        toon = self.toon
        flyGag = self.createThrowGag(gag)
        throwSoundIval = self._throwSfx
        if throwSoundIval.isPlaying():
            throwSoundIval.finish()

        throwSoundIval.node = toon
        toonThrowIval1 = ActorInterval(toon,
                                       'throw',
                                       startFrame=Globals.ThrowStartFrame,
                                       endFrame=Globals.ThrowEndFrame,
                                       playRate=Globals.ThrowPlayRate,
                                       partName='torso')
        toss = Track(
            (0,
             Sequence(Func(toon.setPosHpr, x, y, z, h, p, r),
                      Func(gag.reparentTo, toon.rightHand),
                      Func(gag.setPosHpr, 0, 0, 0, 0, 0, 0), toonThrowIval1)),
            (toonThrowIval1.getDuration(),
             Parallel(
                 Func(gag.detachNode),
                 Sequence(
                     ActorInterval(toon,
                                   'throw',
                                   startFrame=Globals.ThrowEndFrame + 1,
                                   playRate=Globals.ThrowPlayRate,
                                   partName='torso'), Func(
                                       self.completeThrow)))))

        def getEndPos(toon=toon):
            return render.getRelativePoint(toon,
                                           Point3(0, Globals.ThrowDistance, 0))

        fly = Track(
            (0, throwSoundIval),
            (toonThrowIval1.getDuration(),
             Sequence(
                 Func(flyGag.reparentTo, render),
                 Func(flyGag.setPosHpr, toon, 0.52000000000000002,
                      0.96999999999999997, 2.2400000000000002, 0, -45, 0),
                 ProjectileInterval(
                     flyGag, endPos=getEndPos, duration=Globals.ThrowDuration),
                 Func(flyGag.detachNode))))
        return (toss, fly, flyGag)
 def getToonPullingLeverInterval(self, toon):
     walkTime = 0.2
     reach = ActorInterval(toon, 'leverReach', playRate=2.0)
     pull = ActorInterval(toon, 'leverPull', startFrame=6)
     origPos = toon.getPos(render)
     origHpr = toon.getHpr(render)
     newPos = self.lever.getPos(render)
     newHpr = self.lever.getHpr(render)
     origHpr.setX(PythonUtil.fitSrcAngle2Dest(origHpr[0], newHpr[0]))
     toon.setPosHpr(origPos, origHpr)
     reachAndPull = Sequence(ActorInterval(toon, 'walk', loop=True, duration=walkTime - reach.getDuration()), reach, pull)
     leverSeq = Sequence(Wait(walkTime + reach.getDuration() - 0.1), self.stick.hprInterval(0.55, Point3(0.0, 25.0, 0.0), Point3(0.0, 0.0, 0.0)), Wait(0.3), self.stick.hprInterval(0.4, Point3(0.0, 0.0, 0.0), Point3(0.0, 25.0, 0.0)))
     returnSeq = Sequence(Parallel(toon.posInterval(walkTime, newPos, origPos), toon.hprInterval(walkTime, newHpr, origHpr), leverSeq, reachAndPull))
     return returnSeq