def RunSimulation(self): trinity.settings.SetValue('frustumCullingDisabled', 1) trinity.settings.SetValue('eveSpaceSceneVisibilityThreshold', 0) trinity.settings.SetValue('eveSpaceSceneLowDetailThreshold', 0) trinity.settings.SetValue('eveSpaceSceneMediumDetailThreshold', 0) ut.StartTasklet(self._PumpBlue) import sceneutils scene = sceneutils.GetOrCreateScene() scene.objects.append(self.redNodeMutated) self._UpdateBoundingBox(True) rj = trinity.CreateRenderJob('CallbackJob') projection = trinity.TriProjection() projection.PerspectiveFov(1, 1, 1, 10000000) rj.steps.append(trinity.TriStepSetProjection(projection)) view = trinity.TriView() view.SetLookAtPosition((50000, 0, 0), (0, 0, 0), (0, 1, 0)) rj.steps.append(trinity.TriStepSetView(view)) rj.steps.append(trinity.TriStepUpdate(scene)) rj.steps.append(trinity.TriStepRenderScene(scene)) rj.steps.append(trinity.TriStepPythonCB(self.AccumulateBounds)) rj.ScheduleRecurring() for i in range(self._passes): self.activeIndex[0] = i for cs in self.curveSets: cs.Play() for sys in self.systems: sys.ClearParticles() self.started[0] = True ut.SleepSim(self._time) rj.UnscheduleRecurring() self._pumpBlue = False
def SetClientToolsScene(self, scene): if scene is None: self.clientToolsScene = None else: self.clientToolsScene = blue.BluePythonWeakRef(scene) self.AddStep('UPDATE_TOOLS', trinity.TriStepUpdate(scene)) self.AddStep('RENDER_TOOLS', trinity.TriStepRenderScene(scene))
def Set2DBackdropScene(self, backdrop): if backdrop is not None: self.AddStep('UPDATE_BACKDROP', trinity.TriStepUpdate(backdrop)) self.AddStep('RENDER_BACKDROP', trinity.TriStepRenderScene(backdrop)) else: self.RemoveStep('UPDATE_BACKDROP') self.RemoveStep('RENDER_BACKDROP')
def CreateRenderJob(size, view, projection, bgColor=None, transparent=False, postProcessingQuality=2, antiAliasingQuality=3): """ Creates a Jessica render job and adds functionality for 2D sprite background and overlays. """ def _GetRenderStepPosition(renderJob, name): for i, each in enumerate(renderJob.steps): if each.name == name: return i return i if transparent: clearColor = bgColor or (0.0, 0.0, 0.0, 0.0) format = trinity.PIXEL_FORMAT.B8G8R8A8_UNORM else: clearColor = bgColor or (0.0, 0.0, 0.0, 1.0) format = trinity.PIXEL_FORMAT.B8G8R8X8_UNORM rt = trinity.Tr2RenderTarget(size, size, 1, format) rt.name = 'MyRT' ds = trinity.Tr2DepthStencil() ds.Create(size, size, trinity.DEPTH_STENCIL_FORMAT.D24S8, 0, 0) ds.name = 'MyDS' vp = trinity.TriViewport() vp.width = size vp.height = size renderJob = CreateJessicaSpaceRenderJob() renderJob.updateJob = None renderJob.CreateBasicRenderSteps() renderJob.OverrideSettings('hdrEnabled', True) settings = renderJob.GetSettings() settings['postProcessingQuality'] = postProcessingQuality settings['aaQuality'] = antiAliasingQuality renderJob.SetSettings(settings) renderJob.SetClearColor(clearColor) renderJob.OverrideSettings('bbFormat', format) renderJob.SetActiveCamera(view=view, projection=projection) renderJob.SetViewport(vp) renderJob.OverrideBuffers(rt, ds) renderJob.Enable(False) bgStep = trinity.TriStepRenderScene() bgStep.name = 'BACKGROUND_SPRITE' bgSprite1 = CreateSprite(1.0, size) bgSprite2 = CreateSprite(1.0, size) bgSpriteScene = trinity.Tr2Sprite2dScene() bgSpriteScene.children.append(bgSprite1) bgSpriteScene.children.append(bgSprite2) bgStep.scene = bgSpriteScene pos = _GetRenderStepPosition(renderJob, 'CLEAR') renderJob.steps.insert(pos + 1, bgStep) setattr(renderJob, 'iconTexture', bgSprite1.texturePrimary) setattr(renderJob, 'backgroundTexture', bgSprite2.texturePrimary) oStep = trinity.TriStepRenderScene() oStep.name = 'OVERLAY_SPRITES' oSprite1 = CreateSprite(1.0, size) oSprite1.blendMode = 2 oSprite2 = CreateSprite(16.0 / size, size) oSpriteScene = trinity.Tr2Sprite2dScene() oSpriteScene.children.append(oSprite1) oSpriteScene.children.append(oSprite2) oStep.scene = oSpriteScene pos2 = _GetRenderStepPosition(renderJob, 'END_RENDERING') renderJob.steps.insert(pos2 + 1, oStep) setattr(renderJob, 'overlayTexture', oSprite1.texturePrimary) setattr(renderJob, 'techTexture', oSprite2.texturePrimary) setattr(renderJob, 'renderTarget', rt) return renderJob
def _CreateBasicRenderSteps(self): self.AddStep('UPDATE_SCENE', trinity.TriStepUpdate(self.GetScene())) self.AddStep('RENDER_SCENE', trinity.TriStepRenderScene(self.GetScene()))
def _CreateBasicRenderSteps(self): self.AddStep('UPDATE_SCENE', trinity.TriStepUpdate(self.GetScene())) self.AddStep('CLEAR', trinity.TriStepClear((0.0, 0.0, 0.0, 0.0), 1.0)) self.AddStep('RENDER_SCENE', trinity.TriStepRenderScene(self.GetScene()))