From 967ffefbe067f06c1eec18f20b84be3ff40ae246 Mon Sep 17 00:00:00 2001 From: Asval Date: Mon, 6 May 2024 23:22:59 +0200 Subject: [PATCH] point clouds for now + reduced opacity --- CUE4Parse | 2 +- FModel/Resources/default.frag | 7 ++++--- FModel/Settings/UserSettings.cs | 21 ++++++++++++++++++++ FModel/ViewModels/CUE4ParseViewModel.cs | 19 +----------------- FModel/Views/Snooper/Animations/Animation.cs | 2 +- FModel/Views/Snooper/Models/Collision.cs | 11 +++++++--- FModel/Views/Snooper/Models/UModel.cs | 21 ++++++++------------ 7 files changed, 44 insertions(+), 39 deletions(-) diff --git a/CUE4Parse b/CUE4Parse index 8360aeea..05f36306 160000 --- a/CUE4Parse +++ b/CUE4Parse @@ -1 +1 @@ -Subproject commit 8360aeea93df67272069f2a2f9e100272c18560e +Subproject commit 05f36306fae35a30dae565ba02c4fc05e643a995 diff --git a/FModel/Resources/default.frag b/FModel/Resources/default.frag index 34a2225c..71f42fc2 100644 --- a/FModel/Resources/default.frag +++ b/FModel/Resources/default.frag @@ -89,6 +89,7 @@ uniform Parameters uParameters; uniform Light uLights[MAX_LIGHT_COUNT]; uniform int uNumLights; uniform int uUvCount; +uniform float uOpacity; uniform bool uHasVertexColors; uniform vec3 uSectionColor; uniform bool bVertexColors[6]; @@ -214,7 +215,7 @@ void main() { if (bVertexColors[1]) { - FragColor = vec4(uSectionColor, 1.0); + FragColor = vec4(uSectionColor, uOpacity); } else if (bVertexColors[2] && uHasVertexColors) { @@ -224,7 +225,7 @@ void main() { int layer = LayerToIndex(); vec3 normals = ComputeNormals(layer); - FragColor = vec4(normals, 1.0); + FragColor = vec4(normals, uOpacity); } else if (bVertexColors[4]) { @@ -281,6 +282,6 @@ void main() } result = result / (result + vec3(1.0)); - FragColor = vec4(pow(result, vec3(1.0 / 2.2)), 1.0); + FragColor = vec4(pow(result, vec3(1.0 / 2.2)), uOpacity); } } diff --git a/FModel/Settings/UserSettings.cs b/FModel/Settings/UserSettings.cs index 8945c772..b5eb8e3e 100644 --- a/FModel/Settings/UserSettings.cs +++ b/FModel/Settings/UserSettings.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.IO; using System.Windows; using System.Windows.Input; +using CUE4Parse_Conversion; +using CUE4Parse_Conversion.Animations; using CUE4Parse.UE4.Versions; using CUE4Parse_Conversion.Meshes; using CUE4Parse_Conversion.Textures; @@ -48,6 +50,25 @@ namespace FModel.Settings return endpoint.Overwrite || endpoint.IsValid; } + [JsonIgnore] + public ExporterOptions ExportOptions => new() + { + LodFormat = Default.LodExportFormat, + MeshFormat = Default.MeshExportFormat, + AnimFormat = Default.MeshExportFormat switch + { + EMeshFormat.UEFormat => EAnimFormat.UEFormat, + _ => EAnimFormat.ActorX + }, + MaterialFormat = Default.MaterialExportFormat, + TextureFormat = Default.TextureExportFormat, + SocketFormat = Default.SocketExportFormat, + CompressionFormat = Default.CompressionFormat, + Platform = Default.CurrentDir.TexturePlatform, + ExportMorphTargets = Default.SaveMorphTargets, + ExportMaterials = Default.SaveEmbeddedMaterials + }; + private bool _showChangelog = true; public bool ShowChangelog { diff --git a/FModel/ViewModels/CUE4ParseViewModel.cs b/FModel/ViewModels/CUE4ParseViewModel.cs index b9298cda..13eac386 100644 --- a/FModel/ViewModels/CUE4ParseViewModel.cs +++ b/FModel/ViewModels/CUE4ParseViewModel.cs @@ -959,24 +959,7 @@ public class CUE4ParseViewModel : ViewModel private void SaveExport(UObject export, bool auto) { - var exportOptions = new ExporterOptions - { - LodFormat = UserSettings.Default.LodExportFormat, - MeshFormat = UserSettings.Default.MeshExportFormat, - AnimFormat = UserSettings.Default.MeshExportFormat switch - { - EMeshFormat.ActorX => EAnimFormat.ActorX, - _ => EAnimFormat.UEFormat // i think we said ueformat default is okay - }, - MaterialFormat = UserSettings.Default.MaterialExportFormat, - TextureFormat = UserSettings.Default.TextureExportFormat, - SocketFormat = UserSettings.Default.SocketExportFormat, - CompressionFormat = UserSettings.Default.CompressionFormat, - Platform = UserSettings.Default.CurrentDir.TexturePlatform, - ExportMorphTargets = UserSettings.Default.SaveMorphTargets, - ExportMaterials = UserSettings.Default.SaveEmbeddedMaterials - }; - var toSave = new Exporter(export, exportOptions); + var toSave = new Exporter(export, UserSettings.Default.ExportOptions); string dir; if (!auto) diff --git a/FModel/Views/Snooper/Animations/Animation.cs b/FModel/Views/Snooper/Animations/Animation.cs index 35e81597..87936494 100644 --- a/FModel/Views/Snooper/Animations/Animation.cs +++ b/FModel/Views/Snooper/Animations/Animation.cs @@ -134,7 +134,7 @@ public class Animation : IDisposable if (ImGui.MenuItem("Save")) { s.WindowShouldFreeze(true); - saver.Value = new Exporter(_export).TryWriteToDir(new DirectoryInfo(UserSettings.Default.ModelDirectory), out saver.Label, out saver.Path); + saver.Value = new Exporter(_export, UserSettings.Default.ExportOptions).TryWriteToDir(new DirectoryInfo(UserSettings.Default.ModelDirectory), out saver.Label, out saver.Path); s.WindowShouldFreeze(false); } ImGui.Separator(); diff --git a/FModel/Views/Snooper/Models/Collision.cs b/FModel/Views/Snooper/Models/Collision.cs index 6ac7c4d4..953a573a 100644 --- a/FModel/Views/Snooper/Models/Collision.cs +++ b/FModel/Views/Snooper/Models/Collision.cs @@ -46,9 +46,14 @@ public class Collision : IDisposable shader.SetUniform("uCollisionMatrix", _transform.Matrix); _vao.Bind(); - GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line); - GL.DrawElements(PrimitiveType.Triangles, _ebo.Size, DrawElementsType.UnsignedInt, 0); - GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); + if (_indexData.Length > 0) + { + GL.DrawElements(PrimitiveType.Triangles, _ebo.Size, DrawElementsType.UnsignedInt, 0); + } + else + { + GL.DrawArrays(PrimitiveType.Points, 0, _vbo.Size); + } _vao.Unbind(); } diff --git a/FModel/Views/Snooper/Models/UModel.cs b/FModel/Views/Snooper/Models/UModel.cs index 9cdb0b99..918d48e9 100644 --- a/FModel/Views/Snooper/Models/UModel.cs +++ b/FModel/Views/Snooper/Models/UModel.cs @@ -151,7 +151,7 @@ public abstract class UModel : IRenderableModel Vertices[baseIndex + count++] = vert.Tangent.Y; Vertices[baseIndex + count++] = vert.UV.U; Vertices[baseIndex + count++] = vert.UV.V; - Vertices[baseIndex + count++] = hasCustomUvs ? lod.ExtraUV.Value[0][i].U : .5f; + Vertices[baseIndex + count++] = hasCustomUvs ? lod.ExtraUV.Value[0][i].U - 1 : .5f; if (HasVertexColors) { @@ -250,6 +250,7 @@ public abstract class UModel : IRenderableModel if (!outline) { shader.SetUniform("uUvCount", UvCount); + shader.SetUniform("uOpacity", ShowCollisions && IsSelected ? 0.75f : 1f); shader.SetUniform("uHasVertexColors", HasVertexColors); } @@ -308,10 +309,15 @@ public abstract class UModel : IRenderableModel { shader.SetUniform("uInstanceMatrix", GetTransform().Matrix); shader.SetUniform("uScaleDown", Constants.SCALE_DOWN_RATIO); + + GL.Disable(EnableCap.CullFace); + GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line); foreach (var collision in Collisions) { collision.Render(shader); } + GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); + GL.Enable(EnableCap.CullFace); } public void Update(Options options) @@ -375,18 +381,7 @@ public abstract class UModel : IRenderableModel public bool Save(out string label, out string savedFilePath) { - var exportOptions = new ExporterOptions - { - LodFormat = UserSettings.Default.LodExportFormat, - MeshFormat = UserSettings.Default.MeshExportFormat, - MaterialFormat = UserSettings.Default.MaterialExportFormat, - TextureFormat = UserSettings.Default.TextureExportFormat, - SocketFormat = UserSettings.Default.SocketExportFormat, - Platform = UserSettings.Default.CurrentDir.TexturePlatform, - ExportMorphTargets = UserSettings.Default.SaveMorphTargets, - ExportMaterials = UserSettings.Default.SaveEmbeddedMaterials - }; - var toSave = new Exporter(_export, exportOptions); + var toSave = new Exporter(_export, UserSettings.Default.ExportOptions); return toSave.TryWriteToDir(new DirectoryInfo(UserSettings.Default.ModelDirectory), out label, out savedFilePath); }