Exemple #1
0
        public sviParser(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream);

            version = reader.ReadInt32();
            if (version != 100)
            {
                throw new Exception("SVI bad beginning: 0x" + version.ToString("X"));
            }
            meshName = reader.ReadName();
            submeshIdx = reader.ReadInt32();
            int numIndices = reader.ReadInt32();
            indices = reader.ReadUInt16Array(numIndices);

            positionsPresent = reader.ReadByte();
            if (positionsPresent == 1)
            {
                positions = reader.ReadVector3Array(numIndices);
            }

            bonesPresent = reader.ReadByte();
            if (bonesPresent == 1)
            {
                boneWeights3 = new float[numIndices][];
                for (ushort i = 0; i < numIndices; i++)
                {
                    boneWeights3[i] = reader.ReadSingleArray(3);
                }
                boneIndices = new byte[numIndices][];
                for (ushort i = 0; i < numIndices; i++)
                {
                    boneIndices[i] = reader.ReadBytes(4);
                }

                int numBones = reader.ReadInt32();
                bones = new sviBone[numBones];
                for (int i = 0; i < numBones; i++)
                {
                    bones[i] = new sviBone();
                    bones[i].name = reader.ReadName();
                    bones[i].boneIdx = reader.ReadInt32();
                    bones[i].matrix = reader.ReadMatrix();
                }
            }

            normalsPresent = reader.ReadByte();
            if (normalsPresent == 1)
            {
                normals = reader.ReadVector3Array(numIndices);
            }

            uvsPresent = reader.ReadByte();
            if (uvsPresent == 1)
            {
                uvs = reader.ReadVector2Array(numIndices);
            }

            futureSectionPresent = reader.ReadByte();
            if (futureSectionPresent != 0)
            {
                throw new Exception("SVI future section present");
            }
        }
Exemple #2
0
        public sviParser(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream);

            version = reader.ReadInt32();
            if (version != 100)
            {
                throw new Exception("SVI bad beginning: 0x" + version.ToString("X"));
            }
            meshName   = reader.ReadName();
            submeshIdx = reader.ReadInt32();
            int numIndices = reader.ReadInt32();

            indices = reader.ReadUInt16Array(numIndices);

            positionsPresent = reader.ReadByte();
            if (positionsPresent == 1)
            {
                positions = reader.ReadVector3Array(numIndices);
            }

            bonesPresent = reader.ReadByte();
            if (bonesPresent == 1)
            {
                boneWeights3 = new float[numIndices][];
                for (ushort i = 0; i < numIndices; i++)
                {
                    boneWeights3[i] = reader.ReadSingleArray(3);
                }
                boneIndices = new byte[numIndices][];
                for (ushort i = 0; i < numIndices; i++)
                {
                    boneIndices[i] = reader.ReadBytes(4);
                }

                int numBones = reader.ReadInt32();
                bones = new sviBone[numBones];
                for (int i = 0; i < numBones; i++)
                {
                    bones[i]         = new sviBone();
                    bones[i].name    = reader.ReadName();
                    bones[i].boneIdx = reader.ReadInt32();
                    bones[i].matrix  = reader.ReadMatrix();
                }
            }

            normalsPresent = reader.ReadByte();
            if (normalsPresent == 1)
            {
                normals = reader.ReadVector3Array(numIndices);
            }

            uvsPresent = reader.ReadByte();
            if (uvsPresent == 1)
            {
                uvs = reader.ReadVector2Array(numIndices);
            }

            futureSectionPresent = reader.ReadByte();
            if (futureSectionPresent != 0)
            {
                throw new Exception("SVI future section present");
            }
        }