Пример #1
0
 def NewDirectionObstacleCheck(self, destYaw, heading):
     """
     Calculates the direction we want to move in, performs a raycast to a specified length.
     
     The compares the collision normal if there is one with the direction vector to determine if angle between them
     is such where we will allow the character to walk and graze the wall.
     """
     entity = self.entityClient.GetPlayerEntity()
     gw = GameWorld.Manager.GetGameWorld(long(entity.scene.sceneID))
     posComp = entity.GetComponent('position')
     movComp = entity.GetComponent('movement')
     start = posComp.position
     start = geo2.Vec3Add(
         start, (0.0, self.AVATAR_COLLISION_DETECTION_CAPSULE_HEIGHT_MOD *
                 movComp.characterController.height, 0.0))
     yaw, pitch, roll = geo2.QuaternionRotationGetYawPitchRoll(
         posComp.rotation)
     direction = geo2.QuaternionRotationSetYawPitchRoll(yaw + destYaw, 0, 0)
     end = heading
     end = geo2.QuaternionTransformVector(direction, end)
     direction = end = geo2.Vec3Scale(
         end, self.AVATAR_COLLISION_DETECTION_FEELER_LENGTH)
     end = geo2.Vec3Add(end, start)
     hitResult = gw.SweptSphere(
         start, end, self.AVATAR_COLLISION_DETECTION_FEELER_RADIUS)
     result = False
     if hitResult:
         dotProduct = geo2.Vec3Dot(direction, hitResult[1])
         if abs(dotProduct) > self.AVATAR_COLLISION_RESTRICTION_ANGLE_DP:
             result = True
     return result
Пример #2
0
 def Transit(self,
             atPos0,
             eyePos0,
             atPos1,
             eyePos1,
             duration=1.0,
             smoothing=0.1,
             numPoints=1000,
             timeOffset=0.0,
             callback=None):
     newDir = geo2.Vec3Direction(eyePos1, atPos1)
     self.StopEyeAndAtAnimation()
     if self._atTransitOffset:
         atPos0 = geo2.Vec3Add(atPos0, self._atTransitOffset)
     if self._eyeTransitOffset:
         eyePos0 = geo2.Vec3Add(eyePos0, self._eyeTransitOffset)
     self.SetAtPosition(atPos1)
     self.SetEyePosition(eyePos1)
     self._atTransitOffset = geo2.Vec3Subtract(atPos0, atPos1)
     self._eyeTransitOffset = geo2.Vec3Subtract(eyePos0, eyePos1)
     uicore.animations.MorphVector3(self,
                                    '_atTransitOffset',
                                    self._atTransitOffset, (0, 0, 0),
                                    duration=duration,
                                    timeOffset=timeOffset,
                                    callback=callback)
     uicore.animations.MorphVector3(self,
                                    '_eyeTransitOffset',
                                    self._eyeTransitOffset, (0, 0, 0),
                                    duration=duration,
                                    timeOffset=timeOffset,
                                    callback=self.OnTransitEnd)
     self._transitDoneTime = blue.os.GetWallclockTime() + SEC * duration
Пример #3
0
 def update_line_position(posInfo):
     lineData = posInfo[2]
     lineID = lineData.lineID
     fromPosition = posInfo[0]
     if fromPosition is None:
         fromMapNode = GetNodeBySolarSystemID(lineData.fromSolarSystemID)
         fromPosition = fromMapNode.position
         posInfo[0] = fromPosition
     toPosition = posInfo[1]
     if toPosition is None:
         toMapNode = GetNodeBySolarSystemID(lineData.toSolarSystemID)
         toPosition = toMapNode.position
         posInfo[1] = toPosition
     if lineID in adjustLines:
         fromPosition = geo2.Vec3Add(fromPosition, adjustLines[lineID][0])
         toPosition = geo2.Vec3Add(toPosition, adjustLines[lineID][2])
     lineSet.ChangeLinePositionCrt(lineID, fromPosition, toPosition)
     if lineData.jumpType == JUMPBRIDGE_TYPE:
         linkVec = geo2.Vec3Subtract(toPosition, fromPosition)
         normLinkVec = geo2.Vec3Normalize(linkVec)
         rightVec = geo2.Vec3Cross(worldUp, normLinkVec)
         upVec = geo2.Vec3Cross(rightVec, normLinkVec)
         offsetVec = geo2.Vec3Scale(geo2.Vec3Normalize(upVec), geo2.Vec3Length(linkVec) * 1.0)
         midPos = geo2.Vec3Scale(geo2.Vec3Add(toPosition, fromPosition), 0.5)
         splinePos = geo2.Vec3Add(midPos, offsetVec)
         lineSet.ChangeLineIntermediateCrt(lineID, splinePos)
Пример #4
0
 def NewDirectionObstacleCheck(self, destYaw, heading):
     entity = self.entityClient.GetPlayerEntity()
     gw = GameWorld.Manager.GetGameWorld(long(entity.scene.sceneID))
     posComp = entity.GetComponent('position')
     movComp = entity.GetComponent('movement')
     start = posComp.position
     start = geo2.Vec3Add(
         start, (0.0, self.AVATAR_COLLISION_DETECTION_CAPSULE_HEIGHT_MOD *
                 movComp.characterController.height, 0.0))
     yaw, pitch, roll = geo2.QuaternionRotationGetYawPitchRoll(
         posComp.rotation)
     direction = geo2.QuaternionRotationSetYawPitchRoll(yaw + destYaw, 0, 0)
     end = heading
     end = geo2.QuaternionTransformVector(direction, end)
     direction = end = geo2.Vec3Scale(
         end, self.AVATAR_COLLISION_DETECTION_FEELER_LENGTH)
     end = geo2.Vec3Add(end, start)
     hitResult = gw.SweptSphere(
         start, end, self.AVATAR_COLLISION_DETECTION_FEELER_RADIUS)
     result = False
     if hitResult:
         dotProduct = geo2.Vec3Dot(direction, hitResult[1])
         if abs(dotProduct) > self.AVATAR_COLLISION_RESTRICTION_ANGLE_DP:
             result = True
     return result
Пример #5
0
    def PanUpdateThread(self):
        try:
            while True:
                if self.panTarget is None:
                    break
                if self._IsPanTargetOutOfBounds():
                    return
                distLeft = geo2.Vec3LengthD(self.panTarget)
                if distLeft == 0:
                    break
                if distLeft < self.kPanStopDist:
                    dist = 1.0
                else:
                    dist = min(1.0, self._GetPanSpeed() / blue.os.fps)
                toMove = geo2.Vec3ScaleD(self.panTarget, dist)
                self.SetEyePosition(geo2.Vec3Add(self._eyePosition, toMove))
                self.SetAtPosition(geo2.Vec3Add(self._atPosition, toMove))
                self.panTarget = geo2.Vec3SubtractD(self.panTarget, toMove)
                if dist == 1.0:
                    break
                blue.synchro.Yield()

        finally:
            self.panUpdateThread = None
            self.panTarget = None
Пример #6
0
 def Update(self):
     normalCamera = self._GetNonDebugCamera()
     if not self.IsUpdatingDebugCamera() and normalCamera:
         if normalCamera:
             normalCamera.Update()
     if self.IsShowingNormalCamera() and normalCamera:
         camPos = normalCamera.GetPosition()
         poi = normalCamera.GetPointOfInterest()
         vec = geo2.Vec3Subtract(poi, camPos)
         vec = geo2.Vec3Normalize(vec)
         vec = geo2.Vec3Scale(vec, 0.5)
         self.debugRenderClient.RenderCone(camPos,
                                           geo2.Vec3Add(camPos, vec),
                                           0.25,
                                           4278190335L,
                                           time=1)
         if self.lastCamPos is not None and camPos != self.lastCamPos:
             self.debugRenderClient.RenderRay(self.lastCamPos,
                                              camPos,
                                              4278190335L,
                                              4278255360L,
                                              time=1000,
                                              pulse=True)
         self.lastCamPos = camPos
     if self.translationVector != [0.0, 0.0, 0.0]:
         now = blue.os.GetWallclockTime()
         frameTime = float(now - self.lastUpdateTime) / const.SEC
         poi = cameras.PolarCamera.GetPointOfInterest(self)
         rotMatrix = geo2.MatrixRotationYawPitchRoll(
             math.pi / 2.0 - self.yaw, math.pi / 2.0 - self.pitch, 0.0)
         scaledVector = geo2.Vec3Scale(self.translationVector, frameTime)
         relativeVector = geo2.Vec3TransformCoord(scaledVector, rotMatrix)
         newPos = geo2.Vec3Add(poi, relativeVector)
         cameras.PolarCamera.SetPointOfInterest(self, newPos)
     cameras.PolarCamera.Update(self)
Пример #7
0
 def Update(self):
     cameras.BasicCamera.Update(self)
     self.TurnOffAvatar()
     if not trinity.app.IsActive():
         return
     fwdActive, backActive, moveLActive, moveRActive = self.navigation.GetKeyState(
     )
     speed = cameras.FLY_CAMERA_ACCELERATION * cameras.FLY_CAMERA_BASE_MOVEMENT_SPEED
     if fwdActive:
         self.cameraPosition = geo2.Vec3Add(self.cameraPosition,
                                            (val * -speed
                                             for val in self.direction))
     elif backActive:
         self.cameraPosition = geo2.Vec3Add(self.cameraPosition,
                                            (val * speed
                                             for val in self.direction))
     if moveLActive:
         rotateLeft = (-self.direction[2], self.direction[1],
                       self.direction[0])
         translation = geo2.Vec3Add(self.cameraPosition,
                                    (val * speed for val in rotateLeft))
         self.cameraPosition = (translation[0], self.cameraPosition[1],
                                translation[2])
     elif moveRActive:
         rotateRight = (self.direction[2], self.direction[1],
                        -self.direction[0])
         translation = geo2.Vec3Add(self.cameraPosition,
                                    (val * speed for val in rotateRight))
         self.cameraPosition = (translation[0], self.cameraPosition[1],
                                translation[2])
Пример #8
0
 def Pan(self, diff):
     """
         Pan the camera by a vector in world space
     """
     pos = self.GetPosition()
     self.SetPosition(geo2.Vec3Add(pos, diff))
     self.pointOfInterest = geo2.Vec3Add(self.pointOfInterest, diff)
Пример #9
0
    def _DrawVelocityTrace(self):
        while True:
            try:
                entity = self.debugSelectionClient.GetSelectedEntity()
                if entity is not None:
                    if not entity.HasComponent('movement'):
                        return
                    scaleFactor = 1.5 / 4.0
                    offset = 0.25
                    pos = entity.position.position
                    vel = entity.GetComponent('movement').physics.velocity
                    speed = geo2.Vec3Length(vel)
                    speedScaled = speed * scaleFactor
                    velPos = geo2.Vec3Add(pos, (0, offset + speedScaled, 0))
                    velRulePos = geo2.Vec3Add(pos, (0, offset + 1, 0))
                    if self.lastVelPos != velPos:
                        self.debugRenderClient.RenderRay(self.lastVelPos,
                                                         velPos,
                                                         4278190335L,
                                                         4278190335L,
                                                         time=1000,
                                                         pulse=True)
                        self.debugRenderClient.RenderRay(self.lastVelRulePos,
                                                         velRulePos,
                                                         4278255360L,
                                                         4278255360L,
                                                         time=1000,
                                                         pulse=False)
                        self.lastVelPos = velPos
                        self.lastVelRulePos = velRulePos
            except:
                log.LogException()

            blue.pyos.synchro.SleepWallclock(const.ONE_TICK / const.MSEC)
 def getPoint(i):
     p = obb[3]
     x = obb[0]
     y = obb[1]
     z = obb[2]
     size = obb[4]
     p = geo2.Vec3Add(p, geo2.Vec3Scale(x, size[0] if i & 1 else -size[0]))
     p = geo2.Vec3Add(p, geo2.Vec3Scale(y, size[1] if i & 2 else -size[1]))
     p = geo2.Vec3Add(p, geo2.Vec3Scale(z, size[2] if i & 4 else -size[2]))
     return p
Пример #11
0
def DrawCircularArc(lineSet, centerPosition, radius, angle, startAngle = 0.0, lineWidth = 1.0, startColor = (0.3, 0.3, 0.3, 0.5), endColor = (0.3, 0.3, 0.3, 0.5)):
    cos = math.cos(startAngle)
    sin = math.sin(startAngle)
    p1 = geo2.Vec3Add(centerPosition, (-radius * cos, 0.0, -radius * sin))
    cos = math.cos(startAngle + angle)
    sin = math.sin(startAngle + angle)
    p2 = geo2.Vec3Add(centerPosition, (-radius * cos, 0.0, -radius * sin))
    lineID = lineSet.AddSpheredLineCrt(p1, startColor, p2, endColor, centerPosition, lineWidth)
    lineSet.ChangeLineSegmentation(lineID, int(math.degrees(angle)))
    return lineID
Пример #12
0
 def MoveTF(self, tf, dx, dy):
     camera = sm.GetService('sceneManager').GetRegisteredCamera('starmap')
     X = float(dx) / float(trinity.device.width)
     Y = -float(dy) / float(trinity.device.height)
     viewVec = camera.viewVec
     upVec = geo2.Vec3Scale(camera.upVec, Y)
     rightVec = geo2.Vec3Scale(camera.rightVec, X)
     pos = geo2.Vec3Add(rightVec, upVec)
     pos = geo2.Vec3Scale(pos, pow(tf.cameraDistSq, 0.5) * 1.5)
     pos = geo2.QuaternionTransformVector(camera.rotationAroundParent, pos)
     tf.translation = geo2.Vec3Add(tf.translation, pos)
Пример #13
0
 def UpdateAtEyePositions(self):
     trackPos = self.GetTrackPosition()
     lookDir = self.GetLookDirection()
     ballPos = GetBallPosition(self.trackBall)
     if self.trackBall.model:
         radius = self.trackBall.model.GetBoundingSphereRadius()
     else:
         radius = self.trackBall.radius * 1.2
     self.SetEyePosition(
         geo2.Vec3Add(ballPos, geo2.Vec3Scale(lookDir, -radius)))
     self.SetAtPosition(
         geo2.Vec3Add(ballPos, geo2.Vec3Scale(lookDir, -2 * radius)))
Пример #14
0
 def Zoom(self, val):
     dev = trinity.device
     pos = self.GetPosition()
     target = self.GetPointOfInterest()
     view = geo2.Vec3Normalize(geo2.Subtract(pos, target))
     length = geo2.Vec3Length(geo2.Subtract(pos, target))
     nextPos = geo2.Vec3Add(pos, geo2.Vec3Scale(view, length * val))
     nextLength = geo2.Vec3Length(geo2.Vec3Subtract(nextPos, target))
     if nextLength < self.minZoomDistance:
         nextPos = geo2.Vec3Add(target, geo2.Vec3Scale(view, self.minZoomDistance))
     elif nextLength > self.maxZoomDistance:
         nextPos = geo2.Vec3Add(target, geo2.Vec3Scale(view, self.maxZoomDistance))
     self.SetPosition(nextPos)
Пример #15
0
def GetSynchedAnimStartLocation(sourcePos, sourceRot, targetPos, targetRot, animInfo):
    relVec = geo2.Vec3Subtract(sourcePos, targetPos)
    curDist = geo2.Vec3Length(relVec)
    if curDist <= 0.01:
        sourcePos = geo2.Vec3Add(targetPos, (0, 0, -1))
        relVec = geo2.Vec3Subtract(sourcePos, targetPos)
    entName = const.animation.ATTACKER_NAME
    if entName in animInfo and const.animation.METADATA_TURN_TO_FACE in animInfo[entName] and animInfo[entName][const.animation.METADATA_TURN_TO_FACE] == False:
        newSourceRot = sourceRot
    else:
        newSourceRot = GetQuatFromDirection(sourcePos, targetPos)
    entName = const.animation.VICTIM_NAME
    if entName in animInfo and const.animation.METADATA_TURN_TO_FACE in animInfo[entName] and animInfo[entName][const.animation.METADATA_TURN_TO_FACE] == False:
        newTargetRot = targetRot
        newTargetYaw, trash, trash = geo2.QuaternionRotationGetYawPitchRoll(targetRot)
    else:
        newTargetRot = GetQuatFromDirection(targetPos, sourcePos)
        if entName in animInfo and const.animation.METADATA_START_OFFSET_YAW in animInfo[entName]:
            degrees = animInfo[entName][const.animation.METADATA_START_OFFSET_YAW]
            offsetYaw = math.pi * -degrees / 180.0
            offsetRot = geo2.QuaternionRotationSetYawPitchRoll(offsetYaw, 0.0, 0.0)
            newTargetRot = geo2.QuaternionMultiply(newTargetRot, offsetRot)
    distance = 0.5
    if const.animation.METADATA_START_DISTANCE in animInfo:
        distance = animInfo[const.animation.METADATA_START_DISTANCE]
    entName = const.animation.VICTIM_NAME
    if entName in animInfo and const.animation.METADATA_START_OFFSET_YAW in animInfo[entName]:
        if '/righthanded' in blue.pyos.GetArg():
            front = (0, 0, distance)
        else:
            front = (0, 0, -distance)
        degrees = animInfo[entName][const.animation.METADATA_START_OFFSET_YAW]
        radians = math.pi * degrees / 180.0
        offsetRot = geo2.QuaternionRotationSetYawPitchRoll(radians, 0.0, 0.0)
        yawOffsetQuat = geo2.QuaternionMultiply(newTargetRot, offsetRot)
        radOffset = geo2.QuaternionTransformVector(yawOffsetQuat, front)
        newSourcePos = geo2.Vec3Add(targetPos, radOffset)
        newSourceRot = GetQuatFromDirection(newSourcePos, targetPos)
    else:
        direction = geo2.Vec3Normalize(relVec)
        newSourcePos = geo2.Vec3Add(targetPos, (distance * direction[0], distance * direction[1], distance * direction[2]))
    entName = const.animation.ATTACKER_NAME
    if entName in animInfo and const.animation.METADATA_START_OFFSET_YAW in animInfo[entName]:
        degrees = animInfo[entName][const.animation.METADATA_START_OFFSET_YAW]
        radians = math.pi * -degrees / 180.0
        offsetRot = geo2.QuaternionRotationSetYawPitchRoll(radians, 0.0, 0.0)
        newSourceRot = geo2.QuaternionMultiply(newSourceRot, offsetRot)
    return (newSourcePos,
     newSourceRot,
     targetPos,
     newTargetRot)
Пример #16
0
 def UpdateSolarSystemPosition(self, solarSystemPosition):
     self.mapPositionSolarSystem = solarSystemPosition
     self.position = geo2.Vec3Add(solarSystemPosition, self.mapPositionLocal)
     self.projectBracket.trackPosition = self.position
     if self.trackingTransforms:
         for each in self.trackingTransforms:
             each.translation = self.position
Пример #17
0
 def Update(self):
     BaseSpaceCamera.Update(self)
     if self.model and self.model.translationCurve:
         atPos = self.model.translationCurve.value
         diff = geo2.Vec3Subtract(atPos, self._atPosition)
         self.atPosition = atPos
         self.eyePosition = geo2.Vec3Add(self.eyePosition, diff)
Пример #18
0
 def Update(self):
     self._UpdateAnchorPosition()
     BaseSpaceCamera.Update(self)
     if not self.lookAtBall or not self.ego:
         return
     zoomProp = self.GetZoomProportion()
     self._UpdateAtOffset()
     self._UpdateEyeOffset()
     newAtPos = self.GetTrackPosition(self.lookAtBall)
     atDiff = geo2.Vec3Subtract(newAtPos, self._atPosition)
     self.SetAtPosition(newAtPos)
     if self.IsChasing():
         self.SetEyePosition(
             self.trackLerper.GetValue(self._eyePosition,
                                       self.GetChaseEyePosition()))
     elif self.IsTracking():
         self.SetEyePosition(
             self.trackLerper.GetValue(self._eyePosition,
                                       self.GetTrackingEyePosition()))
     else:
         prop = self._GetEyePosDriftProporition()
         eyeOffset = geo2.Vec3Scale(atDiff, prop)
         self.SetEyePosition(geo2.Vec3Add(self._eyePosition, eyeOffset))
     if not self.IsInTransit():
         if self.GetItemID() == self.ego or self.IsTracking(
         ) or self.IsChasing():
             self.SetZoom(zoomProp)
         self.EnforceMinZoom()
     if not self.isManualFovEnabled and IsDynamicCameraMovementEnabled():
         self.SetFovTarget(self.GetDynamicFov())
Пример #19
0
 def SetYaw(self, yaw):
     rotMat = geo2.MatrixRotationY(yaw - math.pi)
     eyePos = geo2.Vec3Subtract(self._eyePosition, self._atPosition)
     x = math.sqrt(eyePos[0]**2 + eyePos[2]**2)
     vec = (0, eyePos[1], x)
     self._eyePosition = geo2.Vec3Add(geo2.Vec3Transform(vec, rotMat),
                                      self._atPosition)
Пример #20
0
 def _GetBonePosRot(self, ENTID, boneName, posProp, rotProp):
     entity = self.entityService.FindEntityByID(ENTID)
     if entity is None:
         self.LogError('GetBonePosRot: Entity with ID ', ENTID,
                       ' not found!')
         return False
     animClient = entity.GetComponent('animation')
     posComp = entity.GetComponent('position')
     if animClient is not None and posComp is not None:
         if animClient.controller is not None:
             boneTransform = animClient.controller.animationNetwork.GetBoneTransform(
                 boneName)
             if boneTransform:
                 translation, orientation = boneTransform
                 translation = geo2.QuaternionTransformVector(
                     posComp.rotation, translation)
                 translation = geo2.Vec3Add(posComp.position, translation)
                 orientation = geo2.QuaternionMultiply(
                     posComp.rotation, orientation)
                 translation = list(translation)
                 orientation = list(orientation)
                 GameWorld.AddPropertyForCurrentPythonProc(
                     {posProp: translation})
                 GameWorld.AddPropertyForCurrentPythonProc(
                     {rotProp: orientation})
                 return True
     self.LogError('GetBonePosRot: Missing critical data in entity!')
     return False
Пример #21
0
 def SetPitch(self, pitch):
     pitch = self.ClampPitch(pitch)
     axis = geo2.Vec3Cross(self.upDirection, self.GetLookAtDirection())
     rotMat = geo2.MatrixRotationAxis(axis, pitch)
     vec = (0, self.GetZoomDistance(), 0)
     self._eyePosition = geo2.Vec3Add(self._atPosition,
                                      geo2.Vec3Transform(vec, rotMat))
Пример #22
0
 def MoveCursor(self, tf, dx, dy, camera):
     dev = trinity.device
     X = float(dx) / float(dev.width)
     Y = float(dy) / float(dev.height) * -1
     upVec = geo2.Vec3Scale(camera.upVec, Y)
     rightVec = geo2.Vec3Scale(camera.rightVec, X)
     pos = geo2.Vec3Add(rightVec, upVec)
     cameraDistance = geo2.Vec3Length(geo2.Vec3Subtract(camera.pos, self.cursor.translation))
     pos = geo2.Vec3Scale(pos, cameraDistance * 3.0)
     if tf in self.yCursor:
         pos = (0.0, pos[1], 0.0)
     elif tf in self.xCursor:
         pos = (pos[0], 0.0, 0.0)
     elif tf in self.zCursor:
         pos = (0.0, 0.0, pos[2])
     self.cursor.translation = geo2.Vec3Add(self.cursor.translation, pos)
Пример #23
0
def TransformAccumulatedAnimFromPos(curPos, curRot, offsetTranslation, offsetYaw):
    offsetYaw = offsetYaw * math.pi / 180.0
    trajRot = geo2.QuaternionRotationSetYawPitchRoll(offsetYaw, 0.0, 0.0)
    offsetPosRotated = geo2.QuaternionTransformVector(curRot, offsetTranslation)
    newPos = geo2.Vec3Add(curPos, offsetPosRotated)
    newRot = geo2.QuaternionMultiply(trajRot, curRot)
    return (newPos, newRot)
Пример #24
0
 def UpdateModelPosition(self, pos):
     self.UpdateModel()
     if self.model:
         pos = geo2.Vec3Add(pos, self.movingOffset)
         pos = self.EnforcePositionRestrictions(pos)
         if pos:
             self.model.translationCurve.value = pos
Пример #25
0
 def PlaySoundFX(self, targetObject, spewCone):
     position, direction = spewCone
     audioEmitter = audio2.AudEmitter(targetObject.name + '_src')
     translatedPosition = geo2.Vec3Add(targetObject.worldPosition, position)
     audioEmitter.SetPosition(direction, translatedPosition)
     audioEmitter.SetAttenuationScalingFactor(10000)
     audioEmitter.SendEvent('scattering_spew_play')
    def LoadMarkers(self):
        if self.markersHandler and self.localMarkerIDs:
            for markerID in self.localMarkerIDs:
                self.markersHandler.RemoveMarker(markerID)

        self.localMarkerIDs = set()
        solarSystemData = self.systemMapSvc.GetSolarsystemData(
            self.solarsystemID)
        loadMarkerGroups = GetMapViewSetting(VIEWMODE_MARKERS_SETTINGS)
        for each in solarSystemData:
            if self.markersHandler and each.groupID in loadMarkerGroups:
                bracketData = sm.GetService('bracket').GetMappedBracketProps(
                    cfg.invgroups.Get(each.groupID).categoryID, each.groupID,
                    each.typeID)
                markerID = (MARKERID_SOLARSYSTEM_CELESTIAL, each.itemID)
                markerObject = self.markersHandler.AddMarker(
                    markerID,
                    geo2.Vec3Add(
                        self.position,
                        SolarSystemPosToMapPos((each.x, each.y, each.z))),
                    MarkerCelestial,
                    texturePath=bracketData[0],
                    celestialData=each,
                    distanceFadeAlpha=True,
                    maxVisibleRange=2500)
                markerObject.SetSolarSystemID(self.solarsystemID)
                self.localMarkerIDs.add(markerID)
Пример #27
0
 def _UpdateCameraNoiseOffset(self):
     if self.noiseScaleCurve:
         self.noiseScale = self.noiseScaleCurve.UpdateScalar(
             blue.os.GetSimTime())
     if self.noiseScale == 0:
         return
     if self.noiseDampCurve:
         self.noiseDamp = self.noiseDampCurve.UpdateScalar(
             blue.os.GetSimTime())
     dT = 1.0 / blue.os.fps
     ran = random.random() - 0.5
     self._noiseX = (self._noiseX +
                     self.noiseDamp * ran) / (1.0 + self.noiseDamp * dT)
     self._noiseX = max(-MAX_NOISE, min(self._noiseX, MAX_NOISE))
     ran = random.random() - 0.5
     self._noiseY = (self._noiseY +
                     self.noiseDamp * ran) / (1.0 + self.noiseDamp * dT)
     self._noiseY = max(-MAX_NOISE, min(self._noiseY, MAX_NOISE))
     noiseScale = self.GetZoomDistance() / 100.0 * self.noiseScale
     direction = self.GetLookAtDirection()
     vecX = geo2.Vec3Cross(direction, self._upDirection)
     vecY = geo2.Vec3Cross(direction, vecX)
     vecX = geo2.Vec3Scale(vecX, self._noiseX * noiseScale)
     vecY = geo2.Vec3Scale(vecY, self._noiseY * noiseScale)
     noiseOffset = geo2.Vec3Add(vecX, vecY)
     self._AddToAtOffset(noiseOffset)
Пример #28
0
 def UpdateMapPositionLocal(self, mapPositionLocal):
     self.mapPositionLocal = mapPositionLocal
     self.position = geo2.Vec3Add(self.mapPositionSolarSystem, mapPositionLocal)
     self.projectBracket.trackPosition = self.position
     if self.trackingTransforms:
         for each in self.trackingTransforms:
             each.translation = self.position
    def ShowMyHomeStation(self):
        if self.destroyed:
            return
        markerID = (MARKERID_MYHOME, session.charid)
        self.markersHandler.RemoveMarker(markerID)
        try:
            self.markersAlwaysVisible.remove(markerID)
        except:
            pass

        homeStationID = sm.RemoteSvc('charMgr').GetHomeStation()
        if not homeStationID or self.destroyed:
            return
        stationInfo = self.mapSvc.GetStation(homeStationID)
        if self.destroyed:
            return
        if stationInfo.solarSystemID != self.currentSolarsystem.solarsystemID:
            return
        mapPosition = (0, 0, 0)
        localPosition = SolarSystemPosToMapPos(
            (stationInfo.x, stationInfo.y, stationInfo.z))
        mapPosition = geo2.Vec3Add(mapPosition, localPosition)
        markerObject = self.markersHandler.AddMarker(
            markerID,
            mapPosition,
            MarkerMyHome,
            stationInfo=stationInfo,
            texturePath='res:/UI/Texture/classes/MapView/homeIcon.png',
            hintString='Home Station',
            distanceFadeAlpha=False)
        markerObject.SetSolarSystemID(stationInfo.solarSystemID)
        self.markersAlwaysVisible.add(markerID)
Пример #30
0
    def PickProbes(self, pickBorder = False):
        mouseInsideProbes = []
        borderPick = []
        probeHandler = self.GetProbeHandler()
        if probeHandler:
            probeData = sm.StartService('scanSvc').GetProbeData()
            cameraPosition = geo2.Vec3Add(self.mapView.camera.pointOfInterest, self.mapView.camera._eyePosition)
            probes = probeHandler.GetProbeControls()
            for probeID, probeControl in probes.iteritems():
                if probeID not in probeData or probeData[probeID].state != const.probeStateIdle:
                    continue
                targetPlanePos = probeControl.GetWorldPosition()
                cameraDistance = geo2.Vec3Length(geo2.Vec3Subtract(cameraPosition, targetPlanePos))
                rad = probeControl.GetRange() * SOLARSYSTEM_SCALE
                mousePositionOnCameraPlane = self.GetDotInCameraAlignedPlaneFromPosition(targetPlanePos)
                distanceFromCenter = geo2.Vec3Length(geo2.Vec3Subtract(targetPlanePos, mousePositionOnCameraPlane))
                if pickBorder:
                    pickRadiusPos = self.GetDotInCameraAlignedPlaneFromPosition(targetPlanePos, offsetMouse=(-10, 0))
                    pickRadius = geo2.Vec3Length(geo2.Vec3Subtract(pickRadiusPos, mousePositionOnCameraPlane))
                    if rad + pickRadius > distanceFromCenter > rad - pickRadius:
                        borderPick.append((abs(rad - distanceFromCenter), probeControl))
                elif distanceFromCenter <= rad:
                    mouseInsideProbes.append((cameraDistance, probeControl))

        if pickBorder:
            if borderPick:
                return SortListOfTuples(borderPick)[0]
            else:
                return None
        return SortListOfTuples(mouseInsideProbes)