Warcraft.MDX.MDXHeader.MDXHeader C# (CSharp) Method

MDXHeader() public method

public MDXHeader ( byte data ) : System
data byte
return System
        public MDXHeader(byte[] data)
        {
            using (MemoryStream ms = new MemoryStream(data))
            {
                using (BinaryReader br = new BinaryReader(ms))
                {
                    string Signature = new string(br.ReadChars(4));
                    if (Signature != MDXHeader.Signature)
                    {
                        throw new ArgumentException("The provided data stream does not contain a valid MDX signature. " +
                            "It might be a Legion file, or you may have omitted the signature, which should be \"MD20\".");
                    }

                    this.Version = br.ReadUInt32();
                    this.NameLength = br.ReadUInt32();
                    this.NameOffset = br.ReadUInt32();
                    this.GlobalModelFlags = (ModelObjectFlags)br.ReadUInt32();
                    this.GlobalSequenceCount = br.ReadUInt32();
                    this.GlobalSequencesOffset = br.ReadUInt32();
                    this.AnimationSequenceCount = br.ReadUInt32();
                    this.AnimationSequencesOffset = br.ReadUInt32();
                    this.AnimationLookupTableEntryCount = br.ReadUInt32();
                    this.AnimationLookupTableOffset = br.ReadUInt32();

                    if (GetModelVersion(this.Version) < WarcraftVersion.Wrath)
                    {
                        this.PlayableAnimationLookupTableEntryCount = br.ReadUInt32();
                        this.PlayableAnimationLookupTableOffset = br.ReadUInt32();
                    }

                    this.BoneCount = br.ReadUInt32();
                    this.BonesOffset = br.ReadUInt32();
                    this.KeyedBoneLookupTableCount = br.ReadUInt32();
                    this.KeyedBoneLookupTablesOffset = br.ReadUInt32();

                    this.VertexCount = br.ReadUInt32();
                    this.VerticesOffset = br.ReadUInt32();
                    this.LODViewsCount = br.ReadUInt32();

                    if (GetModelVersion(this.Version) < WarcraftVersion.Wrath)
                    {
                        this.LODViewsOffset = br.ReadUInt32();
                    }

                    this.SubmeshColourAnimationCount = br.ReadUInt32();
                    this.SubmeshColourAnimationsOffset = br.ReadUInt32();
                    this.TextureCount = br.ReadUInt32();
                    this.TexturesOffset = br.ReadUInt32();
                    this.TransparencyAnimationCount = br.ReadUInt32();
                    this.TransparencyAnimationsOffset = br.ReadUInt32();

                    if (GetModelVersion(this.Version) < WarcraftVersion.Wrath)
                    {
                        this.UnknownCount = br.ReadUInt32();
                        this.UnknownOffset = br.ReadUInt32();
                    }

                    this.UVTextureAnimationCount = br.ReadUInt32();
                    this.UVTextureAnimationsOffset = br.ReadUInt32();
                    this.ReplaceableTextureCount = br.ReadUInt32();
                    this.ReplaceableTexturesOffset = br.ReadUInt32();
                    this.RenderFlagCount = br.ReadUInt32();
                    this.RenderFlagsOffset = br.ReadUInt32();

                    this.BoneLookupTableCount = br.ReadUInt32();
                    this.BoneLookupTablesOffset = br.ReadUInt32();
                    this.TextureLookupTableCount = br.ReadUInt32();
                    this.TextureLookupTablesOffset = br.ReadUInt32();
                    this.TextureUnitCount = br.ReadUInt32();
                    this.TextureUnitsOffset = br.ReadUInt32();
                    this.TransparencyLookupTableCount = br.ReadUInt32();
                    this.TransparencyLookupTablesOffset = br.ReadUInt32();
                    this.UVTextureAnimationLookupTableCount = br.ReadUInt32();
                    this.UVTextureAnimationLookupTablesOffset = br.ReadUInt32();

                    this.BoundingBox = br.ReadBox();
                    this.BoundingSphereRadius = br.ReadSingle();

                    this.CollisionBox = br.ReadBox();
                    this.CollisionSphereRadius = br.ReadSingle();

                    this.BoundingTriangleCount = br.ReadUInt32();
                    this.BoundingTrianglesOffset = br.ReadUInt32();
                    this.BoundingVertexCount = br.ReadUInt32();
                    this.BoundingVerticesOffset = br.ReadUInt32();
                    this.BoundingNormalCount = br.ReadUInt32();
                    this.BoundingNormalsOffset = br.ReadUInt32();

                    this.AttachmentsCount = br.ReadUInt32();
                    this.AttachmentsOffset = br.ReadUInt32();
                    this.AttachmentsLookupTableCount = br.ReadUInt32();
                    this.AttachmentsLookupTablesOffset = br.ReadUInt32();

                    this.AnimationEventCount = br.ReadUInt32();
                    this.AnimationEventsOffset = br.ReadUInt32();
                    this.LightCount = br.ReadUInt32();
                    this.LightsOffset = br.ReadUInt32();
                    this.CameraCount = br.ReadUInt32();
                    this.CamerasOffset = br.ReadUInt32();
                    this.CameraLookupTableCount = br.ReadUInt32();
                    this.CameraLookupTablesOffset = br.ReadUInt32();

                    this.RibbonEmitterCount = br.ReadUInt32();
                    this.RibbonEmittersOffset = br.ReadUInt32();
                    this.ParticleEmitterCount = br.ReadUInt32();
                    this.ParticleEmittersOffset = br.ReadUInt32();

                    if (this.GlobalModelFlags.HasFlag(ModelObjectFlags.HasBlendModeOverrides))
                    {
                        this.BlendMapCount = br.ReadUInt32();
                        this.BlendMapsOffset = br.ReadUInt32();
                    }
                }
            }
        }