def PrepareCamera(self): self.cameraParent = trinity.EveSO2ModelCenterPos() self.camera = trinity.EveCamera() self.camera.parent = self.cameraParent self.camera.frontClip = self.frontClip self.camera.backClip = self.backClip self.camera.fieldOfView = self.fieldOfView self.camera.minPitch = self.minPitch self.camera.maxPitch = self.maxPitch
def _GetTrackableCurve(self, itemID): item = sm.StartService('michelle').GetBall(itemID) if item is None or getattr(item, 'model', None) is None: return if item.model.__bluetype__ in evespacescene.EVESPACE_TRINITY_CLASSES: tracker = trinity.EveSO2ModelCenterPos() tracker.parent = item.model return tracker return item
def _DoAnimatedLookAt(self, item, setZ=None, resetCamera=False, trackableItem=None, cache=False): if item.model.__bluetype__ not in evespacescene.EVESPACE_TRINITY_CLASSES: self.animationController.Schedule( camutils.SetTranslationCurve(trackableItem)) return tracker = trinity.EveSO2ModelCenterPos() tracker.parent = item.model self.animationController.Schedule(camutils.LookAt_Translation(tracker)) self.animationController.Schedule(camutils.LookAt_FOV(resetCamera)) self.animationController.Schedule( camutils.LookAt_Pan(setZ, cache=cache))
def Prepare(self, addToScene=True): shipBall = self.GetEffectShipBall() if shipBall is None: raise RuntimeError('ShipEffect: no ball found:' + self.__guid__) self.gfx = self.RecycleOrLoad(self.graphicFile) if self.gfx is None: raise RuntimeError('ShipEffect: no effect found:' + self.__guid__) self.AddSoundToEffect(2) self.gfxModel = trinity.EveRootTransform() if shipBall.model.__bluetype__ == 'trinity.EveShip2': self.gfxModel.modelRotationCurve = shipBall.model.modelRotationCurve self.gfxModel.modelTranslationCurve = shipBall.model.modelTranslationCurve self.gfxModel.children.append(self.gfx) import effects effectBall = shipBall if effects.FX_TF_POSITION_BALL & self.transformFlags: self.gfxModel.translationCurve = shipBall if effects.FX_TF_POSITION_MODEL & self.transformFlags: self.gfxModel.translationCurve = trinity.EveSO2ModelCenterPos() self.gfxModel.translationCurve.parent = shipBall.model if effects.FX_TF_POSITION_TARGET & self.transformFlags: effectBall = self.GetEffectTargetBall() self.gfxModel.translationCurve = effectBall if effects.FX_TF_SCALE_BOUNDING & self.transformFlags: shipBBoxMin, shipBBoxMax = effectBall.model.GetLocalBoundingBox() bBox = (max(-shipBBoxMin[0], shipBBoxMax[0]) * 1.2, max(-shipBBoxMin[1], shipBBoxMax[1]) * 1.2, max(-shipBBoxMin[2], shipBBoxMax[2]) * 1.2) self.gfxModel.scaling = bBox elif effects.FX_TF_SCALE_SYMMETRIC & self.transformFlags: radius = effectBall.model.GetBoundingSphereRadius() self.gfxModel.scaling = (radius, radius, radius) self.gfx.translation = (0, 0, 0) elif effects.FX_TF_SCALE_RADIUS & self.transformFlags: radius = effectBall.model.GetBoundingSphereRadius() self.gfxModel.scaling = (radius, radius, radius) if effects.FX_TF_ROTATION_BALL & self.transformFlags: self.gfxModel.rotationCurve = effectBall self.gfxModel.name = self.__guid__ if addToScene: self.AddToScene(self.gfxModel)
def SetCameraParent(self, itemID): if self.freeLook: return cameraParent = self.GetCameraParent() if cameraParent is None: return item = sm.StartService('michelle').GetBall(itemID) if item is None or getattr(item, 'model', None) is None: self.LookAt(eve.session.shipid) return tracker = None if item.model.__bluetype__ in ('trinity.EveShip2', 'trinity.EveStation2', 'trinity.EveRootTransform'): tracker = trinity.EveSO2ModelCenterPos() tracker.parent = item.model camera = sm.GetService('sceneManager').GetRegisteredCamera('default') if camera is None: return if tracker: cameraParent.translationCurve = tracker else: cameraParent.translationCurve = item
def PrepareCamera(self): self.camera = trinity.EveCamera() self.cameraParent = self.camera.parent = trinity.EveSO2ModelCenterPos()
def SetTranslation(self, value): if self._translationCurve is None: self.SetTranslationCurve(trinity.EveSO2ModelCenterPos()) self._translationCurve.value.SetXYZ(*value)
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 PrepareCamera(self): """ Creates the camera and camera parent """ self.camera = trinity.EveCamera() self.cameraParent = self.camera.parent = trinity.EveSO2ModelCenterPos()