public GroupInformation(byte[] inData) { using (MemoryStream ms = new MemoryStream(inData)) { using (BinaryReader br = new BinaryReader(ms)) { this.Flags = (GroupFlags)br.ReadUInt32(); this.BoundingBox = br.ReadBox(); this.GroupNameOffset = br.ReadInt32(); } } }
public void LoadBinaryData(byte[] inData) { using (MemoryStream ms = new MemoryStream(inData)) { using (BinaryReader br = new BinaryReader(ms)) { this.GroupNameOffset = br.ReadUInt32(); this.DescriptiveGroupNameOffset = br.ReadUInt32(); this.Flags = (GroupFlags) br.ReadUInt32(); this.BoundingBox = br.ReadBox(); this.PortalReferenceStartingIndex = br.ReadUInt16(); this.PortalReferenceCount = br.ReadUInt16(); this.RenderBatchCountA = br.ReadUInt16(); this.RenderBatchCountInterior = br.ReadUInt16(); this.RenderBatchCountExterior = br.ReadUInt16(); this.Unknown = br.ReadUInt16(); for (int i = 0; i < 4; ++i) { this.FogIndices.Add(br.ReadByte()); } this.LiquidType = br.ReadUInt32(); this.GroupID = new UInt32ForeignKey("WMOAreaTable", "WMOGroupID", br.ReadUInt32()); this.UnknownFlags = br.ReadUInt32(); this.Unused = br.ReadUInt32(); // Required subchunks this.PolygonMaterials = br.ReadIFFChunk<ModelPolygonMaterials>(); this.VertexIndices = br.ReadIFFChunk<ModelVertexIndices>(); this.Vertices = br.ReadIFFChunk<ModelVertices>(); this.Normals = br.ReadIFFChunk<ModelNormals>(); this.TextureCoordinates = br.ReadIFFChunk<ModelTextureCoordinates>(); this.RenderBatches = br.ReadIFFChunk<ModelRenderBatches>(); // Optional chunks if (br.PeekChunkSignature() == MOBS.Signature) { this.mobs = br.ReadIFFChunk<MOBS>(); } if (this.Flags.HasFlag(GroupFlags.HasLights)) { this.LightReferences = br.ReadIFFChunk<ModelLightReferences>(); } if (this.Flags.HasFlag(GroupFlags.HasDoodads)) { this.DoodadReferences = br.ReadIFFChunk<ModelDoodadReferences>(); } if (this.Flags.HasFlag(GroupFlags.HasBSP)) { this.BSPNodes = br.ReadIFFChunk<ModelBSPNodes>(); this.BSPFaceIndices = br.ReadIFFChunk<ModelBSPFaceIndices>(); } if (this.Flags.HasFlag(GroupFlags.UnknownLODRelated)) { this.mpbv = br.ReadIFFChunk<MPBV>(); this.mpbp = br.ReadIFFChunk<MPBP>(); this.mpbi = br.ReadIFFChunk<MPBI>(); this.mpbg = br.ReadIFFChunk<MPBG>(); } if (this.Flags.HasFlag(GroupFlags.HasVertexColours)) { this.VertexColours = br.ReadIFFChunk<ModelVertexColours>(); } if (this.Flags.HasFlag(GroupFlags.HasLiquids)) { this.Liquids = br.ReadIFFChunk<ModelLiquids>(); } if (this.Flags.HasFlag(GroupFlags.HasTriangleStrips)) { this.TriangleStripIndices = br.ReadIFFChunk<ModelTriangleStripIndices>(); this.TriangleStrips = br.ReadIFFChunk<ModelTriangleStrips>(); } if (this.Flags.HasFlag(GroupFlags.HasTwoTextureCoordinateSets)) { this.AdditionalTextureCoordinates = br.ReadIFFChunk<ModelTextureCoordinates>(); } if (this.Flags.HasFlag(GroupFlags.HasTwoVertexShadingSets)) { this.AdditionalVertexColours = br.ReadIFFChunk<ModelVertexColours>(); } if (this.Flags.HasFlag(GroupFlags.HasThreeTextureCoordinateSets)) { this.SecondAddtionalTextureCoordinates = br.ReadIFFChunk<ModelTextureCoordinates>(); } } } }
public void LoadBinaryData(byte[] inData) { using (MemoryStream ms = new MemoryStream(inData)) { using (BinaryReader br = new BinaryReader(ms)) { this.TextureCount = br.ReadUInt32(); this.GroupCount = br.ReadUInt32(); this.PortalCount = br.ReadUInt32(); this.LightCount = br.ReadUInt32(); this.DoodadNameCount = br.ReadUInt32(); this.DoodadDefinitionCount = br.ReadUInt32(); this.DoodadSetCount = br.ReadUInt32(); this.BaseAmbientColour = br.ReadRGBA(); this.AreaTableID = new UInt32ForeignKey("WMOAreaTable", "WMOID", br.ReadUInt32()); this.BoundingBox = br.ReadBox(); this.Flags = (RootFlags) br.ReadUInt32(); } } }
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(); } } } }
public MDXAnimationSequence(byte[] data) { using (MemoryStream ms = new MemoryStream(data)) { using (BinaryReader br = new BinaryReader(ms)) { if (data.Length != 68) { throw new ArgumentException("Animation block data was too long or too short."); } this.AnimationID = br.ReadUInt32(); this.StartTimestamp = br.ReadUInt32(); this.EndTimestamp = br.ReadUInt32(); this.MovementSpeed = br.ReadSingle(); this.Flags = (MDXAnimationSequenceFlags)br.ReadUInt32(); this.Probability = br.ReadInt16(); this.Padding = br.ReadUInt16(); this.MinimumRepetitions = br.ReadUInt32(); this.MaximumRepetitions = br.ReadUInt32(); this.BlendTime = br.ReadUInt32(); this.BoundingBox = br.ReadBox(); this.BoundingSphereRadius = br.ReadSingle(); this.NextAnimationID = br.ReadInt16(); this.NextAliasedAnimationID = br.ReadUInt16(); } } }