Skip to content

Commit

Permalink
Added 3D viewport for previewing 3D visual models
Browse files Browse the repository at this point in the history
  • Loading branch information
BuilderDemo7 committed Dec 16, 2023
1 parent 9f8f43f commit 97c0aed
Show file tree
Hide file tree
Showing 16 changed files with 19,809 additions and 87 deletions.
73 changes: 73 additions & 0 deletions WADExplorer/Extras/DFFCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,29 @@
using System.Threading.Tasks;
using System.Diagnostics;

using System.Windows;
using System.Windows.Media.Media3D;
using System.Windows.Media;

// Hello, dear coder/viewer/programmer
// Get ready to get lost because there are
// Many classes in this code
// Sincerely, BuilderDemo7

namespace WADExplorer
{
// useful for XZY formats ig
public enum Vector3Puzzle : int
{
XYZ = 0,
XZY = 1,
ZXY = 2,
ZYX = 3,

YZX = 4,
YXZ = 5
}

// vectors cores ;)
public class Vector4
{
Expand Down Expand Up @@ -101,6 +117,48 @@ public string Format(string format)
return String.Format(format,_x,_y,_z);
}

public static implicit operator Vector3D(Vector3 vector3)
{
return new Vector3D((double)vector3.X, (double)vector3.Y, (double)vector3.Z);
}

public static implicit operator Vector3(Vector3D vector3D)
{
return new Vector3((float)vector3D.X, (float)vector3D.Y, (float)vector3D.Z);
}

public static implicit operator Point3D(Vector3 vector3)
{
return new Point3D((float)vector3.X, (float)vector3.Y, (float)vector3.Z);
}

public static implicit operator Vector3(Point3D p3d)
{
return new Vector3((float)p3d.X, (float)p3d.Y, (float)p3d.Z);
}

public Vector3 Puzzle(Vector3Puzzle puzzle)
{
switch (puzzle)
{
case Vector3Puzzle.XYZ:
default:
return new Vector3(_x, _y, _z);

case Vector3Puzzle.XZY:
return new Vector3(_x, _z, _y);
case Vector3Puzzle.ZXY:
return new Vector3(_z, _x, _y);
case Vector3Puzzle.ZYX:
return new Vector3(_z, _y, _x);

case Vector3Puzzle.YZX:
return new Vector3(_y, _z, _x);
case Vector3Puzzle.YXZ:
return new Vector3(_y, _x, _z);
}
}

public byte[] GetBytes()
{
byte[] bytes = new byte[12];
Expand Down Expand Up @@ -146,6 +204,16 @@ public string Format(string format)
return String.Format(format, _x, _y);
}

public static implicit operator Point(Vector2 vector2)
{
return new Point((double)vector2.X, (double)vector2.Y);
}

public static implicit operator Vector2(Point p)
{
return new Vector2((float)p.X, (float)p.Y);
}

public byte[] GetBytes()
{
byte[] bytes = new byte[8];
Expand Down Expand Up @@ -221,8 +289,13 @@ public byte[] GetBytes()
stream.Dispose();
return bytes;
}
public TexCoords Flip()
{
return new TexCoords(1 - Coords.X, 1 - Coords.Y);
}
public TexCoords() { }
public TexCoords(Vector2 uv) { Coords = uv; }
public TexCoords(float u, float v) { Coords = new Vector2(u,v); }
public TexCoords(Stream stream) { Load(stream); }
}
public class Vertex
Expand Down
10 changes: 10 additions & 0 deletions WADExplorer/REWAD/InsideItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ public class InsideItem
[Browsable(false)]
public byte[] Buffer { get; set; }

public InsideItem FindFirstChildByName(string name, bool checkSiblings = false)
{
foreach(InsideItem child in Children)
{
if (child.Name.ToLower() == name.ToLower())
return child;
}
return null;
}

public InsideItem() { }
public InsideItem(
bool folder,
Expand Down
26 changes: 26 additions & 0 deletions WADExplorer/REWAD/Package.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,32 @@ public void Load(string filename)
Load(fileS);
}

// Example: Data/[Cache]
public InsideItem GetChildByPath(string path)
{
char sep = '/';
if (path.Contains(@"\"))
sep = (char)(byte)(0x5C);



string[] pathNames = path.Split(sep);

if (pathNames[0].Contains(":"))
{
throw new InvalidOperationException("The path cannot be a path to a disk unit");
}

InsideItem r = Items[0].FindFirstChildByName(pathNames[0].Replace("\0", ""));
for (int id = 1; id < pathNames.Length; id++)
{
string p = pathNames[id];

r = r.FindFirstChildByName(p);
}
return r;
}

public virtual byte[] RegenerateAndReturnBuffer(bool saveInNewFormat = true)
{
if (saveInNewFormat==false)
Expand Down
206 changes: 206 additions & 0 deletions WADExplorer/References/HelixToolkit.Wpf.Input.XML

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file added WADExplorer/References/HelixToolkit.Wpf.Input.pdb
Binary file not shown.
Loading

0 comments on commit 97c0aed

Please sign in to comment.