public void ToStreamEx_TexTable(Stream s, PmxTextureTable tx, PmxElementFormat f = null)
        {
            PmxStreamHelper.WriteString(s, Name, f);
            PmxStreamHelper.WriteString(s, NameE, f);
            V4_BytesConvert.ToStream(s, Diffuse);
            V3_BytesConvert.ToStream(s, Specular);
            PmxStreamHelper.WriteElement_Float(s, Power);
            V3_BytesConvert.ToStream(s, Ambient);
            s.WriteByte((byte)Flags);
            V4_BytesConvert.ToStream(s, EdgeColor);
            PmxStreamHelper.WriteElement_Float(s, EdgeSize);
            PmxStreamHelper.WriteElement_Int32(s, tx.GetIndex(Tex), f.TexSize);
            PmxStreamHelper.WriteElement_Int32(s, tx.GetIndex(Sphere), f.TexSize);
            s.WriteByte((byte)SphereMode);
            int toonIndex = SystemToon.GetToonIndex(Toon);

            if (toonIndex < 0)
            {
                s.WriteByte(0);
                PmxStreamHelper.WriteElement_Int32(s, tx.GetIndex(Toon), f.TexSize);
            }
            else
            {
                s.WriteByte(1);
                s.WriteByte((byte)toonIndex);
            }
            PmxStreamHelper.WriteString(s, Memo, f);
            PmxStreamHelper.WriteElement_Int32(s, FaceCount);
            if (f.WithID)
            {
                PmxStreamHelper.WriteElement_UInt(s, base.UID);
                PmxStreamHelper.WriteElement_UInt(s, base.CID);
            }
        }
Exemplo n.º 2
0
        // Token: 0x060001AB RID: 427 RVA: 0x000102D8 File Offset: 0x0000E4D8
        public void ToStreamEx_TexTable(Stream s, PmxTextureTable tx, PmxElementFormat f)
        {
            PmxStreamHelper.WriteString(s, this.Name, f);
            PmxStreamHelper.WriteString(s, this.NameE, f);
            V4_BytesConvert.ToStream(s, V4_BytesConvert.ColorToVector4(this.Diffuse));
            V3_BytesConvert.ToStream(s, V3_BytesConvert.ColorToVector3(this.Specular));
            PmxStreamHelper.WriteElement_Float(s, this.Power);
            V3_BytesConvert.ToStream(s, V3_BytesConvert.ColorToVector3(this.Ambient));
            s.WriteByte((byte)this.Flags);
            V4_BytesConvert.ToStream(s, V4_BytesConvert.ColorToVector4(this.EdgeColor));
            PmxStreamHelper.WriteElement_Float(s, this.EdgeSize);
            PmxStreamHelper.WriteElement_Int32(s, tx.GetIndex(this.Tex), f.TexSize, true);
            PmxStreamHelper.WriteElement_Int32(s, tx.GetIndex(this.Sphere), f.TexSize, true);
            s.WriteByte((byte)this.SphereMode);
            int  toonIndex = SystemToon.GetToonIndex(this.Toon);
            bool flag      = toonIndex < 0;

            if (flag)
            {
                s.WriteByte(0);
                PmxStreamHelper.WriteElement_Int32(s, tx.GetIndex(this.Toon), f.TexSize, true);
            }
            else
            {
                s.WriteByte(1);
                s.WriteByte((byte)toonIndex);
            }
            PmxStreamHelper.WriteString(s, this.Memo, f);
            PmxStreamHelper.WriteElement_Int32(s, this.FaceCount, 4, true);
        }
Exemplo n.º 3
0
        // Token: 0x060002B3 RID: 691 RVA: 0x00014E10 File Offset: 0x00013010
        public SystemToon.ToonInfo GetToonInfo(List <PmxMaterial> list)
        {
            int  count = list.Count;
            bool flag  = count < 0;

            SystemToon.ToonInfo result;
            if (flag)
            {
                result = null;
            }
            else
            {
                SystemToon.ToonInfo toonInfo        = new SystemToon.ToonInfo(count);
                bool[]                   array      = new bool[10];
                List <string>            list2      = new List <string>(count);
                Dictionary <string, int> dictionary = new Dictionary <string, int>(count);
                for (int i = 0; i < count; i++)
                {
                    PmxMaterial pmxMaterial = list[i];
                    bool        flag2       = string.IsNullOrEmpty(pmxMaterial.Toon);
                    if (flag2)
                    {
                        toonInfo.MaterialToon[i] = -1;
                    }
                    else
                    {
                        int toonIndex = SystemToon.GetToonIndex(pmxMaterial.Toon);
                        toonInfo.MaterialToon[i] = toonIndex;
                        bool flag3 = -1 <= toonIndex && toonIndex < 10;
                        if (flag3)
                        {
                            bool flag4 = toonIndex >= 0;
                            if (flag4)
                            {
                                array[toonIndex] = true;
                            }
                        }
                        else
                        {
                            bool flag5 = !dictionary.ContainsKey(pmxMaterial.Toon);
                            if (flag5)
                            {
                                list2.Add(pmxMaterial.Toon);
                                dictionary.Add(pmxMaterial.Toon, 0);
                            }
                        }
                    }
                }
                bool flag6 = list2.Count > 0;
                if (flag6)
                {
                    Dictionary <string, int> dictionary2 = new Dictionary <string, int>(list2.Count);
                    int num = 0;
                    for (int j = 0; j < list2.Count; j++)
                    {
                        for (int k = num; k < array.Length; k++)
                        {
                            bool flag7 = !array[k];
                            if (flag7)
                            {
                                toonInfo.ToonNames[k] = list2[j];
                                dictionary2.Add(list2[j], k);
                                array[k] = true;
                                num      = k + 1;
                                break;
                            }
                        }
                    }
                    for (int l = 0; l < count; l++)
                    {
                        bool flag8 = toonInfo.MaterialToon[l] < -1;
                        if (flag8)
                        {
                            PmxMaterial pmxMaterial2 = list[l];
                            bool        flag9        = dictionary2.ContainsKey(pmxMaterial2.Toon);
                            if (flag9)
                            {
                                toonInfo.MaterialToon[l] = dictionary2[pmxMaterial2.Toon];
                            }
                            else
                            {
                                toonInfo.MaterialToon[l] = -1;
                                toonInfo.IsRejection     = true;
                            }
                        }
                    }
                }
                result = toonInfo;
            }
            return(result);
        }