def _Tick(self, progress, cameraContext): cameraParent = cameraContext.GetCameraParent() if self.starting: cameraParent.translationCurve = None self.starting = False endPos = self._getEndPos() cameraParent.translation = geo2.Vec3Lerp(self.startPos, endPos, progress)
def Tick(self, camera, simTime, clockTime): if self.isDone: return t = blue.os.TimeDiffInMs(self.timeStart, simTime) / 1000.0 progress = self.progressCurve.GetValueAt(t) cameraParent = camera.GetCameraParent() if not self.started: self._FirstTick(cameraParent, simTime) self.started = True endPos = self.endPosFunction() endPos = geo2.Vec3Add(endPos, self.translationOffset) cameraParent.translation = geo2.Vec3Lerp(self.startPos, endPos, progress)
def HandlePointOfInterest(self): """ Handles poi calculations. If there is a desired poi, then we lerp to that, making sure to update it if the camera or avatar moves around. Otherwise, if there is no desired poi, we calculate the correct one based on the camera position and avatar position """ if self.desiredPoi is not None: camMoved = geo2.Vec3Distance( self.lerpPoiCamStats, (self.camera.yaw, self.camera.pitch, 0.0)) avatarMoved = geo2.Vec3Distance( self.lerpPoiAvatarStats, self.entity.GetComponent('position').position) if camMoved > const.FLOAT_TOLERANCE or avatarMoved > const.FLOAT_TOLERANCE: self.desiredPoi = self.CalcCorrectCameraPoi( self.camera.yaw, self.camera.pitch) if avatarMoved > const.FLOAT_TOLERANCE: vect = geo2.Vec3Normalize( geo2.Vec3Subtract(self.centerPoint, self.lastCenterPoint)) dist = geo2.Vec3Distance(self.lastCenterPoint, self.centerPoint) self.camera.poi = geo2.Vec3Add(self.camera.poi, (val * dist for val in vect)) self.lerpPoiCamStats = (self.camera.yaw, self.camera.pitch, 0.0) self.lerpPoiAvatarStats = self.entity.GetComponent( 'position').position self.useLerp = True if self.useLerp: newPoi = geo2.Vec3Lerp(self.camera.poi, self.desiredPoi, self.frameTime * LERP_SPEED) zoom = mathUtil.Lerp(self.camera.zoom, self.desiredZoom, self.frameTime * LERP_SPEED) else: newPoi = self.PlerpVec3(self.originalPoi, self.desiredPoi, self.lerpTimeLeft) zoom = self.Plerp(self.startZoom, self.desiredZoom, self.lerpTimeLeft) self.camera.zoom = self.camera.collisionZoom = self.camera.desiredZoom = zoom self.lerpTimeLeft -= self.frameTime * const.SEC if geo2.Vec3Distance( newPoi, self.desiredPoi) < const.FLOAT_TOLERANCE and abs( self.camera.zoom - self.desiredZoom) < const.FLOAT_TOLERANCE: self.desiredPoi = None self.camera.zoom = self.camera.collisionZoom = self.camera.desiredZoom = self.desiredZoom else: newPoi = self.CalcCorrectCameraPoi(self.camera.yaw, self.camera.pitch) self.camera.SetPointOfInterest(newPoi)
def update_mapNode_position(mapNode): newPosition = geo2.Vec3Lerp(mapNode.oldPosition, mapNode.position, ndt) starParticles.SetItemElement(mapNode.particleID, 0, newPosition) for lineData in mapNode.lineData: if mapNode.solarSystemID == lineData.fromSolarSystemID: if lineData.lineID in changeLinePositions: changeLinePositions[lineData.lineID][0] = newPosition else: changeLinePositions[lineData.lineID] = [newPosition, None, lineData] elif lineData.lineID in changeLinePositions: changeLinePositions[lineData.lineID][1] = newPosition else: changeLinePositions[lineData.lineID] = [None, newPosition, lineData]
def _SetupDynamicLight(self, curveSet): angle = random.random() * 2 * pi light = trinity.Tr2PointLight() light.color = geo2.Vec3Lerp(DYNAMIC_WARP_LIGHT_COLOR, (1, 1, 1, 1), random.random()) light.radius = 0.7 light.position = (sin(angle) * 1.5, cos(angle) * 1.5, 2) curve = trinity.Tr2ScalarCurve() curve.AddKey(0, 2) curve.AddKey(8.0 / 20.0, -6) curve.Sort() curve.timeOffset = curveSet.scaledTime curveSet.curves.append(curve) binding = trinity.CreateBinding(curveSet, curve, 'currentValue', light, 'position.z') return (light, curve, binding)
def HandlePointOfInterest(self): if self.desiredPoi is not None: camMoved = geo2.Vec3Distance( self.lerpPoiCamStats, (self.camera.yaw, self.camera.pitch, 0.0)) avatarMoved = geo2.Vec3Distance( self.lerpPoiAvatarStats, self.entity.GetComponent('position').position) if camMoved > const.FLOAT_TOLERANCE or avatarMoved > const.FLOAT_TOLERANCE: self.desiredPoi = self.CalcCorrectCameraPoi( self.camera.yaw, self.camera.pitch) if avatarMoved > const.FLOAT_TOLERANCE: vect = geo2.Vec3Normalize( geo2.Vec3Subtract(self.centerPoint, self.lastCenterPoint)) dist = geo2.Vec3Distance(self.lastCenterPoint, self.centerPoint) self.camera.poi = geo2.Vec3Add(self.camera.poi, (val * dist for val in vect)) self.lerpPoiCamStats = (self.camera.yaw, self.camera.pitch, 0.0) self.lerpPoiAvatarStats = self.entity.GetComponent( 'position').position self.useLerp = True if self.useLerp: newPoi = geo2.Vec3Lerp(self.camera.poi, self.desiredPoi, self.frameTime * LERP_SPEED) zoom = mathUtil.Lerp(self.camera.zoom, self.desiredZoom, self.frameTime * LERP_SPEED) else: newPoi = self.PlerpVec3(self.originalPoi, self.desiredPoi, self.lerpTimeLeft) zoom = self.Plerp(self.startZoom, self.desiredZoom, self.lerpTimeLeft) self.camera.zoom = self.camera.collisionZoom = self.camera.desiredZoom = zoom self.lerpTimeLeft -= self.frameTime * const.SEC if geo2.Vec3Distance( newPoi, self.desiredPoi) < const.FLOAT_TOLERANCE and abs( self.camera.zoom - self.desiredZoom) < const.FLOAT_TOLERANCE: self.desiredPoi = None self.camera.zoom = self.camera.collisionZoom = self.camera.desiredZoom = self.desiredZoom else: newPoi = self.CalcCorrectCameraPoi(self.camera.yaw, self.camera.pitch) self.camera.SetPointOfInterest(newPoi)
def GetTransitAtCurve(self, posStart, posEnd, newDir, smoothing, numPoints): """ Returns control points for the lookAt transit curve spline. We travel along a straight line offset quadtratically according the the smoothing argument""" currDir = self.GetLookAtDirection() angle = math.acos(geo2.Vec3Dot((currDir[0], 0, currDir[2]), (newDir[1], 0, newDir[2]))) if smoothing and angle: offset = geo2.Vec3Normalize(geo2.Vec3Negate(newDir)) dist = geo2.Vec3Distance(posStart, posEnd) offset = geo2.Vec3Scale(offset, dist * angle * smoothing) else: offset = (0, 0, 0) points = [] for i in xrange(numPoints + 1): t = self._GetHermiteValue(float(i) / numPoints) offsetDist = 2 * (t - t ** 2) point = geo2.Vec3Lerp(posStart, posEnd, t) point = geo2.Add(point, geo2.Vec3Scale(offset, offsetDist)) points.append(point) return points
def _Tick(self, progress, camera): offset = geo2.Vec3Lerp(self.offset, (0, 0, 0), math.pow(progress, 2.0)) camera.SetEffectOffset(offset)
def _Tick(self, progress, camera): transl = geo2.Vec3Lerp((0, 0, 0), self.finalOffset, math.pow(progress, 4.0)) camera.SetEffectOffset(transl)
def GetCenter(self): p0, p1 = self.GetBoundingBox() return geo2.Vec3Lerp(p0, p1, 0.5)
def _LookAt(self, item, itemID, setZ, resetCamera, smooth): if not item: return if item.GetModel() is None: return camera = sm.GetService('sceneManager').GetRegisteredCamera('default') if camera is None: return camera.interest = None self.GetCameraInterest().translationCurve = None cameraParent = self.GetCameraParent() if cameraParent is None: return sm.StartService('state').SetState(itemID, state.lookingAt, 1) self.lookingAt = itemID item.LookAtMe() if cameraParent.translationCurve is not None: startPos = cameraParent.translationCurve.GetVectorAt( blue.os.GetSimTime()) startPos = (startPos.x, startPos.y, startPos.z) cameraParent.translationCurve = None else: startPos = cameraParent.translation startFov = camera.fieldOfView if resetCamera: endFov = sm.GetService('sceneManager').maxFov else: endFov = camera.fieldOfView if setZ is None: startTrZ = camera.translationFromParent endTrZ = self.CheckTranslationFromParent(1.0) elif setZ < 0.0: camera.translationFromParent = 2.0 * self.CheckTranslationFromParent( setZ) startTrZ = None endTrZ = None else: camera.translationFromParent = self.CheckTranslationFromParent( setZ) startTrZ = None endTrZ = None start = blue.os.GetWallclockTime() ndt = 0.0 time = 500.0 tracker = None tempTF = None if item.model.__bluetype__ in ('trinity.EveShip2', 'trinity.EveStation2', 'trinity.EveRootTransform'): tracker = trinity.EveSO2ModelCenterPos() tracker.parent = item.model while ndt != 1.0 and smooth: ndt = max( 0.0, min( blue.os.TimeDiffInMs(start, blue.os.GetWallclockTime()) / time, 1.0)) if tracker is None: break if hasattr(tracker.parent, 'modelWorldPosition'): endPos = tracker.parent.modelWorldPosition elif getattr(item.model, 'translationCurve', None) is not None: endPos = item.model.translationCurve.GetVectorAt( blue.os.GetSimTime()) endPos = (endPos.x, endPos.y, endPos.z) else: endPos = item.model.translation if startPos and endPos: cameraParent.translation = geo2.Vec3Lerp(startPos, endPos, ndt) if startTrZ and endTrZ: if endTrZ > startTrZ or resetCamera: camera.translationFromParent = mathUtil.Lerp( startTrZ, endTrZ, ndt) if startFov != endFov: camera.fieldOfView = mathUtil.Lerp(startFov, endFov, ndt) blue.pyos.synchro.Yield() if tracker: cameraParent.translationCurve = tracker else: cameraParent.translationCurve = item if self.current == 'default': self.lastInflightLookat = [itemID, camera.translationFromParent]
def _Tick(self, progress, cameraContext): cameraContext.GetSpaceCamera().extraTranslation = geo2.Vec3Lerp( self.offset, (0, 0, 0), math.pow(progress, 2.0))
def _Tick(self, progress, cameraContext): transl = geo2.Vec3Lerp((0, 0, 0), self.finalOffset, math.pow(progress, 4.0)) cameraContext.GetSpaceCamera().extraTranslation = transl