コード例 #1
0
ファイル: sceneRenderJobSpace.py プロジェクト: R4M80MrX/eve-1
 def _RefreshRenderTargets(self):
     self.renderTargetList = (blue.BluePythonWeakRef(self.customBackBuffer),
      blue.BluePythonWeakRef(self.customDepthStencil),
      blue.BluePythonWeakRef(self.depthTexture),
      blue.BluePythonWeakRef(self.blitTexture),
      blue.BluePythonWeakRef(self.distortionTexture))
     renderTargets = (x.object for x in self.renderTargetList)
     self.SetRenderTargets(*renderTargets)
コード例 #2
0
 def CreateScatterStep(renderJob, scene, append = True):
     step = trinity.TriStepRunJob()
     step.name = 'Subsurface scattering'
     step.job = trinity.CreateRenderJob('Render scattering')
     if append:
         renderJob.steps.append(step)
     SkinLightmapRenderer.renderJob = blue.BluePythonWeakRef(step.job)
     SkinLightmapRenderer.scene = blue.BluePythonWeakRef(scene)
     return step
コード例 #3
0
 def SetCameraProjection(self, proj):
     if proj is None:
         self.RemoveStep('SET_PROJECTION')
         self.projection = None
     else:
         self.AddStep('SET_PROJECTION', trinity.TriStepSetProjection(proj))
         if self.stereoEnabled:
             self.originalProjection = blue.BluePythonWeakRef(proj)
         else:
             self.projection = blue.BluePythonWeakRef(proj)
コード例 #4
0
    def AddStep(self, stepKey, step):
        """
        Instead of appending a step, this version will check the desired render step order
        and insert a named step in what it thinks is the correct order.
        If a step already exists, it is replaced
        If the renderJob is a multiview stage, check if the step is valid for this stage, if so add it
        """
        renderStepOrder = self.GetRenderStepOrderList()
        if renderStepOrder is None:
            return
        elif stepKey not in renderStepOrder:
            return
        else:
            if stepKey in self.stepsLookup:
                s = self.stepsLookup[stepKey]
                if s.object is None:
                    del self.stepsLookup[stepKey]
                else:
                    replaceIdx = self.steps.index(s.object)
                    if replaceIdx >= 0:
                        while True:
                            try:
                                self.steps.remove(s.object)
                            except:
                                break

                        self.steps.insert(replaceIdx, step)
                        step.name = stepKey
                        self.stepsLookup[stepKey] = blue.BluePythonWeakRef(
                            step)
                        self._AddStereoStep(step)
                        return step
            stepIdx = renderStepOrder.index(stepKey)
            nextExistingStepIdx = None
            nextExistingStep = None
            for i, oStep in enumerate(renderStepOrder[stepIdx + 1:]):
                if oStep in self.stepsLookup and self.stepsLookup[
                        oStep].object is not None:
                    nextExistingStepIdx = i + stepIdx
                    nextExistingStep = self.stepsLookup[oStep].object
                    break

            if nextExistingStepIdx is not None:
                insertPosition = self.steps.index(nextExistingStep)
                self.steps.insert(insertPosition, step)
                step.name = stepKey
                self.stepsLookup[stepKey] = blue.BluePythonWeakRef(step)
                self._AddStereoStep(step)
                return step
            step.name = stepKey
            self.stepsLookup[stepKey] = blue.BluePythonWeakRef(step)
            self.steps.append(step)
            self._AddStereoStep(step)
            return step
コード例 #5
0
    def AddStep(self, stepKey, step):
        renderStepOrder = self.GetRenderStepOrderList()
        if renderStepOrder is None:
            return
        elif stepKey not in renderStepOrder:
            return
        else:
            if stepKey in self.stepsLookup:
                s = self.stepsLookup[stepKey]
                if s.object is None:
                    del self.stepsLookup[stepKey]
                else:
                    replaceIdx = self.steps.index(s.object)
                    if replaceIdx >= 0:
                        while True:
                            try:
                                self.steps.remove(s.object)
                            except:
                                break

                        self.steps.insert(replaceIdx, step)
                        step.name = stepKey
                        self.stepsLookup[stepKey] = blue.BluePythonWeakRef(
                            step)
                        self._AddStereoStep(step)
                        return step
            stepIdx = renderStepOrder.index(stepKey)
            nextExistingStepIdx = None
            nextExistingStep = None
            for i, oStep in enumerate(renderStepOrder[stepIdx + 1:]):
                if oStep in self.stepsLookup and self.stepsLookup[
                        oStep].object is not None:
                    nextExistingStepIdx = i + stepIdx
                    nextExistingStep = self.stepsLookup[oStep].object
                    break

            if nextExistingStepIdx is not None:
                insertPosition = self.steps.index(nextExistingStep)
                self.steps.insert(insertPosition, step)
                step.name = stepKey
                self.stepsLookup[stepKey] = blue.BluePythonWeakRef(step)
                self._AddStereoStep(step)
                return step
            step.name = stepKey
            self.stepsLookup[stepKey] = blue.BluePythonWeakRef(step)
            self.steps.append(step)
            self._AddStereoStep(step)
            return step
コード例 #6
0
ファイル: AvatarGhost.py プロジェクト: connoryang/1v1dec
 def CreateSculptingStep(renderJob, append=True):
     ghostStep = trinity.TriStepRunJob()
     ghostStep.name = 'Sculpting overlay'
     if append:
         renderJob.steps.append(ghostStep)
     AvatarGhost.renderStepSlot = blue.BluePythonWeakRef(ghostStep)
     return ghostStep
コード例 #7
0
 def SetViewport(self, viewport):
     if viewport is None:
         self.RemoveStep('SET_VIEWPORT')
         self.viewport = None
     else:
         self.AddStep('SET_VIEWPORT', trinity.TriStepSetViewport(viewport))
         self.viewport = blue.BluePythonWeakRef(viewport)
コード例 #8
0
def AddWeakBlue(classInstance, dictionaryName, blueObjectKey, value):
    """
    Summary:
    weakref(classInstance ).dictionaryName[ BluePythonWeakRef( blueObjectKey) ] = value
       .. with auto-remove of dead keys.
    
    Description:
    Add blueObject to dictionary as a weakreference; it will use a callback to automatically remove
    itself when being destroyed, which in turn needs a weakref to avoid a circular dependency, where
    the callback keeps the dictionary alive.
    Unfortunately holding a weakref to a dict isn't allowed in python, so get around that by assuming
    dictionary is a member of classInstance, using getattr to get to the actual dictionary.. 
    TODO think about WeakKeyDictionaryBlue or somesuch?
    """
    dictionary = getattr(classInstance, dictionaryName)
    if dictionary is None:
        return
    for key in dictionary.iterkeys():
        if key.object == blueObjectKey:
            dictionary[key] = value
            return

    weakInstance = weakref.ref(classInstance)
    weakObjectKey = blue.BluePythonWeakRef(blueObjectKey)
    weakObjectKey.callback = lambda: __WeakBlueRemoveHelper(
        weakInstance, dictionaryName, weakObjectKey)
    dictionary[weakObjectKey] = value
コード例 #9
0
 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))
コード例 #10
0
 def SetCameraView(self, view):
     if view is None:
         self.RemoveStep('SET_VIEW')
         self.view = None
     else:
         self.AddStep('SET_VIEW', trinity.TriStepSetView(view))
         self.view = blue.BluePythonWeakRef(view)
コード例 #11
0
    def AddToQueue(self, avatarBluePythonWeakRef, dollWeakref, factoryWeakref,
                   lodWanted):
        """
        Incoming lod-switch request.
        
        If it's already in the queue, update the requested values; if it's being updated, refresh.
        Else, add it, and if it's the only entry in the queue, kick it off right away.
        
        Avatar, doll and factory are stored as weak references, and are automatically wrapped
        into blue and python weakrefs 
        """
        if type(avatarBluePythonWeakRef) != blue.BluePythonWeakRef:
            avatarBluePythonWeakRef = blue.BluePythonWeakRef(
                avatarBluePythonWeakRef)
        if type(dollWeakref) != weakref.ref:
            dollWeakref = weakref.ref(dollWeakref)
        if type(factoryWeakref) != weakref.ref:
            factoryWeakref = weakref.ref(factoryWeakref)
        for i in xrange(len(self.queue)):
            q = self.queue[i]
            if q.doll() == dollWeakref() and q.factory() == factoryWeakref(
            ) and q.avatar.object == avatarBluePythonWeakRef.object:
                q.lodWanted = lodWanted
                if q.doll().busyUpdating:
                    q.doll().Update(q.factory(), q.avatar.object)
                break
        else:
            entry = self.QueueEntry(avatarBluePythonWeakRef, dollWeakref,
                                    factoryWeakref, lodWanted)
            self.queue.append(entry)

        self.updateEvent.set()
コード例 #12
0
ファイル: sceneRenderJobBase.py プロジェクト: R4M80MrX/eve-1
 def SetSwapChain(self, swapChain):
     self.DoReleaseResources(1)
     if swapChain is None:
         self.RemoveStep('PRESENT_SWAPCHAIN')
     else:
         self.AddStep('PRESENT_SWAPCHAIN', trinity.TriStepPresentSwapChain(swapChain))
     self.swapChain = blue.BluePythonWeakRef(swapChain)
     self.DoPrepareResources()
コード例 #13
0
 def SetScene(self, scene):
     """
     Sets a scene into the render job. You must implement _SetScene(self, scene) on derived classes
     """
     if scene is None:
         self.scene = None
     else:
         self.scene = blue.BluePythonWeakRef(scene)
     self._SetScene(scene)
コード例 #14
0
 def CreateShadowStep(renderJob, append = True):
     shadowStep = trinity.TriStepRunJob()
     shadowStep.name = 'Spotlight shadows'
     shadowStep.job = trinity.CreateRenderJob('Render shadowmaps')
     if append:
         renderJob.steps.append(shadowStep)
     SkinSpotLightShadows.renderJob = blue.BluePythonWeakRef(shadowStep.job)
     if SkinSpotLightShadows.instance is not None:
         SkinSpotLightShadows.instance.RefreshLights()
     return shadowStep
コード例 #15
0
 def ApplyVisualization(self, rj):
     scene = rj.GetScene()
     if scene is not None:
         for light in scene.lights:
             if self.ShouldLightBeVisualized(light):
                 self.lightStates.append(
                     (blue.BluePythonWeakRef(light), light.renderDebugInfo,
                      light.renderDebugType))
                 light.renderDebugInfo = True
                 light.renderDebugType = self.lightDebugRenderType
コード例 #16
0
    def RegisterJob(self, job):
        wr = blue.BluePythonWeakRef(job)
        if self.primaryJob.sceneType == SCENE_TYPE_INTERIOR:
            job.UseFXAA(True)

        def ClearDereferenced():
            self.registeredJobs.remove(wr)

        wr.callback = ClearDereferenced
        self.registeredJobs.append(wr)
コード例 #17
0
 def SetClientToolsScene(self, scene):
     """
     A function that sets a primitive scene for rendering client tools (for the
     Dungeon Editor).
     """
     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))
コード例 #18
0
ファイル: renderJobUtils.py プロジェクト: R4M80MrX/eve-1
    def _Get(self, key, function, *args):
        if self.targets.has_key(key) and self.targets[key].object is not None:
            return self.targets[key].object

        def DeleteObject():
            self.targets.pop(key)

        rt = function(*args)
        self.targets[key] = blue.BluePythonWeakRef(rt)
        self.targets[key].callback = DeleteObject
        return rt
コード例 #19
0
 def __init__(self, factory, doll = None, avatar = None, visualModel = None):
     self.factory = factory
     self.factory.WaitUntilLoaded()
     self.doll = doll
     self.avatar = avatar
     self.visualModel = visualModel
     if not visualModel and hasattr(avatar, 'visualModel'):
         self.visualModel = avatar.visualModel
     self.__scene = blue.BluePythonWeakRef(None)
     self.autoLod = False
     self.disableDel = False
     trinity.device.RegisterResource(self)
コード例 #20
0
 def SetSwapChain(self, swapChain):
     """
     Adds or removes a final present swapchain renderstep.
     """
     self.DoReleaseResources(1)
     if swapChain is None:
         self.RemoveStep('PRESENT_SWAPCHAIN')
     else:
         self.AddStep('PRESENT_SWAPCHAIN',
                      trinity.TriStepPresentSwapChain(swapChain))
     self.swapChain = blue.BluePythonWeakRef(swapChain)
     self.DoPrepareResources()
コード例 #21
0
def AddWeakBlue(classInstance, dictionaryName, blueObjectKey, value):
    dictionary = getattr(classInstance, dictionaryName)
    if dictionary is None:
        return
    for key in dictionary.iterkeys():
        if key.object == blueObjectKey:
            dictionary[key] = value
            return

    weakInstance = weakref.ref(classInstance)
    weakObjectKey = blue.BluePythonWeakRef(blueObjectKey)
    weakObjectKey.callback = lambda : __WeakBlueRemoveHelper(weakInstance, dictionaryName, weakObjectKey)
    dictionary[weakObjectKey] = value
コード例 #22
0
ファイル: renderJobUtils.py プロジェクト: connoryang/1v1dec
    def _Get(self, key, function, *args):
        if key in self.targets and self.targets[key].object is not None:
            rt = self.targets[key].object
            if not rt.isValid:
                function(target=rt, *args)
            return rt

        def DeleteObject():
            self.targets.pop(key)

        rt = function(*args)
        self.targets[key] = _blue.BluePythonWeakRef(rt)
        self.targets[key].callback = DeleteObject
        return rt
コード例 #23
0
ファイル: desktop.py プロジェクト: connoryang/1v1dec
 def Create3DRenderTarget(self, destscene):
     sprite = blue.resMan.LoadObject('res:/uicore/uiInSpace.red')
     area = sprite.mesh.opaqueAreas[0]
     texture = area.effect.resources[0]
     destscene.objects.append(sprite)
     rj = trinity.CreateRenderJob()
     rj.Update(destscene)
     myScene = self.GetRenderObject()
     renderTarget = trinity.Tr2RenderTarget(self.width, self.height, 1, trinity.PIXEL_FORMAT.B8G8R8A8_UNORM)
     rj.PushRenderTarget(renderTarget)
     rj.RenderScene(myScene).name = 'Render 2D scene'
     rj.PopRenderTarget()
     rj.ScheduleRecurring(insertFront=True)
     texture.SetResource(trinity.TriTextureRes(renderTarget))
     myScene.is2dRender = True
     self.sceneObject = blue.BluePythonWeakRef(sprite)
     self.renderSteps[-1].enabled = False
コード例 #24
0
    def Initialize(self, size, speed, amplitude, tiling, texturePath):
        """
        Initializes the output texture, render job, builds render steps.
        Returns the output texture.
        """
        def TextureDestroyed():
            """
            Closure for weakref callback. Destroys the
            render job.
            """
            self.Destroy()

        texture = trinity.Tr2RenderTarget(size, size, 1,
                                          trinity.PIXEL_FORMAT.B8G8R8A8_UNORM)
        self.name = 'Caustics'
        self.size = size
        self.texture = blue.BluePythonWeakRef(texture)
        self.texture.callback = TextureDestroyed
        self.steps.append(trinity.TriStepPushRenderTarget(texture))
        self.steps.append(trinity.TriStepClear((0, 0, 0, 0)))
        self.steps.append(trinity.TriStepSetStdRndStates(
            trinity.RM_FULLSCREEN))
        material = trinity.Tr2ShaderMaterial()
        material.highLevelShaderName = 'Caustics'
        param = trinity.TriTexture2DParameter()
        param.name = 'Texture'
        param.resourcePath = texturePath
        material.parameters['Texture'] = param
        param = trinity.Tr2FloatParameter()
        param.name = 'Speed'
        param.value = speed
        material.parameters['Speed'] = param
        param = trinity.Tr2FloatParameter()
        param.name = 'Amplitude'
        param.value = amplitude
        material.parameters['Amplitude'] = param
        param = trinity.Tr2FloatParameter()
        param.name = 'Tiling'
        param.value = tiling
        material.parameters['Tiling'] = param
        material.BindLowLevelShader([])
        self.steps.append(trinity.TriStepRenderFullScreenShader(material))
        self.steps.append(trinity.TriStepPopRenderTarget())
        trinity.renderJobs.recurring.append(self)
        return trinity.TriTextureRes(texture)
コード例 #25
0
    def _Get(self, key, function, *args):
        """
            Returns a render target created by the function argument
            using args as arguments for the function.
        """
        if key in self.targets and self.targets[key].object is not None:
            rt = self.targets[key].object
            if not rt.isValid:
                function(target=rt, *args)
            return rt

        def DeleteObject():
            self.targets.pop(key)

        rt = function(*args)
        self.targets[key] = _blue.BluePythonWeakRef(rt)
        self.targets[key].callback = DeleteObject
        return rt
コード例 #26
0
ファイル: paperDollTests.py プロジェクト: R4M80MrX/eve-1
 def SpawnDolls(self, lod, count):
     for i in xrange(count):
         pdc = PD.PaperDollCharacter(self.factory)
         pdc.disableDel = self.debugMode
         pdc.doll = PD.Doll('TestDoll')
         if self.respathsIterator:
             spawnKey = 'Loading doll #{0} at LOD {1}'.format(i, lod)
             self.results.PunchIn(spawnKey)
             pdc.doll.Load(self.respathsIterator.next(), self.factory)
             self.results.PunchOut(spawnKey)
         spawnKey = 'Spawning doll #{0} at LOD {1} without call to Update'.format(i, lod)
         self.results.PunchIn(spawnKey)
         pdc.Spawn(self.scene, point=self.points.pop(), lod=99999, updateDoll=False, usePrepass=self.usePrepass)
         self.results.PunchOut(spawnKey)
         self.paperDollCharacters.append(pdc)
         avatar = blue.BluePythonWeakRef(pdc.avatar)
         doll = weakref.ref(pdc.doll)
         factory = weakref.ref(pdc.factory)
         PD.LodQueue.instance.AddToQueue(avatar, doll, factory, lod)
コード例 #27
0
        def __init__(self, avatar, doll, factory, stub):
            self.avatar = blue.BluePythonWeakRef(avatar)
            self.doll = weakref.ref(doll)
            self.factory = weakref.ref(factory)
            doll.overrideLod = LodQueue.magicLOD

            def MakeBuilder(lod):
                lodBuilder = blue.BlueObjectBuilderPython()
                lodBuilder.SetCreateMethod(lambda objectMarker, callingProxy:
                                           self.DoCreate(callingProxy, lod))
                lodBuilder.SetSelectedHandler(
                    lambda objectMarker, callingProxy: self.OnSelected(
                        callingProxy, lod))
                proxy = blue.BlueObjectProxy()
                proxy.builder = lodBuilder
                return proxy

            avatar.highDetailModel = MakeBuilder(0)
            avatar.mediumDetailModel = MakeBuilder(1)
            avatar.lowDetailModel = MakeBuilder(2)
            factory.AppendMeshesToVisualModel(avatar.visualModel, stub.meshes)
コード例 #28
0
ファイル: playlistresource.py プロジェクト: connoryang/1v1dec
    def init(self,
             width,
             height,
             playlist,
             low_quality_texture_path=None,
             **kwargs):
        self.destroyed = False
        self.low_quality_texture_path = low_quality_texture_path
        self.generate_mips = kwargs.pop('generate_mips', False)
        self.constructor_params = kwargs
        self.playlist = playlist(**kwargs)

        def texture_destroyed():
            self._destroy()

        texture = trinity.TriTextureRes()
        self.weak_texture = blue.BluePythonWeakRef(texture)
        self.weak_texture.callback = texture_destroyed
        if not self.low_quality_texture_path or not _is_low_quality():
            uthread2.start_tasklet(self.play_next)
        else:
            self._create_low_quality_render_job()
        return texture
コード例 #29
0
ファイル: resource.py プロジェクト: connoryang/1v1dec
    def init(self,
             video_local=None,
             video_remote=None,
             generate_mips=0,
             **kwargs):
        if not video_local and not video_remote:
            raise ValueError()
        self.generate_mips = bool(generate_mips)

        def texture_destroyed():
            self._destroy()

        texture = trinity.TriTextureRes()
        self.weak_texture = blue.BluePythonWeakRef(texture)
        self.weak_texture.callback = texture_destroyed
        self.constructor_params = dict(kwargs)
        self.constructor_params.update({
            'video_local': video_local,
            'video_remote': video_remote,
            'generate_mips': generate_mips
        })
        uthread2.start_tasklet(self._init, video_local, video_remote)
        return texture
コード例 #30
0
    def AddToQueue(self, avatarBluePythonWeakRef, dollWeakref, factoryWeakref,
                   lodWanted):
        if type(avatarBluePythonWeakRef) != blue.BluePythonWeakRef:
            avatarBluePythonWeakRef = blue.BluePythonWeakRef(
                avatarBluePythonWeakRef)
        if type(dollWeakref) != weakref.ref:
            dollWeakref = weakref.ref(dollWeakref)
        if type(factoryWeakref) != weakref.ref:
            factoryWeakref = weakref.ref(factoryWeakref)
        for i in xrange(len(self.queue)):
            q = self.queue[i]
            if q.doll() == dollWeakref() and q.factory() == factoryWeakref(
            ) and q.avatar.object == avatarBluePythonWeakRef.object:
                q.lodWanted = lodWanted
                if q.doll().busyUpdating:
                    q.doll().Update(q.factory(), q.avatar.object)
                break
        else:
            entry = self.QueueEntry(avatarBluePythonWeakRef, dollWeakref,
                                    factoryWeakref, lodWanted)
            self.queue.append(entry)

        self.updateEvent.set()