Пример #1
0
 def PickObject(self, x, y):
     if self.sceneManager.GetActiveScene() != self.renderScene:
         return
     rescale = 1.0 / 10000.0
     projection = trinity.TriProjection()
     projection.PerspectiveFov(trinity.GetFieldOfView(),
                               trinity.GetAspectRatio(),
                               trinity.GetFrontClip(),
                               trinity.GetBackClip())
     view = trinity.TriView()
     view.transform = trinity.GetViewTransform()
     scaling, rotation, translation = geo2.MatrixDecompose(
         self.transform.worldTransform)
     pZ = geo2.Vec3Transform((0, 0, 1), self.transform.worldTransform)
     surfaceNormal = geo2.Subtract(pZ, translation)
     cameraZ = geo2.Vector(view.transform[0][2], view.transform[1][2],
                           view.transform[2][2])
     if geo2.Vec3Dot(surfaceNormal, cameraZ) < 0:
         return
     self.renderObject.translation = geo2.Vec3Scale(translation, rescale)
     self.renderObject.rotation = rotation
     self.renderObject.scaling = geo2.Vec3Scale(scaling, rescale)
     scaling, rotation, translation = geo2.MatrixDecompose(view.transform)
     translation = geo2.Vec3Scale(translation, rescale)
     view.transform = geo2.MatrixTransformation(None, None, scaling, None,
                                                rotation, translation)
     return self.renderObject.PickObject(x, y, projection, view,
                                         trinity.device.viewport)
Пример #2
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)
Пример #3
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)
Пример #4
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)
 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
Пример #6
0
 def _GetNewLookAtEyePos(self, atPos1, itemID, radius):
     typeID = self.lookAtBall.typeID
     if typeID and evetypes.GetGroupID(typeID) == invconst.groupBillboard:
         direction = GetSpeedDirection(self.lookAtBall)
         if geo2.Vec3Dot(self.GetLookAtDirection(), direction) < 0:
             direction = geo2.Vec3Scale(direction, -1)
         radius = self.lookAtBall.radius * 5
     else:
         direction = self.GetLookAtDirection()
     eyePos1 = geo2.Vec3Add(atPos1, geo2.Vec3Scale(direction, radius))
     return eyePos1
Пример #7
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)
Пример #8
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)))
Пример #9
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)
Пример #10
0
 def OnActivated(self, **kwargs):
     BaseSpaceCamera.OnActivated(self, **kwargs)
     duration = max(blue.os.desiredSimDilation, 0.2) * 1.75
     self._eyePosition = geo2.Vec3Scale(self.GetLookAtDirection(), -30.0)
     eyePos1 = geo2.Vec3Scale(self.GetLookAtDirection(), 8.0)
     uicore.animations.MorphVector3(self,
                                    '_eyePosition',
                                    self._eyePosition,
                                    eyePos1,
                                    duration=duration)
     uicore.animations.MorphScalar(self,
                                   'fov',
                                   startVal=self.fov,
                                   endVal=0.55,
                                   duration=duration)
Пример #11
0
 def UpdateSpeedOffset(self):
     if IsDynamicCameraMovementEnabled() and not self.IsTracking():
         speedProp = self.GetSpeedOffsetProportion()
         offsetAmount = speedProp * 0.5 * self.maxZoom
         self.speedOffset = geo2.Vec3Scale(self.speedDir, offsetAmount)
     else:
         self.speedOffset = (0, 0, 0)
Пример #12
0
 def _OnActivated(self):
     duration = 15.0
     ball = GetBallWaitForModel(self.ego)
     self.SetEyePosition(
         geo2.Vec3Scale(GetSpeedDirection(ball), 2 * GetBallRadius(ball)))
     self.SetMaxZoom(GetBallMaxZoom(ball, self.nearClip))
     uicore.animations.MorphScalar(self,
                                   'yaw',
                                   self.yaw,
                                   self.yaw + math.pi / 20,
                                   duration=duration)
     uicore.animations.MorphScalar(self,
                                   'pitch',
                                   self.pitch,
                                   self.pitch + math.pi / 40,
                                   duration=duration)
     dist = GetInitialLookAtDistance(self.maxZoom, self.minZoom)
     zoom0 = self.GetZoomProportionByZoomDistance(5 * dist)
     zoom1 = self.GetZoomProportionByZoomDistance(dist)
     uicore.animations.MorphScalar(self,
                                   'zoom',
                                   zoom0,
                                   zoom1,
                                   duration=duration * 0.8)
     blue.synchro.SleepWallclock(duration * 1000)
     uthread.new(self.SwitchToPrimaryCamera)
Пример #13
0
 def _OnActivated(self):
     duration = 30.0
     ball = GetBallWaitForModel(self.ego)
     self.SetEyePosition(
         geo2.Vec3Scale(GetSpeedDirection(ball), 2 * GetBallRadius(ball)))
     self.SetMaxZoom(GetBallMaxZoom(ball, self.nearClip))
     self.pitch -= math.pi / 40
     uicore.animations.MorphScalar(self,
                                   'yaw',
                                   self.yaw,
                                   self.yaw + math.pi / 3,
                                   duration=duration)
     uicore.animations.MorphScalar(self,
                                   'pitch',
                                   self.pitch,
                                   self.pitch - math.pi / 10,
                                   duration=duration)
     zoom0 = 0.48
     zoom1 = 0.65
     self.SetZoom(zoom0)
     uicore.animations.MorphScalar(self,
                                   'zoom',
                                   zoom0,
                                   zoom1,
                                   duration=duration * 0.8)
     blue.synchro.SleepWallclock(duration * 1000 + 500)
     uthread.new(self.SwitchToPrimaryCamera)
Пример #14
0
 def Stop(self):
     self.ending = True
     if self.cameraLookAnimation is not None:
         self.cameraLookAnimation.Stop()
     camera = self.GetCamera()
     camera.shakeController.EndCameraShake('JumpIn')
     sm.GetService('viewState').GetView(
         ViewState.Space).ActivatePrimaryCamera()
     with ExceptionEater('JumpTransitionTunnelEnd'):
         if not self.destinationSceneApplied:
             self.transition.ApplyDestinationScene()
         camera = self.GetCamera()
         anim = camera.animationController
         offset = geo2.Vec3Scale(self.normDir, -self.camOffsetEnd)
         anim.Schedule(transitioncam.InFOV(self.endCamDurationS))
         camera.shakeController.DoCameraShake(self.shakeJumpIn)
     if self.startCS is not None:
         self.startCS.Stop()
     if self.mainCS is not None:
         self.mainCS.Stop()
     if self.stopCS is not None:
         self.stopCS.Play()
     self.FadeUIIn()
     uthread.new(self.BlinkSystemName)
     uthread.new(self._DelayedCleanup)
     self.cameraLookAnimation.OnJumpDone()
Пример #15
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
Пример #16
0
 def UpdatePosition(self, localPosition=None):
     """
     Updates the position and scale of the supernova.
     localPosition: An optional 3 tuple for the local position. If not passed in the session.solarsystemid is
     used to determine the position.
     """
     if not self.model:
         self._LoadModel()
     if not localPosition:
         localSystem = sm.StartService('map').GetItem(session.solarsystemid)
         localPosition = (localSystem.x, localSystem.y, localSystem.z)
     if not self.effectPosition:
         effectSystem = sm.StartService('map').GetItem(SUPERNOVA_SYSTEM_ID)
         self.effectPosition = (effectSystem.x, effectSystem.y,
                                effectSystem.z)
     effect = self.model.children[0]
     direction = geo2.Vec3SubtractD(localPosition, self.effectPosition)
     direction = (direction[0], direction[1], -direction[2])
     distance = geo2.Vec3LengthD(direction) / 1e+16
     direction = geo2.Vec3Normalize(direction)
     if distance < self.nearDistance:
         scale = self.nearSize
     else:
         shift = (self.farSize * self.farDistance - self.nearSize *
                  self.nearDistance) / (self.nearSize - self.farSize)
         baseSize = self.nearSize * (self.nearDistance + shift)
         scale = baseSize / (distance + shift)
     effect.scaling = (scale, scale, scale)
     effect.translation = geo2.Vec3Scale(direction, 15.0)
Пример #17
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())
Пример #18
0
    def GetStarGateLineOffsets(self, solarSystemID):
        fromSystemInfo = cfg.mapSolarSystemContentCache[solarSystemID]
        mapNode = self.GetNodeBySolarSystemID(solarSystemID)
        adjustLines = {}
        for lineData in mapNode.lineData:
            if solarSystemID == lineData.fromSolarSystemID:
                otherSystemInfo = cfg.mapSolarSystemContentCache[lineData.toSolarSystemID]
            else:
                otherSystemInfo = cfg.mapSolarSystemContentCache[lineData.fromSolarSystemID]
            fromStargateVector = None
            for each in fromSystemInfo.stargates:
                if fromSystemInfo.stargates[each].destination in otherSystemInfo.stargates:
                    fromStargate = fromSystemInfo.stargates[each]
                    fromStargateVector = (fromStargate.position.x, fromStargate.position.y, fromStargate.position.z)
                    break

            if fromStargateVector:
                stargateOffset = geo2.Vec3Scale(fromStargateVector, ScaleSolarSystemValue(1.0))
                if solarSystemID == lineData.fromSolarSystemID:
                    adjustLines[lineData.lineID] = (lineData.fromSolarSystemID,
                     lineData.toSolarSystemID,
                     stargateOffset,
                     (0, 0, 0),
                     lineData.jumpType)
                else:
                    adjustLines[lineData.lineID] = (lineData.fromSolarSystemID,
                     lineData.toSolarSystemID,
                     (0, 0, 0),
                     stargateOffset,
                     lineData.jumpType)

        return adjustLines
Пример #19
0
 def UpdatePosition(self, localPosition=None):
     if not self.model:
         self._LoadModel()
     if not len(self.model.children):
         return
     if not localPosition:
         localSystem = sm.StartService('map').GetItem(session.solarsystemid)
         localPosition = (localSystem.x, localSystem.y, localSystem.z)
     if not self.effectPosition:
         effectSystem = sm.StartService('map').GetItem(SUPERNOVA_SYSTEM_ID)
         self.effectPosition = (effectSystem.x, effectSystem.y,
                                effectSystem.z)
     effect = self.model.children[0]
     direction = geo2.Vec3SubtractD(localPosition, self.effectPosition)
     direction = (direction[0], direction[1], -direction[2])
     distance = geo2.Vec3LengthD(direction) / 1e+16
     direction = geo2.Vec3Normalize(direction)
     if distance < self.nearDistance:
         scale = self.nearSize
     else:
         shift = (self.farSize * self.farDistance - self.nearSize *
                  self.nearDistance) / (self.nearSize - self.farSize)
         baseSize = self.nearSize * (self.nearDistance + shift)
         scale = baseSize / (distance + shift)
     effect.scaling = (scale, scale, scale)
     effect.translation = geo2.Vec3Scale(direction, 15.0)
Пример #20
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
Пример #21
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)
Пример #22
0
def GetCenter(positions):
    if not positions:
        return (0, 0, 0)
    accPos = geo2.Vector((0, 0, 0))
    for pos in positions:
        accPos += pos

    return geo2.Vec3Scale(accPos, 1.0 / len(positions))
Пример #23
0
 def DistanceFromSegment(self, p, p0, p1, v, c2):
     w = geo2.Vec3Subtract(p, p0)
     c1 = geo2.Vec3Dot(v, w)
     if c1 <= 0:
         return None
     if c2 <= c1:
         return geo2.Vec3Distance(p, p1)
     return geo2.Vec3Distance(p, geo2.Vec3Add(p0, geo2.Vec3Scale(v, c1 / c2)))
Пример #24
0
 def Zoom(self, val):
     """
         Move the camera towards the point of interest
         val - the percentage of the distance between the camera and the target point
     """
     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)
Пример #25
0
 def UpdateProbePosition(self, probeID, position):
     probeData = self.probeData[probeID]
     distSq = geo2.Vec3LengthSq(position)
     if distSq > probescanning.const.MAX_PROBE_DIST_FROM_SUN_SQUARED:
         scale = probescanning.const.MAX_PROBE_DIST_FROM_SUN_SQUARED / distSq
         position = geo2.Vec3Scale(position, scale)
     probeData.pos = probeData.destination = position
     return position
Пример #26
0
 def SetCamera(self, yaw, pitch, pan):
     cam = sm.GetService('sceneManager').GetActiveCamera()
     cam.SetYaw(math.radians(yaw))
     cam.SetPitch(math.radians(pitch))
     pan = ClampPan(pan)
     newPos = geo2.Vec3Add(geo2.Vec3Scale(cam.GetLookAtDirection(), pan),
                           cam.GetAtPosition())
     cam.TransitTo(atPosition=cam.GetAtPosition(), eyePosition=newPos)
Пример #27
0
 def _GetTrackAtOffset(self):
     trackOffset = geo2.Vec3Subtract(self.GetTrackPosition(self.trackBall),
                                     self._atPosition)
     length = geo2.Vec3Length(trackOffset)
     maxLen = 250000
     if length > maxLen:
         trackOffset = geo2.Vec3Scale(trackOffset, maxLen / length)
     return trackOffset
Пример #28
0
 def _EnforceMaximumDistanceDetached(self):
     dist = geo2.Vec3Length(self.eyePosition)
     if dist > evecamera.LOOKATRANGE_MAX_NEW and not self.IsInTransit():
         direction = geo2.Vec3Normalize(self.eyePosition)
         newEye = geo2.Vec3Scale(direction, evecamera.LOOKATRANGE_MAX_NEW)
         diff = geo2.Vec3Subtract(self.eyePosition, newEye)
         self.SetEyePosition(newEye)
         self.SetAtPosition(geo2.Vec3Subtract(self._atPosition, diff))
Пример #29
0
 def SetAppropriateAtPositionForRotation(self, atPos):
     distanceToNewAtPos = geo2.Vec3Distance(self.eyePosition, atPos)
     distanceToNewAtPos = min(evecamera.LOOKATRANGE_MAX_NEW,
                              distanceToNewAtPos)
     lookVec = geo2.Vec3Scale(self.GetLookAtDirection(), distanceToNewAtPos)
     newAtPos = geo2.Vec3Subtract(self.eyePosition, lookVec)
     if newAtPos != self._eyePosition:
         self.SetAtPosition(newAtPos)
Пример #30
0
 def fset(self, rotationQuaternion):
     rotationMatrix = geo2.MatrixRotationQuaternion(rotationQuaternion)
     transformedVec = geo2.Vec3Transform((1.0, 0.0, 0.0),
                                         rotationMatrix)
     cameraDistance = geo2.Vec3Length(self._eyePositionCurrent)
     self._eyePositionCurrent = geo2.Vec3Scale(transformedVec,
                                               cameraDistance)
     self._eyePosition = self._eyePositionCurrent