def bspline3_get_points_on_segment(s, points):
    plen = len(points)
    p0i = clamp(s - 2, 0, plen - 1)
    p1i = clamp(s - 1, 0, plen - 1)
    p2i = clamp(s, 0, plen - 1)
    p3i = clamp(s + 1, 0, plen - 1)
    return points[p0i], points[p1i], points[p2i], points[p3i]
Пример #2
0
 def __updateCameraByMouseMove(self, dx, dy, dz):
     if self.__cam is None:
         return
     elif self.__cam != BigWorld.camera() and not self.__handleInactiveCamera:
         return
     else:
         from gui.ClientHangarSpace import hangarCFG
         cfg = hangarCFG()
         self.__cam.movementMode = FAST_CAMERA_MOVEMENT_MODE
         if self.__rotationEnabled:
             sourceMat = Math.Matrix(self.__cam.source)
             yaw = sourceMat.yaw
             pitch = sourceMat.pitch
             currentMatrix = Math.Matrix(self.__cam.invViewMatrix)
             currentYaw = currentMatrix.yaw
             yaw = self.__yawCameraFilter.getNextYaw(currentYaw, yaw, dx)
             pitch -= dy * cfg['cam_sens']
             camPitchConstr = self.__camConstraints[0]
             startPitch, endPitch = camPitchConstr
             pitch = math_utils.clamp(math.radians(startPitch), math.radians(endPitch), pitch)
             mat = Math.Matrix()
             mat.setRotateYPR((yaw, pitch, 0.0))
             self.__cam.source = mat
         if self.__zoomEnabled:
             if dz < 0.0:
                 dist = self.__cam.pivotMaxDist
             else:
                 dist = self.__cam.targetMaxDist
             dist -= dz * cfg['cam_dist_sens']
             minDist, maxDist = self.__camConstraints[2]
             dist = math_utils.clamp(minDist, maxDist, dist)
             self.__cam.pivotMaxDist = dist
             self.__updateDynamicFov(dist=dist, rampTime=0.1)
         return
 def __calculateIdealState(self, deltaTime):
     aimPoint = self.__aimingSystem.aimPoint
     direction = self.__aimingSystem.direction
     impactPitch = max(direction.pitch, self._cfg['minimalPitch'])
     self.__rotation = max(self.__rotation, impactPitch)
     distRange = self._cfg['distRange']
     distanceCurSq = (
         aimPoint -
         BigWorld.player().getVehicleAttached().position).lengthSquared
     distanceMinSq = distRange[0]**2.0
     forcedPitch = impactPitch
     if distanceCurSq < distanceMinSq:
         forcedPitch = atan2(sqrt(distanceMinSq - distanceCurSq),
                             sqrt(distanceCurSq))
     angularShift = self._cfg['angularSpeed'] * deltaTime
     angularShift = angularShift if self.__choosePitchLevel(
         aimPoint) else -angularShift
     minPitch = max(forcedPitch, impactPitch)
     maxPitch = max(forcedPitch, self._cfg['maximalPitch'])
     self.__rotation = math_utils.clamp(minPitch, maxPitch,
                                        self.__rotation + angularShift)
     desiredDistance = self.__getDesiredCameraDistance()
     cameraDirection = self.__getCameraDirection()
     desiredDistance = self.__resolveCollisions(aimPoint, desiredDistance,
                                                cameraDirection)
     desiredDistance = math_utils.clamp(distRange[0], distRange[1],
                                        desiredDistance)
     translation = aimPoint - cameraDirection.scale(desiredDistance)
     rotation = Vector3(cameraDirection.yaw, -cameraDirection.pitch, 0.0)
     return (translation, rotation)
 def __calcAimOffset(self, aimLocalTransform=None):
     aimingSystemMatrix = self.__aimingSystem.matrix
     worldCrosshair = Matrix(self.__crosshairMatrix)
     if aimLocalTransform is not None:
         worldCrosshair.postMultiply(aimLocalTransform)
     worldCrosshair.postMultiply(aimingSystemMatrix)
     aimOffset = cameras.projectPoint(worldCrosshair.translation)
     return Vector2(math_utils.clamp(-0.95, 0.95, aimOffset.x), math_utils.clamp(-0.95, 0.95, aimOffset.y))
Пример #5
0
 def set_color(self, color):
     self.color = color
     self.color = (
         math_utils.clamp(self.color[0], 0, 255),
         math_utils.clamp(self.color[1], 0, 255),
         math_utils.clamp(self.color[2], 0, 255),
         math_utils.clamp(self.color[3], 0, 255),
     )
Пример #6
0
 def __getClampedCursor(self):
     cursorPosition = GUI.mcursor().position
     cursorPosition.x = math_utils.clamp(-self.CURSOR_POSITION_CLAMP_VALUE,
                                         self.CURSOR_POSITION_CLAMP_VALUE,
                                         cursorPosition.x)
     cursorPosition.y = math_utils.clamp(-self.CURSOR_POSITION_CLAMP_VALUE,
                                         self.CURSOR_POSITION_CLAMP_VALUE,
                                         cursorPosition.y)
     return cursorPosition
 def __clampToLimits(self, turretYaw, gunPitch):
     if self.__yawLimits is not None:
         turretYaw = math_utils.clamp(self.__yawLimits[0], self.__yawLimits[1], turretYaw)
     pitchLimits = calcPitchLimitsFromDesc(turretYaw, self.getPitchLimits(turretYaw))
     adjustment = max(0, self.__returningOscillator.deviation.y)
     pitchLimits[0] -= adjustment
     pitchLimits[1] += adjustment
     gunPitch = math_utils.clamp(pitchLimits[0], pitchLimits[1] + self.__pitchCompensating, gunPitch)
     return (turretYaw, gunPitch)
Пример #8
0
 def setCameraLocation(self, targetPos=None, pivotPos=None, yaw=None, pitch=None, dist=None, camConstraints=None, ignoreConstraints=False, movementMode=FAST_CAMERA_MOVEMENT_MODE):
     if self.__cam is None:
         _logger.error('Unable to set camera location, because camera reference is None.')
         return
     else:
         from gui.ClientHangarSpace import hangarCFG
         cfg = hangarCFG()
         sourceMat = Math.Matrix(self.__cam.source)
         yawS = sourceMat.yaw if yaw is None else yaw
         pitchS = sourceMat.pitch if pitch is None else pitch
         if dist is None:
             dist = self.__cam.pivotMaxDist
         if movementMode != IMMEDIATE_CAMERA_MOVEMENT_MODE:
             self.__cam.movementMode = movementMode
         if camConstraints is None or camConstraints[0] is None:
             self.__camConstraints[0] = cfg['cam_pitch_constr']
         else:
             self.__camConstraints[0] = camConstraints[0]
         if camConstraints is None or camConstraints[1] is None:
             self.__camConstraints[1] = cfg['cam_yaw_constr']
         else:
             self.__camConstraints[1] = camConstraints[1]
         if camConstraints is None or camConstraints[2] is None:
             self.__updateCameraLimits()
         else:
             self.__camConstraints[2] = camConstraints[2]
         if not ignoreConstraints:
             if yaw is not None:
                 camYawConstr = self.__camConstraints[1]
                 startYaw, endYaw = camYawConstr
                 self.__yawCameraFilter.setConstraints(math.radians(startYaw), math.radians(endYaw))
                 self.__yawCameraFilter.setYawLimits(camYawConstr)
                 yawS = self.__yawCameraFilter.toLimit(yawS)
             if pitch is not None:
                 camPitchConstr = self.__camConstraints[0]
                 startPitch, endPitch = (math.radians(pc) for pc in camPitchConstr)
                 pitchS = math_utils.clamp(startPitch, endPitch, pitchS)
             minDist, maxDist = self.__camConstraints[2]
             dist = math_utils.clamp(minDist, maxDist, dist)
         if yaw is not None or pitch is not None:
             mat = Math.Matrix()
             pitchS = math_utils.clamp(-math.pi / 2 * 0.99, math.pi / 2 * 0.99, pitchS)
             mat.setRotateYPR((yawS, pitchS, 0.0))
             self.__cam.source = mat
         if targetPos is not None:
             targetMat = self.__cam.target
             targetMat.setTranslate(targetPos)
             self.__cam.target = targetMat
             self.__cam.target.setTranslate(targetPos)
         if pivotPos is not None:
             self.__cam.pivotPosition = pivotPos
         self.__cam.pivotMaxDist = dist
         if movementMode == IMMEDIATE_CAMERA_MOVEMENT_MODE:
             self.__cam.pivotMinDist = 0.0
             self.__cam.forceUpdate()
         return
Пример #9
0
def clampToLimits(base, self, turretYaw, gunPitch):
    if config.get('battle/camera/enabled') and config.get('battle/camera/sniper/noCameraLimit/enabled'):
        if not BigWorld.isKeyDown(KEY_RIGHTMOUSE) and self._SniperAimingSystem__yawLimits is not None and config.get('battle/camera/sniper/noCameraLimit/mode') == "hotkey":
            turretYaw = math_utils.clamp(self._SniperAimingSystem__yawLimits[0], self._SniperAimingSystem__yawLimits[1], turretYaw)
        pitchLimits = calcPitchLimitsFromDesc(turretYaw, self.getPitchLimits(turretYaw))
        adjustment = max(0, self._SniperAimingSystem__returningOscillator.deviation.y)
        pitchLimits[0] -= adjustment
        pitchLimits[1] += adjustment
        gunPitch = math_utils.clamp(pitchLimits[0], pitchLimits[1] + self._SniperAimingSystem__pitchCompensating, gunPitch)
        return (turretYaw, gunPitch)
    return base(self, turretYaw, gunPitch)
 def __calculateAimOffset(self, aimWorldPos):
     replayCtrl = BattleReplay.g_replayCtrl
     if replayCtrl.isPlaying and replayCtrl.isControllingCamera:
         aimOffset = replayCtrl.getAimClipPosition()
     else:
         aimOffset = cameras.projectPoint(aimWorldPos)
         aimOffset = Vector2(math_utils.clamp(-0.95, 0.95, aimOffset.x),
                             math_utils.clamp(-0.95, 0.95, aimOffset.y))
         if replayCtrl.isRecording:
             replayCtrl.setAimClipPosition(aimOffset)
     return aimOffset
def getCellIdFromPosition(desiredShotPoint, boundingBox, dimensions):
    mapXLength = boundingBox[1][0] - boundingBox[0][0]
    mapYLength = boundingBox[1][1] - boundingBox[0][1]
    xOffset = -boundingBox[0][0]
    yOffset = -boundingBox[0][1]
    x = math_utils.clamp(boundingBox[0][0] + 0.1, boundingBox[1][0] - 0.1,
                         desiredShotPoint.x)
    y = math_utils.clamp(boundingBox[0][1] + 0.1, boundingBox[1][1] - 0.1,
                         desiredShotPoint.z)
    mapGridX = math.floor((xOffset + x) / mapXLength * dimensions)
    mapGridY = dimensions - (math.floor(
        (yOffset + y) / mapYLength * dimensions) + 1)
    return mapGridX * dimensions + mapGridY
Пример #12
0
 def __setupCamera(self):
     from gui.ClientHangarSpace import hangarCFG
     cfg = hangarCFG()
     self.__cam = BigWorld.CursorCamera()
     self.__cam.isHangar = True
     self.__cam.spaceID = self.__spaceId
     camDistConstr = cfg['cam_dist_constr']
     minDist, maxDist = camDistConstr
     self.__cam.pivotMaxDist = math_utils.clamp(minDist, maxDist, cfg['cam_start_dist'])
     self.__cam.pivotMinDist = 0.0
     self.__cam.maxDistHalfLife = cfg['cam_fluency']
     self.__cam.turningHalfLife = cfg['cam_fluency']
     self.__cam.movementHalfLife = cfg['cam_fluency']
     self.__cam.pivotPosition = cfg['cam_pivot_pos']
     self.__camConstraints[0] = cfg['cam_pitch_constr']
     self.__camConstraints[1] = cfg['cam_yaw_constr']
     self.__camConstraints[2] = (0.0, 0.0)
     camYawConstr = self.__camConstraints[1]
     startYaw, endYaw = camYawConstr
     self.__yawCameraFilter = HangarCameraYawFilter(math.radians(startYaw), math.radians(endYaw), cfg['cam_sens'])
     self.__yawCameraFilter.setYawLimits(camYawConstr)
     mat = Math.Matrix()
     yaw = self.__yawCameraFilter.toLimit(math.radians(cfg['cam_start_angles'][0]))
     mat.setRotateYPR((yaw, math.radians(cfg['cam_start_angles'][1]), 0.0))
     self.__cam.source = mat
     mat = Math.Matrix()
     mat.setTranslate(cfg['cam_start_target_pos'])
     self.__cam.target = mat
     self.__cam.forceUpdate()
     BigWorld.camera(self.__cam)
     self.__cameraIdle = HangarCameraIdle(self.__cam)
     self.__cameraParallax = HangarCameraParallax(self.__cam)
     self.__cam.setDynamicCollisions(True)
 def __cameraUpdate(self):
     currentTime = BigWorld.timeExact()
     self.__elapsedTime += currentTime - self.__prevTime
     self.__prevTime = currentTime
     interpolationCoefficient = self.__easingMethod(
         self.__elapsedTime, 1.0, self.__totalInterpolationTime)
     interpolationCoefficient = math_utils.clamp(0.0, 1.0,
                                                 interpolationCoefficient)
     iSource = self.__initialState.source
     iTarget = self.__initialState.target.b.translation
     iPivotPosition = self.__initialState.pivotPosition
     fSource = self.__finalState.source
     fTarget = self.__finalState.target.b.translation
     fPivotPosition = self.__finalState.pivotPosition
     self.__cam.source = Math.slerp(iSource, fSource,
                                    interpolationCoefficient)
     self.__cam.target.b.translation = math_utils.lerp(
         iTarget, fTarget, interpolationCoefficient)
     self.__cam.pivotPosition = math_utils.lerp(iPivotPosition,
                                                fPivotPosition,
                                                interpolationCoefficient)
     BigWorld.projection().fov = math_utils.lerp(self.__initialFov,
                                                 self.__finalFov,
                                                 interpolationCoefficient)
     if self.__elapsedTime > self.__totalInterpolationTime:
         self.delayCallback(0.0, self.disable)
         return 10.0
Пример #14
0
 def __updateZoom(self):
     cfg = self._cfg
     zooms = self.__getZooms()
     self.__zoom = cfg['zoom'] = math_utils.clamp(zooms[0], zooms[-1],
                                                  self.__zoom)
     if self.camera is BigWorld.camera():
         self.delayCallback(0.0, self.__applyZoom, self.__zoom)
 def __interpolateStates(self, deltaTime, translation, rotation):
     lerpParam = math_utils.clamp(
         0.0, 1.0, deltaTime * self._cfg['interpolationSpeed'])
     self.__sourceMatrix = slerp(self.__sourceMatrix, rotation, lerpParam)
     self.__targetMatrix.translation = math_utils.lerp(
         self.__targetMatrix.translation, translation, lerpParam)
     return (self.__sourceMatrix, self.__targetMatrix)
Пример #16
0
 def on_max_spell_text_changed(self, e):
     if len(e.text) > 0 and e.text.isnumeric():
         map_settings.settings.max_spell = math_utils.clamp(
             int(e.text), 0, len(spell.spells_definitions))
     else:
         map_settings.settings.max_spell = len(spell.spells_definitions)
         self.update_general_panel()
Пример #17
0
 def update(self):
     if self._state == HintBase.STATE_INACTIVE or self._state == HintBase.STATE_COMPLETE:
         return
     elif self.hangarSpace is None or self.hangarSpace.space is None:
         return
     else:
         camera = self.hangarSpace.space.camera
         if camera is None:
             return
         elif self.__prevCameraDirection is None:
             self.__prevCameraDirection = copy(camera.direction)
             self.__prevCameraDirection.normalise()
             return
         curDirection = copy(camera.direction)
         curDirection.normalise()
         cosAngle = self.__prevCameraDirection.dot(curDirection)
         cosAngle = math_utils.clamp(-1.0, 1.0, cosAngle)
         self.__curAngle += abs(math.acos(cosAngle))
         self.__prevCameraDirection = curDirection
         resultCommand = None
         if self._state == HintBase.STATE_HINT:
             if self.__curAngle > self.__neededAngle:
                 self._state = HintBase.STATE_COMPLETE
                 resultCommand = HINT_COMMAND.SHOW_COMPLETED_WITH_HINT
         elif self._state == HintBase.STATE_DEFAULT:
             if time.time() - self._timeStart > self._timeout:
                 self._state = HintBase.STATE_HINT
                 resultCommand = HINT_COMMAND.SHOW
             elif self.__curAngle > self.__cancelAngle:
                 self._state = HintBase.STATE_COMPLETE
                 resultCommand = HINT_COMMAND.SHOW_COMPLETED
         return resultCommand
 def __getTurretYawForAnchor(self, anchorId, defaultYaw):
     turretYaw = defaultYaw
     if anchorId is not None and hasTurretRotator(self.__vDesc):
         anchorHelper = self.__getAnchorHelperById(anchorId)
         if anchorHelper is not None:
             if anchorHelper.turretYaw is not None:
                 turretYaw = anchorHelper.turretYaw
             else:
                 if anchorHelper.attachedPartIdx == TankPartIndexes.HULL:
                     needsCorrection = anchorId.slotType in (
                         GUI_ITEM_TYPE.EMBLEM, GUI_ITEM_TYPE.INSCRIPTION
                     ) or anchorId.slotType == GUI_ITEM_TYPE.PROJECTION_DECAL and anchorHelper.descriptor.showOn == ApplyArea.HULL
                     if needsCorrection:
                         turretYaw = self.__correctTurretYaw(
                             anchorHelper, defaultYaw)
                 anchorHelper = AnchorHelper(anchorHelper.location,
                                             anchorHelper.descriptor,
                                             turretYaw,
                                             anchorHelper.partIdx,
                                             anchorHelper.attachedPartIdx)
                 self.__updateAnchorHelperWithId(anchorId, anchorHelper)
     turretYawLimits = self.__vDesc.gun.turretYawLimits
     if turretYawLimits is not None:
         turretYaw = math_utils.clamp(turretYawLimits[0],
                                      turretYawLimits[1], turretYaw)
     return turretYaw
Пример #19
0
 def getNextYaw(self, currentYaw, targetYaw, delta):
     if delta == 0.0 or self.__prevDirection * delta < 0.0:
         targetYaw = currentYaw
     self.__prevDirection = delta
     nextYaw = targetYaw + delta * self.__camSens
     if delta > 0.0:
         if nextYaw >= currentYaw:
             deltaYaw = nextYaw - currentYaw
         else:
             deltaYaw = 2.0 * math.pi - currentYaw + nextYaw
         if deltaYaw > math.pi:
             nextYaw = currentYaw + math.pi * 0.9
     else:
         if nextYaw <= currentYaw:
             deltaYaw = currentYaw - nextYaw
         else:
             deltaYaw = 2.0 * math.pi + currentYaw - nextYaw
         if deltaYaw > math.pi:
             nextYaw = currentYaw - math.pi * 0.9
     if not self.__cycled:
         if not self.__reversed:
             if delta > 0.0 and (nextYaw > self.__end or nextYaw < currentYaw):
                 nextYaw = self.__end
             elif delta < 0.0 and (nextYaw < self.__start or nextYaw > currentYaw):
                 nextYaw = self.__start
         elif delta > 0.0 and nextYaw > self.__end and nextYaw <= self.__start:
             nextYaw = self.__end
         elif delta < 0.0 and nextYaw < self.__start and nextYaw >= self.__end:
             nextYaw = self.__start
     if self.__yawLimits is not None:
         if nextYaw < 0.0:
             nextYaw += 2.0 * math.pi
         nextYaw = math_utils.clamp(self.__yawLimits[0], self.__yawLimits[1], nextYaw)
     return nextYaw
def readFloat(dataSec, name, minVal, maxVal, defaultVal):
    if dataSec is None:
        return defaultVal
    else:
        value = dataSec.readFloat(name, defaultVal)
        value = math_utils.clamp(minVal, maxVal, value)
        return value
 def getNextGunPitch(self, curAngle, shotAngle, timeDiff, angleLimits):
     replayCtrl = BattleReplay.g_replayCtrl
     if replayCtrl.isPlaying:
         gunPitch = replayCtrl.getGunPitch()
         if gunPitch > -100000:
             return gunPitch
     if self.__maxGunRotationSpeed == 0.0:
         shotAngle = curAngle
         shotDiff = 0.0
         descr = self._avatar.getVehicleDescriptor()
         speedLimit = descr.gun.rotationSpeed * timeDiff
     else:
         if math.fabs(curAngle - shotAngle) < VehicleGunRotator.ANGLE_EPS:
             if angleLimits is not None:
                 return math_utils.clamp(angleLimits[0], angleLimits[1],
                                         shotAngle)
             return shotAngle
         shotDiff = shotAngle - curAngle
         speedLimit = self.__maxGunRotationSpeed * timeDiff
     if angleLimits is not None:
         if shotAngle < angleLimits[0]:
             shotDiff = angleLimits[0] - curAngle
         elif shotAngle > angleLimits[1]:
             shotDiff = angleLimits[1] - curAngle
     staticPitch = self.__getGunStaticPitch()
     if staticPitch is not None and shotDiff * (curAngle -
                                                staticPitch) < 0.0:
         speedLimit *= 2.0
     if staticPitch is not None and self.estimatedTurretRotationTime > 0.0:
         idealYawSpeed = abs(shotDiff) / self.estimatedTurretRotationTime
         speedLimit = min(speedLimit, idealYawSpeed * timeDiff)
     return curAngle + min(
         shotDiff, speedLimit) if shotDiff > 0.0 else curAngle + max(
             shotDiff, -speedLimit)
 def handleMovement(self, dx, dy):
     self.__idealTurretYaw, self.__idealGunPitch = self.__worldYawPitchToTurret(
         self.__worldYaw, self.__worldPitch)
     pitchExcess = self.__calcPitchExcess(self.__idealTurretYaw + dx,
                                          self.__idealGunPitch + dy)
     if pitchExcess * dy < 0:
         dy = 0
     self.__idealTurretYaw, self.__idealGunPitch = self.__clampToLimits(
         self.__idealTurretYaw + dx, self.__idealGunPitch + dy)
     if pitchExcess != 0.0:
         self.__adjustPitchLimitExtension(abs(pitchExcess), True)
     currentGunMat = self.__getPlayerGunMat(self.__idealTurretYaw,
                                            self.__idealGunPitch)
     self.__worldYaw = currentGunMat.yaw
     self.__worldPitch = currentGunMat.pitch
     self._matrix.set(currentGunMat)
     self.__oscillator.velocity = Vector3(0.0, 0.0, 0.0)
     self.__returningOscillator.velocity = Vector3(0.0, 0.0, 0.0)
     _, uncompensatedPitch = self._getTurretYawGunPitch(
         self.getDesiredShotPoint())
     self.__pitchCompensating = math_utils.clamp(
         math.radians(-2.0), math.radians(2.0),
         self.__idealGunPitch - uncompensatedPitch)
     if abs(self.__pitchCompensating) < 1e-06:
         self.__pitchCompensating = 0.0
 def __init__(self):
     ClientSelectableObject.__init__(self)
     CallbackDelayer.__init__(self)
     TimeDeltaMeter.__init__(self)
     self.__state = CameraMovementStates.FROM_OBJECT
     self.__camera = cameras.FreeCamera()
     self.cameraPitch = math_utils.clamp(-math.pi / 2 * 0.99,
                                         math.pi / 2 * 0.99,
                                         self.cameraPitch)
     self.cameraYaw = normalizeAngle(self.cameraYaw)
     self.__goalPosition = Math.Vector3(0.0, 0.0, 0.0)
     self.__goalDistance = None
     self.__goalTarget = Math.Vector3(0.0, 0.0, 0.0)
     self.__startPosition = Math.Vector3(0.0, 0.0, 0.0)
     self.__startYaw = 0.0
     self.__startPitch = 0.0
     self.__curTime = None
     self.__easedInYaw = 0.0
     self.__easedInPitch = 0.0
     self.__easeInDuration = 0.0
     self.__startFov = None
     self.__goalFov = None
     if self.enableYawLimits:
         self.__yawLimits = Math.Vector2(self.yawLimitMin, self.yawLimitMax)
     else:
         self.__yawLimits = None
     self.__pitchLimits = Math.Vector2(math.degrees(self.pitchLimitMin),
                                       math.degrees(self.pitchLimitMax))
     self.__p1 = Math.Vector3(0.0, 0.0, 0.0)
     self.__p2 = Math.Vector3(0.0, 0.0, 0.0)
     self.__wasPreviousUpdateSkipped = False
     return
 def __setStartParams(self, params):
     a = params.minValue
     b = params.maxValue - params.minValue
     clampedValue = math_utils.clamp(params.minValue, params.maxValue,
                                     params.startValue)
     dArg = -1.0 + (clampedValue - a) * 2.0 / b if b != 0.0 else 0.0
     params.startTime = math.asin(dArg)
Пример #25
0
 def enable(self,
            targetPos,
            saveDist,
            switchToPos=None,
            switchToPlace=None):
     BigWorld.wg_trajectory_drawer().setStrategicMode(False)
     self.__prevTime = 0.0
     if switchToPlace == SwitchToPlaces.TO_TRANSITION_DIST:
         self.__camDist = math_utils.clamp(self._cfg['distRange'][0],
                                           self._cfg['distRange'][1],
                                           self._cfg['transitionDist'])
     elif switchToPlace == SwitchToPlaces.TO_RELATIVE_POS and switchToPos is not None:
         minDist, maxDist = self._cfg['distRange']
         self.__camDist = (maxDist - minDist) * switchToPos + minDist
     elif switchToPlace == SwitchToPlaces.TO_NEAR_POS and switchToPos is not None:
         minDist, maxDist = self._cfg['distRange']
         self.__camDist = math_utils.clamp(minDist, maxDist, switchToPos)
     elif self.settingsCore.getSetting(SPGAim.AUTO_CHANGE_AIM_MODE):
         self.__camDist = math_utils.clamp(self._cfg['distRange'][0],
                                           self._cfg['transitionDist'],
                                           self.__camDist)
     self.__desiredCamDist = self.__camDist
     self.__scrollSmoother.start(self.__desiredCamDist)
     self.__enableSwitchers()
     self.__aimingSystem.enable(targetPos)
     self.__positionHysteresis.update(Vector3(0.0, 0.0, 0.0))
     self.__timeHysteresis.update(BigWorld.timeExact())
     camTarget = MatrixProduct()
     self.__rotation = max(self.__aimingSystem.direction.pitch,
                           self._cfg['minimalPitch'])
     cameraDirection = self.__getCameraDirection()
     self.__targetMatrix.translation = self.aimingSystem.aimPoint - cameraDirection.scale(
         self.__camDist)
     self.__cam.target = camTarget
     self.__cam.target.b = self.__targetMatrix
     self.__sourceMatrix = math_utils.createRotationMatrix(
         (cameraDirection.yaw, -cameraDirection.pitch, 0.0))
     self.__cam.source = self.__sourceMatrix
     self.__cam.forceUpdate()
     BigWorld.camera(self.__cam)
     BigWorld.player().positionControl.moveTo(self.__aimingSystem.hitPoint)
     BigWorld.player().positionControl.followCamera(False)
     self.__cameraUpdate()
     self.delayCallback(0.01, self.__cameraUpdate)
     self.__needReset = 1
     return
Пример #26
0
 def __calculateWorldAimMovement(self, dx, dy):
     nextAimRadius = currentAimRadius = math.fabs(self.__cursor.heightAboveBase / math.tan(self.pitch))
     if dy != 0:
         newPitch = math_utils.clamp(self.__anglesRange[0], -0.001, self.pitch + dy)
         nextAimRadius = math.fabs(self.__cursor.heightAboveBase / math.tan(newPitch))
     ddx = math.tan(dx) * currentAimRadius
     ddy = nextAimRadius - currentAimRadius
     return (ddx, ddy)
 def __updateSkillDataBlock(self, skillID, level=None):
     skillInfo = self.epicMetaGameCtrl.getAllSkillsInformation()[skillID]
     currentLvl = self.epicMetaGameCtrl.getSkillLevels().get(skillID, 1)
     specLevel = clamp(1, skillInfo.maxLvl, int(level) if level else currentLvl)
     bodyBlocks = []
     g_battleAbilityTooltipMgr.createBattleAbilityTooltipRenderers(skillInfo, currentLvl, specLevel, bodyBlocks)
     bodyBlock = formatters.packBuildUpBlockData(bodyBlocks, gap=15)
     self.as_setSkillDataBlockS(bodyBlock)
 def __calcPitchExcess(self, turretYaw, gunPitch):
     if self.__yawLimits is not None:
         turretYaw = math_utils.clamp(self.__yawLimits[0], self.__yawLimits[1], turretYaw)
     pitchLimits = calcPitchLimitsFromDesc(turretYaw, self.getPitchLimits(turretYaw))
     if pitchLimits[0] > gunPitch:
         return pitchLimits[0] - gunPitch
     else:
         return self.__pitchCompensating + pitchLimits[1] - gunPitch if self.__pitchCompensating + pitchLimits[1] < gunPitch else 0.0
 def lookupVerticalFov(horizontalFovValue):
     lookupDict = FovExtended.vFovWide if BigWorld.getAspectRatio(
     ) > FovExtended.arWide else FovExtended.vFovNarrow
     if horizontalFovValue not in lookupDict.keys():
         horizontalFovValue = (int(horizontalFovValue / 5) + 1) * 5
         horizontalFovValue = math_utils.clamp(lookupDict.keys()[0],
                                               lookupDict.keys()[-1],
                                               horizontalFovValue)
     return math.radians(lookupDict[horizontalFovValue])
def readVec3(dataSec, name, minVal, maxVal, defaultVal):
    if dataSec is None:
        return Math.Vector3(defaultVal)
    else:
        value = dataSec.readVector3(name, Math.Vector3(defaultVal))
        for i in xrange(3):
            value[i] = math_utils.clamp(minVal[i], maxVal[i], value[i])

        return value