-
-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
that's a problem for future me
- Loading branch information
Showing
13 changed files
with
581 additions
and
396 deletions.
There are no files selected for viewing
Submodule CUE4Parse
updated
7 files
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
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
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,64 @@ | ||
using System; | ||
using System.Numerics; | ||
using CUE4Parse_Conversion.Animations; | ||
using CUE4Parse.UE4.Objects.Core.Math; | ||
|
||
namespace FModel.Views.Snooper; | ||
|
||
public class Animation : IDisposable | ||
{ | ||
public float CurrentTime; | ||
public float DeltaTime; | ||
public CAnimSet CurrentAnimation; | ||
public Matrix4x4[] FinalBonesMatrix; | ||
|
||
public Animation(CAnimSet anim) | ||
{ | ||
CurrentTime = 0f; | ||
CurrentAnimation = anim; | ||
|
||
FinalBonesMatrix = new Matrix4x4[anim.TrackBoneNames.Length]; | ||
for (int i = 0; i < FinalBonesMatrix.Length; i++) | ||
{ | ||
FinalBonesMatrix[i] = Matrix4x4.Identity; | ||
} | ||
} | ||
|
||
public void UpdateAnimation(float deltaTime) | ||
{ | ||
DeltaTime = deltaTime; | ||
if (CurrentAnimation != null) | ||
{ | ||
CurrentTime = deltaTime; | ||
CalculateBoneTransform(); | ||
} | ||
} | ||
|
||
public void CalculateBoneTransform() | ||
{ | ||
var sequence = CurrentAnimation.Sequences[0]; | ||
for (int boneIndex = 0; boneIndex < FinalBonesMatrix.Length; boneIndex++) | ||
{ | ||
var boneOrientation = FQuat.Identity; | ||
var bonePosition = FVector.ZeroVector; | ||
sequence.Tracks[boneIndex].GetBonePosition(CurrentTime, sequence.NumFrames, false, ref bonePosition, ref boneOrientation); | ||
|
||
boneOrientation *= CurrentAnimation.BonePositions[boneIndex].Orientation; | ||
bonePosition = boneOrientation.RotateVector(bonePosition); | ||
bonePosition *= Constants.SCALE_DOWN_RATIO; | ||
if (CurrentAnimation.TrackBoneNames[boneIndex].Text == "pelvis") | ||
{ | ||
|
||
} | ||
|
||
FinalBonesMatrix[boneIndex] = | ||
Matrix4x4.CreateFromQuaternion(boneOrientation) * | ||
Matrix4x4.CreateTranslation(bonePosition.ToMapVector()); | ||
} | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
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
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
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,52 @@ | ||
using System; | ||
using CUE4Parse.UE4.Assets.Exports.Animation; | ||
using CUE4Parse.UE4.Assets.Exports.SkeletalMesh; | ||
using CUE4Parse.UE4.Objects.UObject; | ||
|
||
namespace FModel.Views.Snooper; | ||
|
||
public class Skeleton : IDisposable | ||
{ | ||
public readonly USkeleton RefSkel; | ||
public readonly bool IsLoaded; | ||
public readonly Socket[] Sockets; | ||
|
||
public Animation Anim; | ||
|
||
public Skeleton(FPackageIndex package) | ||
{ | ||
RefSkel = package.Load<USkeleton>(); | ||
if (RefSkel == null) return; | ||
|
||
IsLoaded = true; | ||
Sockets = new Socket[RefSkel.Sockets.Length]; | ||
for (int i = 0; i < Sockets.Length; i++) | ||
{ | ||
if (RefSkel.Sockets[i].Load<USkeletalMeshSocket>() is not { } socket || | ||
!RefSkel.ReferenceSkeleton.FinalNameToIndexMap.TryGetValue(socket.BoneName.Text, out var boneIndex)) | ||
continue; | ||
|
||
var t = RefSkel.ReferenceSkeleton.FinalRefBonePose[boneIndex]; | ||
var transform = Transform.Identity; | ||
transform.Position = t.Translation.ToMapVector() * Constants.SCALE_DOWN_RATIO; | ||
transform.Rotation = t.Rotator(); | ||
transform.Scale = t.Scale3D.ToMapVector(); | ||
|
||
Sockets[i] = new Socket(socket, transform); | ||
} | ||
} | ||
|
||
public void SetUniform(Shader shader) | ||
{ | ||
if (!IsLoaded) return; | ||
for (var i = 0; i < Anim?.FinalBonesMatrix.Length; i++) | ||
{ | ||
shader.SetUniform($"uFinalBonesMatrix[{i}]", Anim.FinalBonesMatrix[i]); | ||
} | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
Oops, something went wrong.