Пример #1
0
        public void Parse(DataReader reader)
        {
            Name = reader.ReadString(reader.ReadInt32());
            if (reader.BaseStream.Position % 4 != 0)
            {
                reader.BaseStream.Position += 4 - (reader.BaseStream.Position % 4);
            }

            int subMeshCount = reader.ReadInt32();

            for (int i = 0; i < subMeshCount; i++)
            {
                UnitySubMesh sm = new UnitySubMesh();
                sm.Parse(reader);
                SubMesh.Add(sm);
            }

            int blendCount = reader.ReadInt32();

            for (int i = 0; i < blendCount; i++)
            {
                var sm = new UnityBlendShapeVertex();
                sm.Parse(reader);
                BlendShapeVertices.Add(sm);
            }

            int blendShapeCount = reader.ReadInt32();

            for (int i = 0; i < blendShapeCount; i++)
            {
                var sm = new UnityBlendShape();
                sm.Parse(reader);
                BlendShapes.Add(sm);
            }
            int blendShapeChannelCount = reader.ReadInt32();

            for (int i = 0; i < blendShapeChannelCount; i++)
            {
                var sm = new UnityBlendShapeChannel();
                sm.Parse(reader);
                BlendShapeChannels.Add(sm);
            }
            int fullWeightCount = reader.ReadInt32();

            for (int i = 0; i < fullWeightCount; i++)
            {
                var sm = reader.ReadSingle();
                FullWeights.Add(sm);
            }

            int bindPoseCount = reader.ReadInt32();

            for (int i = 0; i < bindPoseCount; i++)
            {
                var sm = new Matrix4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(),
                                     reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(),
                                     reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(),
                                     reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
                BindPoses.Add(sm);
            }

            int boneNameHashCount = reader.ReadInt32();

            for (int i = 0; i < boneNameHashCount; i++)
            {
                BoneNameHashes.Add(reader.ReadInt32());
            }

            RootBoneNameHash = reader.ReadInt32();
            MeshCompression  = reader.ReadByte();
            IsReadable       = reader.ReadByte() == 1;
            KeepVertices     = reader.ReadByte() == 1;
            KeepIndices      = reader.ReadByte() == 1;

            int IndexBufferCount = reader.ReadInt32();

            for (int i = 0; i < IndexBufferCount / 2; i++)
            {
                IndexBuffer.Add(reader.ReadUInt16());
            }

            int BoneICount = reader.ReadInt32();

            for (int i = 0; i < BoneICount; i++)
            {
                var bi = new UnityBoneInfluence();
                bi.Parse(reader);
                BoneInfluences.Add(bi);
            }

            VertexData.Parse(reader);

            reader.PrintPosition();

            CompVertices.Parse(reader);

            reader.PrintPosition();
        }