This commit is contained in:
4sval 2023-03-17 17:08:00 +01:00
parent 26e92238ba
commit fdfaddd627
6 changed files with 20 additions and 18 deletions

@ -1 +1 @@
Subproject commit d0a849608247dbdcb14b9b6e6851addd761f3c73
Subproject commit 4a3efdafa7321e98d0ca1c29d3c3d2140980ab9f

View File

@ -16,7 +16,7 @@ using CUE4Parse.UE4.Assets.Exports;
using CUE4Parse.UE4.Assets.Exports.Animation;
using CUE4Parse.UE4.Assets.Exports.Material;
using CUE4Parse.UE4.Assets.Exports.SkeletalMesh;
using CUE4Parse.UE4.Assets.Exports.Solaris;
using CUE4Parse.UE4.Assets.Exports.Verse;
using CUE4Parse.UE4.Assets.Exports.Sound;
using CUE4Parse.UE4.Assets.Exports.StaticMesh;
using CUE4Parse.UE4.Assets.Exports.Texture;
@ -781,13 +781,13 @@ public class CUE4ParseViewModel : ViewModel
var saveTextures = HasFlag(bulk, EBulkType.Textures);
switch (export)
{
case USolarisDigest solarisDigest when isNone:
case UVerseDigest verseDigest when isNone:
{
if (!TabControl.CanAddTabs) return false;
TabControl.AddTab($"{solarisDigest.ProjectName}.verse");
TabControl.AddTab($"{verseDigest.ProjectName}.verse");
TabControl.SelectedTab.Highlighter = AvalonExtensions.HighlighterSelector("verse");
TabControl.SelectedTab.SetDocumentText(solarisDigest.ReadableCode, false, false);
TabControl.SelectedTab.SetDocumentText(verseDigest.ReadableCode, false, false);
return true;
}
case UTexture2D { IsVirtual: false } texture when isNone:

View File

@ -8,7 +8,7 @@ public class Bone
public string LoweredParentName;
public int SkeletonIndex = -1;
public bool[] IsAnimated;
public bool IsAnimated;
public Bone(int i, int p, Transform t)
{
@ -21,5 +21,5 @@ public class Bone
public bool IsMapped => SkeletonIndex > -1;
public bool IsNative => Index == SkeletonIndex;
public override string ToString() => $"Mesh Ref '{Index}' is Skel Ref '{SkeletonIndex}' ({IsNative})";
public override string ToString() => $"Mesh Ref '{Index}' is Skel Ref '{SkeletonIndex}' ({IsAnimated})";
}

View File

@ -62,7 +62,7 @@ public class Skeleton : IDisposable
public void Animate(CAnimSet anim, bool rotationOnly)
{
TrackSkeleton(anim);
MapSkeleton(anim);
_animatedBonesTransform = new Transform[anim.Sequences.Count][][];
for (int s = 0; s < _animatedBonesTransform.Length; s++)
@ -74,9 +74,9 @@ public class Skeleton : IDisposable
_animatedBonesTransform[s][bone.Index] = new Transform[sequence.NumFrames];
var skeletonBoneIndex = bone.SkeletonIndex;
bone.IsAnimated[s] = sequence.OriginalSequence.FindTrackForBoneIndex(skeletonBoneIndex) >= 0;
if (!bone.IsAnimated[s])
if (sequence.OriginalSequence.FindTrackForBoneIndex(skeletonBoneIndex) < 0)
{
bone.IsAnimated |= false;
for (int frame = 0; frame < _animatedBonesTransform[s][bone.Index].Length; frame++)
{
_animatedBonesTransform[s][bone.Index][frame] = new Transform
@ -88,6 +88,7 @@ public class Skeleton : IDisposable
}
else
{
bone.IsAnimated |= true;
for (int frame = 0; frame < _animatedBonesTransform[s][bone.Index].Length; frame++)
{
var boneOrientation = bone.Rest.Rotation;
@ -162,7 +163,7 @@ public class Skeleton : IDisposable
}
}
private void TrackSkeleton(CAnimSet anim)
private void MapSkeleton(CAnimSet anim)
{
ResetAnimatedData();
@ -174,19 +175,18 @@ public class Skeleton : IDisposable
continue;
bone.SkeletonIndex = boneIndex;
bone.IsAnimated = false;
}
var seqCount = anim.Sequences.Count;
#if DEBUG
foreach ((var boneName, var bone) in BonesByLoweredName)
{
bone.IsAnimated = new bool[seqCount];
#if DEBUG
if (bone.IsRoot || bone.IsMapped) // assuming root bone always is mapped
continue;
Log.Warning($"{Name} Bone Mismatch: {boneName} ({bone.Index}) was not present in the anim's target skeleton");
#endif
}
#endif
}
public void ResetAnimatedData(bool full = false)
@ -194,7 +194,7 @@ public class Skeleton : IDisposable
foreach (var bone in BonesByLoweredName.Values)
{
bone.SkeletonIndex = -1;
bone.IsAnimated = null;
bone.IsAnimated = false;
}
if (!full) return;

View File

@ -295,7 +295,7 @@ public class SnimGui
- WASD to move around
- Shift to move faster
- XC to zoom
- Z to animate selected model
- Z to animate the selected model
- Left Mouse Button pressed to look around
- Right Click to select a model in the world

View File

@ -159,7 +159,9 @@ public class Snooper : GameWindow
var delta = (float) e.Time;
Renderer.CameraOp.Modify(KeyboardState, delta);
if (KeyboardState.IsKeyPressed(Keys.Z))
if (KeyboardState.IsKeyPressed(Keys.Z) &&
Renderer.Options.TryGetModel(out var selectedModel) &&
selectedModel.HasSkeleton)
{
Renderer.Options.RemoveAnimations();
Renderer.Options.AnimateMesh(true);