Esempio n. 1
0
        private void readMorphContainer(BinaryReader br)
        {
            uint num = (uint)br.ReadUInt16();

            this.Morphs.Clear();
            for (uint num2 = 0u; num2 < num; num2 += 1u)
            {
                MMDMorph mMDMorph = new MMDMorph();
                mMDMorph.Name = this.readString(br, 20);
                uint num3 = br.ReadUInt32();
                if (br.ReadByte() == 0)
                {
                    this.baseMorph = mMDMorph;
                }
                else
                {
                    this.Morphs.Add(mMDMorph);
                }
                mMDMorph.Type          = MMDMorphType.Vertex;
                mMDMorph.VertexIndices = new uint[num3];
                mMDMorph.VertexData    = new float[num3 * 3u];
                for (uint num4 = 0u; num4 < num3; num4 += 1u)
                {
                    mMDMorph.VertexIndices[(int)((UIntPtr)num4)]          = br.ReadUInt32();
                    mMDMorph.VertexData[(int)((UIntPtr)(num4 * 3u))]      = br.ReadSingle();
                    mMDMorph.VertexData[(int)((UIntPtr)(num4 * 3u + 1u))] = br.ReadSingle();
                    mMDMorph.VertexData[(int)((UIntPtr)(num4 * 3u + 2u))] = br.ReadSingle();
                }
            }
            foreach (MMDMorph current in this.Morphs)
            {
                for (int i = 0; i < current.VertexIndices.Length; i++)
                {
                    current.VertexIndices[i] = this.baseMorph.VertexIndices[(int)((UIntPtr)current.VertexIndices[i])];
                }
            }
        }
Esempio n. 2
0
        private void readMorphContainer(BinaryReader br)
        {
            uint num = br.ReadUInt32();

            this.Morphs.Clear();
            for (uint num2 = 0u; num2 < num; num2 += 1u)
            {
                MMDMorph mMDMorph = new MMDMorph();
                mMDMorph.Name = this.readString(br);
                this.readString(br);
                br.ReadByte();
                mMDMorph.Type = (MMDMorphType)br.ReadByte();
                int num3 = br.ReadInt32();
                if (mMDMorph.Type == MMDMorphType.Vertex)
                {
                    mMDMorph.VertexIndices = new uint[num3];
                    mMDMorph.VertexData    = new float[num3 * 3];
                    for (int i = 0; i < num3; i++)
                    {
                        mMDMorph.VertexIndices[i]      = (uint)this.readVertexIndex(br);
                        mMDMorph.VertexData[i * 3]     = br.ReadSingle();
                        mMDMorph.VertexData[i * 3 + 1] = br.ReadSingle();
                        mMDMorph.VertexData[i * 3 + 2] = br.ReadSingle();
                    }
                }
                else if (mMDMorph.Type == MMDMorphType.UV || mMDMorph.Type == MMDMorphType.AddUV1 || mMDMorph.Type == MMDMorphType.AddUV2 || mMDMorph.Type == MMDMorphType.AddUV3 || mMDMorph.Type == MMDMorphType.AddUV4)
                {
                    for (int j = 0; j < num3; j++)
                    {
                        this.readVertexIndex(br);
                        br.ReadSingle();
                        br.ReadSingle();
                        br.ReadSingle();
                        br.ReadSingle();
                    }
                }
                else if (mMDMorph.Type == MMDMorphType.Bone)
                {
                    for (int k = 0; k < num3; k++)
                    {
                        this.readBoneIndex(br);
                        br.ReadSingle();
                        br.ReadSingle();
                        br.ReadSingle();
                        br.ReadSingle();
                        br.ReadSingle();
                        br.ReadSingle();
                        br.ReadSingle();
                    }
                }
                else if (mMDMorph.Type == MMDMorphType.Material)
                {
                    mMDMorph.MatgerialMorphData = new List <MMDMatgerialMorphData>();
                    for (int l = 0; l < num3; l++)
                    {
                        MMDMatgerialMorphData mMDMatgerialMorphData = new MMDMatgerialMorphData();
                        mMDMatgerialMorphData.MaterialIndex = this.readMaterialIndex(br);
                        mMDMatgerialMorphData.OffsetType    = br.ReadByte();
                        mMDMatgerialMorphData.diffuse       = this.readColor(br, true);
                        mMDMatgerialMorphData.specular      = this.readColor(br, false);
                        mMDMatgerialMorphData.specularPower = br.ReadSingle();
                        mMDMatgerialMorphData.ambient       = this.readColor(br, false);
                        mMDMatgerialMorphData.edgeColor     = this.readColor(br, true);
                        mMDMatgerialMorphData.edgeSize      = br.ReadSingle();
                        mMDMatgerialMorphData.texColor      = this.readColor(br, true);
                        mMDMatgerialMorphData.sphereColor   = this.readColor(br, true);
                        mMDMatgerialMorphData.toonColor     = this.readColor(br, true);
                        mMDMorph.MatgerialMorphData.Add(mMDMatgerialMorphData);
                    }
                }
                else if (mMDMorph.Type == MMDMorphType.Group)
                {
                    for (int m = 0; m < num3; m++)
                    {
                        this.readMorphIndex(br);
                        br.ReadSingle();
                    }
                }
                this.Morphs.Add(mMDMorph);
            }
        }