-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trying to get Dat animations working, but currently no luck yet.
- Loading branch information
1 parent
6f381a2
commit 0a22cb2
Showing
12 changed files
with
480 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace fin.data.lazy { | ||
public class LazyList<T> : ILazyArray<T> { | ||
private readonly List<T> impl_ = new(); | ||
private readonly List<bool> populated_ = new(); | ||
private readonly Func<int, T> handler_; | ||
|
||
public LazyList(Func<int, T> handler) { | ||
this.handler_ = handler; | ||
} | ||
|
||
public LazyList(Func<LazyList<T>, int, T> handler) { | ||
this.handler_ = (int key) => handler(this, key); | ||
} | ||
|
||
public int Count => this.impl_.Count; | ||
|
||
public void Clear() { | ||
this.impl_.Clear(); | ||
this.populated_.Clear(); | ||
} | ||
|
||
public bool ContainsKey(int key) => this.populated_[key]; | ||
|
||
|
||
public T this[int key] { | ||
get { | ||
if (this.Count > key && this.populated_[key]) { | ||
return this.impl_[key]; | ||
} | ||
|
||
while (this.Count <= key) { | ||
this.impl_.Add(default!); | ||
this.populated_.Add(false); | ||
} | ||
|
||
this.populated_[key] = true; | ||
return this.impl_[key] = this.handler_(key); | ||
} | ||
set { | ||
while (this.Count <= key) { | ||
this.impl_.Add(default!); | ||
this.populated_.Add(false); | ||
} | ||
|
||
this.populated_[key] = true; | ||
this.impl_[key] = value; | ||
} | ||
} | ||
|
||
public IEnumerable<int> Keys | ||
=> Enumerable.Range(0, this.Count).Where(this.ContainsKey); | ||
|
||
public IEnumerable<T> Values | ||
=> this.impl_.Where((value, i) => ContainsKey(i)); | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
FinModelUtility/Formats/Dat/Dat/src/api/DatBoneTracksHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using dat.schema.animation; | ||
|
||
using fin.model; | ||
|
||
namespace dat.api { | ||
public static class DatBoneTracksHelper { | ||
public static void AddDatKeyframesToBoneTracks( | ||
IEnumerable<IDatKeyframes> allDatKeyframes, | ||
IBoneTracks boneTracks) { | ||
var positionTrack = boneTracks.UseSeparatePositionAxesTrack(); | ||
var rotationTrack = boneTracks.UseEulerRadiansRotationTrack(); | ||
var scaleTrack = boneTracks.UseScaleTrack(); | ||
|
||
foreach (var datKeyframes in allDatKeyframes) { | ||
var jointTrackType = datKeyframes.JointTrackType; | ||
switch (jointTrackType) { | ||
case JointTrackType.HSD_A_J_TRAX: | ||
case JointTrackType.HSD_A_J_TRAY: | ||
case JointTrackType.HSD_A_J_TRAZ: { | ||
var axis = jointTrackType - JointTrackType.HSD_A_J_TRAX; | ||
foreach (var keyframe in datKeyframes.Keyframes) { | ||
var (frame, value, tangent) = keyframe; | ||
positionTrack.Set(frame, | ||
axis, | ||
value, | ||
tangent, | ||
tangent); | ||
} | ||
|
||
break; | ||
} | ||
case JointTrackType.HSD_A_J_ROTX: | ||
case JointTrackType.HSD_A_J_ROTY: | ||
case JointTrackType.HSD_A_J_ROTZ: { | ||
var axis = jointTrackType - JointTrackType.HSD_A_J_ROTX; | ||
foreach (var keyframe in datKeyframes.Keyframes) { | ||
var (frame, value, tangent) = keyframe; | ||
rotationTrack.Set(frame, | ||
axis, | ||
value, | ||
tangent, | ||
tangent); | ||
} | ||
|
||
break; | ||
} | ||
case JointTrackType.HSD_A_J_SCAX: | ||
case JointTrackType.HSD_A_J_SCAY: | ||
case JointTrackType.HSD_A_J_SCAZ: { | ||
var axis = jointTrackType - JointTrackType.HSD_A_J_SCAX; | ||
foreach (var keyframe in datKeyframes.Keyframes) { | ||
var (frame, value, tangent) = keyframe; | ||
scaleTrack.Set(frame, | ||
axis, | ||
value, | ||
tangent, | ||
tangent); | ||
} | ||
|
||
break; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
FinModelUtility/Formats/Dat/Dat/src/schema/DatNodeInterfaces.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.