diff --git a/CUE4Parse b/CUE4Parse
index 1cf7b4bc..d2efb39f 160000
--- a/CUE4Parse
+++ b/CUE4Parse
@@ -1 +1 @@
-Subproject commit 1cf7b4bc8e2f91e60fc5c9e60c6cb9a1ff1af315
+Subproject commit d2efb39f5fdc9bfbdae47cd7138601ecb0ef6812
diff --git a/FModel/Framework/ImGuiController.cs b/FModel/Framework/ImGuiController.cs
index 48dc9beb..808ad9ba 100644
--- a/FModel/Framework/ImGuiController.cs
+++ b/FModel/Framework/ImGuiController.cs
@@ -239,7 +239,7 @@ outputColor = color * texture(in_fontTexture, texCoord);
io.AddMouseButtonEvent(1, mState[MouseButton.Right]);
io.AddMouseButtonEvent(2, mState[MouseButton.Middle]);
- io.AddMousePosEvent(mState.PreviousX, mState.PreviousY);
+ io.AddMousePosEvent(mState.X, mState.Y);
foreach (Keys key in Enum.GetValues(typeof(Keys)))
{
diff --git a/FModel/Views/Snooper/Material.cs b/FModel/Views/Snooper/Material.cs
index 773a88b6..2ab80b3d 100644
--- a/FModel/Views/Snooper/Material.cs
+++ b/FModel/Views/Snooper/Material.cs
@@ -1,5 +1,7 @@
using System;
+using System.Collections.Generic;
using CUE4Parse.UE4.Assets.Exports.Material;
+using CUE4Parse.UE4.Assets.Exports.Texture;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
@@ -64,32 +66,22 @@ public class Material : IDisposable
}
else
{
- Diffuse = new Texture[UvNumber];
- for (int i = 0; i < Diffuse.Length; i++)
- if (Parameters.TryGetTexture2d(out var o, CMaterialParams2.Diffuse[i]) && cache.TryGetCachedTexture(o, out var t))
- Diffuse[i] = t;
+ Fill(cache, ref Diffuse, Parameters.HasTopDiffuse, CMaterialParams2.Diffuse, CMaterialParams2.FallbackDiffuse);
+ Fill(cache, ref Normals, true, CMaterialParams2.Normals, CMaterialParams2.FallbackNormals);
+ Fill(cache, ref SpecularMasks, true, CMaterialParams2.SpecularMasks, CMaterialParams2.FallbackSpecularMasks);
+ Fill(cache, ref Emissive, true, CMaterialParams2.Emissive, CMaterialParams2.FallbackEmissive);
- Normals = new Texture[UvNumber];
- for (int i = 0; i < Normals.Length; i++)
- if (Parameters.TryGetTexture2d(out var o, CMaterialParams2.Normals[i]) && cache.TryGetCachedTexture(o, out var t))
- Normals[i] = t;
-
- SpecularMasks = new Texture[UvNumber];
- for (int i = 0; i < SpecularMasks.Length; i++)
- if (Parameters.TryGetTexture2d(out var o, CMaterialParams2.SpecularMasks[i]) && cache.TryGetCachedTexture(o, out var t))
- SpecularMasks[i] = t;
-
- Emissive = new Texture[UvNumber];
EmissionColor = new Vector4[UvNumber];
- for (int i = 0; i < Emissive.Length; i++)
- if (Parameters.TryGetTexture2d(out var o, CMaterialParams2.Emissive[i]) && cache.TryGetCachedTexture(o, out var t))
- {
- Emissive[i] = t;
+ for (int i = 0; i < EmissionColor.Length; i++)
+ {
+ if (Emissive[i] == null) continue;
- if (Parameters.TryGetLinearColor(out var color, $"Emissive{(i > 0 ? i + 1 : "")}") && color is { A: > 0})
- EmissionColor[i] = new Vector4(color.R, color.G, color.B, color.A);
- else EmissionColor[i] = Vector4.One;
+ if (Parameters.TryGetLinearColor(out var color, $"Emissive{(i > 0 ? i + 1 : "")}") && color is { A: > 0 })
+ {
+ EmissionColor[i] = new Vector4(color.R, color.G, color.B, color.A);
}
+ else EmissionColor[i] = Vector4.One;
+ }
// diffuse light is based on normal map, so increase ambient if no normal map
_ambientLight = new Vector3(Normals[0] == null ? 1.0f : 0.2f);
@@ -99,6 +91,31 @@ public class Material : IDisposable
HasDiffuseColor = DiffuseColor != Vector4.Zero;
}
+ ///
+ ///
+ /// has at least 1 clearly defined texture
+ /// list of texture parameter names
+ /// fallback texture parameter name
+ private void Fill(Cache cache, ref Texture[] array, bool top, IReadOnlyList triggers, string fallback)
+ {
+ array = new Texture[UvNumber];
+ if (top)
+ {
+ for (int i = 0; i < array.Length; i++)
+ if (Parameters.TryGetTexture2d(out var o, triggers[i]) && cache.TryGetCachedTexture(o, out var t))
+ array[i] = t;
+ }
+ // else if (Parameters.Colors.TryGetValue("ColorMult", out var color) && color is { A: > 0})
+ // {
+ //
+ // }
+ else if (Parameters.Textures.TryGetValue(fallback, out var u) && u is UTexture2D o && cache.TryGetCachedTexture(o, out var t))
+ {
+ for (int i = 0; i < array.Length; i++)
+ array[i] = t;
+ }
+ }
+
public void Render(Shader shader)
{
var unit = 0;
diff --git a/FModel/Views/Snooper/Model.cs b/FModel/Views/Snooper/Model.cs
index 485e0a90..436bfbdb 100644
--- a/FModel/Views/Snooper/Model.cs
+++ b/FModel/Views/Snooper/Model.cs
@@ -21,7 +21,7 @@ public class Model : IDisposable
private BufferObject _matrixVbo;
private VertexArrayObject _vao;
- private readonly int _vertexSize = 10; // VertexIndex + Position + Normal + UV + TextureIndex
+ private readonly int _vertexSize = 10; // VertexIndex + Position + Normal + UV + TextureLayer
private readonly uint[] _facesIndex = { 1, 0, 2 };
private const int _faceSize = 3; // just so we don't have to do .Length
diff --git a/FModel/Views/Snooper/Renderer.cs b/FModel/Views/Snooper/Renderer.cs
index cde75e90..a5570ca7 100644
--- a/FModel/Views/Snooper/Renderer.cs
+++ b/FModel/Views/Snooper/Renderer.cs
@@ -144,7 +144,7 @@ public class Renderer : IDisposable
cancellationToken.ThrowIfCancellationRequested();
if (persistentLevel.Actors[i].Load() is not { } actor ||actor.ExportType == "LODActor" ||
- !actor.TryGetValue(out FPackageIndex staticMeshComponent, "StaticMeshComponent") ||
+ !actor.TryGetValue(out FPackageIndex staticMeshComponent, "StaticMeshComponent", "Mesh") ||
staticMeshComponent.Load() is not { } staticMeshComp) continue;
if (!staticMeshComp.TryGetValue(out FPackageIndex staticMesh, "StaticMesh") && actor.Class is UBlueprintGeneratedClass)
diff --git a/FModel/Views/Snooper/SnimGui.cs b/FModel/Views/Snooper/SnimGui.cs
index 2bfaa151..b1a23bbf 100644
--- a/FModel/Views/Snooper/SnimGui.cs
+++ b/FModel/Views/Snooper/SnimGui.cs
@@ -55,6 +55,9 @@ public class SnimGui
DrawNavbar();
ImGui.Begin("Camera");
+ ImGui.DragFloat("Speed", ref s.Camera.Speed, 0.01f);
+ ImGui.DragFloat("Near", ref s.Camera.Near, 0.1f, 0.01f, s.Camera.Far - 0.1f, "%.2f m", ImGuiSliderFlags.AlwaysClamp);
+ ImGui.DragFloat("Far", ref s.Camera.Far, 0.1f, s.Camera.Near + 0.1f, 0f, "%.2f m", ImGuiSliderFlags.AlwaysClamp);
ImGui.End();
ImGui.Begin("World");
ImGui.End();
@@ -186,7 +189,11 @@ public class SnimGui
PushStyleCompact();
ImGui.Columns(4, "Actions", false);
- // if (ImGui.Button("Go To")) s.Camera.Position = model.Transforms[s.Renderer.Settings.SelectedModelInstance].Position;
+ if (ImGui.Button("Go To"))
+ {
+ var instancePos = model.Transforms[model.SelectedInstance].Position;
+ s.Camera.Position = new Vector3(instancePos.X, instancePos.Z, instancePos.Y);
+ }
ImGui.NextColumn(); ImGui.Checkbox("Show", ref model.Show);
ImGui.NextColumn(); ImGui.BeginDisabled(!model.HasVertexColors); ImGui.Checkbox("Colors", ref model.DisplayVertexColors); ImGui.EndDisabled();
ImGui.NextColumn(); ImGui.BeginDisabled(!model.HasBones); ImGui.Checkbox("Bones", ref model.DisplayBones); ImGui.EndDisabled();
diff --git a/FModel/Views/Snooper/Snooper.cs b/FModel/Views/Snooper/Snooper.cs
index 5c9141cb..5b5b68e0 100644
--- a/FModel/Views/Snooper/Snooper.cs
+++ b/FModel/Views/Snooper/Snooper.cs
@@ -1,6 +1,7 @@
using System.Threading;
using System.Windows;
using CUE4Parse.UE4.Assets.Exports;
+using ImGuiNET;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
using OpenTK.Windowing.Common;
@@ -143,7 +144,7 @@ public class Snooper : GameWindow
protected override void OnUpdateFrame(FrameEventArgs e)
{
base.OnUpdateFrame(e);
- if (!IsVisible)
+ if (!IsVisible || ImGui.GetIO().WantTextInput)
return;
var multiplier = KeyboardState.IsKeyDown(Keys.LeftShift) ? 2f : 1f;