// Token: 0x0600009F RID: 159 RVA: 0x00009588 File Offset: 0x00007788
        public Texture2D ApplyFilter(Texture2D srcTex, TextureModifier.FilterParam filter)
        {
            Texture2D texture2D = UnityEngine.Object.Instantiate <Texture2D>(srcTex);

            this.FilterTexture(texture2D, srcTex, filter);
            return(texture2D);
        }
 // Token: 0x0600009E RID: 158 RVA: 0x00009550 File Offset: 0x00007750
 private void FilterTexture(Texture2D texture, TextureModifier.FilterParam filter)
 {
     TextureModifier.TextureHolder orAdd = this._originalTexCache.GetOrAdd(texture);
     orAdd.dirty = false;
     filter.ClearDirtyFlag();
     this.FilterTexture(texture, orAdd.texture, filter);
 }
        // Token: 0x06000097 RID: 151 RVA: 0x00009238 File Offset: 0x00007438
        public bool DuplicateFilter(Maid maid, string slotName, Material mat, string fromPropName, string toPropName)
        {
            Texture2D texture2D = mat.GetTexture(fromPropName) as Texture2D;

            if (texture2D == null || string.IsNullOrEmpty(texture2D.name))
            {
                return(false);
            }
            TextureModifier.FilterParam filter = this.GetFilter(maid, slotName, mat.name, texture2D.name);
            Texture2D texture2D2 = mat.GetTexture(toPropName) as Texture2D;

            if (texture2D2 == null || string.IsNullOrEmpty(texture2D2.name))
            {
                return(false);
            }
            StringBuilder stringBuilder = this.CreateKey(new string[]
            {
                MaidHelper.GetGuid(maid),
                slotName,
                mat.name,
                texture2D2.name
            });

            TextureModifier.FilterParam filter2 = new TextureModifier.FilterParam(filter);
            this._filterParams.Add(stringBuilder.ToString(), filter2);
            this.FilterTexture(texture2D2, filter2);
            return(true);
        }
 // Token: 0x060000A8 RID: 168 RVA: 0x0000996C File Offset: 0x00007B6C
 public TextureModifier.FilterParam GetOrAdd(string key)
 {
     TextureModifier.FilterParam filterParam;
     if (this._params.TryGetValue(key, out filterParam))
     {
         return(filterParam);
     }
     filterParam       = new TextureModifier.FilterParam();
     this._params[key] = filterParam;
     return(filterParam);
 }
 // Token: 0x060000AD RID: 173 RVA: 0x00009B00 File Offset: 0x00007D00
 public FilterParam(TextureModifier.FilterParam filter)
 {
     this.Dirty      = new TextureModifier.DirtyFlag();
     this.Hue        = new TextureModifier.DirtyValue(this.Dirty, TextureModifier.FilterParam.HueRange, filter.Hue.Value);
     this.Saturation = new TextureModifier.DirtyValue(this.Dirty, TextureModifier.FilterParam.SaturRange, filter.Saturation.Value);
     this.Lightness  = new TextureModifier.DirtyValue(this.Dirty, TextureModifier.FilterParam.LightRange, filter.Lightness.Value);
     this.InputMin   = new TextureModifier.DirtyValue(this.Dirty, TextureModifier.FilterParam.InpMinRange, filter.InputMin.Value);
     this.InputMax   = new TextureModifier.DirtyValue(this.Dirty, TextureModifier.FilterParam.InpMaxRange, filter.InputMax.Value);
     this.InputMid   = new TextureModifier.DirtyValue(this.Dirty, TextureModifier.FilterParam.InpMidRange, filter.InputMid.Value);
     this.OutputMin  = new TextureModifier.DirtyValue(this.Dirty, TextureModifier.FilterParam.OutMinRange, filter.OutputMin.Value);
     this.OutputMax  = new TextureModifier.DirtyValue(this.Dirty, TextureModifier.FilterParam.OutMaxRange, filter.OutputMax.Value);
 }
        // Token: 0x06000093 RID: 147 RVA: 0x00009110 File Offset: 0x00007310
        public bool IsChanged(Maid maid, string slotName, string matName, string texName)
        {
            StringBuilder stringBuilder = this.CreateKey(new string[]
            {
                MaidHelper.GetGuid(maid),
                slotName,
                matName,
                texName
            });

            TextureModifier.FilterParam filterParam = this._filterParams.Get(stringBuilder.ToString());
            return(filterParam != null && !filterParam.HasNotChanged());
        }
        // Token: 0x060000A0 RID: 160 RVA: 0x00009734 File Offset: 0x00007934
        public void FilterTexture(Texture2D dstTex, Texture2D srcTex, TextureModifier.FilterParam filterParam)
        {
            float outputBase  = filterParam.OutputMin * 0.01f;
            float outputScale = (filterParam.OutputMax - filterParam.OutputMin) * 0.01f;
            float num         = filterParam.InputMax - filterParam.InputMin;

            if (num < 0.001f)
            {
                num = 0.01f;
            }
            float num2 = filterParam.InputMid;

            if (num2 < 0.001f)
            {
                num2 = 0.01f;
            }
            float inputExp   = Mathf.Log(num2 * 0.01f) / Mathf.Log(0.5f);
            float inputBase  = -filterParam.InputMin / num;
            float inputScale = 1f / (num * 0.01f);
            float hue        = filterParam.Hue / 360f;
            float saturation = filterParam.Saturation / 100f;
            float lightness  = filterParam.Lightness / 100f;

            this.Filter(dstTex, srcTex, delegate(Color32 color)
            {
                Color c = color;
                c.r     = Mathf.Clamp01(c.r * inputScale + inputBase);
                c.g     = Mathf.Clamp01(c.g * inputScale + inputBase);
                c.b     = Mathf.Clamp01(c.b * inputScale + inputBase);
                if (!ColorUtil.Equals(inputExp, 1f))
                {
                    c.r = Mathf.Pow(c.r, inputExp);
                    c.g = Mathf.Pow(c.g, inputExp);
                    c.b = Mathf.Pow(c.b, inputExp);
                }
                Vector4 vector = ColorUtil.RGB2HSL(ref c);
                vector.x       = (vector.x + hue) % 1f;
                vector.y      *= saturation;
                vector.z      *= lightness;
                c   = ColorUtil.HSL2RGB(ref vector);
                c.r = c.r * outputScale + outputBase;
                c.g = c.g * outputScale + outputBase;
                c.b = c.b * outputScale + outputBase;
                return(c);
            });
        }
        // Token: 0x0600008A RID: 138 RVA: 0x00008E64 File Offset: 0x00007064
        public void ProcGUI(Maid maid, string slotName, Material material, string propName)
        {
            Texture2D texture2D = material.GetTexture(propName) as Texture2D;

            if (texture2D == null || string.IsNullOrEmpty(texture2D.name))
            {
                return;
            }
            StringBuilder stringBuilder = this.CreateKey(new string[]
            {
                MaidHelper.GetGuid(maid),
                slotName,
                material.name,
                texture2D.name
            });

            TextureModifier.FilterParam orAdd = this._filterParams.GetOrAdd(stringBuilder.ToString());
            orAdd.ProcGUI(texture2D);
        }
        // Token: 0x0600008E RID: 142 RVA: 0x00008F94 File Offset: 0x00007194
        public bool UpdateTex(Maid maid, Material mat, EditTarget texEdit)
        {
            Texture2D texture2D = mat.GetTexture(texEdit.propName) as Texture2D;

            if (texture2D == null || string.IsNullOrEmpty(texture2D.name))
            {
                return(false);
            }
            StringBuilder stringBuilder = this.CreateKey(new string[]
            {
                MaidHelper.GetGuid(maid),
                texEdit.slotName,
                mat.name,
                texture2D.name
            });

            TextureModifier.FilterParam orAdd = this._filterParams.GetOrAdd(stringBuilder.ToString());
            if (!orAdd.IsDirty)
            {
                return(false);
            }
            this.FilterTexture(texture2D, orAdd);
            return(true);
        }
        // Token: 0x0600009D RID: 157 RVA: 0x000094D0 File Offset: 0x000076D0
        private void FilterTexture(ICollection <Material> slotMaterials, List <Texture2D> textures, Maid maid, EditTarget texEdit)
        {
            Material  material  = null;
            Texture2D texture2D = null;

            if (slotMaterials != null)
            {
                material = slotMaterials.ElementAtOrDefault(texEdit.matNo);
                if (material != null)
                {
                    texture2D = (material.GetTexture(texEdit.propName) as Texture2D);
                }
            }
            if (material == null || texture2D == null)
            {
                return;
            }
            TextureModifier.FilterParam filterParam = this.GetFilterParam(maid, texEdit.slotName, material, texEdit.propName);
            if (!filterParam.Dirty.Value)
            {
                return;
            }
            this.FilterTexture(texture2D, filterParam);
        }
コード例 #11
0
        // Token: 0x06000066 RID: 102 RVA: 0x00007270 File Offset: 0x00005470
        public void Save(string fileName, string presetName, Dictionary <string, bool> dDelNodes)
        {
            Maid       currentMaid = this._holder.CurrentMaid;
            PresetData presetData  = new PresetData
            {
                name = presetName
            };

            foreach (SlotInfo slotInfo in ACConstants.SlotNames.Values)
            {
                if (slotInfo.enable)
                {
                    TBodySkin slot = currentMaid.body0.GetSlot((int)slotInfo.Id);
                    SlotState mask;
                    if (slot.obj == null)
                    {
                        mask = SlotState.NotLoaded;
                    }
                    else if (!slot.boVisible)
                    {
                        mask = SlotState.Masked;
                    }
                    else
                    {
                        mask = SlotState.Displayed;
                    }
                    Material[] materials = this._holder.GetMaterials(slot);
                    if (materials.Length != 0)
                    {
                        CCSlot ccslot = new CCSlot(slotInfo.Id)
                        {
                            mask = mask
                        };
                        foreach (Material material in materials)
                        {
                            ShaderType shaderType = ShaderType.Resolve(material.shader.name);
                            if (shaderType != ShaderType.UNKNOWN)
                            {
                                CCMaterial ccmaterial = new CCMaterial(material, shaderType);
                                ccslot.Add(ccmaterial);
                                foreach (ShaderPropTex shaderPropTex in shaderType.texProps)
                                {
                                    Texture2D texture2D = material.GetTexture(shaderPropTex.propId) as Texture2D;
                                    if (!(texture2D == null) && !string.IsNullOrEmpty(texture2D.name))
                                    {
                                        TextureInfo textureInfo = new TextureInfo();
                                        ccmaterial.Add(textureInfo);
                                        textureInfo.propName = shaderPropTex.keyName;
                                        textureInfo.texFile  = texture2D.name;
                                        TextureModifier.FilterParam filter = this._texModifier.GetFilter(currentMaid, slotInfo.Id.ToString(), material.name, texture2D.name);
                                        if (filter != null && !filter.HasNotChanged())
                                        {
                                            textureInfo.filter = new TexFilter(filter);
                                        }
                                        Vector2 textureOffset = material.GetTextureOffset(shaderPropTex.propId);
                                        if (Math.Abs(textureOffset.x) > 0.001f)
                                        {
                                            textureInfo.offsetX = new float?(textureOffset.x);
                                        }
                                        if (Math.Abs(textureOffset.y) > 0.001f)
                                        {
                                            textureInfo.offsetY = new float?(textureOffset.y);
                                        }
                                        Vector2 textureScale = material.GetTextureScale(shaderPropTex.propId);
                                        if (Math.Abs(textureScale.x) > 0.001f)
                                        {
                                            textureInfo.scaleX = new float?(textureScale.x);
                                        }
                                        if (Math.Abs(textureScale.y) > 0.001f)
                                        {
                                            textureInfo.scaleY = new float?(textureScale.y);
                                        }
                                    }
                                }
                            }
                        }
                        presetData.slots.Add(ccslot);
                    }
                }
            }
            for (int k = TypeUtil.BODY_START; k <= TypeUtil.BODY_END; k++)
            {
                MPN      mpn  = (MPN)Enum.ToObject(typeof(MPN), k);
                MaidProp prop = currentMaid.GetProp(mpn);
                if (prop != null)
                {
                    if (prop.type == 1 || prop.type == 2)
                    {
                        presetData.mpnvals.Add(new CCMPNValue(mpn, prop.value, prop.min, prop.max));
                    }
                    else if (prop.type == 3 && prop.nFileNameRID != 0)
                    {
                        presetData.mpns.Add(new CCMPN(mpn, prop.strFileName));
                    }
                }
            }
            for (int l = TypeUtil.WEAR_START; l <= TypeUtil.WEAR_END; l++)
            {
                MPN      mpn2  = (MPN)Enum.ToObject(typeof(MPN), l);
                MaidProp prop2 = currentMaid.GetProp(mpn2);
                if (prop2 != null && prop2.nFileNameRID != 0)
                {
                    presetData.mpns.Add(new CCMPN(mpn2, prop2.strFileName));
                }
            }
            for (MaidParts.PARTS_COLOR parts_COLOR = TypeUtil.PARTS_COLOR_START; parts_COLOR <= TypeUtil.PARTS_COLOR_END; parts_COLOR++)
            {
                MaidParts.PartsColor partsColor = currentMaid.Parts.GetPartsColor(parts_COLOR);
                presetData.partsColors[parts_COLOR.ToString()] = new CCPartsColor(partsColor);
            }
            presetData.delNodes = new Dictionary <string, bool>(dDelNodes);
            LogUtil.Debug(new object[]
            {
                "create preset...",
                fileName
            });
            this.SavePreset(fileName, presetData);
        }
コード例 #12
0
 // Token: 0x0600006A RID: 106 RVA: 0x000079DC File Offset: 0x00005BDC
 public void ApplyPresetMaterial(Maid maid, PresetData preset)
 {
     if (maid == null)
     {
         maid = this._holder.CurrentMaid;
     }
     if (maid == null)
     {
         return;
     }
     foreach (CCSlot ccslot in preset.slots)
     {
         int id = (int)ccslot.id;
         if (id < maid.body0.goSlot.Count)
         {
             TBodySkin  slot      = maid.body0.GetSlot(id);
             Material[] materials = this._holder.GetMaterials(slot);
             if (slot.obj == null)
             {
                 LogUtil.Debug(new object[]
                 {
                     "slot.obj null. name=",
                     ccslot.id
                 });
             }
             if (materials.Any <Material>())
             {
                 string text = ccslot.id.ToString();
                 int    num  = -1;
                 foreach (CCMaterial ccmaterial in ccslot.materials)
                 {
                     if (++num < materials.Length)
                     {
                         Material material = materials[num];
                         if (ccmaterial.name != material.name)
                         {
                             LogUtil.DebugF("Material name mismatched. skipping apply preset-slot={0}, matNo={1}, name=({2}<=>{3})", new object[]
                             {
                                 ccslot.id,
                                 num,
                                 ccmaterial.name,
                                 material.name
                             });
                             continue;
                         }
                         ccmaterial.Apply(material);
                         List <TextureInfo> texList = ccmaterial.texList;
                         if (texList == null)
                         {
                             continue;
                         }
                         using (List <TextureInfo> .Enumerator enumerator3 = texList.GetEnumerator())
                         {
                             while (enumerator3.MoveNext())
                             {
                                 TextureInfo textureInfo = enumerator3.Current;
                                 Texture     texture     = material.GetTexture(textureInfo.propName);
                                 if (texture == null || texture.name != textureInfo.texFile)
                                 {
                                     string text2 = textureInfo.texFile;
                                     if (text2.LastIndexOf('.') == -1)
                                     {
                                         text2 += FileConst.EXT_TEXTURE;
                                     }
                                     if (this._fileUtil.Exists(text2))
                                     {
                                         maid.body0.ChangeTex(text, num, textureInfo.propName, text2, null, MaidParts.PARTS_COLOR.NONE);
                                         Texture texture2 = material.GetTexture(textureInfo.propName);
                                         if (texture2 != null)
                                         {
                                             texture2.name = textureInfo.texFile;
                                         }
                                     }
                                     else
                                     {
                                         LogUtil.Debug(new object[]
                                         {
                                             "texture file not found. file=",
                                             text2
                                         });
                                     }
                                 }
                                 if (textureInfo.offsetX != null || textureInfo.offsetY != null)
                                 {
                                     Vector2 textureOffset = material.GetTextureOffset(textureInfo.propName);
                                     if (textureInfo.offsetX != null)
                                     {
                                         textureOffset.x = textureInfo.offsetX.Value;
                                     }
                                     if (textureInfo.offsetY != null)
                                     {
                                         textureOffset.y = textureInfo.offsetY.Value;
                                     }
                                     material.SetTextureOffset(textureInfo.propName, textureOffset);
                                 }
                                 if (textureInfo.scaleX != null || textureInfo.scaleY != null)
                                 {
                                     Vector2 textureScale = material.GetTextureScale(textureInfo.propName);
                                     if (textureInfo.scaleX != null)
                                     {
                                         textureScale.x = textureInfo.scaleX.Value;
                                     }
                                     if (textureInfo.scaleY != null)
                                     {
                                         textureScale.y = textureInfo.scaleY.Value;
                                     }
                                     material.SetTextureScale(textureInfo.propName, textureScale);
                                 }
                                 if (textureInfo.filter != null)
                                 {
                                     TextureModifier.FilterParam filter = textureInfo.filter.ToFilter();
                                     this._texModifier.ApplyFilter(maid, text, material, textureInfo.propName, filter);
                                 }
                             }
                             continue;
                         }
                     }
                     LogUtil.LogF("ACCPresetに指定されたマテリアル番号に対応するマテリアルが見つかりません。スキップします。 slot={0}, matNo={1}, name={2}", new object[]
                     {
                         ccslot.id,
                         num,
                         ccmaterial.name
                     });
                     break;
                 }
             }
         }
     }
 }
 // Token: 0x060000A6 RID: 166 RVA: 0x0000993A File Offset: 0x00007B3A
 public void Add(string key, TextureModifier.FilterParam filter)
 {
     this._params[key] = filter;
 }