def setSpeed(self, forwardSpeed, rotateSpeed, strafeSpeed = 0.0):
        self.forwardSpeed = forwardSpeed
        self.rotateSpeed = rotateSpeed
        self.strafeSpeed = strafeSpeed

        action = None
        if self.standWalkRunReverse != None and not self.doingActivity:
            action = self.getMoveAction(forwardSpeed, rotateSpeed, strafeSpeed)
            anim, anim2, minSpeed, maxSpeed, rate, rate2 = self.standWalkRunReverse[action]
            if self.currentMoveAction != action or self.lastForcedTorsoAnim != self.forcedTorsoAnim or self.wasDoingActivity:
                self.playingAnim = anim
                self.lastForcedTorsoAnim = self.forcedTorsoAnim
                self.currentMoveAction = action

                self.resetMoveAnims(anim, anim2)

            speed = max(Vec3(forwardSpeed, strafeSpeed, rotateSpeed / 10.0).length(), minSpeed)
            ratio = speed / maxSpeed
            ratioClamped = CIGlobals.clamp(ratio, 0, 1)
            self.setControlEffect(anim, 1 - ratioClamped)
            self.setControlEffect(anim2, ratioClamped)

            if ratio > 1:
                self.setPlayRate(rate * ratio, anim)
                self.setPlayRate(rate2 * ratio, anim2)
            else:
                self.setPlayRate(rate, anim)
                self.setPlayRate(rate2, anim2)

            self.wasDoingActivity = False
        elif self.doingActivity and not self.wasDoingActivity:
            self.wasDoingActivity = True
            self.resetMoveAnims()

        return action
 def decayPunchAngle(self):
     if self.punchAngle.lengthSquared() > 0.001 or self.punchAngleVel.lengthSquared() > 0.001:
         dt = globalClock.getDt()
         self.punchAngle += self.punchAngleVel * dt
         damping = 1 - (self.PunchDamping * dt)
         
         if damping < 0:
             damping = 0
         self.punchAngleVel *= damping
         
         # Torsional spring
         springForceMag = self.PunchSpring * dt
         springForceMag = CIGlobals.clamp(springForceMag, 0.0, 2.0)
         self.punchAngleVel -= self.punchAngle * springForceMag
         
         # Don't wrap around
         self.punchAngle.set(CIGlobals.clamp(self.punchAngle[0], -179, 179),
                             CIGlobals.clamp(self.punchAngle[1], -89, 89),
                             CIGlobals.clamp(self.punchAngle[2], -89, 89))
     else:
         self.punchAngle = Vec3(0)
         self.punchAngleVel = Vec3(0)
Ejemplo n.º 3
0
    def setSpeed(self, forwardSpeed, rotateSpeed, strafeSpeed=0.0):
        Avatar.setSpeed(self, forwardSpeed, rotateSpeed, strafeSpeed)

        currSpeed = self.currentSpeed
        if self.doingActivity:
            currSpeed = 0

        if self.footstepSound and self.standWalkRunReverse is not None:
            action = self.getMoveAction(forwardSpeed, rotateSpeed, strafeSpeed)
            minSpeed = self.standWalkRunReverse[action][2]
            maxSpeed = self.standWalkRunReverse[action][3]
            self.footstepSound.setVolume(
                CIGlobals.clamp(
                    CIGlobals.remapVal(currSpeed, minSpeed, maxSpeed, 0, 1), 0,
                    1))
            self.footstepSound.setPlayRate(max(1, currSpeed / maxSpeed))
Ejemplo n.º 4
0
 def calcZoom(self):
     z = max(int(abs(self.viewport.camera.getZ() * 16)), 0.001)
     return CIGlobals.clamp(10000 / z, 0.001, 256)