Exemple #1
0
        public VxlReader(Stream s)
        {
            if (!s.ReadASCII(16).StartsWith("Voxel Animation"))
                throw new InvalidDataException("Invalid vxl header");

            s.ReadUInt32();
            LimbCount = s.ReadUInt32();
            s.ReadUInt32();
            BodySize = s.ReadUInt32();
            s.Seek(770, SeekOrigin.Current);

            // Read Limb headers
            Limbs = new VxlLimb[LimbCount];
            for (var i = 0; i < LimbCount; i++)
            {
                Limbs[i] = new VxlLimb();
                Limbs[i].Name = s.ReadASCII(16);
                s.Seek(12, SeekOrigin.Current);
            }

            // Skip to the Limb footers
            s.Seek(802 + 28*LimbCount + BodySize, SeekOrigin.Begin);

            var LimbDataOffset = new uint[LimbCount];
            for (var i = 0; i < LimbCount; i++)
            {
                LimbDataOffset[i] = s.ReadUInt32();
                s.Seek(8, SeekOrigin.Current);
                Limbs[i].Scale = s.ReadFloat();
                s.Seek(48, SeekOrigin.Current);

                Limbs[i].Bounds = new float[6];
                for (var j = 0; j < 6; j++)
                    Limbs[i].Bounds[j] = s.ReadFloat();
                Limbs[i].Size = s.ReadBytes(3);
                Limbs[i].Type = (NormalType)s.ReadByte();
            }

            for (var i = 0; i < LimbCount; i++)
            {
                s.Seek(802 + 28*LimbCount + LimbDataOffset[i], SeekOrigin.Begin);
                ReadVoxelData(s, Limbs[i]);
            }
        }
Exemple #2
0
        public IdxEntry(Stream s)
        {
            var name = s.ReadASCII(16);
            var pos = name.IndexOf('\0');
            if (pos != 0)
                name = name.Substring(0, pos);

            Filename = string.Concat(name, ".wav");
            Offset = s.ReadUInt32();
            Length = s.ReadUInt32();
            SampleRate = s.ReadUInt32();
            Flags = s.ReadUInt32();
            ChunkSize = s.ReadUInt32();
        }
Exemple #3
0
		public IdxEntry(Stream s)
		{
			var asciiname = s.ReadASCII(16);

			var pos = asciiname.IndexOf('\0');
			if (pos != 0)
				asciiname = asciiname.Substring(0, pos);

			Name = asciiname;
			Extension = DefaultExtension;
			Offset = s.ReadUInt32();
			Length = s.ReadUInt32();
			SampleRate = s.ReadUInt32();
			Flags = s.ReadUInt32();
			ChunkSize = s.ReadUInt32();
			Hash = HashFilename(string.Concat(Name, ".", Extension), PackageHashType.CRC32);
		}
Exemple #4
0
        public IdxReader(Stream s)
        {
            s.Seek(0, SeekOrigin.Begin);

            var id = s.ReadASCII(4);

            if (id != "GABA")
                throw new InvalidDataException("Unable to load Idx file, did not find magic id, found {0} instead".F(id));

            var two = s.ReadInt32();

            if (two != 2)
                throw new InvalidDataException("Unable to load Idx file, did not find magic number 2, found {0} instead".F(two));

            SoundCount = s.ReadInt32();

            Entries = new List<IdxEntry>();

            for (var i = 0; i < SoundCount; i++)
                Entries.Add(new IdxEntry(s));
        }
Exemple #5
0
        bool IsIcnD2(Stream s)
        {
            if (s.Length < 0x20)
                return false;

            var start = s.Position;

            s.Position = 0x18;
            if (s.ReadASCII(4) != "SSET")
            {
                s.Position = start;
                return false;
            }

            ssetLength = int2.Swap(s.ReadUInt32()) - 8;
            s.Position += 3;
            ssetOffset = 0x18 + 16;
            if (s.Length < ssetOffset + ssetLength)
            {
                s.Position = start;
                return false;
            }

            s.Position = ssetOffset + ssetLength;
            if (s.ReadASCII(4) != "RPAL")
            {
                s.Position = start;
                return false;
            }

            rpalLength = int2.Swap(s.ReadUInt32());
            rpalOffset = ssetOffset + ssetLength + 8;
            if (s.Length < rpalOffset + rpalLength)
            {
                s.Position = start;
                return false;
            }

            s.Position = rpalOffset + rpalLength;
            if (s.ReadASCII(4) != "RTBL")
            {
                s.Position = start;
                return false;
            }

            rtblLength = int2.Swap(s.ReadUInt32());
            rtblOffset = rpalOffset + rpalLength + 8;

            if (s.Length < rtblOffset + rtblLength)
            {
                s.Position = start;
                return false;
            }

            numTiles = ssetLength / TileSize;

            if (rtblLength < numTiles)
            {
                s.Position = start;
                return false;
            }

            s.Position = start;
            return true;
        }