mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-14 20:54:16 +01:00
Improve AVFX writing.
This commit is contained in:
parent
ab53f17a7e
commit
5dd4701c4c
2 changed files with 69 additions and 56 deletions
|
|
@ -20,8 +20,8 @@ public class AvfxFile : IWritable
|
||||||
Data = r.ReadBytes((int)Size.RoundTo4());
|
Data = r.ReadBytes((int)Size.RoundTo4());
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ToBool()
|
public byte ToBool()
|
||||||
=> BitConverter.ToBoolean(Data);
|
=> BitConverter.ToBoolean(Data) ? (byte)1 : (byte)0;
|
||||||
|
|
||||||
public uint ToUint()
|
public uint ToUint()
|
||||||
=> BitConverter.ToUInt32(Data);
|
=> BitConverter.ToUInt32(Data);
|
||||||
|
|
@ -36,51 +36,52 @@ public class AvfxFile : IWritable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static readonly Vector3 BadVector = new(float.NaN);
|
||||||
|
|
||||||
public Vector3 ClipBox;
|
public Vector3 ClipBox = BadVector;
|
||||||
public Vector3 ClipBoxSize;
|
public Vector3 ClipBoxSize = BadVector;
|
||||||
public Vector3 RevisedValuesPos;
|
public Vector3 RevisedValuesPos = BadVector;
|
||||||
public Vector3 RevisedValuesRot;
|
public Vector3 RevisedValuesRot = BadVector;
|
||||||
public Vector3 RevisedValuesScale;
|
public Vector3 RevisedValuesScale = BadVector;
|
||||||
public Vector3 RevisedValuesColor;
|
public Vector3 RevisedValuesColor = BadVector;
|
||||||
|
|
||||||
public uint Version;
|
public uint Version = uint.MaxValue;
|
||||||
public uint DrawLayerType;
|
public uint DrawLayerType = uint.MaxValue;
|
||||||
public uint DrawOrderType;
|
public uint DrawOrderType = uint.MaxValue;
|
||||||
public uint DirectionalLightSourceType;
|
public uint DirectionalLightSourceType = uint.MaxValue;
|
||||||
public uint PointLightsType1;
|
public uint PointLightsType1 = uint.MaxValue;
|
||||||
public uint PointLightsType2;
|
public uint PointLightsType2 = uint.MaxValue;
|
||||||
|
|
||||||
public float BiasZmaxScale;
|
public float BiasZmaxScale = float.NaN;
|
||||||
public float BiasZmaxDistance;
|
public float BiasZmaxDistance = float.NaN;
|
||||||
public float NearClipBegin;
|
public float NearClipBegin = float.NaN;
|
||||||
public float NearClipEnd;
|
public float NearClipEnd = float.NaN;
|
||||||
public float FadeInnerX;
|
public float FadeInnerX = float.NaN;
|
||||||
public float FadeOuterX;
|
public float FadeOuterX = float.NaN;
|
||||||
public float FadeInnerY;
|
public float FadeInnerY = float.NaN;
|
||||||
public float FadeOuterY;
|
public float FadeOuterY = float.NaN;
|
||||||
public float FadeInnerZ;
|
public float FadeInnerZ = float.NaN;
|
||||||
public float FadeOuterZ;
|
public float FadeOuterZ = float.NaN;
|
||||||
public float FarClipBegin;
|
public float FarClipBegin = float.NaN;
|
||||||
public float FarClipEnd;
|
public float FarClipEnd = float.NaN;
|
||||||
public float SoftParticleFadeRange;
|
public float SoftParticleFadeRange = float.NaN;
|
||||||
public float SoftKeyOffset;
|
public float SoftKeyOffset = float.NaN;
|
||||||
public float GlobalFogInfluence;
|
public float GlobalFogInfluence = float.NaN;
|
||||||
|
|
||||||
public bool IsDelayFastParticle;
|
public byte IsDelayFastParticle = byte.MaxValue;
|
||||||
public bool IsFitGround;
|
public byte IsFitGround = byte.MaxValue;
|
||||||
public bool IsTransformSkip;
|
public byte IsTransformSkip = byte.MaxValue;
|
||||||
public bool IsAllStopOnHide;
|
public byte IsAllStopOnHide = byte.MaxValue;
|
||||||
public bool CanBeClippedOut;
|
public byte CanBeClippedOut = byte.MaxValue;
|
||||||
public bool ClipBoxEnabled;
|
public byte ClipBoxEnabled = byte.MaxValue;
|
||||||
public bool IsCameraSpace;
|
public byte IsCameraSpace = byte.MaxValue;
|
||||||
public bool IsFullEnvLight;
|
public byte IsFullEnvLight = byte.MaxValue;
|
||||||
public bool IsClipOwnSetting;
|
public byte IsClipOwnSetting = byte.MaxValue;
|
||||||
public bool FadeEnabledX;
|
public byte FadeEnabledX = byte.MaxValue;
|
||||||
public bool FadeEnabledY;
|
public byte FadeEnabledY = byte.MaxValue;
|
||||||
public bool FadeEnabledZ;
|
public byte FadeEnabledZ = byte.MaxValue;
|
||||||
public bool GlobalFogEnabled;
|
public byte GlobalFogEnabled = byte.MaxValue;
|
||||||
public bool LtsEnabled;
|
public byte LtsEnabled = byte.MaxValue;
|
||||||
|
|
||||||
public Block[] Schedulers = Array.Empty<Block>();
|
public Block[] Schedulers = Array.Empty<Block>();
|
||||||
public Block[] Timelines = Array.Empty<Block>();
|
public Block[] Timelines = Array.Empty<Block>();
|
||||||
|
|
@ -91,7 +92,8 @@ public class AvfxFile : IWritable
|
||||||
public string[] Textures = Array.Empty<string>();
|
public string[] Textures = Array.Empty<string>();
|
||||||
public Block[] Models = Array.Empty<Block>();
|
public Block[] Models = Array.Empty<Block>();
|
||||||
|
|
||||||
public bool Valid { get; } = true;
|
public bool Valid
|
||||||
|
=> true;
|
||||||
|
|
||||||
public AvfxFile(byte[] data)
|
public AvfxFile(byte[] data)
|
||||||
{
|
{
|
||||||
|
|
@ -198,7 +200,6 @@ public class AvfxFile : IWritable
|
||||||
var sizePos = w.BaseStream.Position;
|
var sizePos = w.BaseStream.Position;
|
||||||
w.Write(0u);
|
w.Write(0u);
|
||||||
w.WriteBlock(AvfxMagic.Version, Version)
|
w.WriteBlock(AvfxMagic.Version, Version)
|
||||||
.WriteBlock(AvfxMagic.IsDelayFastParticle, IsDelayFastParticle)
|
|
||||||
.WriteBlock(AvfxMagic.IsDelayFastParticle, IsDelayFastParticle)
|
.WriteBlock(AvfxMagic.IsDelayFastParticle, IsDelayFastParticle)
|
||||||
.WriteBlock(AvfxMagic.IsFitGround, IsFitGround)
|
.WriteBlock(AvfxMagic.IsFitGround, IsFitGround)
|
||||||
.WriteBlock(AvfxMagic.IsTransformSkip, IsTransformSkip)
|
.WriteBlock(AvfxMagic.IsTransformSkip, IsTransformSkip)
|
||||||
|
|
@ -276,7 +277,7 @@ public class AvfxFile : IWritable
|
||||||
foreach (var block in Models)
|
foreach (var block in Models)
|
||||||
w.WriteBlock(block);
|
w.WriteBlock(block);
|
||||||
w.Seek((int)sizePos, SeekOrigin.Begin);
|
w.Seek((int)sizePos, SeekOrigin.Begin);
|
||||||
w.Write((uint)w.BaseStream.Length);
|
w.Write((uint)w.BaseStream.Length - 8u);
|
||||||
return m.ToArray();
|
return m.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -108,25 +108,37 @@ public static class AvfxMagic
|
||||||
|
|
||||||
internal static BinaryWriter WriteBlock(this BinaryWriter bw, uint magic, uint value)
|
internal static BinaryWriter WriteBlock(this BinaryWriter bw, uint magic, uint value)
|
||||||
{
|
{
|
||||||
bw.Write(magic);
|
if (value != uint.MaxValue)
|
||||||
bw.Write(4u);
|
|
||||||
bw.Write(value);
|
|
||||||
return bw;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static BinaryWriter WriteBlock(this BinaryWriter bw, uint magic, bool value)
|
|
||||||
{
|
{
|
||||||
bw.Write(magic);
|
bw.Write(magic);
|
||||||
bw.Write(4u);
|
bw.Write(4u);
|
||||||
bw.Write(value ? 1u : 0u);
|
bw.Write(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bw;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static BinaryWriter WriteBlock(this BinaryWriter bw, uint magic, byte value)
|
||||||
|
{
|
||||||
|
if (value != byte.MaxValue)
|
||||||
|
{
|
||||||
|
bw.Write(magic);
|
||||||
|
bw.Write(4u);
|
||||||
|
bw.Write(value == 1 ? 1u : 0u);
|
||||||
|
}
|
||||||
|
|
||||||
return bw;
|
return bw;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static BinaryWriter WriteBlock(this BinaryWriter bw, uint magic, float value)
|
internal static BinaryWriter WriteBlock(this BinaryWriter bw, uint magic, float value)
|
||||||
|
{
|
||||||
|
if (!float.IsNaN(value))
|
||||||
{
|
{
|
||||||
bw.Write(magic);
|
bw.Write(magic);
|
||||||
bw.Write(4u);
|
bw.Write(4u);
|
||||||
bw.Write(value);
|
bw.Write(value);
|
||||||
|
}
|
||||||
|
|
||||||
return bw;
|
return bw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue