Ejemplo n.º 1
0
        private void ReadDx10Header(Ibasa.IO.BinaryReader reader)
        {
            if (!IsDX10Mode)
                return;

            DxgiFormat = (DxgiFormat)reader.ReadInt32();
            ResourceDimension = (ResourceDimensionEnum)reader.ReadInt32();
            MiscFlags = (MiscFlagsEnum)reader.ReadInt32();
            ArraySize = reader.ReadInt32();
            reader.ReadBytes(4); //skip padding
        }
Ejemplo n.º 2
0
        private void ReadHeader(Ibasa.IO.BinaryReader reader)
        {
            HeaderFlags = (HeaderFlagsEnum)reader.ReadInt32();
            Height = reader.ReadInt32();
            Width = reader.ReadInt32();
            Pitch = reader.ReadInt32();
            Depth = reader.ReadInt32();
            MipmapCount = reader.ReadInt32();
            reader.ReadBytes(44); //skip padding

            int pixelSize = reader.ReadInt32();
            if (pixelSize != 32)
                throw new InvalidDataException(string.Format("Pixel format size {0} does not match 32.", pixelSize));

            PixelFlags = (PixelFlagsEnum)reader.ReadInt32();
            FourCC = new FourCC(reader.ReadInt32());
            RGBBitCount = reader.ReadInt32();
            RBitMask = reader.ReadInt32();
            GBitMask = reader.ReadInt32();
            BBitMask = reader.ReadInt32();
            ABitMask = reader.ReadInt32();

            SurfaceFlags = (SurfaceFlagsEnum)reader.ReadInt32();
            CubemapFlags = (CubemapFlagsEnum)reader.ReadInt32();

            reader.ReadBytes(12); //skip padding
        }
Ejemplo n.º 3
0
Archivo: Vtf.cs Proyecto: Frassle/Ibasa
        private void ReadHeader73(Ibasa.IO.BinaryReader reader)
        {
            if (VersionMinor >= 3)
            {
                reader.ReadBytes(3); //skip padding
                int resourceCount = reader.ReadInt32();
                reader.ReadBytes(8); //skip padding

                var resources = new Resource[resourceCount];

                for (int res = 0; res < resourceCount; ++res)
                {
                    int type = reader.ReadInt32();
                    resources[res] = new Resource(
                        (ResourceType)type & ResourceType.Mask,
                        (ResourceFlags)type & ResourceFlags.Mask, 
                        reader.ReadInt32());
                }

                Resources = new ImmutableArray<Resource>(resources);
            }
            else if(VersionMinor == 2)
            {
                //skip padding
                reader.ReadBytes(15); //skip padding

                Resources = new ImmutableArray<Resource>(0);
            }
        }
Ejemplo n.º 4
0
Archivo: Vtf.cs Proyecto: Frassle/Ibasa
 private void ReadHeader72(Ibasa.IO.BinaryReader reader)
 {
     if (VersionMinor >= 2)
     {
         Depth = reader.ReadUInt16();
         Depth = Depth == 0 ? 1 : Depth; //map 0 to 1
     }
     else
     {
         Depth = 1;
         reader.ReadBytes(1); //skip padding
     }
 }
Ejemplo n.º 5
0
Archivo: Vtf.cs Proyecto: Frassle/Ibasa
 private void ReadHeader70(Ibasa.IO.BinaryReader reader)
 {
     Width = reader.ReadUInt16();
     Height = reader.ReadUInt16();
     Flags = (TextureFlags)reader.ReadInt32();
     Frames = reader.ReadUInt16();
     StartFrame = reader.ReadUInt16();
     reader.ReadBytes(4); //skip padding
     Reflectivity = new Vector3f(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
     reader.ReadBytes(4); //skip padding
     BumpmapScale = reader.ReadSingle();
     ImageFormat = (ImageFormat)reader.ReadInt32();
     MipmapCount = reader.ReadByte();
     LowResImageFormat = (ImageFormat)reader.ReadInt32();
     LowResImageWidth = reader.ReadByte();
     LowResImageHeight = reader.ReadByte();
 }
Ejemplo n.º 6
0
Archivo: Mdl.cs Proyecto: Frassle/Ibasa
        ImmutableArray<Model> LoadModels(Ibasa.IO.BinaryReader reader, int count)
        {
            long offset = reader.BaseStream.Position;

            Model[] models = new Model[count];
            for (int i = 0; i < count; ++i)
            {
                reader.BaseStream.Position = offset;

                string name = Encoding.ASCII.GetString(reader.ReadBytes(64)).Trim('\0');
                int type = reader.ReadInt32();
                float boundingRadius = reader.ReadSingle();

                int meshCount = reader.ReadInt32();
                long meshOffset = offset + reader.ReadInt32();

                int vertexCount = reader.ReadInt32();
                int vertexIndex = reader.ReadInt32();
                int tangentIndex = reader.ReadInt32();

                int numattachments = reader.ReadInt32();
                int attachmentindex = reader.ReadInt32();

                int eyeballCount = reader.ReadInt32();
                long eyeballOffset = offset + reader.ReadInt32();

                int vertexData = reader.ReadInt32();
                int indexData = reader.ReadInt32();

                reader.Seek(8 * 4, SeekOrigin.Current); //skip 8 ints

                offset = reader.BaseStream.Position;

                reader.BaseStream.Position = meshOffset;
                ImmutableArray<Mesh> meshes = LoadMeshes(reader, meshCount);

                reader.BaseStream.Position = meshOffset;
                ImmutableArray<Eyeball> eyeballs = LoadEyeballs(reader, meshCount);

                models[i] = new Model(name, type, boundingRadius, meshes, vertexCount, vertexIndex, tangentIndex, eyeballs);
            }
            return new ImmutableArray<Model>(models);
        }