def RenderPin(outPath, objectPath, size=128, freezeTime=True): if freezeTime: FreezeTime() model = blue.resMan.LoadObject(objectPath) blue.resMan.Wait() blue.os.Pump() if hasattr(model, 'curveSets'): model.curveSets.removeAt(-1) scene = trinity.EveSpaceScene() scene.sunDirection = (-0.5, -0.5, -0.6) scene.objects.append(model) bgColor = (0.0, 0.0, 0.0, 1.0) transparent = False if model.mesh != None: bBoxMin = (0.0, 0.0, 0.0) bBoxMax = (0.0, 0.0, 0.0) for i in range(model.mesh.geometry.GetMeshAreaCount(0)): boundingBoxMin, boundingBoxMax = model.mesh.geometry.GetAreaBoundingBox( 0, i) if abs(boundingBoxMax[1] - boundingBoxMin[1]) > 0.005: if geo2.Vec3Length(bBoxMin) < geo2.Vec3Length(boundingBoxMin): bBoxMin = boundingBoxMin if geo2.Vec3Length(bBoxMax) < geo2.Vec3Length(boundingBoxMax): bBoxMax = boundingBoxMax view, projection = camera_util.GetViewAndProjectionUsingBoundingBox( bBoxMin, bBoxMax) hostBitmap = RenderToSurface(scene=scene, view=view, projection=projection, size=size, bgColor=bgColor, transparent=transparent) hostBitmap.Save(outPath)
def RenderISISObject(outPath, model, isSkinned, size=128): scene = trinity.EveSpaceScene() SetupModel(model) _ApplyIsisEffect(model, isSkinned) scene.objects.append(model) blue.resMan.Wait() blue.os.Pump() view = projection = None if model: boundingSphereRadius = model.GetBoundingSphereRadius() angle = (-1.5708, 0, 0) if model.mesh is not None: geometry = model.mesh.geometry boundingSphereCenter = model.GetBoundingSphereCenter() view, projection = camera_util.GetViewAndProjectionUsingMeshGeometry( geometry, scene=scene, boundingSphereRadius=boundingSphereRadius, boundingSphereCenter=boundingSphereCenter, cameraAngle=angle) hostBitmap = RenderToSurface(scene=scene, view=view, projection=projection, size=size, transparent=False) hostBitmap.Save(outPath) trinity.app.ProcessMessages()
def RenderISISObject(outPath, model, isSkinned, size=128): """ Generates a render for ISIS. This render fixes the camera to the side and applies a specialized shader to the model. Assumption: This is only used for V3/V5 Ships. """ scene = trinity.EveSpaceScene() SetupModel(model) _ApplyIsisEffect(model, isSkinned) scene.objects.append(model) blue.resMan.Wait() blue.os.Pump() view = projection = None if model: boundingSphereRadius = model.GetBoundingSphereRadius() angle = (-1.5708, 0, 0) if model.mesh is not None: geometry = model.mesh.geometry boundingSphereCenter = model.GetBoundingSphereCenter() view, projection = camera_util.GetViewAndProjectionUsingMeshGeometry( geometry, scene=scene, boundingSphereRadius=boundingSphereRadius, boundingSphereCenter=boundingSphereCenter, cameraAngle=angle) hostBitmap = RenderToSurface(scene=scene, view=view, projection=projection, size=size, transparent=False) hostBitmap.Save(outPath) trinity.app.ProcessMessages()
def GetOrCreateScene(): scene = FindScene() if scene is None or not isinstance(scene, trinity.EveSpaceScene): scene = trinity.EveSpaceScene() if trinity.device.scene != scene: trinity.device.scene = scene return scene
def ApplyAttributes(self, attributes): Base.ApplyAttributes(self, attributes) self.viewport = trinity.TriViewport() self.viewport.x = 0 self.viewport.y = 0 self.viewport.width = 1 self.viewport.height = 1 self.viewport.minZ = 0.0 self.viewport.maxZ = 1.0 self.projection = trinity.TriProjection() self.frontClip = 1.0 self.backClip = 350000.0 self.fieldOfView = 1.0 self.minPitch = -3.0 self.maxPitch = 3.4 self.minZoom = 0.0 self.maxZoom = 1.0 self._zoom = 0.5 self.scene = trinity.EveSpaceScene() self.transform = trinity.EveRootTransform() self.scene.objects.append(self.transform) self.PrepareCamera() self.DisplayScene() self.CreateBracketCurveSet() self.UpdateViewPort()
def LoadView(self, **kwargs): """ Called when the view is loaded """ import trinity sm.GetService('sceneManager').RegisterScene(trinity.EveSpaceScene(), 'dockpanelview') sm.GetService('sceneManager').SetRegisteredScenes('dockpanelview')
def StartupUI(self, *args): self.usingSingleSignOn = False uicore.Startup(self.uiLayerList) uicore.Message = eve.Message uiutil.AskName = uiutil.NamePopup log.SetUiMessageFunc(uicore.Message) if blue.win32.IsTransgaming(): sm.StartService('cider') self.SetupViewStates() sm.GetService('device').SetupUIScaling() sceneManager = sm.StartService('sceneManager') sceneManager.SetSceneType(SCENE_TYPE_SPACE) sceneManager.Initialize(trinity.EveSpaceScene()) sm.StartService('connection') sm.StartService('damage') sm.StartService('logger') sm.StartService('vivox') sm.StartService('ownerprimer') sm.StartService('petition') sm.StartService('ui') sm.StartService('window') sm.StartService('log') sm.StartService('z') sm.StartService('consider') sm.StartService('incursion') sm.StartService('cameraClient') sm.StartService('moonScan') sm.StartService('preview') sm.StartService('crimewatchSvc') if blue.win32: try: blue.win32.WTSRegisterSessionNotification( trinity.device.GetWindow(), 0) uicore.uilib.SessionChangeHandler = self.OnWindowsUserSessionChange except: sys.exc_clear() uicore.uilib.SessionChangeHandler = None sm.GetService('launcher').SetClientBootProgress(60) token = None for arg in blue.pyos.GetArg()[1:]: if arg.startswith('/ssoToken'): try: argName, token = arg.split('=') except: raise RuntimeError( 'Invalid format of SSO token, should be /ssoToken=<token>' ) pr = sm.GetService('webtools').GetVars() if pr: sm.GetService('webtools').GoSlimLogin() elif token is not None: self.usingSingleSignOn = True self.DoLogin(token) else: sm.GetService('viewState').ActivateView('login')
def CopyMyScene(self): """ copies the stuff I need from original scene to display when you have been podded """ sceneOrg = self._sceneManager.GetRegisteredScene('default') if sceneOrg is None: return scene = trinity.EveSpaceScene() self.podDeathScene = scene scene.sunDiffuseColor = sceneOrg.sunDiffuseColor scene.ambientColor = sceneOrg.ambientColor scene.fogColor = sceneOrg.fogColor scene.backgroundRenderingEnabled = True scene.backgroundEffect = blue.classes.Copy(sceneOrg.backgroundEffect) for pathName in [ 'envMapResPath', 'envMap1ResPath', 'envMap2ResPath', 'envMap3ResPath' ]: path = getattr(sceneOrg, pathName, '') setattr(scene, pathName, path) sunBall = trinity.TriVectorCurve() sunPos = sceneOrg.sunBall.GetVectorAt(blue.os.GetSimTime()) sunBall.value = (sunPos.x, sunPos.y, sunPos.z) scene.sunBall = sunBall time = blue.os.GetSimTime() objectLists = [(sceneOrg.lensflares, scene.lensflares, trinity.EveLensflare), (sceneOrg.planets, scene.planets, trinity.EvePlanet), (sceneOrg.objects, scene.objects, trinity.EveStation2)] for eachList, destination, allowedTypes in objectLists: for obj in eachList: if session.solarsystemid is None: return try: if not isinstance(obj, allowedTypes): continue if not obj.display: continue if getattr( obj, 'translationCurve', None ) is not None and obj.translationCurve.__bluetype__ == 'destiny.ClientBall': pos = obj.translationCurve.GetVectorAt(time) if getattr(obj.translationCurve, 'translationCurve', None): obj.translationCurve.resourceCallback = None obj.translationCurve.model = None translationCurve = trinity.TriVectorCurve() translationCurve.value = (pos.x, pos.y, pos.z) obj.translationCurve = translationCurve if getattr( obj, 'rotationCurve', None ) is not None and obj.rotationCurve.__bluetype__ == 'destiny.ClientBall': obj.rotationCurve = None destination.append(obj) except Exception: pass
def RenderSpaceObject(outPath, scenePath='', objectPath='', sofDNA=None, size=128, bgColor=None, transparent=False, backgroundPath=None, overlayPath=None, techPath=None, cameraAngle=None, freezeTime=True, postProcessingQuality=2, supersampleQuality=2, modifyScene=None, sunDirection=None, animationStates=[]): if freezeTime: FreezeTime() trinity.GetVariableStore().RegisterVariable('DepthMap', trinity.TriTextureRes()) trinity.GetVariableStore().RegisterVariable('DepthMapMsaa', trinity.TriTextureRes()) if scenePath: scene = blue.resMan.LoadObject(scenePath) else: scene = trinity.EveSpaceScene() model = LoadSpaceObject(objectPath, sofDNA, scene, animationStates) view, projection = GetViewProjectionForModel(model, scene, cameraAngle) if modifyScene: view, projection = modifyScene(scene, view, projection) sunDirection = sunDirection or (-view.transform[0][2], -view.transform[1][2], -view.transform[2][2]) SetupScene(scene, transparentBackground=transparent, sunDirection=sunDirection, pbr=bool(sofDNA)) hostBitmap = RenderToSurface(scene=scene, view=view, projection=projection, size=size, bgColor=bgColor, transparent=transparent, backgroundPath=backgroundPath, overlayPath=overlayPath, techPath=techPath, postProcessingQuality=postProcessingQuality, supersampleQuality=supersampleQuality) hostBitmap.Save(outPath)
def RenderToSurface(view, projection, size=128, scene=None, bgColor=None, transparent=False, backgroundPath=None, overlayPath=None, techPath=None, iconPath=None, postProcessingQuality=2, supersampleQuality=1): size *= 2**supersampleQuality renderJob = CreateRenderJob(size, view, projection, bgColor, transparent, postProcessingQuality, supersampleQuality) if scene: renderJob.SetScene(scene) else: renderJob.SetScene(trinity.EveSpaceScene()) if backgroundPath: if scene: scene.backgroundRenderingEnabled = False renderJob.backgroundTexture.resPath = backgroundPath if iconPath: renderJob.iconTexture.resPath = iconPath if overlayPath: renderJob.overlayTexture.resPath = overlayPath if techPath: renderJob.techTexture.resPath = techPath blue.resMan.Wait() renderJob.DoPrepareResources() renderJob.ScheduleOnce() renderJob.WaitForFinish() hostBitmap = trinity.Tr2HostBitmap(renderJob.renderTarget) for _ in range(supersampleQuality): hostBitmap.Downsample2x2() return hostBitmap
def RenderToSurface(view, projection, size=128, scene=None, bgColor=None, transparent=False, backgroundPath=None, overlayPath=None, techPath=None, iconPath=None, postProcessingQuality=2, antiAliasingQuality=3): """ Renders a scene and sprites to a surface. """ renderJob = CreateRenderJob(size, view, projection, bgColor, transparent, postProcessingQuality, antiAliasingQuality) if scene: renderJob.SetScene(scene) else: renderJob.SetScene(trinity.EveSpaceScene()) if backgroundPath: if scene: scene.backgroundRenderingEnabled = False renderJob.backgroundTexture.resPath = backgroundPath if iconPath: renderJob.iconTexture.resPath = iconPath if overlayPath: renderJob.overlayTexture.resPath = overlayPath if techPath: renderJob.techTexture.resPath = techPath blue.resMan.Wait() renderJob.DoPrepareResources() renderJob.ScheduleOnce() renderJob.WaitForFinish() hostBitmap = trinity.Tr2HostBitmap(renderJob.renderTarget) return hostBitmap
def LoadView(self, **kwargs): import trinity sm.GetService('sceneManager').RegisterScene(trinity.EveSpaceScene(), ViewState.DockPanel) sm.GetService('sceneManager').SetRegisteredScenes(ViewState.DockPanel)
def StartupUI(self, *args): self.usingSingleSignOn = False uicore.SetFontHandler(EveFontHandler()) uicore.SetAudioHandler(sm.StartService('audio')) uicore.Startup(self.uiLayerList) uicore.SetCommandHandler(sm.StartService('cmd')) import eve.client.script.ui.control.tooltips as tooltipHandler uicore.SetTooltipHandler(tooltipHandler) uicore.Message = eve.Message uiutil.AskName = uiutil.NamePopup log.SetUiMessageFunc(uicore.Message) if blue.win32.IsTransgaming(): sm.StartService('cider') SetupViewStates(self.viewState, uicore.layer.viewstate) sm.GetService('device').SetupUIScaling() sceneManager = sm.StartService('sceneManager') sceneManager.SetSceneType(SCENE_TYPE_SPACE) sceneManager.Initialize(trinity.EveSpaceScene()) self.RegisterBlueResources() sm.StartService('connection') sm.StartService('logger') sm.StartService('vivox') sm.StartService('ownerprimer') sm.StartService('petition') sm.StartService('ui') sm.StartService('window') sm.StartService('log') sm.StartService('consider') sm.StartService('incursion') sm.StartService('cameraClient') sm.StartService('moonScan') sm.StartService('preview') sm.StartService('crimewatchSvc') sm.StartService('flightPredictionSvc') sm.StartService('flightControls') sm.StartService('sensorSuite') sm.StartService('hackingUI') sm.StartService('radialmenu') sm.StartService('tourneyBanUI') sm.StartService('achievementSvc') uicore.megaMenuManager = MegaMenuManager() if blue.win32: try: blue.win32.WTSRegisterSessionNotification( trinity.device.GetWindow(), 0) uicore.uilib.SessionChangeHandler = self.OnWindowsUserSessionChange except: sys.exc_clear() uicore.uilib.SessionChangeHandler = None sm.GetService('launcher').SetClientBootProgress(60) token = None for arg in blue.pyos.GetArg()[1:]: if arg.startswith('/ssoToken'): try: argName, token = arg.split('=') except: raise RuntimeError( 'Invalid format of SSO token, should be /ssoToken=<token>' ) pr = sm.GetService('webtools').GetVars() if pr: sm.GetService('webtools').GoSlimLogin() elif token is not None: self.usingSingleSignOn = True self.DoLogin(token) else: self.viewState.ActivateView('login')
def LoadView(self, **kwargs): sm.GetService('sceneManager').RegisterScene(trinity.EveSpaceScene(), self.name) sm.GetService('sceneManager').SetRegisteredScenes(self.name) sm.GetService('shipTreeUI').OnShipTreeOpened()
def RenderSpaceObject(outPath, scenePath='', objectPath='', sofDNA=None, size=128, bgColor=None, transparent=False, backgroundPath=None, overlayPath=None, techPath=None, cameraAngle=None, freezeTime=True, postProcessingQuality=2, antiAliasingQuality=3, modifyScene=None, sunDirection=None, animationStates=[]): """ This method loads up a trinity.EveSpaceObject and a trinity.EveSpaceScene from res paths passed in. The model and scene are modified and the camera (transforms) are set up in the same way as the Eve Photo service. """ if freezeTime: FreezeTime() trinity.GetVariableStore().RegisterVariable('DepthMap', trinity.TriTextureRes()) trinity.GetVariableStore().RegisterVariable('DepthMapMsaa', trinity.TriTextureRes()) if scenePath: scene = blue.resMan.LoadObject(scenePath) SetupScene(scene, transparentBackground=transparent, sunDirection=sunDirection) else: scene = trinity.EveSpaceScene() model = None if sofDNA: factory = GetSofFactory() model = factory.BuildFromDNA(sofDNA) elif objectPath: model = blue.resMan.LoadObject(objectPath) if model: SetupModel(model) scene.objects.append(model) if len(animationStates) > 0: soanimation.LoadAnimationStatesFromFiles(animationStates, model, trinity) soanimation.TriggerDefaultStates(model) blue.resMan.Wait() blue.os.Pump() view = projection = None if model: boundingSphereRadius = model.GetBoundingSphereRadius() if model.mesh is not None: geometry = model.mesh.geometry boundingSphereCenter = model.GetBoundingSphereCenter() view, projection = camera_util.GetViewAndProjectionUsingMeshGeometry( geometry, scene=scene, boundingSphereRadius=boundingSphereRadius, boundingSphereCenter=boundingSphereCenter, cameraAngle=cameraAngle) else: view, projection = camera_util.GetViewAndProjectionUsingBoundingSphere( boundingSphereRadius) if modifyScene: view, projection = modifyScene(scene, view, projection) hostBitmap = RenderToSurface(scene=scene, view=view, projection=projection, size=size, bgColor=bgColor, transparent=transparent, backgroundPath=backgroundPath, overlayPath=overlayPath, techPath=techPath, postProcessingQuality=postProcessingQuality, antiAliasingQuality=antiAliasingQuality) hostBitmap.Save(outPath)
def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.mapSvc = sm.GetService('map') innerPadding = attributes.innerPadding or 0 self.infoLayer = Container(parent=self, clipChildren=True, name='infoLayer', padding=innerPadding) if attributes.showCloseButton: closeButton = ButtonIcon( parent=self.infoLayer, hint='Close', texturePath='res:/UI/Texture/classes/DockPanel/closeButton.png', func=attributes.closeFunction or self.Close, align=uiconst.TOPRIGHT) if attributes.showInfobox: self.infoBox = SolarSystemInfoBox(parent=self.infoLayer, align=uiconst.TOPLEFT, left=32, top=32) self.mapNavigation = MapViewNavigation(parent=self, align=uiconst.TOALL, state=uiconst.UI_NORMAL, mapView=self, padding=(0, 32, 0, 0)) sceneContainer = MapViewSceneContainer(parent=self, align=uiconst.TOALL, state=uiconst.UI_DISABLED, padding=innerPadding) sceneContainer.Startup() self.sceneContainer = sceneContainer self.sceneContainer.display = False self.camera.SetCallback(self.OnCameraMoved) scene = trinity.EveSpaceScene() scene.starfield = trinity.Load( 'res:/dx9/scene/starfield/spritestars.red') scene.backgroundEffect = trinity.Load( 'res:/dx9/scene/starfield/starfieldNebula.red') scene.backgroundRenderingEnabled = True node = nodemanager.FindNode(scene.backgroundEffect.resources, 'NebulaMap', 'trinity.TriTexture2DParameter') if node is not None: s = sm.GetService('sceneManager') sceneCube = s.GetNebulaPathForSystem(session.solarsystemid) node.resourcePath = sceneCube or 'res:/UI/Texture/classes/MapView/backdrop_cube.dds' self.mapRoot = trinity.EveRootTransform() self.mapRoot.name = 'universe' scene.objects.append(self.mapRoot) self.sceneContainer.scene = scene self.sceneContainer.DisplaySpaceScene() self.markersHandler = MapViewMarkersHandler( self, self.sceneContainer.bracketCurveSet, self.infoLayer, eventHandler=self.mapNavigation) self.abstractMode = settings.user.ui.Get( VIEWMODE_LAYOUT_SHOW_ABSTRACT_SETTINGS, VIEWMODE_LAYOUT_SHOW_ABSTRACT_DEFAULT) if self.abstractMode: self.yScaleFactor = 0.0001 sm.RegisterNotify(self) uthread.new(uicore.registry.SetFocus, self)
def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.mapSvc = sm.GetService('map') self.mapViewID = attributes.mapViewID self.autoFocusEnabled = settings.char.ui.Get( '%s_autoFocusEnabled_%s' % (SETTING_PREFIX, self.mapViewID), True) innerPadding = attributes.innerPadding or 0 self.infoLayer = Container(parent=self, clipChildren=True, name='infoLayer', padding=innerPadding) if attributes.showCloseButton: ButtonIcon( parent=self.infoLayer, hint=localization.GetByLabel('UI/Generic/Close'), texturePath='res:/UI/Texture/classes/DockPanel/closeButton.png', func=attributes.closeFunction or self.Close, align=uiconst.TOPRIGHT) self.showInfobox = attributes.Get('showInfobox', self.showInfobox) if self.showInfobox: self.infoBox = SolarSystemInfoBox(parent=self.infoLayer, align=uiconst.TOPLEFT, left=32, top=32) navigationClass = attributes.Get('navigationClass', MapViewScannerNavigation) navigationPadding = attributes.Get('navigationPadding', (0, 32, 0, 0)) self.mapNavigation = navigationClass(parent=self, align=uiconst.TOALL, state=uiconst.UI_NORMAL, mapView=self, padding=navigationPadding) sceneContainer = MapViewSceneContainer(parent=self, align=uiconst.TOALL, state=uiconst.UI_DISABLED, padding=innerPadding) sceneContainer.Startup() self.sceneContainer = sceneContainer self.sceneContainer.display = False scene = trinity.EveSpaceScene() self.showSolarSystemNebula = attributes.Get('showSolarSystemNebula', self.showSolarSystemNebula) if self.showSolarSystemNebula: scene.backgroundEffect = trinity.Load( 'res:/dx9/scene/starfield/starfieldNebula.red') scene.backgroundRenderingEnabled = True self.showStarfield = attributes.Get('showStarfield', self.showStarfield) if self.showStarfield: scene.starfield = trinity.Load( 'res:/dx9/scene/starfield/spritestars.red') scene.backgroundRenderingEnabled = True self.mapRoot = trinity.EveRootTransform() self.mapRoot.name = 'mapRoot' scene.objects.append(self.mapRoot) self.sceneBlendMode = attributes.Get('sceneBlendMode', self.sceneBlendMode) self.sceneContainer.scene = scene self.sceneContainer.DisplaySpaceScene(blendMode=self.sceneBlendMode) self.markersHandler = MapViewMarkersHandler( self, self.sceneContainer.bracketCurveSet, self.infoLayer, eventHandler=self.mapNavigation, stackMarkers=attributes.Get('stackMarkers', True)) self.bookmarkHandler = MapViewBookmarkHandler(self) self.showDebugInfo = attributes.Get('showDebugInfo', self.showDebugInfo) if self.showDebugInfo: self.debugOutput = EveLabelSmall(parent=self, align=uiconst.BOTTOMLEFT, left=6, top=6, idx=0) self.debugOutputTimer = AutoTimer(5, self.UpdateDebugOutput) self.camera.fieldOfView = 0.7 self.camera.minDistance = 0.5 self.camera.maxDistance = 8000.0 self.camera.frontClip = 0.1 self.camera.backClip = 50000.0 self.camera.LoadRegisteredCameraSettings(self.mapViewID) self.camera.SetCallback(self.OnCameraMoved) sm.RegisterNotify(self) uthread.new(uicore.registry.SetFocus, self)