Exemple #1
0
        public void Read(HsdfFile header, FileReader reader)
        {
            reader.Seek(-4);
            uint size = reader.ReadUInt32();

            Name = reader.ReadString((int)size, true);
        }
Exemple #2
0
        private void UpdateFileNames(string FileName)
        {
            string name = System.IO.Path.GetFileNameWithoutExtension(FileName);

            for (int i = 0; i < files.Count; i++)
            {
                files[i].FileName = $"{name}{string.Format("{0:00}", i)}";

                using (var fileReader = new FileReader(files[i].FileData))
                {
                    fileReader.SetByteOrder(true);
                    string magic = fileReader.ReadString(4, Encoding.ASCII);
                    if (magic == "HBDF")
                    {
                        files[i].FileName = $"{files[i].FileName}.hbdf";
                        if (HsdfFile.HasMeshes(files[i].FileData))
                        {
                            files[i].ImageKey = "model";
                            files[i].FileName = $"Models/{files[i].FileName}.hbdf";
                        }
                        else
                        {
                            files[i].FileName = $"Animations/{files[i].FileName}.hbdf";
                        }
                    }
                    else
                    {
                        files[i].FileName = $"{files[i].FileName}.dat";
                    }
                }
            }
        }
Exemple #3
0
        public void Read(HsdfFile header, FileReader reader)
        {
            Name = ((NameBlock)header.ReadBlock(reader)).Name;
            uint size = reader.ReadUInt32();

            CompressionFlags = reader.ReadUInt32();
            Data             = reader.ReadBytes((int)size);
            if (CompressionFlags == 1)
            {
                Data = LZ77.Decompress(Data);
            }
        }
        public void Read(HsdfFile header, FileReader reader)
        {
            reader.Seek(-4);
            uint size = reader.ReadUInt32();
            long pos  = reader.Position;

            while (reader.Position < pos + size)
            {
                uint offset = (uint)(reader.Position - pos);
                Strings.Add(offset, reader.ReadZeroTerminatedString());
            }
            reader.Align(4);
        }
Exemple #5
0
        public void Read(HsdfFile header, FileReader reader)
        {
            ScaleX   = reader.ReadSingleInt();
            ScaleY   = reader.ReadSingleInt();
            ScaleZ   = reader.ReadSingleInt();
            Unknown1 = reader.ReadUInt32();
            Unknown2 = reader.ReadUInt32();
            Unknown3 = reader.ReadUInt32();
            Unknown4 = reader.ReadUInt32();
            ushort numBlocks = reader.ReadUInt16();
            ushort dataSize  = reader.ReadUInt16();

            PolyGroups = reader.ReadMultipleStructs <PolyGroup>((int)numBlocks);
            Data       = reader.ReadBytes(dataSize);
        }
Exemple #6
0
        public void Read(HsdfFile header, FileReader reader)
        {
            reader.Seek(-4);
            uint size = reader.ReadUInt32();
            long pos  = reader.Position;

            if (size > 12)
            {
                reader.Seek(8); //padding
                Name = ((NameBlock)header.ReadBlock(reader)).Name;
                if (reader.Position < pos + size)
                {
                    PaletteName = ((NameBlock)header.ReadBlock(reader)).Name;
                }
            }
        }
Exemple #7
0
        public void Read(HsdfFile header, FileReader reader)
        {
            Name   = ((NameBlock)header.ReadBlock(reader)).Name;
            Format = (NitroTex.NitroTexFormat)reader.ReadUInt32();
            Width  = reader.ReadUInt16();
            Height = reader.ReadUInt16();
            Params = reader.ReadUInt32();
            uint textureSize = reader.ReadUInt32();
            uint tex4x4Size  = reader.ReadUInt32();

            CompressionFlags = reader.ReadUInt32();
            ImageData        = reader.ReadBytes((int)textureSize);
            if (CompressionFlags == 1)
            {
                ImageData = LZ77.Decompress(ImageData);
            }
            ImageData4x4 = reader.ReadBytes((int)tex4x4Size);
        }
Exemple #8
0
        public void Read(HsdfFile header, FileReader reader)
        {
            List <TextureMapperBlock> NameMappers = new List <TextureMapperBlock>();
            List <PaletteDataBlock>   PaletteData = new List <PaletteDataBlock>();

            ushort numInfos    = reader.ReadUInt16();
            ushort numImages   = reader.ReadUInt16();
            ushort numPalettes = reader.ReadUInt16();

            reader.ReadUInt16(); //padding
            for (int i = 0; i < numInfos + numImages + numPalettes; i++)
            {
                var block = header.ReadBlock(reader);
                if (block is TextureMapperBlock)
                {
                    NameMappers.Add((TextureMapperBlock)block);
                }
                if (block is ImageBlock)
                {
                    Images.Add((ImageBlock)block);
                }
                if (block is PaletteDataBlock)
                {
                    PaletteData.Add((PaletteDataBlock)block);
                }
            }

            foreach (var image in Images)
            {
                var mapper = NameMappers.FirstOrDefault(x => x.Name == image.Name);
                if (mapper != null)
                {
                    var palette = PaletteData.FirstOrDefault(x => x.Name == mapper.PaletteName);
                    if (palette != null)
                    {
                        image.PaletteData = palette;
                    }
                }
            }

            PaletteData.Clear();
            NameMappers.Clear();
        }
Exemple #9
0
        public void Read(HsdfFile header, FileReader reader)
        {
            Type        = (ObjectType)reader.ReadUInt16();
            ParentIndex = reader.ReadInt16();
            Unknown2    = reader.ReadUInt32();
            NameOffset  = reader.ReadUInt32();
            TranslateX  = reader.ReadSingleInt();
            TranslateY  = reader.ReadSingleInt();
            TranslateZ  = reader.ReadSingleInt();
            RotateX     = reader.ReadInt32() / 16384f;
            RotateY     = reader.ReadInt32() / 16384f;
            RotateZ     = reader.ReadInt32() / 16384f;
            ScaleX      = reader.ReadSingleInt();
            ScaleY      = reader.ReadSingleInt();
            ScaleZ      = reader.ReadSingleInt();

            //Read the next block
            if (Type == ObjectType.Mesh)
            {
                MeshData = (MeshBlock)header.ReadBlock(reader);
            }
        }
Exemple #10
0
 public void Write(HsdfFile header, FileWriter writer)
 {
 }
 public void Read(HsdfFile header, FileReader reader)
 {
 }
Exemple #12
0
        public void Read(HsdfFile header, FileReader reader)
        {
            uint   unknown1     = reader.ReadUInt32();
            uint   unknown2     = reader.ReadUInt32();
            uint   unknown3     = reader.ReadUInt32();
            uint   unknown4     = reader.ReadUInt32();
            uint   unknown5     = reader.ReadUInt32();
            uint   unknown6     = reader.ReadUInt32();
            uint   unknown7     = reader.ReadUInt32();
            uint   unknown8     = reader.ReadUInt32();
            uint   unknown9     = reader.ReadUInt32();
            uint   unknown10    = reader.ReadUInt32();
            ushort numObjects   = reader.ReadUInt16();
            ushort numMaterials = reader.ReadUInt16();
            ushort numTextures  = reader.ReadUInt16();
            ushort numMatrices  = reader.ReadUInt16();

            var materials = reader.ReadMultipleStructs <MaterialBlock>(numMaterials);

            for (int i = 0; i < numTextures; i++)
            {
                Attributes.Add(new AttributeBlock(reader));
            }
            for (int i = 0; i < numMatrices; i++)
            {
                Matrices.Add(new MatrixBlock(reader));
            }
            for (int i = 0; i < numObjects; i++)
            {
                Objects.Add((ObjectBlock)header.ReadBlock(reader));
            }

            StringTable table = (StringTable)header.ReadBlock(reader);

            for (int i = 0; i < numObjects; i++)
            {
                if (table.Strings.ContainsKey(Objects[i].NameOffset))
                {
                    Objects[i].Name = table.Strings[Objects[i].NameOffset];
                }
            }

            for (int i = 0; i < numMaterials; i++)
            {
                var mat = new MaterialData(materials[i]);
                if (table.Strings.ContainsKey(materials[i].NameOffset))
                {
                    mat.Name = table.Strings[materials[i].NameOffset];
                }

                Materials.Add(mat);
            }

            for (int i = 0; i < numTextures; i++)
            {
                if (table.Strings.ContainsKey(Attributes[i].NameOffset))
                {
                    Attributes[i].Name        = table.Strings[Attributes[i].NameOffset];
                    Attributes[i].TextureName = table.Strings[Attributes[i].TextureNameOffset];
                }
            }
        }
Exemple #13
0
 public void Load(System.IO.Stream stream)
 {
     Header = new HsdfFile(stream);
 }