NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

AvatarGhost.py (3059B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\paperDoll\AvatarGhost.py
      2 import trinity
      3 import blue
      4 from eve.common.script.paperDoll.paperDollCommonFunctions import Yield
      5 
      6 class AvatarGhost(object):
      7     renderStepSlot = None
      8 
      9     def __init__(self):
     10         pass
     11 
     12     def __del__(self):
     13         self.StopGhostRenderJob()
     14 
     15     def StopGhostRenderJob(self):
     16         if hasattr(self, 'ghostRJ') and self.ghostRJ is not None:
     17             if AvatarGhost.renderStepSlot is not None and AvatarGhost.renderStepSlot.object is not None:
     18                 AvatarGhost.renderStepSlot.object.job = None
     19             else:
     20                 self.ghostRJ.UnscheduleRecurring()
     21             self.ghostRJ = None
     22 
     23     def StartGhostRenderJob(self, avatar, fxPath, rjName = 'Avatar Ghost', meshFilter = None, insertFront = True):
     24         self.StopGhostRenderJob()
     25         if avatar is None or avatar.visualModel is None or not avatar.visualModel.meshes:
     26             return
     27         rj = trinity.CreateRenderJob(rjName)
     28         self.ghostRJ = rj
     29         self.avatar = avatar.CloneTo()
     30         self.avatar.rotation = avatar.rotation
     31         self.avatar.translation = avatar.translation
     32         self.avatar.animationUpdater = avatar.animationUpdater
     33         for meshIx in xrange(len(avatar.visualModel.meshes)):
     34             mesh = avatar.visualModel.meshes[meshIx]
     35             self.avatar.visualModel.meshes[meshIx].SetGeometryRes(mesh.geometry)
     36 
     37         effect = trinity.Tr2Effect()
     38         effect.effectFilePath = fxPath
     39         effect.RebuildCachedData()
     40         while not effect.effectResource.isPrepared:
     41             Yield()
     42 
     43         effect.PopulateParameters()
     44         fx = []
     45         index = 0
     46         while index < len(self.avatar.visualModel.meshes):
     47             mesh = self.avatar.visualModel.meshes[index]
     48             if meshFilter is not None and not meshFilter(mesh):
     49                 self.avatar.visualModel.meshes.removeAt(index)
     50             else:
     51                 index = index + 1
     52                 areasList = [mesh.opaqueAreas, mesh.decalAreas, mesh.transparentAreas]
     53                 for areas in areasList:
     54                     for area in areas:
     55                         area.effect = effect
     56                         fx.append(area.effect)
     57 
     58         self.ghostScene = trinity.WodBakingScene()
     59         self.ghostScene.Avatar = self.avatar
     60         rj.SetStdRndStates(trinity.RM_OPAQUE)
     61         rj.Update(self.ghostScene)
     62         rj.RenderScene(self.ghostScene)
     63         if AvatarGhost.renderStepSlot is not None and AvatarGhost.renderStepSlot.object is not None:
     64             AvatarGhost.renderStepSlot.object.job = rj
     65         else:
     66             rj.ScheduleRecurring(insertFront=insertFront)
     67         return fx
     68 
     69     @staticmethod
     70     def CreateSculptingStep(renderJob, append = True):
     71         ghostStep = trinity.TriStepRunJob()
     72         ghostStep.name = 'Sculpting overlay'
     73         if append:
     74             renderJob.steps.append(ghostStep)
     75         AvatarGhost.renderStepSlot = blue.BluePythonWeakRef(ghostStep)
     76         return ghostStep