Пример #1
0
 def __resolveCollisions(self, aimPoint, distance, direction):
     distRange = self.__cfg['distRange']
     collisionTestOrigin = self.__getCollisionTestOrigin(
         aimPoint, direction)
     sign = copysign(
         1.0, distance * distance -
         (aimPoint - collisionTestOrigin).lengthSquared)
     srcPoint = collisionTestOrigin
     endPoint = aimPoint - direction.scale(distance + sign * distRange[0])
     collision = collideDynamicAndStatic(
         srcPoint, endPoint, (BigWorld.player().playerVehicleID, ))
     if collision:
         collisionDistance = (aimPoint - collision[0]).length
         if sign * (collisionDistance - distance) < distRange[0]:
             distance = collisionDistance - sign * distRange[0]
     if mathUtils.almostZero(self.__rotation):
         srcPoint = aimPoint - direction.scale(distance)
         endPoint = aimPoint
         collision = collideDynamicAndStatic(
             srcPoint, endPoint, (BigWorld.player().playerVehicleID, ))
         if collision:
             self.__aimingSystem.aimPoint = collision[0]
             if collision[1]:
                 self.__positionHysteresis.update(aimPoint)
                 self.__timeHysteresis.update(self.__prevTime)
     return distance
Пример #2
0
def _getDesiredShotPointUncached(start, dir, onlyOnGround, isStrategicMode,
                                 terrainOnlyCheck):
    end = start + dir.scale(10000.0)
    if isStrategicMode:
        if terrainOnlyCheck:
            return __collideTerrainOnly(start, end)
        point1 = __collideStaticOnly(start, end)
        point2 = collideDynamicAndStatic(start,
                                         end,
                                         (BigWorld.player().playerVehicleID, ),
                                         skipGun=isStrategicMode)
        if point1 is None or point2 is None:
            point = None
        else:
            dir = Math.Vector3(point2[0]) - Math.Vector3(point1[0])
            point = (Math.Vector3(point1[0]) + dir.scale(0.5), None)
    else:
        point = collideDynamicAndStatic(start,
                                        end,
                                        (BigWorld.player().playerVehicleID, ),
                                        skipGun=isStrategicMode)
    if point is not None:
        return point[0]
    elif not onlyOnGround:
        return shootInSkyPoint(start, dir)
    else:
        return
Пример #3
0
 def __pickVehicle(self):
     if self.__boundVehicleMProv is not None:
         return
     else:
         x, y = GUI.mcursor().position
         from AvatarInputHandler import cameras
         dir, start = cameras.getWorldRayAndPoint(x, y)
         end = start + dir.scale(100000.0)
         pos, colldata = collideDynamicAndStatic(start, end, (), 0)
         vehicle = None
         if colldata is not None:
             entity = colldata[0]
             from Vehicle import Vehicle
             if isinstance(entity, Vehicle):
                 vehMatProv = entity.matrix
                 vehMatInv = Matrix(vehMatProv)
                 vehMatInv.invert()
                 localPos = vehMatInv.applyPoint(pos)
                 result = Math.MatrixProduct()
                 localTransMat = Matrix()
                 localTransMat.translation = localPos
                 result.a = localTransMat
                 result.b = vehMatProv
                 return result
         return
Пример #4
0
 def __pickVehicle(self):
     if self.__boundVehicleMProv is not None:
         return
     else:
         x, y = GUI.mcursor().position
         from AvatarInputHandler import cameras
         dir, start = cameras.getWorldRayAndPoint(x, y)
         end = start + dir.scale(100000.0)
         pos, colldata = collideDynamicAndStatic(start, end, (), 0)
         vehicle = None
         if colldata is not None:
             entity = colldata[0]
             from Vehicle import Vehicle
             if isinstance(entity, Vehicle):
                 vehMatProv = entity.matrix
                 vehMatInv = Matrix(vehMatProv)
                 vehMatInv.invert()
                 localPos = vehMatInv.applyPoint(pos)
                 result = Math.MatrixProduct()
                 localTransMat = Matrix()
                 localTransMat.translation = localPos
                 result.a = localTransMat
                 result.b = vehMatProv
                 return result
         return
Пример #5
0
def isRayAtVehicle(start, end):
	posColldata = collideDynamicAndStatic(start, end, (BigWorld.player().playerVehicleID,), 0)
	if posColldata:
		pos, collData = posColldata
		if collData and collData.isVehicle():
			return True
	
	return False
Пример #6
0
def getDesiredShotPoint(start, dir, onlyOnGround = False, isStrategicMode = False):
    end = start + dir.scale(10000.0)
    if isStrategicMode:
        point1 = __collideStaticOnly(start, end)
        point2 = collideDynamicAndStatic(start, end, (BigWorld.player().playerVehicleID,), skipGun=isStrategicMode)
        if point1 is None or point2 is None:
            point = None
        else:
            dir = Math.Vector3(point2[0]) - Math.Vector3(point1[0])
            point = (Math.Vector3(point1[0]) + dir.scale(0.5), None)
    else:
        point = collideDynamicAndStatic(start, end, (BigWorld.player().playerVehicleID,), skipGun=isStrategicMode)
    if point is not None:
        return point[0]
    elif not onlyOnGround:
        return shootInSkyPoint(start, dir)
    else:
        return
Пример #7
0
 def pick(self):
     x, y = GUI.mcursor().position
     from AvatarInputHandler import cameras
     dir, start = cameras.getWorldRayAndPoint(x, y)
     end = start + dir.scale(100000.0)
     posColldata = collideDynamicAndStatic(start, end, (), 0)
     if posColldata is None:
         return (None, None)
     pos, collData = posColldata
     if collData is None or not collData.isVehicle():
         return (None, None)
     return (collData[0], pos)
Пример #8
0
 def pick(self):
     x, y = GUI.mcursor().position
     from AvatarInputHandler import cameras
     dir, start = cameras.getWorldRayAndPoint(x, y)
     end = start + dir.scale(100000.0)
     posColldata = collideDynamicAndStatic(start, end, (), 0)
     if posColldata is None:
         return (None, None)
     else:
         pos, collData = posColldata
         if collData is None or not collData.isVehicle():
             return (None, None)
         return (collData[0], pos)
def getDistance():
    global distance, getDistanceID
    if ownVehicle is not None:
        pos = GUI.mcursor().position
        direction, start = getWorldRayAndPoint(*pos)
        end = start + direction.scale(100000.0)
        point = collideDynamicAndStatic(start, end, (ownVehicle.id, ), 0)
        aimingPoint = point[0] if point is not None else shootInSkyPoint(
            start, direction)
        prevDistance = distance
        distance = int((aimingPoint - ownVehicle.position).length)
        if prevDistance != distance:
            as_event('ON_CROSSHAIR')
        getDistanceID = callback(0.1, getDistance)
Пример #10
0
def SniperAimingSystem_getDesiredShotPoint(self, *args):
    start = self.matrix.translation
    dir = self.matrix.applyVector(Math.Vector3(0, 0, 1))

    end = start + dir.scale(10000.0)
    point = collideDynamicAndStatic(start, end, (BigWorld.player().playerVehicleID,), skipGun=False)
    if point is not None:
        result = point[0]
        self._shootDistance = (result - start).length
    else:
        if self._shootDistance > 0.0:
            result = start + dir.scale(self._shootDistance)
        else:
            result = AimingSystems.shootInSkyPoint(start, dir)

    return result
Пример #11
0
def SniperAimingSystem_getDesiredShotPoint(self):
    start = self.matrix.translation
    dir = self.matrix.applyVector(Math.Vector3(0, 0, 1))

    end = start + dir.scale(10000.0)
    point = collideDynamicAndStatic(start, end, (BigWorld.player().playerVehicleID,), skipGun=False)
    if point is not None:
        result = point[0]
        self._shootDistance = (result - start).length
    else:
        if self._shootDistance > 0.0:
            result = start + dir.scale(self._shootDistance)
        else:
            result = AimingSystems.shootInSkyPoint(start, dir)

    return result
Пример #12
0
 def _play(self, playID, effect, targetPosition):
     self._callbacks.pop(playID)
     altitude = Math.Vector3(0, self.SHOT_HEIGHT, 0)
     if effect['offsetDeviation']:
         radius = random.uniform(0, effect['offsetDeviation'])
         angle = random.uniform(0, 2 * math.pi)
         offset = Math.Vector3(radius * math.cos(angle), 0,
                               radius * math.sin(angle))
         targetPosition = targetPosition + offset
     if effect['groundRaycast']:
         startPoint = targetPosition + altitude
         endPoint = targetPosition - altitude
         collisionPoint = collideDynamicAndStatic(startPoint, endPoint, ())
         if collisionPoint:
             targetPosition = collisionPoint[0]
     if effect['shotEffects']:
         shotEffect = random.choice(effect['shotEffects'])
         effectsIndex = vehicles.g_cache.shotEffectsIndexes[shotEffect]
         effectsDescr = vehicles.g_cache.shotEffects[effectsIndex]
         artilleryID = effectsDescr.get('artilleryID')
         if artilleryID is not None:
             self.salvo.addProjectile(artilleryID, self.GRAVITY,
                                      targetPosition + altitude,
                                      self.SHELL_VELOCITY)
     if effect['sequences']:
         sequenceID, sequenceData = random.choice(
             effect['sequences'].items())
         matrix = Math.Matrix()
         matrix.setRotateY(self.yaw)
         matrix.setScale(sequenceData['scale'])
         matrix.translation = targetPosition
         loader = AnimationSequence.Loader(sequenceID, self.spaceID)
         animator = loader.loadSync()
         animator.bindToWorld(matrix)
         animator.speed = 1
         animator.loopCount = 1
         animator.start()
         self._sequences.append(animator)
     return
 def getCursorWorldPos(self):
     x, y = GUI.mcursor().position
     dir, start = cameras.getWorldRayAndPoint(x, y)
     end = start + dir.scale(100000.0)
     return collideDynamicAndStatic(start, end, (), 0)