Exemplo n.º 1
0
 public BrgMeshHeader(BrgBinaryReader reader)
 {
     this.Version            = reader.ReadInt16();
     this.Format             = (BrgMeshFormat)reader.ReadInt16();
     this.NumVertices        = reader.ReadInt16();
     this.NumFaces           = reader.ReadInt16();
     this.InterpolationType  = (BrgMeshInterpolationType)reader.ReadByte();
     this.AnimationType      = (BrgMeshAnimType)reader.ReadByte();
     this.UserDataEntryCount = reader.ReadInt16();
     this.CenterPosition     = reader.ReadVector3D(true, false);
     this.CenterRadius       = reader.ReadSingle();
     this.MassPosition       = reader.ReadVector3D(true, false);
     this.HotspotPosition    = reader.ReadVector3D(true, false);
     this.ExtendedHeaderSize = reader.ReadInt16();
     this.Flags         = (BrgMeshFlag)reader.ReadInt16();
     this.MinimumExtent = reader.ReadVector3D(true, false);
     this.MaximumExtent = reader.ReadVector3D(true, false);
 }
Exemplo n.º 2
0
 public BrgMeshHeader(BrgBinaryReader reader)
 {
     this.Version = reader.ReadInt16();
     this.Format = (BrgMeshFormat)reader.ReadInt16();
     this.NumVertices = reader.ReadInt16();
     this.NumFaces = reader.ReadInt16();
     this.InterpolationType = (BrgMeshInterpolationType)reader.ReadByte();
     this.AnimationType = (BrgMeshAnimType)reader.ReadByte();
     this.UserDataEntryCount = reader.ReadInt16();
     this.CenterPosition = reader.ReadVector3D(true, false);
     this.CenterRadius = reader.ReadSingle();
     this.MassPosition = reader.ReadVector3D(true, false);
     this.HotspotPosition = reader.ReadVector3D(true, false);
     this.ExtendedHeaderSize = reader.ReadInt16();
     this.Flags = (BrgMeshFlag)reader.ReadInt16();
     this.MinimumExtent = reader.ReadVector3D(true, false);
     this.MaximumExtent = reader.ReadVector3D(true, false);
 }
 public BrgMeshExtendedHeader(BrgBinaryReader reader, int extendedHeaderSize)
 {
     this.NumNameIndexes = reader.ReadInt16();
     this.NumDummies     = reader.ReadInt16();
     this.NameLength     = reader.ReadInt16();
     if (extendedHeaderSize > 6)
     {
         this.PointMaterial = reader.ReadInt16();
         this.PointRadius   = reader.ReadSingle();
     }
     if (extendedHeaderSize > 12)
     {
         this.NumMaterials      = reader.ReadByte();
         this.ShadowNameLength0 = reader.ReadByte();
         this.ShadowNameLength1 = reader.ReadByte();
         this.ShadowNameLength2 = reader.ReadByte();
     }
     if (extendedHeaderSize > 16)
     {
         this.AnimationLength = reader.ReadSingle();
     }
     if (extendedHeaderSize > 20)
     {
         this.MaterialLibraryTimestamp = reader.ReadInt32();
     }
     if (extendedHeaderSize > 24)
     {
         this.Reserved = reader.ReadSingle();
     }
     if (extendedHeaderSize > 28)
     {
         this.ExportedScaleFactor = reader.ReadSingle();
     }
     if (extendedHeaderSize > 32)
     {
         this.NumNonUniformKeys = reader.ReadInt32(); //09c
     }
     if (extendedHeaderSize > 36)
     {
         this.NumUniqueMaterials = reader.ReadInt32();
     }
 }
 public BrgMeshExtendedHeader(BrgBinaryReader reader, int extendedHeaderSize)
 {
     this.NumNameIndexes = reader.ReadInt16();
     this.NumDummies = reader.ReadInt16();
     this.NameLength = reader.ReadInt16();
     if (extendedHeaderSize > 6)
     {
         this.PointMaterial = reader.ReadInt16();
         this.PointRadius = reader.ReadSingle();
     }
     if (extendedHeaderSize > 12)
     {
         this.NumMaterials = reader.ReadByte();
         this.ShadowNameLength0 = reader.ReadByte();
         this.ShadowNameLength1 = reader.ReadByte();
         this.ShadowNameLength2 = reader.ReadByte();
     }
     if (extendedHeaderSize > 16)
     {
         this.AnimationLength = reader.ReadSingle();
     }
     if (extendedHeaderSize > 20)
     {
         this.MaterialLibraryTimestamp = reader.ReadInt32();
     }
     if (extendedHeaderSize > 24)
     {
         this.Reserved = reader.ReadSingle();
     }
     if (extendedHeaderSize > 28)
     {
         this.ExportedScaleFactor = reader.ReadSingle();
     }
     if (extendedHeaderSize > 32)
     {
         this.NumNonUniformKeys = reader.ReadInt32(); //09c
     }
     if (extendedHeaderSize > 36)
     {
         this.NumUniqueMaterials = reader.ReadInt32();
     }
 }
Exemplo n.º 5
0
        public DdtFile(System.IO.Stream fileStream)
        {
            using (BrgBinaryReader reader = new BrgBinaryReader(new LittleEndianBitConverter(), fileStream))
            {
                reader.ReadInt32();
                type = (DdtType)reader.ReadByte();
                alphaBits = reader.ReadByte();
                texelFormat = (DdtTexelFormat)reader.ReadByte();
                mipMap = reader.ReadByte();
                Height = reader.ReadInt32();
                Width = reader.ReadInt32();

                int length = 0;
                for (int i = 0; i < mipMap; i++)
                {
                    reader.ReadInt32();
                    length += reader.ReadInt32();
                }

                imageData = reader.ReadBytes(length);
            }
        }
Exemplo n.º 6
0
        public BrgMaterial(BrgBinaryReader reader, BrgFile file)
            : this(file)
        {
            Id         = reader.ReadInt32();
            Flags      = (BrgMatFlag)reader.ReadInt32();
            unknown01b = reader.ReadInt32();
            int nameLength = reader.ReadInt32();
            this.DiffuseColor  = reader.ReadColor3D();
            this.AmbientColor  = reader.ReadColor3D();
            this.SpecularColor = reader.ReadColor3D();
            this.EmissiveColor = reader.ReadColor3D();

            this.DiffuseMap = reader.ReadString(nameLength);
            if (Flags.HasFlag(BrgMatFlag.SpecularExponent))
            {
                this.SpecularExponent = reader.ReadSingle();
            }
            if (Flags.HasFlag(BrgMatFlag.BumpMap))
            {
                this.BumpMap = reader.ReadString(reader.ReadInt32());
            }
            if (Flags.HasFlag(BrgMatFlag.Alpha))
            {
                this.Opacity = reader.ReadSingle();
            }

            if (Flags.HasFlag(BrgMatFlag.REFLECTIONTEXTURE))
            {
                byte numSFX = reader.ReadByte();
                sfx = new List <BrgMatSFX>(numSFX);
                for (int i = 0; i < numSFX; i++)
                {
                    sfx.Add(reader.ReadMaterialSFX());
                }
            }
            else
            {
                sfx = new List <BrgMatSFX>();
            }
        }
Exemplo n.º 7
0
        public BrgMesh(BrgBinaryReader reader, BrgFile file)
            : base()
        {
            this.ParentFile = file;
            this.Header = new BrgMeshHeader(reader);

            this.VertexMaterials = new List<Int16>();
            if (!this.Header.Flags.HasFlag(BrgMeshFlag.PARTICLEPOINTS))
            {
                this.Vertices = new List<Vector3D>(this.Header.NumVertices);
                for (int i = 0; i < this.Header.NumVertices; i++)
                {
                    this.Vertices.Add(reader.ReadVector3D(true, this.Header.Version == 22));
                }
                this.Normals = new List<Vector3D>(this.Header.NumVertices);
                for (int i = 0; i < this.Header.NumVertices; i++)
                {
                    if (this.Header.Version >= 13 && this.Header.Version <= 17)
                    {
                        reader.ReadInt16(); // No idea what this is
                    }
                    else // v == 18, 19 or 22
                    {
                        this.Normals.Add(reader.ReadVector3D(true, this.Header.Version == 22));
                    }
                }

                if ((!this.Header.Flags.HasFlag(BrgMeshFlag.SECONDARYMESH) ||
                    this.Header.Flags.HasFlag(BrgMeshFlag.ANIMTEXCOORDS) ||
                    this.Header.Flags.HasFlag(BrgMeshFlag.PARTICLESYSTEM)) &&
                    this.Header.Flags.HasFlag(BrgMeshFlag.TEXCOORDSA))
                {
                    this.TextureCoordinates = new List<Vector3D>(this.Header.NumVertices);
                    for (int i = 0; i < this.Header.NumVertices; i++)
                    {
                        this.TextureCoordinates.Add(new Vector3D(reader.ReadVector2D(this.Header.Version == 22), 0f));
                    }
                }

                if (!this.Header.Flags.HasFlag(BrgMeshFlag.SECONDARYMESH) ||
                    this.Header.Flags.HasFlag(BrgMeshFlag.PARTICLESYSTEM))
                {
                    this.Faces = new List<Face>(this.Header.NumFaces);
                    for (int i = 0; i < this.Header.NumFaces; ++i)
                    {
                        this.Faces.Add(new Face());
                    }

                    if (this.Header.Flags.HasFlag(BrgMeshFlag.MATERIAL))
                    {
                        for (int i = 0; i < this.Header.NumFaces; i++)
                        {
                            this.Faces[i].MaterialIndex = reader.ReadInt16();
                        }
                    }

                    for (int i = 0; i < this.Header.NumFaces; i++)
                    {
                        this.Faces[i].Indices.Add(reader.ReadInt16());
                        this.Faces[i].Indices.Add(reader.ReadInt16());
                        this.Faces[i].Indices.Add(reader.ReadInt16());
                    }

                    if (this.Header.Flags.HasFlag(BrgMeshFlag.MATERIAL))
                    {
                        this.VertexMaterials = new List<Int16>(this.Header.NumVertices);
                        for (int i = 0; i < this.Header.NumVertices; i++)
                        {
                            this.VertexMaterials.Add(reader.ReadInt16());
                        }
                    }
                }
            }

            this.UserDataEntries = new BrgUserDataEntry[this.Header.UserDataEntryCount];
            if (!this.Header.Flags.HasFlag(BrgMeshFlag.PARTICLEPOINTS))
            {
                for (int i = 0; i < this.Header.UserDataEntryCount; i++)
                {
                    this.UserDataEntries[i] = reader.ReadUserDataEntry(false);
                }
            }

            this.ExtendedHeader = new BrgMeshExtendedHeader(reader, this.Header.ExtendedHeaderSize);

            this.particleData = new float[0];
            if (this.Header.Flags.HasFlag(BrgMeshFlag.PARTICLEPOINTS))
            {
                this.particleData = new float[4 * this.Header.NumVertices];
                for (int i = 0; i < this.particleData.Length; i++)
                {
                    this.particleData[i] = reader.ReadSingle();
                }
                for (int i = 0; i < this.Header.UserDataEntryCount; i++)
                {
                    this.UserDataEntries[i] = reader.ReadUserDataEntry(true);
                }
            }

            if (this.Header.Version == 13)
            {
                reader.ReadBytes(this.ExtendedHeader.NameLength);
            }

            if (this.Header.Version >= 13 && this.Header.Version <= 18)
            {
                this.Header.Flags |= BrgMeshFlag.ATTACHPOINTS;
            }
            if (this.Header.Flags.HasFlag(BrgMeshFlag.ATTACHPOINTS))
            {
                Int16 numMatrix = this.ExtendedHeader.NumDummies;
                Int16 numIndex = this.ExtendedHeader.NumNameIndexes;
                if (this.Header.Version == 19 || this.Header.Version == 22)
                {
                    numMatrix = reader.ReadInt16();
                    numIndex = reader.ReadInt16();
                    reader.ReadInt16();
                }

                BrgAttachpoint[] attpts = new BrgAttachpoint[numMatrix];
                for (int i = 0; i < numMatrix; i++)
                {
                    attpts[i] = new BrgAttachpoint();
                }
                for (int i = 0; i < numMatrix; i++)
                {
                    attpts[i].XVector = reader.ReadVector3D(true, this.Header.Version == 22);
                }
                for (int i = 0; i < numMatrix; i++)
                {
                    attpts[i].YVector = reader.ReadVector3D(true, this.Header.Version == 22);
                }
                for (int i = 0; i < numMatrix; i++)
                {
                    attpts[i].ZVector = reader.ReadVector3D(true, this.Header.Version == 22);
                }
                if (this.Header.Version == 19 || this.Header.Version == 22)
                {
                    for (int i = 0; i < numMatrix; i++)
                    {
                        attpts[i].Position = reader.ReadVector3D(true, this.Header.Version == 22);
                    }
                }
                for (int i = 0; i < numMatrix; i++)
                {
                    attpts[i].BoundingBoxMin = reader.ReadVector3D(true, this.Header.Version == 22);
                }
                for (int i = 0; i < numMatrix; i++)
                {
                    attpts[i].BoundingBoxMax = reader.ReadVector3D(true, this.Header.Version == 22);
                }

                List<int> nameId = new List<int>();
                for (int i = 0; i < numIndex; i++)
                {
                    int duplicate = reader.ReadInt32(); // have yet to find a model with duplicates
                    reader.ReadInt32(); // Skip the id (at least I think its an ID)
                    for (int j = 0; j < duplicate; j++)
                    {
                        nameId.Add(i);
                    }
                }

                this.Attachpoints = new List<BrgAttachpoint>();
                for (int i = 0; i < nameId.Count; i++)
                {
                    this.Attachpoints.Add(new BrgAttachpoint(attpts[reader.ReadByte()]));
                    this.Attachpoints[i].NameId = nameId[i];
                    //attpts[reader.ReadByte()].NameId = nameId[i];
                }
                //attachpoints = new List<BrgAttachpoint>(attpts);
            }
            else
            {
                this.Attachpoints = new List<BrgAttachpoint>();
            }

            if (((this.Header.Flags.HasFlag(BrgMeshFlag.COLORALPHACHANNEL) ||
                this.Header.Flags.HasFlag(BrgMeshFlag.COLORCHANNEL)) &&
                !this.Header.Flags.HasFlag(BrgMeshFlag.SECONDARYMESH)) ||
                this.Header.Flags.HasFlag(BrgMeshFlag.ANIMVERTCOLORALPHA))
            {
                this.Colors = new List<Color4D>(this.Header.NumVertices);
                for (int i = 0; i < this.Header.NumVertices; i++)
                {
                    this.Colors.Add(reader.ReadTexel());
                }
            }

            // Only seen on first mesh
            this.NonUniformKeys = new float[0];
            if (this.Header.AnimationType.HasFlag(BrgMeshAnimType.NonUniform))
            {
                this.NonUniformKeys = new float[this.ExtendedHeader.NumNonUniformKeys];
                for (int i = 0; i < this.ExtendedHeader.NumNonUniformKeys; i++)
                {
                    this.NonUniformKeys[i] = reader.ReadSingle();
                }
            }

            if (this.Header.Version >= 14 && this.Header.Version <= 19)
            {
                // Face Normals??
                Vector3D[] legacy = new Vector3D[this.Header.NumFaces];
                for (int i = 0; i < this.Header.NumFaces; i++)
                {
                    legacy[i] = reader.ReadVector3D();
                }
            }

            if (!this.Header.Flags.HasFlag(BrgMeshFlag.SECONDARYMESH) && this.Header.Version != 22)
            {
                reader.ReadBytes(ExtendedHeader.ShadowNameLength0 + ExtendedHeader.ShadowNameLength1);
            }
        }
Exemplo n.º 8
0
        public void Read(Stream stream)
        {
            using (BrgBinaryReader reader = new BrgBinaryReader(new LittleEndianBitConverter(), stream))
            {
                uint magic = reader.ReadUInt32();
                if (magic != 1280463949)
                {
                    throw new Exception("This is not a MTRL file!");
                }

                uint nameLength = reader.ReadUInt32();
                for (int i = 0; i < 5; ++i)
                {
                    this.unk[i] = reader.ReadUInt32();
                }

                this.Diffuse       = reader.ReadColor3D();
                this.Ambient       = reader.ReadColor3D();
                this.Specular      = reader.ReadColor3D();
                this.Emissive      = reader.ReadColor3D();
                this.SpecularLevel = reader.ReadSingle();
                this.Alpha         = reader.ReadSingle();

                this.Id = reader.ReadInt32();

                this.SelfIlluminating = reader.ReadByte();
                this.ClampU           = reader.ReadByte();
                this.ClampV           = reader.ReadByte();
                this.LightSpecular    = reader.ReadByte();
                this.AffectsAmbient   = reader.ReadByte();
                this.AffectsDiffuse   = reader.ReadByte();
                this.AffectsSpecular  = reader.ReadByte();
                this.Updateable       = reader.ReadByte();

                this.AlphaMode         = reader.ReadInt32(); // Seems to be very often 10, wave has a 2 here, phoenix has 6
                this.AmbientIntensity  = reader.ReadInt32();
                this.DiffuseIntensity  = reader.ReadInt32();
                this.SpecularIntensity = reader.ReadInt32();
                this.EmissiveIntensity = reader.ReadInt32();
                this.ColorTransform    = reader.ReadInt32(); // Val of 4 seems to be PC
                this.TextureTransform  = reader.ReadInt32();
                this.TextureFactor     = reader.ReadInt32(); // Has something to do with Cube Map
                this.MultiTextureMode  = reader.ReadInt32(); // Has something to do with Cube Map
                this.TexGenMode0       = reader.ReadInt32();
                this.TexGenMode1       = reader.ReadInt32(); // Has something to do with Cube Map
                this.TexCoordSet0      = reader.ReadInt32();
                this.TexCoordSet1      = reader.ReadInt32();
                this.TexCoordSet2      = reader.ReadInt32();
                this.TexCoordSet3      = reader.ReadInt32();
                this.TexCoordSet4      = reader.ReadInt32();
                this.TexCoordSet5      = reader.ReadInt32();
                this.TexCoordSet6      = reader.ReadInt32();
                this.TexCoordSet7      = reader.ReadInt32();

                for (int i = 0; i < 3; ++i)
                {
                    this.unk2[i] = reader.ReadTexel();
                }
                for (int i = 0; i < 3; ++i)
                {
                    this.unk3[i] = reader.ReadTexel();
                }
                for (int i = 0; i < 4; ++i)
                {
                    this.unk4[i] = reader.ReadInt32();
                }

                if (nameLength > 0)
                {
                    this.Texture = reader.ReadString();
                }
            }
        }
Exemplo n.º 9
0
        public void Read(Stream stream)
        {
            using (BrgBinaryReader reader = new BrgBinaryReader(new LittleEndianBitConverter(), stream))
            {
                uint magic = reader.ReadUInt32();
                if (magic != 1280463949)
                {
                    throw new Exception("This is not a MTRL file!");
                }

                uint nameLength = reader.ReadUInt32();
                for (int i = 0; i < 5; ++i)
                {
                    this.unk[i] = reader.ReadUInt32();
                }

                this.Diffuse = reader.ReadColor3D();
                this.Ambient = reader.ReadColor3D();
                this.Specular = reader.ReadColor3D();
                this.Emissive = reader.ReadColor3D();
                this.SpecularLevel = reader.ReadSingle();
                this.Alpha = reader.ReadSingle();

                this.Id = reader.ReadInt32();

                this.SelfIlluminating = reader.ReadByte();
                this.ClampU = reader.ReadByte();
                this.ClampV = reader.ReadByte();
                this.LightSpecular = reader.ReadByte();
                this.AffectsAmbient = reader.ReadByte();
                this.AffectsDiffuse = reader.ReadByte();
                this.AffectsSpecular = reader.ReadByte();
                this.Updateable = reader.ReadByte();

                this.AlphaMode = reader.ReadInt32(); // Seems to be very often 10, wave has a 2 here, phoenix has 6
                this.AmbientIntensity = reader.ReadInt32();
                this.DiffuseIntensity = reader.ReadInt32();
                this.SpecularIntensity = reader.ReadInt32();
                this.EmissiveIntensity = reader.ReadInt32();
                this.ColorTransform = reader.ReadInt32(); // Val of 4 seems to be PC
                this.TextureTransform = reader.ReadInt32();
                this.TextureFactor = reader.ReadInt32(); // Has something to do with Cube Map
                this.MultiTextureMode = reader.ReadInt32(); // Has something to do with Cube Map
                this.TexGenMode0 = reader.ReadInt32();
                this.TexGenMode1 = reader.ReadInt32(); // Has something to do with Cube Map
                this.TexCoordSet0 = reader.ReadInt32();
                this.TexCoordSet1 = reader.ReadInt32();
                this.TexCoordSet2 = reader.ReadInt32();
                this.TexCoordSet3 = reader.ReadInt32();
                this.TexCoordSet4 = reader.ReadInt32();
                this.TexCoordSet5 = reader.ReadInt32();
                this.TexCoordSet6 = reader.ReadInt32();
                this.TexCoordSet7 = reader.ReadInt32();

                for (int i = 0; i < 3; ++i)
                {
                    this.unk2[i] = reader.ReadTexel();
                }
                for (int i = 0; i < 3; ++i)
                {
                    this.unk3[i] = reader.ReadTexel();
                }
                for (int i = 0; i < 4; ++i)
                {
                    this.unk4[i] = reader.ReadInt32();
                }

                if (nameLength > 0)
                {
                    this.Texture = reader.ReadString();
                }
            }
        }
Exemplo n.º 10
0
        public BrgMesh(BrgBinaryReader reader, BrgFile file)
            : this(file)
        {
            this.ParentFile = file;
            this.Header     = new BrgMeshHeader(reader);

            if (!this.Header.Flags.HasFlag(BrgMeshFlag.PARTICLEPOINTS))
            {
                this.Vertices = new List <Vector3>(this.Header.NumVertices);
                for (int i = 0; i < this.Header.NumVertices; i++)
                {
                    this.Vertices.Add(reader.ReadVector3D(true, this.Header.Version == 22));
                }
                this.Normals = new List <Vector3>(this.Header.NumVertices);
                for (int i = 0; i < this.Header.NumVertices; i++)
                {
                    if (this.Header.Version >= 13 && this.Header.Version <= 17)
                    {
                        reader.ReadInt16(); // TODO figure this out
                    }
                    else // v == 18, 19 or 22
                    {
                        this.Normals.Add(reader.ReadVector3D(true, this.Header.Version == 22));
                    }
                }

                if ((!this.Header.Flags.HasFlag(BrgMeshFlag.SECONDARYMESH) ||
                     this.Header.Flags.HasFlag(BrgMeshFlag.ANIMTEXCOORDS) ||
                     this.Header.Flags.HasFlag(BrgMeshFlag.PARTICLESYSTEM)) &&
                    this.Header.Flags.HasFlag(BrgMeshFlag.TEXCOORDSA))
                {
                    this.TextureCoordinates = new List <Vector3>(this.Header.NumVertices);
                    for (int i = 0; i < this.Header.NumVertices; i++)
                    {
                        this.TextureCoordinates.Add(new Vector3(reader.ReadVector2D(this.Header.Version == 22), 0f));
                    }
                }

                if (!this.Header.Flags.HasFlag(BrgMeshFlag.SECONDARYMESH) ||
                    this.Header.Flags.HasFlag(BrgMeshFlag.PARTICLESYSTEM))
                {
                    this.Faces = new List <Face>(this.Header.NumFaces);
                    for (int i = 0; i < this.Header.NumFaces; ++i)
                    {
                        this.Faces.Add(new Face());
                    }

                    if (this.Header.Flags.HasFlag(BrgMeshFlag.MATERIAL))
                    {
                        for (int i = 0; i < this.Header.NumFaces; i++)
                        {
                            this.Faces[i].MaterialIndex = reader.ReadInt16();
                        }
                    }

                    for (int i = 0; i < this.Header.NumFaces; i++)
                    {
                        this.Faces[i].Indices.Add(reader.ReadInt16());
                        this.Faces[i].Indices.Add(reader.ReadInt16());
                        this.Faces[i].Indices.Add(reader.ReadInt16());
                    }

                    if (this.Header.Flags.HasFlag(BrgMeshFlag.MATERIAL))
                    {
                        this.VertexMaterials = new List <Int16>(this.Header.NumVertices);
                        for (int i = 0; i < this.Header.NumVertices; i++)
                        {
                            this.VertexMaterials.Add(reader.ReadInt16());
                        }
                    }
                }
            }

            this.UserDataEntries = new BrgUserDataEntry[this.Header.UserDataEntryCount];
            if (!this.Header.Flags.HasFlag(BrgMeshFlag.PARTICLEPOINTS))
            {
                for (int i = 0; i < this.Header.UserDataEntryCount; i++)
                {
                    this.UserDataEntries[i] = reader.ReadUserDataEntry(false);
                }
            }

            this.ExtendedHeader = new BrgMeshExtendedHeader(reader, this.Header.ExtendedHeaderSize);

            if (this.Header.Flags.HasFlag(BrgMeshFlag.PARTICLEPOINTS))
            {
                this.particleData = new float[4 * this.Header.NumVertices];
                for (int i = 0; i < this.particleData.Length; i++)
                {
                    this.particleData[i] = reader.ReadSingle();
                }
                for (int i = 0; i < this.Header.UserDataEntryCount; i++)
                {
                    this.UserDataEntries[i] = reader.ReadUserDataEntry(true);
                }
            }

            if (this.Header.Version == 13)
            {
                reader.ReadBytes(this.ExtendedHeader.NameLength);
            }

            if (this.Header.Version >= 13 && this.Header.Version <= 18)
            {
                this.Header.Flags |= BrgMeshFlag.ATTACHPOINTS;
            }
            if (this.Header.Flags.HasFlag(BrgMeshFlag.ATTACHPOINTS))
            {
                Int16 numMatrix = this.ExtendedHeader.NumDummies;
                Int16 numIndex  = this.ExtendedHeader.NumNameIndexes;
                if (this.Header.Version == 19 || this.Header.Version == 22)
                {
                    numMatrix = reader.ReadInt16();
                    numIndex  = reader.ReadInt16();
                    reader.ReadInt16();
                }

                BrgAttachpoint[] attpts = new BrgAttachpoint[numMatrix];
                for (int i = 0; i < numMatrix; i++)
                {
                    attpts[i] = new BrgAttachpoint();
                }
                for (int i = 0; i < numMatrix; i++)
                {
                    attpts[i].XVector = reader.ReadVector3D(true, this.Header.Version == 22);
                }
                for (int i = 0; i < numMatrix; i++)
                {
                    attpts[i].YVector = reader.ReadVector3D(true, this.Header.Version == 22);
                }
                for (int i = 0; i < numMatrix; i++)
                {
                    attpts[i].ZVector = reader.ReadVector3D(true, this.Header.Version == 22);
                }
                if (this.Header.Version == 19 || this.Header.Version == 22)
                {
                    for (int i = 0; i < numMatrix; i++)
                    {
                        attpts[i].Position = reader.ReadVector3D(true, this.Header.Version == 22);
                    }
                }
                for (int i = 0; i < numMatrix; i++)
                {
                    attpts[i].BoundingBoxMin = reader.ReadVector3D(true, this.Header.Version == 22);
                }
                for (int i = 0; i < numMatrix; i++)
                {
                    attpts[i].BoundingBoxMax = reader.ReadVector3D(true, this.Header.Version == 22);
                }

                List <int> nameId = new List <int>();
                for (int i = 0; i < numIndex; i++)
                {
                    int duplicate = reader.ReadInt32(); // have yet to find a model with duplicates
                    reader.ReadInt32();                 // TODO figure out what this means
                    for (int j = 0; j < duplicate; j++)
                    {
                        nameId.Add(i);
                    }
                }

                for (int i = 0; i < nameId.Count; i++)
                {
                    this.Attachpoints.Add(new BrgAttachpoint(attpts[reader.ReadByte()]));
                    this.Attachpoints[i].NameId = nameId[i];
                    //attpts[reader.ReadByte()].NameId = nameId[i];
                }
                //attachpoints = new List<BrgAttachpoint>(attpts);
            }

            if (((this.Header.Flags.HasFlag(BrgMeshFlag.COLORALPHACHANNEL) ||
                  this.Header.Flags.HasFlag(BrgMeshFlag.COLORCHANNEL)) &&
                 !this.Header.Flags.HasFlag(BrgMeshFlag.SECONDARYMESH)) ||
                this.Header.Flags.HasFlag(BrgMeshFlag.ANIMVERTCOLORALPHA))
            {
                this.Colors = new List <Color4D>(this.Header.NumVertices);
                for (int i = 0; i < this.Header.NumVertices; i++)
                {
                    this.Colors.Add(reader.ReadTexel());
                }
            }

            // Only seen on first mesh
            if (this.Header.AnimationType.HasFlag(BrgMeshAnimType.NonUniform))
            {
                this.NonUniformKeys = new List <float>(this.ExtendedHeader.NumNonUniformKeys);
                for (int i = 0; i < this.ExtendedHeader.NumNonUniformKeys; i++)
                {
                    this.NonUniformKeys[i] = reader.ReadSingle();
                }
            }

            if (this.Header.Version >= 14 && this.Header.Version <= 19)
            {
                // Face Normals??
                Vector3[] legacy = new Vector3[this.Header.NumFaces];
                for (int i = 0; i < this.Header.NumFaces; i++)
                {
                    legacy[i] = reader.ReadVector3D();
                }
            }

            if (!this.Header.Flags.HasFlag(BrgMeshFlag.SECONDARYMESH) && this.Header.Version != 22)
            {
                reader.ReadBytes(ExtendedHeader.ShadowNameLength0 + ExtendedHeader.ShadowNameLength1);
            }
        }