def __interpolateStates(self, deltaTime, translation, rotation): lerpParam = mathUtils.clamp( 0.0, 1.0, deltaTime * self.__cfg['interpolationSpeed']) self.__sourceMatrix = slerp(self.__sourceMatrix, rotation, lerpParam) self.__targetMatrix.translation = mathUtils.lerp( self.__targetMatrix.translation, translation, lerpParam) return (self.__sourceMatrix, self.__targetMatrix)
def __update(self): currentTime = BigWorld.timeExact() self.__elapsedTime += currentTime - self.__prevTime self.__prevTime = currentTime interpolationCoefficient = math_utils.easeInOutQuad(self.__elapsedTime, 1.0, self.__totalTime) interpolationCoefficient = math_utils.clamp(0.0, 1.0, interpolationCoefficient) iSource = self.__initialState.matrix iTarget = self.__finalState.matrix mat = slerp(iSource, iTarget, interpolationCoefficient) mat.translation = math_utils.lerp(iSource.translation, iTarget.translation, interpolationCoefficient) self.__shadowEffect.update(interpolationCoefficient) if self.__elapsedTime > self.__totalTime: self.disable() return mat
def __interpolateStates(self, deltaTime, rotation, desiredDistance, collisionDist): lerpParam = math_utils.clamp( 0.0, 1.0, deltaTime * self._cfg['interpolationSpeed']) self.__sourceMatrix = slerp(self.__sourceMatrix, rotation, lerpParam) camDirection = Vector3() camDirection.setPitchYaw(-self.__sourceMatrix.pitch, self.__sourceMatrix.yaw) camDirection.normalise() self.__camViewPoint = math_utils.lerp(self.__camViewPoint, self.__aimingSystem.aimPoint, lerpParam) self.__collisionDist = math_utils.lerp(self.__collisionDist, collisionDist, lerpParam) desiredDistance = max(desiredDistance, self.__collisionDist) self.__targetMatrix.translation = self.__camViewPoint - camDirection.scale( desiredDistance) return (self.__sourceMatrix, self.__targetMatrix)