Exemple #1
0
        public static Vector2 ReadUV(this DSBinaryReader bin)
        {
            short x = bin.ReadInt16();
            short y = bin.ReadInt16();

            return(new Vector2(x / 1024.0f, y / 1024.0f));
        }
Exemple #2
0
        public static Vector3 ReadVector3(this DSBinaryReader bin)
        {
            float x = bin.ReadSingle();
            float y = bin.ReadSingle();
            float z = bin.ReadSingle();

            return(new Vector3(x, y, z));
        }
Exemple #3
0
        public static Color ReadColor(this DSBinaryReader bin)
        {
            byte r = bin.ReadByte();
            byte g = bin.ReadByte();
            byte b = bin.ReadByte();
            byte a = bin.ReadByte();

            return(new Color(r, g, b, a));
        }
Exemple #4
0
        public static Vector4 ReadPackedTangent(this DSBinaryReader bin)
        {
            byte x = bin.ReadByte();
            byte y = bin.ReadByte();
            byte z = bin.ReadByte();
            byte w = bin.ReadByte();

            return(new Vector4((x - 127.0f) / 127.0f, (y - 127.0f) / 127.0f, (z - 127.0f) / 127.0f, (w - 127.0f) / 127.0f));
        }
Exemple #5
0
        public void AdvanceReaderToEnd(DSBinaryReader bin)
        {
            byte nextByte = 0;

            while (bin.Position < (StartOffset + DesiredLength))
            {
                nextByte = bin.ReadByte();
                if (Padding.HasValue && nextByte != Padding.Value)
                {
                    throw new Exceptions.DSReadException(bin, "Read a value that isn't padding in a section of the file expected to be only padding." +
                                                         $"\nValue Expected (hex): {Padding:X2}\nValue Read (hex): {nextByte:X2}");
                }
            }
        }