def DoBake_t(self, projectedDecalModifier):
        while self.doingDecal or self.doingAvatar:
            PD.Yield()

        self.bakeScene = trinity.WodBakingScene()
        self.bakeScene.Avatar = self.__avatar
        if projectedDecalModifier.decalData.bodyEnabled:
            while not projectedDecalModifier.mapD[pdDef.DOLL_PARTS.BODY].isPrepared:
                PD.Yield(frameNice=False)

            bodyTex = projectedDecalModifier.mapD[pdDef.DOLL_PARTS.BODY]
            self._Bake(bodyTex, (0.0, 0.0, 2.0, 1.0))
            self._ExpandOpaque(pdDef.DOLL_PARTS.BODY, bodyTex)
        elif projectedDecalModifier.mapD.get(pdDef.DOLL_PARTS.BODY):
            del projectedDecalModifier.mapD[pdDef.DOLL_PARTS.BODY]
        if projectedDecalModifier.decalData.headEnabled:
            while not projectedDecalModifier.mapD[pdDef.DOLL_PARTS.HEAD].isPrepared:
                PD.Yield(frameNice=False)

            headTex = projectedDecalModifier.mapD[pdDef.DOLL_PARTS.HEAD]
            self._Bake(headTex, (-0.5, 0.0, 2.0, 2.0))
            self._ExpandOpaque(pdDef.DOLL_PARTS.HEAD, headTex)
        elif projectedDecalModifier.mapD.get(pdDef.DOLL_PARTS.HEAD):
            del projectedDecalModifier.mapD[pdDef.DOLL_PARTS.HEAD]
        self.bakeScene = None
        self.isReady = True
예제 #2
0
    def StartGhostRenderJob(self,
                            avatar,
                            fxPath,
                            rjName='Avatar Ghost',
                            meshFilter=None,
                            insertFront=True):
        self.StopGhostRenderJob()
        if avatar is None or avatar.visualModel is None or not avatar.visualModel.meshes:
            return
        rj = trinity.CreateRenderJob(rjName)
        self.ghostRJ = rj
        self.avatar = avatar.CloneTo()
        self.avatar.clothMeshes.removeAt(-1)
        self.avatar.rotation = avatar.rotation
        self.avatar.translation = avatar.translation
        self.avatar.animationUpdater = avatar.animationUpdater
        for meshIx in xrange(len(avatar.visualModel.meshes)):
            mesh = avatar.visualModel.meshes[meshIx]
            self.avatar.visualModel.meshes[meshIx].SetGeometryRes(
                mesh.geometry)

        effect = trinity.Tr2Effect()
        effect.effectFilePath = fxPath
        effect.PopulateParameters()
        effect.RebuildCachedData()
        while effect.effectResource.isLoading:
            Yield()

        fx = []
        index = 0
        while index < len(self.avatar.visualModel.meshes):
            mesh = self.avatar.visualModel.meshes[index]
            if meshFilter is not None and not meshFilter(mesh):
                self.avatar.visualModel.meshes.removeAt(index)
            else:
                index = index + 1
                areasList = [
                    mesh.opaqueAreas, mesh.decalAreas, mesh.transparentAreas
                ]
                for areas in areasList:
                    for area in areas:
                        area.effect = effect
                        fx.append(area.effect)

        self.ghostScene = trinity.WodBakingScene()
        self.ghostScene.Avatar = self.avatar
        rj.SetStdRndStates(trinity.RM_OPAQUE)
        rj.Update(self.ghostScene)
        rj.RenderScene(self.ghostScene)
        if AvatarGhost.renderStepSlot is not None and AvatarGhost.renderStepSlot.object is not None:
            AvatarGhost.renderStepSlot.object.job = rj
        else:
            rj.ScheduleRecurring(insertFront=insertFront)
        return fx