/// <summary> /// Creates a new Model instance using the provided MdlFile, level of detail, /// and variant ID, without resolving any game data. /// </summary> /// <param name="mdlFile">The MdlFile to back this Model.</param> /// <param name="lod">The quality of the loaded Model.</param> /// <param name="variantId">The variant ID of the Model to load. This will be used /// to specify a Material variant, and may be used by the caller to limit attributes /// depending on data from an ImcFile.</param> /// <exception cref="ArgumentException">The specified MdlFile does not contain /// the specified ModelLod.</exception> public Model(MdlFile mdlFile, ModelLod lod = ModelLod.High, int variantId = 1) { if ((uint)lod > mdlFile.FileHeader.LodCount) { throw new ArgumentException("The given model does not have the requested LoD.", nameof(lod)); } File = mdlFile; Lod = lod; VariantId = variantId; BuildModel(); }
/// <summary> /// Creates a new Model instance using the provided path, access to game data, /// level of detail, and variant ID. The Model will be built and then updated /// with game data. /// </summary> /// <param name="data">A reference to game data access.</param> /// <param name="path">The path to this Model.</param> /// <param name="lod">The quality of the loaded Model.</param> /// <param name="variantId">The variant ID of the Model to load. This will be used /// to specify a Material variant, and may be used by the caller to limit attributes /// depending on data from an ImcFile.</param> /// <exception cref="ArgumentException">The specified MdlFile does not contain /// the specified ModelLod.</exception> public Model(GameData data, string path, ModelLod lod = ModelLod.High, int variantId = 1) { var mdlFile = data.GetFile <MdlFile>(path); if ((uint)lod > mdlFile.FileHeader.LodCount) { throw new ArgumentException("The given model does not have the requested LoD.", nameof(lod)); } File = mdlFile; Lod = lod; VariantId = variantId; BuildModel(); Update(data); }
private File3di(BinaryReader reader, FileVersion version) { if (version != FileVersion.V8) throw new NotSupportedException(); reader.BaseStream.Seek(0, SeekOrigin.Begin); var header = reader.ReadBytes(Header.STRUCT_SIZE).ToStruct<Header>(); Textures = new List<ModelTexture>(header.TextureCount); for (var i = 0; i < header.TextureCount; i++) { var newTex = new ModelTexture(reader, header.Signature); Textures.Add(newTex); } Lods = new List<ModelLod>(); for (var i = 0; i < header.LodInfo.Count; i++) { var lod = new ModelLod(reader, header.Signature); Lods.Add(lod); } }
private File3di(BinaryReader reader, FileVersion version) { if (version != FileVersion.V8) { throw new NotSupportedException(); } reader.BaseStream.Seek(0, SeekOrigin.Begin); var header = reader.ReadBytes(Header.STRUCT_SIZE).ToStruct <Header>(); Textures = new List <ModelTexture>(header.TextureCount); for (var i = 0; i < header.TextureCount; i++) { var newTex = new ModelTexture(reader, header.Signature); Textures.Add(newTex); } Lods = new List <ModelLod>(); for (var i = 0; i < header.LodInfo.Count; i++) { var lod = new ModelLod(reader, header.Signature); Lods.Add(lod); } }