/// <summary> /// Initializes a new instance of the <see cref="NiKeyframeData" /> class. /// </summary> /// <param name="file">The file.</param> /// <param name="reader">The reader.</param> public NiKeyframeData(NiFile file, BinaryReader reader) : base(file, reader) { uint num = reader.ReadUInt32(); if (num != 0u) { this.KeyType = (eKeyType)reader.ReadUInt32(); } if (this.KeyType != eKeyType.XYZ_ROTATION_KEY) { this.QuaternionKeys = new QuatKey[num]; int num2 = 0; while ((long)num2 < (long)((ulong)num)) { this.QuaternionKeys[num2] = new QuatKey(reader, this.KeyType); num2++; } } if (base.Version <= eNifVersion.VER_10_1_0_0 && this.KeyType == eKeyType.XYZ_ROTATION_KEY) { this.UnkownFloat = reader.ReadSingle(); } if (this.KeyType == eKeyType.XYZ_ROTATION_KEY) { this.Rotations = new KeyGroup<FloatKey>[3]; for (int i = 0; i < 3; i++) { this.Rotations[i] = new KeyGroup<FloatKey>(reader); } } this.Translations = new KeyGroup<VecKey>(reader); this.Scales = new KeyGroup<FloatKey>(reader); }
/// <summary> /// Initializes a new instance of the <see cref="StringKey"/> class. /// </summary> /// <param name="reader">The reader.</param> /// <param name="type">The type.</param> /// <exception cref="Exception">Invalid eKeyType</exception> public StringKey(BinaryReader reader, eKeyType type) { this.Time = reader.ReadSingle(); if (type != eKeyType.LINEAR_KEY) { throw new Exception("Invalid eKeyType"); } this.Value = new NiString(null, reader); }
/// <summary> /// Initializes a new instance of the <see cref="QuatKey"/> class. /// </summary> /// <param name="reader">The reader.</param> /// <param name="type">The type.</param> /// <exception cref="Exception">Invalid eKeyType</exception> public QuatKey(BinaryReader reader, eKeyType type) { this.Time = reader.ReadSingle(); if (type < eKeyType.LINEAR_KEY || type > eKeyType.TBC_KEY) { throw new Exception("Invalid eKeyType"); } this.Value = reader.ReadVector4(); if (type == eKeyType.TBC_KEY) { this.TBC = reader.ReadVector3(); } }
/// <summary> /// Initializes a new instance of the <see cref="Color4Key"/> class. /// </summary> /// <param name="reader">The reader.</param> /// <param name="type">The type.</param> /// <exception cref="Exception">Invalid eKeyType!</exception> public Color4Key(BinaryReader reader, eKeyType type) : base(reader, type) { this.Time = reader.ReadSingle(); if (type < eKeyType.LINEAR_KEY || type > eKeyType.TBC_KEY) { throw new Exception("Invalid eKeyType!"); } this.Value = reader.ReadColor4(); if (type == eKeyType.QUADRATIC_KEY) { this.Forward = reader.ReadColor4(); this.Backward = reader.ReadColor4(); } }
public NiKeyframeData(NiFile file, BinaryReader reader) : base(file, reader) { var numRotationKeys = reader.ReadUInt32(); if (numRotationKeys != 0) { KeyType = (eKeyType)reader.ReadUInt32(); } if (KeyType != eKeyType.XYZ_ROTATION_KEY) { QuaternionKeys = new QuatKey[numRotationKeys]; for (var c = 0; c < numRotationKeys; c++) { QuaternionKeys[c] = new QuatKey(reader, KeyType); } } if (Version <= eNifVersion.VER_10_1_0_0 && KeyType == eKeyType.XYZ_ROTATION_KEY) { UnkownFloat = reader.ReadSingle(); // unknown float } if (KeyType == eKeyType.XYZ_ROTATION_KEY) { Rotations = new KeyGroup <FloatKey> [3]; for (var i = 0; i < 3; i++) { Rotations[i] = new KeyGroup <FloatKey>(reader); } } Translations = new KeyGroup <VecKey>(reader); Scales = new KeyGroup <FloatKey>(reader); }
/// <summary> /// Attempts to clone <see cref="Texture"/> specified in the <see cref="TPKBlock"/> data. /// </summary> /// <param name="newname">Collection Name of the new <see cref="Texture"/>.</param> /// <param name="key">Key of the Collection Name of the <see cref="Texture"/> to clone.</param> /// <param name="type">Type of the key passed.</param> /// <returns>True if texture cloning was successful, false otherwise.</returns> public override bool TryCloneTexture(string newname, uint key, eKeyType type) { if (string.IsNullOrWhiteSpace(newname)) { return(false); } if (this.FindTexture(Bin.Hash(newname), type) != null) { return(false); } var copyfrom = (Texture)this.FindTexture(key, type); if (copyfrom == null) { return(false); } var texture = (Texture)copyfrom.MemoryCast(newname); this.Textures.Add(texture); return(true); }
/// <summary> /// Initializes a new instance of the <see cref="BaseKey"/> class. /// </summary> /// <param name="reader">The reader.</param> /// <param name="type">The type.</param> public BaseKey(BinaryReader reader, eKeyType type) { }
/// <summary> /// Attemps to export <see cref="Texture"/> specified to the path and mode provided. /// </summary> /// <param name="key">Key of the Collection Name of the <see cref="Texture"/> to be exported.</param> /// <param name="type">Type of the key passed.</param> /// <param name="path">Path where the texture should be exported.</param> /// <param name="mode">Mode in which export the texture. Range: ".dds", ".png", ".jpg", ".tiff", ".bmp".</param> /// <param name="error">Error occured when trying to clone a texture.</param> /// <returns>True if texture export was successful, false otherwise.</returns> public override bool TryExportTexture(uint key, eKeyType type, string path, string mode, out string error) { error = null; ImageType ddstype; switch (mode) { case ".dds": ddstype = ImageType.Dds; break; case ".png": ddstype = ImageType.Png; break; case ".jpg": ddstype = ImageType.Jpg; break; case ".tiff": ddstype = ImageType.Tiff; break; case ".bmp": ddstype = ImageType.Bmp; break; default: error = $"{mode} is not a supported image type that can be exported."; return(false); } var tex = (Texture)this.FindTexture(key, type); if (tex == null) { error = $"Texture with key 0x{key:X8} does not exist."; return(false); } try { var data = tex.GetDDSArray(); if (mode == ".dds") { using (var bw = new BinaryWriter(File.Open(path, FileMode.Create))) { bw.Write(data); } } else { using (var sr = new MemoryStream(data)) using (var im = new ImageImporter()) using (var ex = new ImageExporter()) { using (var image = im.LoadImageFromStream(sr)) { ex.SaveImage(image, ddstype, path); } } } return(true); } catch (System.Exception e) { while (e.InnerException != null) { e = e.InnerException; } error = e.Message; return(false); } }
/// <summary> /// Attemps to export <see cref="Texture"/> specified to the path and mode provided. /// </summary> /// <param name="key">Key of the Collection Name of the <see cref="Texture"/> to be exported.</param> /// <param name="type">Type of the key passed.</param> /// <param name="path">Path where the texture should be exported.</param> /// <param name="mode">Mode in which export the texture. Range: ".dds", ".png", ".jpg", ".tiff", ".bmp".</param> /// <returns>True if texture export was successful, false otherwise.</returns> public override bool TryExportTexture(uint key, eKeyType type, string path, string mode) { ImageType ddstype; switch (mode) { case ".dds": ddstype = ImageType.Dds; break; case ".png": ddstype = ImageType.Png; break; case ".jpg": ddstype = ImageType.Jpg; break; case ".tiff": ddstype = ImageType.Tiff; break; case ".bmp": ddstype = ImageType.Bmp; break; default: return(false); } var tex = (Texture)this.FindTexture(key, type); if (tex == null) { return(false); } try { var data = tex.GetDDSArray(); if (mode == ".dds") { using (var bw = new BinaryWriter(File.Open(path, FileMode.Create))) { bw.Write(data); } } else { using (var sr = new MemoryStream(data)) using (var im = new ImageImporter()) using (var ex = new ImageExporter()) { using (var image = im.LoadImageFromStream(sr)) { ex.SaveImage(image, ddstype, path); } } } return(true); } catch (System.Exception) { return(false); } }
public cStoreFeedbackCollector() { KeyType = eKeyType.msn; }