public MDXRibbonEmitter(BinaryReader br, WarcraftVersion version) { RibbonID = br.ReadUInt32(); BoneIndex = br.ReadUInt32(); RelativePosition = br.ReadVector3(); Textures = br.ReadMDXArray <ushort>(); Materials = br.ReadMDXArray <ushort>(); Colour = br.ReadMDXTrack <RGB>(version); Alpha = br.ReadMDXTrack <short>(version); HeightAbove = br.ReadMDXTrack <float>(version); HeightBelow = br.ReadMDXTrack <float>(version); EdgesPerSecond = br.ReadSingle(); EdgeLifetime = br.ReadSingle(); Gravity = br.ReadSingle(); TextureTileX = br.ReadUInt16(); TextureTileY = br.ReadUInt16(); TextureSlot = br.ReadMDXTrack <ushort>(version); Visibility = br.ReadMDXTrack <bool>(version); if (version >= WarcraftVersion.Wrath) { PriorityPlane = br.ReadInt16(); Unknown = br.ReadInt16(); } }
/// <summary> /// Sets the skins used in this model. /// </summary> /// <param name="skins"></param> public void SetSkins(IEnumerable <MDXSkin> skins) { var skinArray = new MDXArray <MDXSkin>(skins); if (skinArray.Count != this.SkinCount) { throw new ArgumentException("The number of skins did not match the skin count for the model.", nameof(skins)); } this.Skins = skinArray; }
private void LoadFromStream(Stream dataStream) { using (BinaryReader br = new BinaryReader(dataStream)) { string dataSignature = new string(br.ReadBinarySignature().Reverse().ToArray()); if (dataSignature != 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 = GetModelVersion(br.ReadUInt32()); this.Name = new string(br.ReadMDXArray <char>().GetValues().ToArray()); this.GlobalModelFlags = (ModelObjectFlags)br.ReadUInt32(); this.GlobalSequenceTimestamps = br.ReadMDXArray <uint>(); this.AnimationSequences = br.ReadMDXArray <MDXAnimationSequence>(this.Version); this.AnimationSequenceLookupTable = br.ReadMDXArray <ushort>(); if (this.Version < WarcraftVersion.Wrath) { this.PlayableAnimationLookupTable = br.ReadMDXArray <MDXPlayableAnimationLookupTableEntry>(); } this.Bones = br.ReadMDXArray <MDXBone>(this.Version); this.BoneSocketLookupTable = br.ReadMDXArray <ushort>(); this.Vertices = br.ReadMDXArray <MDXVertex>(); if (this.Version < WarcraftVersion.Wrath) { this.Skins = br.ReadMDXArray <MDXSkin>(this.Version); } else { // Skins are stored out of file, figure out a clean solution this.SkinCount = br.ReadUInt32(); } this.ColourAnimations = br.ReadMDXArray <MDXColourAnimation>(this.Version); this.Textures = br.ReadMDXArray <MDXTexture>(); this.TransparencyAnimations = br.ReadMDXArray <MDXTextureWeight>(this.Version); if (this.Version <= WarcraftVersion.BurningCrusade) { // There's an array of something here, but we've no idea what type of data it is. Thus, we'll skip // over it. br.BaseStream.Position += 8; } this.TextureTransformations = br.ReadMDXArray <MDXTextureTransform>(this.Version); this.ReplaceableTextureLookupTable = br.ReadMDXArray <short>(); this.Materials = br.ReadMDXArray <MDXMaterial>(this.Version); this.BoneLookupTable = br.ReadMDXArray <short>(); this.TextureLookupTable = br.ReadMDXArray <short>(); this.TextureMappingLookupTable = br.ReadMDXArray <EMDXTextureMappingType>(); this.TransparencyLookupTable = br.ReadMDXArray <short>(); this.TextureTransformationLookupTable = br.ReadMDXArray <short>(); this.BoundingBox = br.ReadBox(); this.BoundingSphereRadius = br.ReadSingle(); this.CollisionBox = br.ReadBox(); this.CollisionSphereRadius = br.ReadSingle(); this.CollisionTriangles = br.ReadMDXArray <ushort>(); this.CollisionVertices = br.ReadMDXArray <Vector3>(); this.CollisionNormals = br.ReadMDXArray <Vector3>(); this.Attachments = br.ReadMDXArray <MDXAttachment>(this.Version); this.AttachmentLookupTable = br.ReadMDXArray <MDXAttachmentType>(); this.AnimationEvents = br.ReadMDXArray <MDXAnimationEvent>(this.Version); this.Lights = br.ReadMDXArray <MDXLight>(this.Version); this.Cameras = br.ReadMDXArray <MDXCamera>(this.Version); this.CameraTypeLookupTable = br.ReadMDXArray <MDXCameraType>(); this.RibbonEmitters = br.ReadMDXArray <MDXRibbonEmitter>(this.Version); // TODO: Particle Emitters // Skip for now br.BaseStream.Position += 8; if (this.Version >= WarcraftVersion.Wrath && this.GlobalModelFlags.HasFlag(ModelObjectFlags.HasBlendModeOverrides)) { this.BlendMapOverrides = br.ReadMDXArray <BlendingMode>(); } } }