-
-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
skeleton tree + fixed skeleton bones incorrect relation
- Loading branch information
Showing
20 changed files
with
843 additions
and
593 deletions.
There are no files selected for viewing
Submodule CUE4Parse
updated
3 files
+1 −1 | CUE4Parse-Conversion/Animations/PSA/CAnimSequence.cs | |
+8 −8 | CUE4Parse-Conversion/Animations/PSA/CAnimTrack.cs | |
+1 −0 | CUE4Parse-Conversion/IExporter.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
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,10 @@ | ||
#version 460 core | ||
|
||
in vec3 fPos; | ||
|
||
out vec4 FragColor; | ||
|
||
void main() | ||
{ | ||
FragColor = vec4(1.0, 1.0, 1.0, 1.0); | ||
} |
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,23 @@ | ||
#version 460 core | ||
|
||
layout (location = 1) in vec3 vPos; | ||
layout (location = 9) in mat4 vInstanceMatrix; | ||
|
||
uniform mat4 uView; | ||
uniform mat4 uProjection; | ||
uniform bool uSocket; | ||
|
||
out vec3 fPos; | ||
|
||
void main() | ||
{ | ||
float scale = 0.0075; | ||
mat4 result; | ||
result[0] = vec4(scale, 0.0, 0.0, 0.0); | ||
result[1] = vec4(0.0, scale, 0.0, 0.0); | ||
result[2] = vec4(0.0, 0.0, scale, 0.0); | ||
result[3] = vInstanceMatrix[3]; | ||
|
||
gl_Position = uProjection * uView * result * vec4(vPos, 1.0); | ||
fPos = vec3(result * vec4(vPos, 1.0)); | ||
} |
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,57 @@ | ||
using System.Collections.Generic; | ||
using System.Numerics; | ||
using CUE4Parse.UE4.Objects.Core.Math; | ||
|
||
namespace FModel.Views.Snooper.Models; | ||
|
||
public class Attachment | ||
{ | ||
private string _modelName; | ||
private string _attachedTo; | ||
private readonly List<string> _attachedFor; | ||
private Matrix4x4 _oldRelation; | ||
|
||
public bool IsAttached => _attachedTo.Length > 0; | ||
public bool IsAttachment => _attachedFor.Count > 0; | ||
|
||
public string Icon => IsAttachment ? "link_has" : IsAttached ? "link_on" : "link_off"; | ||
public string Tooltip => IsAttachment ? $"Is Attachment For:\n{string.Join("\n", _attachedFor)}" : IsAttached ? $"Is Attached To {_attachedTo}" : "Not Attached To Any Socket Nor Attachment For Any Model"; | ||
|
||
public Attachment(string modelName) | ||
{ | ||
_modelName = modelName; | ||
_attachedTo = string.Empty; | ||
_attachedFor = new List<string>(); | ||
} | ||
|
||
public void Attach(UModel attachedTo, Transform transform, Socket socket, SocketAttachementInfo info) | ||
{ | ||
socket.AttachedModels.Add(info); | ||
|
||
_attachedTo = $"'{socket.Name}' from '{attachedTo.Name}'{(!socket.BoneName.IsNone ? $" at '{socket.BoneName}'" : "")}"; | ||
attachedTo.Attachments.AddAttachment(_modelName); | ||
|
||
// reset PRS to 0 so it's attached to the actual position (can be transformed relative to the socket later by the user) | ||
_oldRelation = transform.Relation; | ||
transform.Position = FVector.ZeroVector; | ||
transform.Rotation = FQuat.Identity; | ||
transform.Scale = FVector.OneVector; | ||
} | ||
|
||
public void Detach(UModel attachedTo, Transform transform, Socket socket, SocketAttachementInfo info) | ||
{ | ||
socket.AttachedModels.Remove(info); | ||
SafeDetach(attachedTo, transform); | ||
} | ||
|
||
public void SafeDetach(UModel attachedTo, Transform transform) | ||
{ | ||
_attachedTo = string.Empty; | ||
attachedTo.Attachments.RemoveAttachment(_modelName); | ||
|
||
transform.Relation = _oldRelation; | ||
} | ||
|
||
public void AddAttachment(string modelName) => _attachedFor.Add($"'{modelName}'"); | ||
public void RemoveAttachment(string modelName) => _attachedFor.Remove($"'{modelName}'"); | ||
} |
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 CUE4Parse_Conversion.Meshes.PSK; | ||
using FModel.Views.Snooper.Shading; | ||
using OpenTK.Graphics.OpenGL4; | ||
|
||
namespace FModel.Views.Snooper.Models; | ||
|
||
public class BoneModel : UModel | ||
{ | ||
public BoneModel(CStaticMesh staticMesh) | ||
{ | ||
var lod = staticMesh.LODs[LodLevel]; | ||
|
||
Indices = new uint[lod.Indices.Value.Length]; | ||
for (int i = 0; i < Indices.Length; i++) | ||
{ | ||
Indices[i] = (uint) lod.Indices.Value[i]; | ||
} | ||
|
||
Vertices = new float[lod.NumVerts * VertexSize]; | ||
for (int i = 0; i < lod.Verts.Length; i++) | ||
{ | ||
var count = 0; | ||
var baseIndex = i * VertexSize; | ||
var vert = lod.Verts[i]; | ||
Vertices[baseIndex + count++] = vert.Position.X * Constants.SCALE_DOWN_RATIO; | ||
Vertices[baseIndex + count++] = vert.Position.Z * Constants.SCALE_DOWN_RATIO; | ||
Vertices[baseIndex + count++] = vert.Position.Y * Constants.SCALE_DOWN_RATIO; | ||
} | ||
|
||
Materials = new Material[1]; | ||
Materials[0] = new Material { IsUsed = true }; | ||
|
||
Sections = new Section[1]; | ||
Sections[0] = new Section(0, Indices.Length, 0); | ||
|
||
Box = staticMesh.BoundingBox * Constants.SCALE_DOWN_RATIO; | ||
} | ||
|
||
public override void Render(Shader shader, bool outline = false) | ||
{ | ||
GL.Disable(EnableCap.DepthTest); | ||
|
||
Vao.Bind(); | ||
foreach (var section in Sections) | ||
{ | ||
GL.DrawElementsInstanced(PrimitiveType.LineStrip, section.FacesCount, DrawElementsType.UnsignedInt, section.FirstFaceIndexPtr, TransformsCount); | ||
} | ||
Vao.Unbind(); | ||
|
||
GL.Enable(EnableCap.DepthTest); | ||
} | ||
} |
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,14 @@ | ||
namespace FModel.Views.Snooper.Models; | ||
|
||
public enum EAttribute | ||
{ | ||
Index, | ||
Position, | ||
Normals, | ||
Tangent, | ||
UVs, | ||
Layer, | ||
Colors, | ||
BonesId, | ||
BonesWeight | ||
} |
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,38 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Numerics; | ||
using FModel.Views.Snooper.Buffers; | ||
using FModel.Views.Snooper.Shading; | ||
|
||
namespace FModel.Views.Snooper.Models; | ||
|
||
public interface IRenderableModel : IDisposable | ||
{ | ||
protected int Handle { get; set; } | ||
protected BufferObject<uint> Ebo { get; set; } | ||
protected BufferObject<float> Vbo { get; set; } | ||
protected BufferObject<Matrix4x4> MatrixVbo { get; set; } | ||
protected VertexArrayObject<float, uint> Vao { get; set; } | ||
|
||
public string Path { get; } | ||
public string Name { get; } | ||
public string Type { get; } | ||
public int UvCount { get; } | ||
public uint[] Indices { get; protected set; } | ||
public float[] Vertices { get; protected set; } | ||
public Section[] Sections { get; protected set; } | ||
public List<Transform> Transforms { get; } | ||
public Attachment Attachments { get; } | ||
|
||
public bool IsSetup { get; set; } | ||
public bool IsVisible { get; set; } | ||
public bool IsSelected { get; set; } | ||
public bool ShowWireframe { get; set; } | ||
|
||
public void Setup(Options options); | ||
public void SetupInstances(); | ||
public void Render(Shader shader, bool outline = false); | ||
public void PickingRender(Shader shader); | ||
public void Update(Options options); | ||
public void AddInstance(Transform transform); | ||
} |
Oops, something went wrong.