Пример #1
0
        // Token: 0x060000B4 RID: 180 RVA: 0x0000D190 File Offset: 0x0000B390
        public void ToStreamEx(Stream s, PmxElementFormat f)
        {
            PmxHeader       header          = this.Header;
            PmxTextureTable pmxTextureTable = new PmxTextureTable(this.MaterialList);

            this.UpdateElementFormatSize(header.ElementFormat, pmxTextureTable);
            header.ToStreamEx(s, null);
            this.ModelInfo.ToStreamEx(s, header.ElementFormat);
            PmxStreamHelper.WriteElement_Int32(s, this.VertexList.Count, 4, true);
            for (int i = 0; i < this.VertexList.Count; i++)
            {
                this.VertexList[i].ToStreamEx(s, header.ElementFormat);
            }
            PmxStreamHelper.WriteElement_Int32(s, this.FaceList.Count, 4, true);
            for (int j = 0; j < this.FaceList.Count; j++)
            {
                PmxStreamHelper.WriteElement_Int32(s, this.FaceList[j], header.ElementFormat.VertexSize, false);
            }
            pmxTextureTable.ToStreamEx(s, header.ElementFormat);
            PmxStreamHelper.WriteElement_Int32(s, this.MaterialList.Count, 4, true);
            for (int k = 0; k < this.MaterialList.Count; k++)
            {
                this.MaterialList[k].ToStreamEx_TexTable(s, pmxTextureTable, header.ElementFormat);
            }
            PmxStreamHelper.WriteElement_Int32(s, this.BoneList.Count, 4, true);
            for (int l = 0; l < this.BoneList.Count; l++)
            {
                this.BoneList[l].ToStreamEx(s, header.ElementFormat);
            }
            PmxStreamHelper.WriteElement_Int32(s, this.MorphList.Count, 4, true);
            for (int m = 0; m < this.MorphList.Count; m++)
            {
                this.MorphList[m].ToStreamEx(s, header.ElementFormat);
            }
            PmxStreamHelper.WriteElement_Int32(s, this.NodeList.Count, 4, true);
            for (int n = 0; n < this.NodeList.Count; n++)
            {
                this.NodeList[n].ToStreamEx(s, header.ElementFormat);
            }
            PmxStreamHelper.WriteElement_Int32(s, this.BodyList.Count, 4, true);
            for (int num = 0; num < this.BodyList.Count; num++)
            {
                this.BodyList[num].ToStreamEx(s, header.ElementFormat);
            }
            PmxStreamHelper.WriteElement_Int32(s, this.JointList.Count, 4, true);
            for (int num2 = 0; num2 < this.JointList.Count; num2++)
            {
                this.JointList[num2].ToStreamEx(s, header.ElementFormat);
            }
            bool flag = header.Ver >= 2.1f;

            if (flag)
            {
                PmxStreamHelper.WriteElement_Int32(s, this.SoftBodyList.Count, 4, true);
                for (int num3 = 0; num3 < this.SoftBodyList.Count; num3++)
                {
                    this.SoftBodyList[num3].ToStreamEx(s, header.ElementFormat);
                }
            }
        }
Пример #2
0
        public virtual void ToStream(Stream s, bool id)
        {
            PmxHeader header = Header;

            header.ElementFormat.WithID = id;
            PmxTextureTable pmxTextureTable = new PmxTextureTable(MaterialList);

            UpdateElementFormatSize(header.ElementFormat, pmxTextureTable);
            header.ToStreamEx(s);
            ModelInfo.ToStreamEx(s, header.ElementFormat);
            PmxStreamHelper.WriteElement_Int32(s, VertexList.Count);
            for (int i = 0; i < VertexList.Count; i++)
            {
                VertexList[i].ToStreamEx(s, header.ElementFormat);
            }
            PmxStreamHelper.WriteElement_Int32(s, FaceList.Count);
            for (int j = 0; j < FaceList.Count; j++)
            {
                PmxStreamHelper.WriteElement_Int32(s, FaceList[j], header.ElementFormat.VertexSize, signed: false);
            }
            pmxTextureTable.ToStreamEx(s, header.ElementFormat);
            PmxStreamHelper.WriteElement_Int32(s, MaterialList.Count);
            for (int k = 0; k < MaterialList.Count; k++)
            {
                MaterialList[k].ToStreamEx_TexTable(s, pmxTextureTable, header.ElementFormat);
            }
            PmxStreamHelper.WriteElement_Int32(s, BoneList.Count);
            for (int l = 0; l < BoneList.Count; l++)
            {
                BoneList[l].ToStreamEx(s, header.ElementFormat);
            }
            if (header.Ver < 2.1f)
            {
                int num = MorphList.Where((PmxMorph mp) => mp.IsImpulse).Count();
                PmxStreamHelper.WriteElement_Int32(s, MorphList.Count - num);
            }
            else
            {
                PmxStreamHelper.WriteElement_Int32(s, MorphList.Count);
            }
            for (int m = 0; m < MorphList.Count; m++)
            {
                MorphList[m].ToStreamEx(s, header.ElementFormat);
            }
            PmxStreamHelper.WriteElement_Int32(s, NodeList.Count);
            for (int n = 0; n < NodeList.Count; n++)
            {
                NodeList[n].ToStreamEx(s, header.ElementFormat);
            }
            PmxStreamHelper.WriteElement_Int32(s, BodyList.Count);
            for (int num2 = 0; num2 < BodyList.Count; num2++)
            {
                BodyList[num2].ToStreamEx(s, header.ElementFormat);
            }
            PmxStreamHelper.WriteElement_Int32(s, JointList.Count);
            for (int num3 = 0; num3 < JointList.Count; num3++)
            {
                JointList[num3].ToStreamEx(s, header.ElementFormat);
            }
            if (header.Ver >= 2.1f)
            {
                PmxStreamHelper.WriteElement_Int32(s, SoftBodyList.Count);
                for (int num4 = 0; num4 < SoftBodyList.Count; num4++)
                {
                    SoftBodyList[num4].ToStreamEx(s, header.ElementFormat);
                }
            }
            if (id)
            {
                PmxStreamHelper.WriteString(s, FilePath, header.ElementFormat);
            }
            header.ElementFormat.WithID = false;
        }