mirror of
https://github.com/4sval/FModel.git
synced 2026-03-23 18:24:36 -05:00
fixed material index + wrong gl + draw distance + grid fading
This commit is contained in:
parent
8597e491e0
commit
b2002121ab
|
|
@ -13,13 +13,17 @@ public class Camera
|
|||
public float Yaw { get; set; } = -90f;
|
||||
public float Pitch { get; set; } = 0f;
|
||||
public float Zoom { get; set; } = 45f;
|
||||
public float Speed { get; set; } = 1f;
|
||||
public float Speed { get; } = 1f;
|
||||
public float Near { get; } = 0.01f;
|
||||
public float Far { get; } = 100f;
|
||||
public float AspectRatio => 16f / 9f;
|
||||
|
||||
public Camera(Vector3 position, Vector3 direction, float speed)
|
||||
public Camera(Vector3 position, Vector3 direction, float near, float far, float speed)
|
||||
{
|
||||
Position = position;
|
||||
Direction = direction;
|
||||
Near = near;
|
||||
Far = far;
|
||||
Speed = speed;
|
||||
|
||||
// trigonometric math to calculate the cam's yaw/pitch based on position and direction to look
|
||||
|
|
@ -52,7 +56,7 @@ public class Camera
|
|||
|
||||
public Matrix4x4 GetProjectionMatrix()
|
||||
{
|
||||
return Matrix4x4.CreatePerspectiveFieldOfView(Helper.DegreesToRadians(Zoom), AspectRatio, 0.1f, 100.0f);
|
||||
return Matrix4x4.CreatePerspectiveFieldOfView(Helper.DegreesToRadians(Zoom), AspectRatio, Near, Far);
|
||||
}
|
||||
|
||||
public void CalculateDirection()
|
||||
|
|
|
|||
|
|
@ -51,8 +51,8 @@ public class Grid : IDisposable
|
|||
|
||||
_shader.SetUniform("view", camera.GetViewMatrix());
|
||||
_shader.SetUniform("proj", camera.GetProjectionMatrix());
|
||||
_shader.SetUniform("uNear", -0.01f);
|
||||
_shader.SetUniform("uFar", 100f);
|
||||
_shader.SetUniform("uNear", camera.Near);
|
||||
_shader.SetUniform("uFar", camera.Far);
|
||||
|
||||
_gl.DrawArrays(PrimitiveType.Triangles, 0, (uint) Indices.Length);
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class Model : IDisposable
|
|||
for (var s = 0; s < sections.Length; s++)
|
||||
{
|
||||
var section = sections[s];
|
||||
Sections[s] = new Section(section.MaterialName, (uint) section.NumFaces * _faceSize, section.FirstIndex, section);
|
||||
Sections[s] = new Section(section.MaterialName, section.MaterialIndex, (uint) section.NumFaces * _faceSize, section.FirstIndex, section);
|
||||
for (uint face = 0; face < section.NumFaces; face++)
|
||||
{
|
||||
foreach (var f in _facesIndex)
|
||||
|
|
@ -121,7 +121,7 @@ public class Model : IDisposable
|
|||
ImGui.TableHeadersRow();
|
||||
for (int section = 0; section < Sections.Length; section++)
|
||||
{
|
||||
Sections[section].Bind(section, Indices.Length);
|
||||
Sections[section].Bind(Indices.Length);
|
||||
_gl.DrawArrays(PrimitiveType.Triangles, Sections[section].FirstFaceIndex, Sections[section].FacesCount);
|
||||
}
|
||||
ImGui.EndTable();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Numerics;
|
||||
using CUE4Parse.UE4.Assets.Exports.Material;
|
||||
using CUE4Parse.UE4.Assets.Exports.Texture;
|
||||
using CUE4Parse_Conversion.Meshes.PSK;
|
||||
|
|
@ -22,18 +21,21 @@ public class Section : IDisposable
|
|||
private Texture _emissionMap;
|
||||
|
||||
public string Name;
|
||||
public int Index;
|
||||
public uint FacesCount;
|
||||
public int FirstFaceIndex;
|
||||
public CMaterialParams Parameters;
|
||||
|
||||
public Section(string name, uint facesCount, int firstFaceIndex, CMeshSection section)
|
||||
public Section(string name, int index, uint facesCount, int firstFaceIndex, CMeshSection section)
|
||||
{
|
||||
Name = name;
|
||||
Index = index;
|
||||
FacesCount = facesCount;
|
||||
FirstFaceIndex = firstFaceIndex;
|
||||
Parameters = new CMaterialParams();
|
||||
if (section.Material != null && section.Material.TryLoad(out var material) && material is UMaterialInterface unrealMaterial)
|
||||
{
|
||||
Name = unrealMaterial.Name;
|
||||
unrealMaterial.GetParams(Parameters);
|
||||
}
|
||||
}
|
||||
|
|
@ -76,18 +78,18 @@ public class Section : IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
public void Bind(int index, float indices)
|
||||
public void Bind(float indices)
|
||||
{
|
||||
ImGui.TableNextRow();
|
||||
|
||||
ImGui.TableSetColumnIndex(0);
|
||||
ImGui.Text(index.ToString());
|
||||
ImGui.Text(Index.ToString());
|
||||
ImGui.TableSetColumnIndex(1);
|
||||
ImGui.Text(Name);
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
ImGui.BeginTooltip();
|
||||
ImGui.Text($"Faces: {FacesCount} ({Math.Floor(FacesCount / indices * 100f)}%%)");
|
||||
ImGui.Text($"Faces: {FacesCount} ({Math.Round(FacesCount / indices * 100f, 2)}%%)");
|
||||
ImGui.Text($"First Face: {FirstFaceIndex}");
|
||||
ImGui.Separator();
|
||||
ImGui.Text($"Diffuse: ({Parameters.Diffuse?.ExportType}) {Parameters.Diffuse?.Name}");
|
||||
|
|
|
|||
|
|
@ -80,9 +80,10 @@ public class Snooper
|
|||
|
||||
private void SetupCamera(FBox box)
|
||||
{
|
||||
var far = box.Max.Max();
|
||||
var center = box.GetCenter();
|
||||
var position = new Vector3(0f, center.Z, box.Max.Y * 3);
|
||||
_camera = new Camera(position, center, box.Max.Max() / 2f);
|
||||
_camera = new Camera(position, center, 0.01f, far * 50f, far / 2f);
|
||||
}
|
||||
|
||||
private void OnLoad()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user