コード例 #1
0
ファイル: Camera.py プロジェクト: jmanek/pySG
	def rotationMatrix(self):
		w = self.target.normalize()
		u = Vector3.cross(Vector3.up().normalize(), w)
		v = Vector3.cross(w, u)
		rotMat = np.matrix([[u.x, u.y, u.z, 0.0],
				  		[v.x, v.y, v.z, 0.0],   
						[w.x, w.y, w.z, 0.0 ],
						[0.0, 0.0, 0.0, 1.0]], dtype=np.float32)
		return rotMat
コード例 #2
0
ファイル: Renderer.py プロジェクト: jmanek/pySG
	def mouseMove(self, x, y):
		newMouse = Vector2(x, y)
		delta = (newMouse - self.mouse).normalize()
		self.mouse = newMouse
		if delta.x > 0:
			self.camera.position -= Vector3.cross(self.camera.up.normalize(),self.camera.target.normalize()) * delta.x * self.PAN_MOVE
		else:
			self.camera.position += Vector3.cross(self.camera.up.normalize(),self.camera.target.normalize()) * abs(delta.x) * self.PAN_MOVE
		if delta.y < 0:
			self.camera.position -= self.camera.up.normalize() * abs(delta.y) * self.PAN_MOVE
		else:
			self.camera.position += self.camera.up.normalize() * delta.y *self.PAN_MOVE
				
		print delta
コード例 #3
0
ファイル: Camera.py プロジェクト: jmanek/pySG
	def __init__(self, width=None, height=None):
		self.position = Vector3()
		self.target = Vector3(0.0, 0.0, 1.0)
		self.up = Vector3.up()

		self.width = width
		self.height = height
		self.aspectRatio = None
コード例 #4
0
 def getDesiredShotPoint(self, scanStart, scanDir):
     scanPos, isPointConvenient = self.__testMouseTargetPoint(scanStart, scanDir)
     if isPointConvenient:
         return scanPos
     planePos = self.__aimPlane.intersectRay(scanStart, scanDir)
     if scanStart.distSqrTo(planePos) < scanStart.distSqrTo(scanPos):
         return scanPos
     turretYaw, gunPitch = AimingSystems.getTurretYawGunPitch(self.__vehicleDesc, self.__vehicleMat, planePos, True)
     gunMat = AimingSystems.getGunJointMat(self.__vehicleDesc, self.__getTurretMat(turretYaw), gunPitch)
     aimDir = gunMat.applyVector(Vector3(0.0, 0.0, 1.0))
     shotDistance = self.__vehicleDesc.shot.maxDistance
     return AimingSystems.getDesiredShotPoint(gunMat.translation, aimDir, shotDistance=shotDistance)
コード例 #5
0
def getVehiclePointsGen(vehicle):
    vehicleDesr = vehicle.typeDescriptor
    hullPos = vehicleDesr.chassis.hullPosition
    hullBboxMin, hullBboxMax, _ = vehicleDesr.hull.hitTester.bbox
    turretPosOnHull = vehicleDesr.hull.turretPositions[0]
    turretLocalTopY = max(
        hullBboxMax.y,
        turretPosOnHull.y + vehicleDesr.turret.hitTester.bbox[1].y)
    yield Vector3(0.0, hullPos.y + turretLocalTopY, 0.0)
    gunPosOnHull = turretPosOnHull + vehicleDesr.turret.gunPosition
    yield hullPos + gunPosOnHull
    hullLocalCenterY = (hullBboxMin.y + hullBboxMax.y) / 2.0
    hullLocalPt1 = Vector3(0.0, hullLocalCenterY, hullBboxMax.z)
    yield hullPos + hullLocalPt1
    hullLocalPt2 = Vector3(0.0, hullLocalCenterY, hullBboxMin.z)
    yield hullPos + hullLocalPt2
    hullLocalCenterZ = (hullBboxMin.z + hullBboxMax.z) / 2.0
    hullLocalPt3 = Vector3(hullBboxMax.x, gunPosOnHull.y, hullLocalCenterZ)
    yield hullPos + hullLocalPt3
    hullLocalPt4 = Vector3(hullBboxMin.x, gunPosOnHull.y, hullLocalCenterZ)
    yield hullPos + hullLocalPt4
コード例 #6
0
 def __getCollisionTestOrigin(self, aimPoint, direction):
     distRange = self.__cfg['distRange']
     vehiclePosition = BigWorld.player().getVehicleAttached().position
     collisionTestOrigin = Vector3(vehiclePosition)
     if direction.x * direction.x > direction.z * direction.z and not mathUtils.almostZero(direction.x):
         collisionTestOrigin.y = direction.y / direction.x * (vehiclePosition.x - aimPoint.x) + aimPoint.y
     elif not mathUtils.almostZero(direction.z):
         collisionTestOrigin.y = direction.y / direction.z * (vehiclePosition.z - aimPoint.z) + aimPoint.y
     else:
         collisionTestOrigin = aimPoint - direction.scale((distRange[1] - distRange[0]) / 2.0)
         LOG_WARNING("Can't find point on direction ray. Using half point as collision test origin")
     return collisionTestOrigin
コード例 #7
0
 def processHover(self, position, force=False):
     if force:
         position = AimingSystems.getDesiredShotPoint(
             Math.Vector3(position[0], 500.0, position[2]),
             Math.Vector3(0.0, -1.0, 0.0), True, True, True)
         self.__marker.setPosition(position)
         BigWorld.callback(SERVER_TICK_LENGTH, self.__markerForceUpdate)
     else:
         self.__marker.update(position, Vector3(0, 0, 1), 10,
                              SERVER_TICK_LENGTH, None)
     self.hitPosition = position
     self.writeStateToReplay()
コード例 #8
0
 def disable(self):
     if not self.__isEnabled:
         return
     self.__isEnabled = False
     self.__cam.disable()
     self.__activeSelector.destroy()
     self.__activeSelector = _DefaultStrikeSelector(Vector3(0, 0, 0), None)
     self.setGUIVisible(False)
     g_postProcessing.disable()
     BigWorld.setFloraEnabled(True)
     if BigWorld.player().gunRotator is not None:
         BigWorld.player().gunRotator.clientMode = True
コード例 #9
0
 def __createDirectedLine(self, pointA, pointB, width):
     modelName = self.CUBE_MODEL
     model, motor = self.__getModel(modelName)
     direction = pointB - pointA
     scale = (width, width, direction.length)
     rotation = (direction.yaw, direction.pitch, 0)
     translation = pointA + direction * 0.5
     m = math_utils.createSRTMatrix(scale, rotation, translation)
     m.preMultiply(
         math_utils.createTranslationMatrix(Vector3(0.0, -0.5, 0.0)))
     motor.signal = m
     return (modelName, model, motor)
コード例 #10
0
 def initSettings(self, settings):
     self.flagModelName = settings.readString('flagModelName', '')
     self.flagStaffModelName = settings.readString('flagstaffModelName', '')
     self.radiusModel = settings.readString('radiusModel', '')
     self.flagAnim = settings.readString('flagAnim', '')
     self.flagStaffFlagHP = settings.readString('flagstaffFlagHP', '')
     self.baseAttachedSoundEventName = settings.readString('wwsound', '')
     self.flagBackgroundTex = settings.readString('flagBackgroundTex', '')
     self.flagEmblemTex = settings.readString('flagEmblemTex', '')
     self.flagEmblemTexCoords = settings.readVector4('flagEmblemTexCoords', Vector4())
     self.flagScale = settings.readVector3('flagScale', Vector3())
     self.flagNodeAliasName = settings.readString('flagNodeAliasName', '')
コード例 #11
0
 def applyImpulse(self, position, impulse, reason=ImpulseReason.ME_HIT):
     adjustedImpulse, noiseMagnitude = self.__dynamicCfg.adjustImpulse(
         impulse, reason)
     camMatrix = Matrix(self.__cam.matrix)
     impulseLocal = camMatrix.applyVector(adjustedImpulse)
     impulseAsYPR = Vector3(impulseLocal.x,
                            -impulseLocal.y + impulseLocal.z, 0)
     rollPart = self.__dynamicCfg['impulsePartToRoll']
     impulseAsYPR.z = -rollPart * impulseAsYPR.x
     impulseAsYPR.x *= 1 - rollPart
     self.__impulseOscillator.applyImpulse(impulseAsYPR)
     self.__applyNoiseImpulse(noiseMagnitude)
コード例 #12
0
ファイル: ctfmanager.py プロジェクト: webiumsk/WOT-0.9.15.1
 def __init__(self, position, isVisible, flagID):
     position = Vector3(0.0, 0.0, 0.0) if position is None else position
     self.__flagEntity = None
     self.__position = position
     self.__isVisible = isVisible
     self.__flagID = flagID
     spaceId = BigWorld.player().spaceID
     if spaceId != 0:
         self.create()
     else:
         g_ctfManager.addDelayedFlag(self)
     return
コード例 #13
0
def shootProjectile(owner, target, projectile, trail=None, boom=None, srcoff=Vector3(0, 1.5, 0), dstoff=Vector3(0, 1.2, 0), motor=None):
    if hasattr(target, 'matrix'):
        targetMatrix = target.matrix
    else:
        targetMatrix = target
    if not boom and dstoff:
        dstoff.y = 1.8
    if not dstoff:
        dstoff = Vector3(0, 0, 0)
    owner.addModel(projectile)
    projectile.position = Vector3(owner.position) + srcoff
    if not motor:
        motor = BigWorld.Homer()
        motor.speed = projectileSpeed
        motor.turnRate = 10
    if dstoff.lengthSquared == 0:
        motor.target = targetMatrix
    else:
        motor.target = MatrixProduct()
        motor.target.a = targetMatrix
        motor.target.b = Matrix()
        motor.target.b.setTranslate(dstoff)
    if motor.tripTime <= 0.0:
        sourcePosition = Vector3(owner.position) + srcoff
        targetPosition = Vector3(Matrix(targetMatrix).applyToOrigin()) + dstoff
        speed = motor.speed
        t = calculateTripTime(sourcePosition, targetPosition, speed)
        if t == 0:
            owner.delModel(projectile)
            return 0
        motor.tripTime = t
    projectile.addMotor(motor)
    if trail:
        trail(projectile, None, motor.tripTime)
    motor.proximity = 1.0
    if boom:
        motor.proximityCallback = boom
    else:
        motor.proximityCallback = partial(owner.delModel, projectile)
    return motor.tripTime
コード例 #14
0
    def __updateOscillators(self, deltaTime):
        if not SniperCamera.isCameraDynamic():
            self.__impulseOscillator.reset()
            self.__movementOscillator.reset()
            self.__noiseOscillator.reset()
            return (math_utils.createRotationMatrix(Vector3(0, 0, 0)), math_utils.createRotationMatrix(Vector3(0, 0, 0)))
        oscillatorAcceleration = self.__calcCurOscillatorAcceleration(deltaTime)
        self.__movementOscillator.externalForce += oscillatorAcceleration
        self.__impulseOscillator.update(deltaTime)
        self.__movementOscillator.update(deltaTime)
        self.__noiseOscillator.update(deltaTime)
        noiseDeviation = Vector3(self.__noiseOscillator.deviation)
        deviation = self.__impulseOscillator.deviation + self.__movementOscillator.deviation + noiseDeviation
        oscVelocity = self.__impulseOscillator.velocity + self.__movementOscillator.velocity + self.__noiseOscillator.velocity
        if abs(deviation.x) < 1e-05 and abs(oscVelocity.x) < 0.0001:
            deviation.x = 0
        if abs(deviation.y) < 1e-05 and abs(oscVelocity.y) < 0.0001:
            deviation.y = 0
        if abs(deviation.z) < 1e-05 and abs(oscVelocity.z) < 0.0001:
            deviation.z = 0
        curZoomIdx = 0
        zooms = self._cfg['zooms']
        for idx in xrange(len(zooms)):
            if self.__zoom == zooms[idx]:
                curZoomIdx = idx
                break

        zoomExposure = self.__zoom * self.__dynamicCfg['zoomExposure'][curZoomIdx]
        deviation /= zoomExposure
        impulseDeviation = (self.__impulseOscillator.deviation + noiseDeviation) / zoomExposure
        self.__impulseOscillator.externalForce = Vector3(0)
        self.__movementOscillator.externalForce = Vector3(0)
        self.__noiseOscillator.externalForce = Vector3(0)
        return (math_utils.createRotationMatrix(Vector3(deviation.x, deviation.y, deviation.z)), math_utils.createRotationMatrix(impulseDeviation))
コード例 #15
0
    def __generateRetreatTrajectory(self, idealFlightHeight,
                                    bombingEndPosition, bombingDir,
                                    bombingEndTime):
        clientArena = BigWorld.player().arena
        endTrajectoryPosition = clientArena.collideWithSpaceBB(
            bombingEndPosition, bombingEndPosition + bombingDir * 9000.0)
        segmentLength = (endTrajectoryPosition - bombingEndPosition
                         ).length / _RETREAT_SUBDIVISION_FACTOR
        firstRetreatPoint = Vector3(bombingEndPosition +
                                    bombingDir * _INITIAL_RETREAT_SHIFT)
        positions = [firstRetreatPoint]
        positions += [
            firstRetreatPoint + bombingDir * (segmentLength * (idx + 1))
            for idx in xrange(_RETREAT_SUBDIVISION_FACTOR - 1)
        ]
        positions.append(endTrajectoryPosition -
                         bombingDir * min(segmentLength * 0.1, 50.0))
        positions.append(endTrajectoryPosition + bombingDir * 100)
        retreatHeight = _MINIMAL_RETREAT_HEIGHT
        minFlightHeight = idealFlightHeight
        for position in positions:
            zeroHeightPos = Vector3(position)
            zeroHeightPos.y = 0
            collRes = BigWorld.wg_collideSegment(BigWorld.player().spaceID,
                                                 zeroHeightPos + (0, 1000, 0),
                                                 zeroHeightPos + (0, -1000, 0),
                                                 18)
            if collRes is not None:
                minFlightHeight = max(collRes[0].y + retreatHeight,
                                      minFlightHeight)
            else:
                minFlightHeight = max(position.y, minFlightHeight)
            position.y = minFlightHeight

        for idx in xrange(len(positions) - 1):
            positions[idx].y = (positions[idx].y + positions[idx + 1].y) / 2.0

        result = self.__generateRetreatPoints(bombingEndPosition,
                                              bombingEndTime, positions)
        return result
コード例 #16
0
ファイル: VideoCamera.py プロジェクト: webiumsk/WOT-0.9.17-CT
 def __processBindToVehicleKey(self):
     if BigWorld.isKeyDown(Keys.KEY_LSHIFT) or BigWorld.isKeyDown(Keys.KEY_RSHIFT):
         self.__toggleView()
     elif BigWorld.isKeyDown(Keys.KEY_LALT) or BigWorld.isKeyDown(Keys.KEY_RALT):
         worldMat = Math.Matrix(self.__cam.invViewProvider)
         self.__basisMProv.selectNextPlacement()
         boundMatrixInv = Matrix(self.__basisMProv.matrix)
         boundMatrixInv.invert()
         worldMat.postMultiply(boundMatrixInv)
         self.__position = worldMat.translation
         self.__ypr = Vector3(worldMat.yaw, worldMat.pitch, worldMat.roll)
     else:
         self.__switchBind()
コード例 #17
0
ファイル: ModelManager.py プロジェクト: whenisee/wotmods
    def checkCreate(self):
        if self.tmpdata is None:
            BigWorld.callback(1, self.checkCreate)
            return
        else:
            for model in self.tmpdata:
                yaw = model['yaw']
                path = model['path']
                bid = model['id']
                pos = Vector3((model['x'], model['y'], model['z']))
                self.data[bid] = MyModel(bid, pos, yaw, path)

            return
コード例 #18
0
 def intersectRay(self,
                  startPos,
                  direction,
                  checkCloseness=True,
                  checkSign=True):
     collisionPoint = self.__plane.intersectRay(startPos, direction)
     projection = Vector3(0.0, 1.0, 0.0).dot(direction)
     tooClose = collisionPoint.distTo(
         startPos) - self.__lookLength < -0.0001 and checkCloseness
     parallelToPlane = abs(projection) <= _AimPlane.__EPS_COLLIDE_ARENA
     projectionSignDiffers = projection * self.__initialProjection < 0.0 and checkSign
     backwardCollision = (collisionPoint - startPos).dot(direction) <= 0.0
     return startPos + direction * self.__lookLength if tooClose or parallelToPlane or projectionSignDiffers or backwardCollision else collisionPoint
コード例 #19
0
 def __init__(self, dataSec):
     IAimingSystem.__init__(self)
     self.__idealTurretYaw = 0.0
     self.__idealGunPitch = 0.0
     self.__worldYaw = 0.0
     self.__worldPitch = 0.0
     self.__vehicleTypeDescriptor = None
     self.__vehicleMProv = None
     self.__yprDeviationConstraints = Vector3(
         SniperAimingSystem.__STABILIZED_CONSTRAINTS)
     self.__oscillator = Math.PyOscillator(1.0, Vector3(0.0, 0.0, 15.0),
                                           Vector3(0.0, 0.0, 3.5),
                                           self.__yprDeviationConstraints)
     self.__returningOscillator = Math.PyOscillator(
         1.0, Vector3(0.0, 15.0, 15.0), Vector3(0.0, 3.5, 3.5),
         self.__yprDeviationConstraints)
     self.__pitchCompensating = 0.0
     self.__yawLimits = None
     self.__forceFullStabilization = False
     self.__timeBeyondLimits = 0.0
     self.__playerGunMatFunction = AimingSystems.getPlayerGunMat
     return
コード例 #20
0
ファイル: benchmark.py プロジェクト: webiumsk/WOT-0.9.15.1
def exhibit(tankNames=None,
            pivotPoint=None,
            shift=Vector3(0, 0, 10),
            assembler=assembleCompoundModel2):
    if pivotPoint is None:
        p = Vector3(BigWorld.camera().position)
        d = BigWorld.camera().direction
        spaceID = BigWorld.player().spaceID if BigWorld.player(
        ) is not None else BigWorld.camera().spaceID
        collRes = BigWorld.wg_collideSegment(spaceID, p, p + d * 1000, 18, 8)
        if collRes is None:
            pivotPoint = Vector3(0, 0, 0)
        else:
            strikePos = collRes[0]
            pivotPoint = strikePos
    if tankNames is None:
        tankNames = [
            vehicles.g_cache.vehicle(0, x).name for x in xrange(EXAMPLE_COUNT)
        ]
    totalTanks = len(tankNames)
    shift_new = Vector3(d)
    shift_new.y = 0.0
    up = Vector3(0.0, 1.0, 0.0)
    right = up * shift_new
    shift_new.normalise()
    right.normalise()
    offset = 6.0
    shift_new = shift_new * offset
    right = right * offset
    for idx, tankName in enumerate(tankNames):
        desc = vehicles.VehicleDescr(typeName=tankName)
        if idx < totalTanks / 2:
            creationPosition = pivotPoint + shift_new * idx
        else:
            creationPosition = pivotPoint + shift_new * (
                idx - totalTanks / 2) + right
        assembler(getModelNames(desc), creationPosition, desc)

    return
コード例 #21
0
def _VehicleGunRotator__getGunMarkerPosition(base, self, shotPos, shotVec,
                                             dispersionAngles):
    if not (config.get('sight/enabled', True)
            and battle.isBattleTypeSupported):
        return base(self, shotPos, shotVec, dispersionAngles)
    try:
        global timeFlight, currentDistance, timeAIM, cameraHeight
        shotDescr = player.getVehicleDescriptor().shot
        gravity = Vector3(0.0, -shotDescr.gravity, 0.0)
        testVehicleID = self.getAttachedVehicleID()
        collisionStrategy = CollisionStrategy.COLLIDE_DYNAMIC_AND_STATIC
        minBounds, maxBounds = player.arena.getSpaceBB()
        endPos, direction, collData, usedMaxDistance = getCappedShotTargetInfos(
            shotPos, shotVec, gravity, shotDescr, testVehicleID, minBounds,
            maxBounds, collisionStrategy)
        distance = shotDescr.maxDistance if usedMaxDistance else (
            endPos - shotPos).length
        dispersAngle, idealDispersAngle = dispersionAngles
        doubleDistance = distance + distance
        markerDiameter = doubleDistance * dispersAngle
        idealMarkerDiameter = doubleDistance * idealDispersAngle
        replayCtrl = BattleReplay.g_replayCtrl
        if replayCtrl.isPlaying and replayCtrl.isClientReady:
            markerDiameter, endPos, direction = replayCtrl.getGunMarkerParams(
                endPos, direction)

        shotVecXZ = Vector2(shotVec.x, shotVec.z)
        delta = Vector2(endPos.x - shotPos.x, endPos.z - shotPos.z)
        timeFlight = delta.length / shotVecXZ.length
        aimingStartTime, aimingFactor, shotDispMultiplierFactor, _1, _2, _3, aimingTime = player._PlayerAvatar__aimingInfo
        # aimingStartTime = aimingInfo[0]
        # aimingFactor = aimingInfo[1]
        # shotDispMultiplierFactor = aimingInfo[2]
        # unShotDispersionFactorsTurretRotation = aimingInfo[3]
        # chassisShotDispersionFactorsMovement = aimingInfo[4]
        # chassisShotDispersionFactorsRotation = aimingInfo[5]
        # aimingTime = aimingInfo[6]
        aimingTimeAll = math.log(
            aimingFactor / shotDispMultiplierFactor) * aimingTime
        aimingFinishTime = aimingTimeAll + aimingStartTime
        timeAIM = max(0.0, aimingFinishTime - BigWorld.time())
        cameraHeight = camera.position.y - endPos.y
        currentDistance = distance
        as_event('ON_MARKER_POSITION')
        if isDisplaySphere:
            update_sphere(endPos)

    except Exception as ex:
        err(traceback.format_exc())
        return base(self, shotPos, shotVec, dispersionAngles)
    return endPos, direction, markerDiameter, idealMarkerDiameter, collData
    def __calcEdgeLine(self, nodeIdA, nodeIdB):
        if nodeIdA == nodeIdB:
            pass
        centerA, _, _, dimensionsA = self.__getNodeGeometry(nodeIdA)
        centerB, _, _, dimensionsB = self.__getNodeGeometry(nodeIdB)
        sectorA = sectorB = None
        sectorIdsA = [ sector.sectorID for sector in self.__sectorComponent.getSectorGroupById(nodeIdA).sectors ]
        for sectorOfB in self.__sectorComponent.getSectorGroupById(nodeIdB).sectors:
            for neighbourOfBId in self.__sectorComponent.getNeighbouringSectorIdsByOwnSectorId(sectorOfB.sectorID):
                if neighbourOfBId in sectorIdsA:
                    sectorA = self.__sectorComponent.getSectorById(neighbourOfBId)
                    sectorB = sectorOfB
                    break

        if None in (sectorA, sectorB):
            return (None, None)
        else:
            if getArena().arenaType.epicSectorGrid.mainDirection in (AAD.PLUS_Z, AAD.MINUS_Z):
                isHorizontal = sectorA.playerGroup == sectorB.playerGroup
            else:
                isHorizontal = sectorA.IDInPlayerGroup == sectorB.IDInPlayerGroup
            comparisonFunc = (lambda a, b: a.x <= b.x) if isHorizontal else (lambda a, b: a.z <= b.z)
            shortWidth, shortHeight, longWidth, longHeight, shortCenter, longCenter = (dimensionsA.x,
             dimensionsA.z,
             dimensionsB.x,
             dimensionsB.z,
             centerA,
             centerB) if comparisonFunc(dimensionsA, dimensionsB) else (dimensionsB.x,
             dimensionsB.z,
             dimensionsA.x,
             dimensionsA.z,
             centerB,
             centerA)
            if isHorizontal:
                z = longCenter.z + copysign(longHeight * 0.5, shortCenter.z - longCenter.z)
                return (Vector3(shortCenter.x - shortWidth * 0.5, 0, z), Vector3(shortCenter.x + shortWidth * 0.5, 0, z))
            x = longCenter.x + copysign(longWidth * 0.5, shortCenter.x - longCenter.x)
            return (Vector3(x, 0, shortCenter.z - shortHeight * 0.5), Vector3(x, 0, shortCenter.z + shortHeight * 0.5))
コード例 #23
0
    def __spreadAnchorsApart(self, visibleAnchors):
        for slotIds in visibleAnchors.itervalues():
            anchorsCount = len(slotIds)
            if anchorsCount > 1:
                radius = _MIN_PROJECTION_DECAL_ANCHORS_DIST * 0.5 / math.sin(math.pi / anchorsCount)
                position = sum((self.__processedAnchors[slotId].position for slotId in slotIds), Vector3()) / anchorsCount
                direction = sum((self.__processedAnchors[slotId].direction for slotId in slotIds), Vector3()) / anchorsCount
                transformMatrix = Math.Matrix()
                transformMatrix.lookAt(position, direction, (0, 1, 0))
                transformMatrix.invert()
                shift = Vector3(0, radius, 0)
                angle = 2 * math.pi / anchorsCount
                rotor = Math.Matrix()
                rotor.setRotateZ(angle)
                for slotId in sorted(slotIds, key=getProjectionSlotFormfactor):
                    anchor = self.__processedAnchors[slotId]
                    newPosition = transformMatrix.applyPoint(shift)
                    anchor.setShift(newPosition - anchor.position)
                    self.setAnchorShift(slotId, anchor.shift)
                    shift = rotor.applyPoint(shift)

            slotId = slotIds.pop()
            self.setAnchorShift(slotId, Vector3())
コード例 #24
0
 def __updateMatrix(self):
     bb = BigWorld.player().arena.arenaType.boundingBox
     pos2D = _clampPoint2DInBox2D(
         bb[0], bb[1],
         Math.Vector2(self.__planePosition.x, self.__planePosition.z))
     self.__planePosition.x = pos2D[0]
     self.__planePosition.z = pos2D[1]
     collPoint = BigWorld.wg_collideSegment(
         BigWorld.player().spaceID,
         self.__planePosition + Math.Vector3(0, 1000.0, 0),
         self.__planePosition + Math.Vector3(0, -250.0, 0), 3)
     heightFromPlane = 0.0 if collPoint is None else collPoint[0][1]
     self._matrix.translation = self.__planePosition + Vector3(
         0, heightFromPlane + self.__height, 0)
コード例 #25
0
class StrategicAimingSystem(IAimingSystem):
    _LOOK_DIR = Vector3(0, -math.cos(0.001), math.sin(0.001))
    height = property(lambda self: self.__height)
    heightFromPlane = property(lambda self: self.__heightFromPlane)

    def __init__(self, height, yaw):
        self._matrix = mathUtils.createRotationMatrix((yaw, 0, 0))
        self.__planePosition = Vector3(0, 0, 0)
        self.__height = height
        self.__heightFromPlane = 0.0

    def destroy(self):
        pass

    def enable(self, targetPos):
        self.updateTargetPos(targetPos)

    def disable(self):
        pass

    def getDesiredShotPoint(self, terrainOnlyCheck=False):
        return AimingSystems.getDesiredShotPoint(self._matrix.translation,
                                                 Vector3(0, -1, 0), True, True,
                                                 terrainOnlyCheck)

    def handleMovement(self, dx, dy):
        shift = self._matrix.applyVector(Vector3(dx, 0, dy))
        self.__planePosition += Vector3(shift.x, 0, shift.z)
        self.__updateMatrix()

    def updateTargetPos(self, targetPos):
        self.__planePosition.x = targetPos.x
        self.__planePosition.z = targetPos.z
        self.__updateMatrix()

    def __updateMatrix(self):
        bb = BigWorld.player().arena.arenaType.boundingBox
        pos2D = _clampPoint2DInBox2D(
            bb[0], bb[1],
            Math.Vector2(self.__planePosition.x, self.__planePosition.z))
        self.__planePosition.x = pos2D[0]
        self.__planePosition.z = pos2D[1]
        collPoint = BigWorld.wg_collideSegment(
            BigWorld.player().spaceID,
            self.__planePosition + Math.Vector3(0, 1000.0, 0),
            self.__planePosition + Math.Vector3(0, -250.0, 0), 3)
        self.__heightFromPlane = 0.0 if collPoint is None else collPoint[0][1]
        self._matrix.translation = self.__planePosition + Vector3(
            0, self.__heightFromPlane + self.__height, 0)
        return
コード例 #26
0
 def disable(self):
     if not self.__isEnabled:
         return
     else:
         self.__isEnabled = False
         self.__cam.disable()
         self.__activeSelector.destroy()
         self.__activeSelector = _DefaultStrikeSelector(Vector3(0, 0, 0), None)
         self.stopCallback(self.__tick)
         self.setGUIVisible(False)
         self.__cam.writeUserPreferences()
         if BigWorld.player().gunRotator is not None:
             BigWorld.player().gunRotator.ignoreAimingMode = False
         return
コード例 #27
0
 def __getLandAt(self, position):
     if self.__ignoreTerrain:
         return Vector3(position.x, 0, position.z)
     else:
         spaceID = BigWorld.player().spaceID
         if spaceID is None:
             return
         upPoint = Math.Vector3(position)
         upPoint.y += 1000
         downPoint = Math.Vector3(position)
         downPoint.y = -1000
         collideRes = BigWorld.wg_collideSegment(spaceID, upPoint,
                                                 downPoint, 16, 8)
         return None if collideRes is None else collideRes.closestPoint
コード例 #28
0
 def __calcCurOscillatorAcceleration(self, deltaTime):
     vehicle = BigWorld.player().vehicle
     if vehicle is None:
         return Vector3(0, 0, 0)
     curVelocity = vehicle.filter.velocity
     relativeSpeed = curVelocity.length / vehicle.typeDescriptor.physics[
         'speedLimits'][0]
     if relativeSpeed >= SniperCamera._MIN_REL_SPEED_ACC_SMOOTHING:
         self.__accelerationSmoother.maxAllowedAcceleration = self.__dynamicCfg[
             'accelerationThreshold']
     else:
         self.__accelerationSmoother.maxAllowedAcceleration = self.__dynamicCfg[
             'accelerationMax']
     acceleration = self.__accelerationSmoother.update(vehicle, deltaTime)
     camMat = Matrix(self.__cam.matrix)
     acceleration = camMat.applyVector(-acceleration)
     accelSensitivity = self.__dynamicCfg['accelerationSensitivity']
     acceleration.x *= accelSensitivity.x
     acceleration.y *= accelSensitivity.y
     acceleration.z *= accelSensitivity.z
     oscillatorAcceleration = Vector3(0, -acceleration.y + acceleration.z,
                                      -acceleration.x)
     return oscillatorAcceleration
コード例 #29
0
 def __cameraUpdate(self):
     replayCtrl = BattleReplay.g_replayCtrl
     if replayCtrl.isPlaying and replayCtrl.isControllingCamera:
         aimOffset = replayCtrl.getAimClipPosition()
     else:
         aimOffset = self.__calcAimOffset()
         if replayCtrl.isRecording:
             replayCtrl.setAimClipPosition(aimOffset)
     self.__aimOffset = aimOffset
     shotDescr = BigWorld.player().getVehicleDescriptor().shot
     BigWorld.wg_trajectory_drawer().setParams(shotDescr.maxDistance, Math.Vector3(0, -shotDescr.gravity, 0), aimOffset)
     curTime = BigWorld.time()
     deltaTime = curTime - self.__prevTime
     self.__prevTime = curTime
     self.__aimingSystem.update(deltaTime)
     if replayCtrl.isPlaying:
         if self.__needReset != 0:
             if self.__needReset > 1:
                 from helpers import isPlayerAvatar
                 player = BigWorld.player()
                 if isPlayerAvatar():
                     if player.inputHandler.ctrl is not None:
                         player.inputHandler.ctrl.resetGunMarkers()
                 self.__needReset = 0
             else:
                 self.__needReset += 1
         if replayCtrl.isControllingCamera:
             self.__aimingSystem.updateTargetPos(replayCtrl.getGunRotatorTargetPoint())
         else:
             self.__aimingSystem.handleMovement(self.__dxdydz.x * self.__curSense, -self.__dxdydz.y * self.__curSense)
             if self.__dxdydz.x != 0 or self.__dxdydz.y != 0 or self.__dxdydz.z != 0:
                 self.__needReset = 2
     else:
         self.__aimingSystem.handleMovement(self.__dxdydz.x * self.__curSense, -self.__dxdydz.y * self.__curSense)
     distRange = self.__getDistRange()
     self.__calcSmoothingPivotDelta(deltaTime)
     self.__camDist -= self.__dxdydz.z * float(self.__curSense)
     self.__camDist = self.__aimingSystem.overrideCamDist(self.__camDist)
     distRange = self.__getDistRange()
     maxPivotHeight = distRange[1] - distRange[0]
     self.__camDist = math_utils.clamp(0, maxPivotHeight, self.__camDist)
     self._cfg['camDist'] = self.__camDist
     camDistWithSmoothing = self.__camDist + self.__smoothingPivotDelta - self.__aimingSystem.heightFromPlane
     self.__cam.pivotPosition = Math.Vector3(0.0, camDistWithSmoothing, 0.0)
     if self.__dxdydz.z != 0 and self.__onChangeControlMode is not None and math_utils.almostZero(self.__camDist - maxPivotHeight):
         self.__onChangeControlMode()
     self.__updateOscillator(deltaTime)
     if not self.__autoUpdatePosition:
         self.__dxdydz = Vector3(0, 0, 0)
     return 0.0
コード例 #30
0
 def _updateMatrix(self):
     self._clampMinimalAimingRadius()
     self._clampToArenaBB()
     hitPoint = BigWorld.wg_collideSegment(
         BigWorld.player().spaceID,
         self._planePosition + Vector3(0.0, 1000.0, 0.0),
         self._planePosition + Vector3(0.0, -250.0, 0.0), 128, 8)
     aimPoint = Vector3(self._planePosition)
     if hitPoint is not None:
         aimPoint.y = hitPoint.closestPoint[1]
     r0, v0, g0 = BigWorld.player().gunRotator.getShotParams(aimPoint, True)
     hitPoint = BigWorld.wg_simulateProjectileTrajectory(
         r0, v0, g0, SERVER_TICK_LENGTH, SHELL_TRAJECTORY_EPSILON_CLIENT,
         128)
     if hitPoint is not None:
         time = (aimPoint.x - r0.x) / v0.x
         self.__direction = v0 + g0 * time
         self.__direction.normalise()
         self._matrix = math_utils.createRTMatrix(
             (self.__direction.yaw, -self.__direction.pitch, 0.0),
             hitPoint[1])
     self.__aimMatrix.setTranslate(aimPoint)
     return
コード例 #31
0
 def updateBomberTrajectory(self, equipmentID, team, curTime, curPos,
                            curDir, nextTime, nextPos, nextDir,
                            isDroppingPoint):
     if _ENABLE_DEBUG_LOG:
         LOG_DEBUG('===== updateBomberTrajectory =====')
         LOG_DEBUG(equipmentID, team)
         LOG_DEBUG(curPos, curDir, curTime)
         LOG_DEBUG(nextPos, nextDir, nextTime)
         LOG_DEBUG(isDroppingPoint)
     moveDir = nextPos - curPos
     moveDir.normalise()
     nextDir3d = Vector3(nextDir.x, moveDir.y, nextDir.y)
     nextDir3d.normalise()
     startP = BombersWing.CurveControlPoint(curPos,
                                            Vector3(curDir.x, 0, curDir.y),
                                            curTime)
     nextP = BombersWing.CurveControlPoint(nextPos, nextDir3d, nextTime)
     points = (startP, nextP)
     wingID = (team, equipmentID)
     wing = self.__wings.get(wingID)
     if wing is None or wing.withdrawn:
         if wing is not None:
             wing.destroy()
         self.__wings[wingID] = BombersWing.BombersWing(equipmentID, points)
         if _ENABLE_DEBUG_DRAW:
             self.debugPoints.append(curPos)
             self.debugDirs.append(curDir)
     else:
         wing.addControlPoint(points, isDroppingPoint)
     if _ENABLE_DEBUG_DRAW:
         self.debugPoints.append(nextPos)
         self.debugDirs.append(nextDir)
         self.debugPoints.append(nextPos +
                                 Vector3(nextDir.x, 0, nextDir.y) * 10)
         self.debugPoints.append(nextPos)
         self.debugPolyLine.set(self.debugPoints)
     return
コード例 #32
0
ファイル: oscillator.py プロジェクト: v3ss0n/WOTDecompiled
 def __init__(self, mass, stiffness, drag, constraints):
     IOscillator.__init__(self)
     self.mass = mass
     self.stiffness = Vector3(stiffness)
     self.drag = Vector3(drag)
     self.constraints = Vector3(constraints)
     self.deviation = Vector3(0, 0, 0)
     self.velocity = Vector3(0, 0, 0)
     self.externalForce = Vector3(0, 0, 0)
コード例 #33
0
 def __init__(self, mass, stiffness, drag, restEpsilon = 0.001):
     IOscillator.__init__(self)
     self.mass = mass
     self.stiffness = Vector3(stiffness)
     self.drag = Vector3(drag)
     self.deviation = Vector3(0, 0, 0)
     self.velocity = Vector3(0, 0, 0)
     self.externalForce = Vector3(0, 0, 0)
     self.__time = 0.0
     self.__startVelocity = Vector3(0, 0, 0)
     self.restEpsilon = restEpsilon
     sqr = self.drag / (2 * self.mass)
     self.__omega = Vector3(math.sqrt(self.stiffness.x / self.mass - sqr.x * sqr.x), math.sqrt(self.stiffness.y / self.mass - sqr.y * sqr.y), math.sqrt(self.stiffness.z / self.mass - sqr.z * sqr.z))