def ApplyZoom(self, newZoom): """ Apply the requested zoom level and rotate/offset the camera according the the new zoom level. """ projection, view, viewport = uix.GetFullscreenProjectionViewAndViewport( ) aspectRatioAdjustment = camutils.GetARZoomMultiplier( viewport.GetAspectRatio()) if newZoom == self.zoom and not self.zoom > aspectRatioAdjustment: return zoom = max(0.05, min(aspectRatioAdjustment, newZoom)) translationAdjustment = 1 if zoom > 1: translationAdjustment = zoom self.zoom = zoom self.camera.translationFromParent = planetCommon.PLANET_ZOOM_MIN + translationAdjustment * ( min(1.0, zoom) * self.zoomScale)**2 yaw = self.camera.yaw pitch = self.camera.pitch criticalZoom = 0.5 kOrbit = 1.1 kPitch = 0.2 if zoom <= criticalZoom: orbitRotation = (criticalZoom - self.zoom)**2 * math.pi * kOrbit self.pitchDiff = (criticalZoom - self.zoom)**2 * math.pi * kPitch newPitch = pitch + self.pitchDiff - self.oldPitchDiff self.camera.SetOrbit(yaw, newPitch) self.oldPitchDiff = self.pitchDiff else: orbitRotation = 0.0 self.camera.SetRotationOnOrbit(0.0, orbitRotation) sm.GetService('planetUI').OnPlanetZoomChanged(min(1.0, self.zoom))
def CheckTranslationFromParent(self, distance, getMinMax=0, source='default', distanceIsScale=False): if source == 'starmap': mn, mx = ZOOM_MIN_STARMAP, ZOOM_MAX_STARMAP elif source == 'systemmap': mn, mx = ZOOM_NEAR_SYSTEMMAP, ZOOM_FAR_SYSTEMMAP mx *= camutils.GetARZoomMultiplier( trinity.device.viewport.GetAspectRatio()) else: lookingAt = self.LookingAt() or session.shipid if lookingAt not in self.boundingBoxCache: mn = self.GetTranslationFromParentForItem(lookingAt) if mn is not None: self.boundingBoxCache[lookingAt] = mn else: mn = self.boundingBoxCache[lookingAt] if distanceIsScale: distance = mn * distance mx = 1000000.0 retval = max(mn, min(distance, mx)) if getMinMax: return (retval, mn, mx) return retval
def GetLodLevel(position, radius): cam = sm.GetService('sceneManager').GetActiveSpaceCamera() if cam is None: return 1 distance = geo2.Vec3Distance(cam.eyePosition, position) vp = trinity.device.viewport aspectRatio = vp.GetAspectRatio() fov = cam.fov / camutils.GetARZoomMultiplier(aspectRatio) lodQuality = gfxsettings.Get(gfxsettings.GFX_LOD_QUALITY) boundingSize = radius / (math.tan(fov / 2) * distance) * vp.height if boundingSize < 192 / lodQuality: return 1 return 0
def GetLodLevel(position, radius): cam = sm.GetService('sceneManager').GetRegisteredCamera('default') if cam is None: return 1 distance = geo2.Vec3Length(geo2.Vec3Subtract((cam.pos.x, cam.pos.y, cam.pos.z), position)) vp = trinity.device.viewport aspectRatio = vp.GetAspectRatio() fov = cam.fieldOfView / camutils.GetARZoomMultiplier(aspectRatio) lodQuality = gfxsettings.Get(gfxsettings.GFX_LOD_QUALITY) boundingSize = radius / (math.tan(fov / 2) * distance) * vp.height if boundingSize < 192 / lodQuality: return 1 return 0
def _GetTranslationFromParentForItem(self, itemID): ballpark = sm.GetService('michelle').GetBallpark() if ballpark is None: return ball = ballpark.GetBall(itemID) ball, model, ballRadius = ball, getattr(ball, 'model', None), getattr( ball, 'radius', None) if model is None: return rad = None if model.__bluetype__ in evespacescene.EVESPACE_TRINITY_CLASSES: rad = model.GetBoundingSphereRadius() zoomMultiplier = 1.1 * camutils.GetARZoomMultiplier( trinity.GetAspectRatio()) return (rad + self.frontClip) * zoomMultiplier + 2 if len(getattr(model, 'children', [])) > 0: rad = ball.model.children[0].GetBoundingSphereRadius() if rad is None or rad <= 0.0: rad = ballRadius camangle = self.fieldOfView * 0.5 return max(15.0, rad / sin(camangle) * cos(camangle))