def CreateEffectParamsForMesh(self, mesh, isClothMesh = False):
        meshData = self.MeshData(self.width, isClothMesh)

        def IsHair(mesh):
            if not hasattr(mesh, 'name'):
                return True
            if mesh.name.lower().startswith('hair'):
                return True
            return False

        def IsSkin(mesh):
            if not hasattr(mesh, 'name'):
                return False
            skinAreas = ['bottominner',
             'topinner',
             'hands',
             'feet',
             'sleeveslower/standard',
             'sleevesupper/standard']
            for sa in skinAreas:
                if mesh.name.lower().startswith(sa):
                    return True

            return False

        isTranslucent = IsHair(mesh)
        if not isClothMesh:
            for areaMesh in mesh.opaqueAreas:
                if not pdCcf.IsBeard(areaMesh):
                    meshData.createMeshAreaParams(areaMesh, isDecal=False, isTranslucent=isTranslucent or pdCcf.IsGlasses(areaMesh))
                else:
                    meshData.inhibitShadows(areaMesh)

            for areaMesh in mesh.decalAreas:
                if not pdCcf.IsBeard(areaMesh):
                    meshData.createMeshAreaParams(areaMesh, isDecal=True, isTranslucent=isTranslucent or pdCcf.IsGlasses(areaMesh))
                else:
                    meshData.inhibitShadows(areaMesh)

            for areaMesh in mesh.transparentAreas:
                if IsHair(mesh):
                    meshData.createMeshAreaParams(areaMesh, isDecal=True, isTranslucent=True)
                else:
                    meshData.inhibitShadows(areaMesh)

        else:
            if hasattr(mesh, 'effect') and mesh.effect and 'clothavatarhair_detailed' in mesh.effect.effectFilePath.lower():
                isTranslucent = True
            meshData.createMeshAreaParams(mesh, isDecal=True, isCloth=True, isTranslucent=isTranslucent)
        fx = pdCcf.GetEffectsFromMesh(mesh)
        for f in fx:
            self.CreateEffectParams(f, meshData)

        for key in self.meshes.iterkeys():
            if key.object == mesh:
                self.meshes[key] = meshData
                break
        else:
            pdCcf.AddWeakBlue(self, 'meshes', mesh, meshData)
Beispiel #2
0
    def BindClothShaders(self, mesh, doll, isHair):
        if doll.currentLOD <= 0:
            fx = pdCcf.GetEffectsFromMesh(mesh)
            for f in iter(fx):
                isHair = pdPor.PortraitTools.BindHeroHairShader(f, '.fx') or isHair
                if doll.currentLOD <= pdDef.LOD_SKIN:
                    pdPor.PortraitTools.BindHeroClothShader(f, doll.useDXT5N)

        return isHair
Beispiel #3
0
    def BindClothShaders(self, mesh, doll, isHair):
        """
        Look at all effects in a cloth mesh and crank up their quality if needed.
        """
        if doll.currentLOD <= 0:
            fx = pdCcf.GetEffectsFromMesh(mesh)
            for f in iter(fx):
                isHair = pdPor.PortraitTools.BindHeroHairShader(
                    f, '.fx') or isHair
                if doll.currentLOD <= pdDef.LOD_SKIN:
                    pdPor.PortraitTools.BindHeroClothShader(f, doll.useDXT5N)

        return isHair
Beispiel #4
0
    def SetInteriorShader(self, asyncMeshes, mesh, wrinkleFx, doll):
        """
        Applies interior shaders to the given mesh
        """
        fx = pdCcf.GetEffectsFromMesh(mesh)
        tasklets = []
        for f in iter(fx):
            if type(f) == trinity.Tr2ShaderMaterial:
                continue
            t = uthread.new(self.SetInteriorShaderForFx_t,
                            *(f, asyncMeshes, mesh, wrinkleFx, doll))
            tasklets.append(t)

        pdCf.WaitForAll(tasklets, lambda x: x.alive)
Beispiel #5
0
 def FindSkinEffect(meshes):
     for mesh in iter(meshes):
         fx = pdCcf.GetEffectsFromMesh(mesh)
         for effect in iter(fx):
             if effect.name.lower().startswith('c_skin_'):
                 return effect