From a208564245eda8be0252d0895093fea54fee3a38 Mon Sep 17 00:00:00 2001 From: NaoyaKohda Date: Sun, 17 Nov 2024 04:20:28 +0900 Subject: [PATCH] =?UTF-8?q?KeyFrameData=20=E3=81=AB=E3=83=AA=E3=83=8D?= =?UTF-8?q?=E3=83=BC=E3=83=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Editor/DmxRecorder/TimelineConverter.cs | 30 ++++++------------- Assets/ArtNet/Editor/KeyFrameData.cs | 14 +++++++++ Assets/ArtNet/Editor/KeyFrameData.cs.meta | 3 ++ 3 files changed, 26 insertions(+), 21 deletions(-) create mode 100644 Assets/ArtNet/Editor/KeyFrameData.cs create mode 100644 Assets/ArtNet/Editor/KeyFrameData.cs.meta diff --git a/Assets/ArtNet/Editor/DmxRecorder/TimelineConverter.cs b/Assets/ArtNet/Editor/DmxRecorder/TimelineConverter.cs index 00d25c8..1f7c0a6 100644 --- a/Assets/ArtNet/Editor/DmxRecorder/TimelineConverter.cs +++ b/Assets/ArtNet/Editor/DmxRecorder/TimelineConverter.cs @@ -77,17 +77,17 @@ private static void SaveAsset(T asset, string directory, string fileName) whe public class TimelineUniverse { public int Universe { get; } - private List[] ChannelDmxFrameData { get; } + private List[] ChannelDmxFrameData { get; } public TimelineUniverse(int groupKey, IReadOnlyCollection universeData) { Universe = groupKey; - ChannelDmxFrameData = new List[512]; + ChannelDmxFrameData = new List[512]; for (var i = 0; i < ChannelDmxFrameData.Length; i++) { ChannelDmxFrameData[i] = universeData.Where(x => x.Values.Length > i) - .Select(x => new DmxFrameData((float) x.Time, x.Values[i])) + .Select(x => new KeyFrameData((float) x.Time, x.Values[i])) .OrderBy(x => x.Time).ToList(); } } @@ -96,7 +96,7 @@ public TimelineUniverse(int universe, AnimationClip clip) { Universe = universe; var curveBindings = AnimationUtility.GetCurveBindings(clip); - ChannelDmxFrameData = new List[512]; + ChannelDmxFrameData = new List[512]; for (var i = 0; i < ChannelDmxFrameData.Length; i++) { var propertyName = $"Ch{i + 1:D3}"; @@ -108,7 +108,7 @@ public TimelineUniverse(int universe, AnimationClip clip) if (curve is null) continue; - ChannelDmxFrameData[i] = curve.keys.Select(x => new DmxFrameData((int) (x.time * 1000), (byte) x.value)).ToList(); + ChannelDmxFrameData[i] = curve.keys.Select(x => new KeyFrameData((int) (x.time * 1000), (byte) x.value)).ToList(); } } @@ -185,7 +185,7 @@ public void ThinOutUnchangedFrames() if (dmxFrameData.Count == 0) continue; var latest = dmxFrameData[0]; - var newDmxFrameData = new List { dmxFrameData[0] }; + var newDmxFrameData = new List { dmxFrameData[0] }; for (var j = 1; j < dmxFrameData.Count - 1; j++) { @@ -203,9 +203,9 @@ public void ThinOutUnchangedFrames() } private static bool IsOmittedFrame( - DmxFrameData prev, - DmxFrameData current, - DmxFrameData next, + KeyFrameData prev, + KeyFrameData current, + KeyFrameData next, float tolerance = 0.01f) { var prevDiff = current.Value - prev.Value; @@ -235,16 +235,4 @@ public IEnumerable ToUniverseData() return universeData; } } - - public struct DmxFrameData - { - public float Time { get; } - public byte Value { get; } - - public DmxFrameData(float time, byte value) - { - Time = time; - Value = value; - } - } } diff --git a/Assets/ArtNet/Editor/KeyFrameData.cs b/Assets/ArtNet/Editor/KeyFrameData.cs new file mode 100644 index 0000000..12861ee --- /dev/null +++ b/Assets/ArtNet/Editor/KeyFrameData.cs @@ -0,0 +1,14 @@ +namespace ArtNet.Editor +{ + public struct KeyFrameData + { + public float Time { get; } + public byte Value { get; } + + public KeyFrameData(float time, byte value) + { + Time = time; + Value = value; + } + } +} diff --git a/Assets/ArtNet/Editor/KeyFrameData.cs.meta b/Assets/ArtNet/Editor/KeyFrameData.cs.meta new file mode 100644 index 0000000..f645824 --- /dev/null +++ b/Assets/ArtNet/Editor/KeyFrameData.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 320cfc841f6646fe9051fc36aba5798a +timeCreated: 1731783855 \ No newline at end of file