mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-29 18:32:55 +08:00
YFT/XML conversion progress
This commit is contained in:
parent
bec16ea42d
commit
e44b2ef095
@ -110,26 +110,6 @@ namespace CodeWalker.GameFiles
|
|||||||
if (!string.IsNullOrEmpty(ddsfolder))
|
if (!string.IsNullOrEmpty(ddsfolder))
|
||||||
{
|
{
|
||||||
ddsfolder = Path.Combine(outputFolder, ydd.Name);
|
ddsfolder = Path.Combine(outputFolder, ydd.Name);
|
||||||
|
|
||||||
bool hastxd = false;
|
|
||||||
if (ydd?.DrawableDict?.Drawables?.data_items != null)
|
|
||||||
{
|
|
||||||
foreach (var d in ydd.DrawableDict.Drawables.data_items)
|
|
||||||
{
|
|
||||||
if (d?.ShaderGroup?.TextureDictionary != null)
|
|
||||||
{
|
|
||||||
hastxd = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hastxd)
|
|
||||||
{
|
|
||||||
if (!Directory.Exists(ddsfolder))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(ddsfolder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ydd?.DrawableDict != null)
|
if (ydd?.DrawableDict != null)
|
||||||
|
@ -75,14 +75,6 @@ namespace CodeWalker.GameFiles
|
|||||||
if (!string.IsNullOrEmpty(ddsfolder))
|
if (!string.IsNullOrEmpty(ddsfolder))
|
||||||
{
|
{
|
||||||
ddsfolder = Path.Combine(outputFolder, ydr.Name);
|
ddsfolder = Path.Combine(outputFolder, ydr.Name);
|
||||||
|
|
||||||
if (ydr?.Drawable?.ShaderGroup?.TextureDictionary != null)
|
|
||||||
{
|
|
||||||
if (!Directory.Exists(ddsfolder))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(ddsfolder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ydr?.Drawable != null)
|
if (ydr?.Drawable != null)
|
||||||
|
@ -79,40 +79,6 @@ namespace CodeWalker.GameFiles
|
|||||||
if (!string.IsNullOrEmpty(ddsfolder))
|
if (!string.IsNullOrEmpty(ddsfolder))
|
||||||
{
|
{
|
||||||
ddsfolder = Path.Combine(outputFolder, yft.Name);
|
ddsfolder = Path.Combine(outputFolder, yft.Name);
|
||||||
|
|
||||||
bool hastxd = false;
|
|
||||||
if (yft?.Fragment != null)
|
|
||||||
{
|
|
||||||
hastxd = hastxd || (yft.Fragment.Drawable?.ShaderGroup?.TextureDictionary != null);
|
|
||||||
hastxd = hastxd || (yft.Fragment.Drawable2?.ShaderGroup?.TextureDictionary != null);
|
|
||||||
if (yft.Fragment.DrawableArray?.data_items != null)
|
|
||||||
{
|
|
||||||
foreach (var d in yft.Fragment.DrawableArray?.data_items)
|
|
||||||
{
|
|
||||||
if (hastxd) break;
|
|
||||||
if (d?.ShaderGroup?.TextureDictionary != null)
|
|
||||||
{
|
|
||||||
hastxd = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (yft.Fragment.PhysicsLODGroup?.PhysicsLOD1?.Children?.data_items != null)
|
|
||||||
{
|
|
||||||
foreach (var child in yft.Fragment.PhysicsLODGroup.PhysicsLOD1.Children.data_items)
|
|
||||||
{
|
|
||||||
if (hastxd) break;
|
|
||||||
hastxd = hastxd || (child.Drawable1?.ShaderGroup?.TextureDictionary != null);
|
|
||||||
hastxd = hastxd || (child.Drawable2?.ShaderGroup?.TextureDictionary != null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hastxd)
|
|
||||||
{
|
|
||||||
if (!Directory.Exists(ddsfolder))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(ddsfolder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yft?.Fragment != null)
|
if (yft?.Fragment != null)
|
||||||
|
@ -127,26 +127,6 @@ namespace CodeWalker.GameFiles
|
|||||||
if (!string.IsNullOrEmpty(ddsfolder))
|
if (!string.IsNullOrEmpty(ddsfolder))
|
||||||
{
|
{
|
||||||
ddsfolder = Path.Combine(outputFolder, ypt.Name);
|
ddsfolder = Path.Combine(outputFolder, ypt.Name);
|
||||||
|
|
||||||
bool hastxd = false;
|
|
||||||
if (ypt?.DrawableDict != null)
|
|
||||||
{
|
|
||||||
foreach (var d in ypt.DrawableDict.Values)
|
|
||||||
{
|
|
||||||
if (d?.ShaderGroup?.TextureDictionary != null)
|
|
||||||
{
|
|
||||||
hastxd = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hastxd)
|
|
||||||
{
|
|
||||||
if (!Directory.Exists(ddsfolder))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(ddsfolder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ypt?.PtfxList != null)
|
if (ypt?.PtfxList != null)
|
||||||
|
@ -4194,9 +4194,9 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((yft.Fragment.Clothes != null) && (yft.Fragment.Clothes.data_items != null))
|
if ((yft.Fragment.Cloths != null) && (yft.Fragment.Cloths.data_items != null))
|
||||||
{
|
{
|
||||||
foreach (var cloth in yft.Fragment.Clothes.data_items)
|
foreach (var cloth in yft.Fragment.Cloths.data_items)
|
||||||
{
|
{
|
||||||
drawablecount++;
|
drawablecount++;
|
||||||
foreach (var kvp in cloth.Drawable.VertexDecls)
|
foreach (var kvp in cloth.Drawable.VertexDecls)
|
||||||
|
@ -1790,6 +1790,21 @@ namespace CodeWalker.GameFiles
|
|||||||
else SelfClosingTag(sb, indent, name);
|
else SelfClosingTag(sb, indent, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void WriteRawArrayContent<T>(StringBuilder sb, T[] arr, int ind, Func<T, string> formatter = null, int arrRowSize = 10) where T : struct
|
||||||
|
{
|
||||||
|
var aCount = arr?.Length ?? 0;
|
||||||
|
for (int n = 0; n < aCount; n++)
|
||||||
|
{
|
||||||
|
var col = n % arrRowSize;
|
||||||
|
if (col == 0) Indent(sb, ind);
|
||||||
|
if (col > 0) sb.Append(" ");
|
||||||
|
string str = (formatter != null) ? formatter(arr[n]) : arr[n].ToString();
|
||||||
|
sb.Append(str);
|
||||||
|
bool lastcol = (col == (arrRowSize - 1));
|
||||||
|
bool lastn = (n == (aCount - 1));
|
||||||
|
if (lastcol || lastn) sb.AppendLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
public static void WriteRawArray<T>(StringBuilder sb, T[] arr, int ind, string name, string typeName, Func<T, string> formatter = null, int arrRowSize = 10) where T : struct
|
public static void WriteRawArray<T>(StringBuilder sb, T[] arr, int ind, string name, string typeName, Func<T, string> formatter = null, int arrRowSize = 10) where T : struct
|
||||||
{
|
{
|
||||||
var aCount = arr?.Length ?? 0;
|
var aCount = arr?.Length ?? 0;
|
||||||
|
@ -5,6 +5,7 @@ using System.ComponentModel;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright(c) 2017 Neodymium
|
Copyright(c) 2017 Neodymium
|
||||||
@ -892,7 +893,7 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[TypeConverter(typeof(ExpandableObjectConverter))] public class EnvironmentCloth : ResourceSystemBlock
|
[TypeConverter(typeof(ExpandableObjectConverter))] public class EnvironmentCloth : ResourceSystemBlock, IMetaXmlItem
|
||||||
{
|
{
|
||||||
// pgBase
|
// pgBase
|
||||||
// clothBase (TODO)
|
// clothBase (TODO)
|
||||||
@ -938,9 +939,6 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
private ResourceSystemStructBlock<uint> UnknownDataBlock = null;
|
private ResourceSystemStructBlock<uint> UnknownDataBlock = null;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Reads the data-block from a stream.
|
|
||||||
/// </summary>
|
|
||||||
public override void Read(ResourceDataReader reader, params object[] parameters)
|
public override void Read(ResourceDataReader reader, params object[] parameters)
|
||||||
{
|
{
|
||||||
// read structure data
|
// read structure data
|
||||||
@ -992,10 +990,6 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Writes the data-block to a stream.
|
|
||||||
/// </summary>
|
|
||||||
public override void Write(ResourceDataWriter writer, params object[] parameters)
|
public override void Write(ResourceDataWriter writer, params object[] parameters)
|
||||||
{
|
{
|
||||||
// update structure data
|
// update structure data
|
||||||
@ -1037,10 +1031,15 @@ namespace CodeWalker.GameFiles
|
|||||||
writer.Write(this.Unknown_78h);
|
writer.Write(this.Unknown_78h);
|
||||||
writer.Write(this.Unknown_7Ch);
|
writer.Write(this.Unknown_7Ch);
|
||||||
}
|
}
|
||||||
|
public void WriteXml(StringBuilder sb, int indent)
|
||||||
|
{
|
||||||
|
//TODO!!
|
||||||
|
}
|
||||||
|
public void ReadXml(XmlNode node)
|
||||||
|
{
|
||||||
|
//TODO!!
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a list of data blocks which are referenced by this block.
|
|
||||||
/// </summary>
|
|
||||||
public override IResourceBlock[] GetReferences()
|
public override IResourceBlock[] GetReferences()
|
||||||
{
|
{
|
||||||
var list = new List<IResourceBlock>();
|
var list = new List<IResourceBlock>();
|
||||||
@ -1054,6 +1053,7 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
return list.ToArray();
|
return list.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -140,6 +140,28 @@ namespace CodeWalker.GameFiles
|
|||||||
//public float Unknown_22 { get; set; }
|
//public float Unknown_22 { get; set; }
|
||||||
//public float Unknown_23 { get; set; }
|
//public float Unknown_23 { get; set; }
|
||||||
//public float Unknown_24 { get; set; }
|
//public float Unknown_24 { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public Matrix3_s(float[] a)
|
||||||
|
{
|
||||||
|
if ((a != null) && (a.Length == 12))
|
||||||
|
{
|
||||||
|
Row1 = new Vector4(a[0], a[1], a[2], a[3]);
|
||||||
|
Row2 = new Vector4(a[4], a[5], a[6], a[7]);
|
||||||
|
Row3 = new Vector4(a[8], a[9], a[10], a[11]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Row1 = new Vector4(1, 0, 0, 0);
|
||||||
|
Row2 = new Vector4(0, 1, 0, 0);
|
||||||
|
Row3 = new Vector4(0, 0, 1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public float[] ToArray()
|
||||||
|
{
|
||||||
|
return new[] { Row1.X, Row1.Y, Row1.Z, Row1.W, Row2.X, Row2.Y, Row2.Z, Row2.W, Row3.X, Row3.Y, Row3.Z, Row3.W };
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[TypeConverter(typeof(ExpandableObjectConverter))] public struct AABB_s
|
[TypeConverter(typeof(ExpandableObjectConverter))] public struct AABB_s
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -506,9 +507,16 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var filepath = System.IO.Path.Combine(ddsfolder, (Name ?? "null") + ".dds");
|
if (!string.IsNullOrEmpty(ddsfolder))
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(ddsfolder))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(ddsfolder);
|
||||||
|
}
|
||||||
|
var filepath = Path.Combine(ddsfolder, (Name ?? "null") + ".dds");
|
||||||
var dds = DDSIO.GetDDSFile(this);
|
var dds = DDSIO.GetDDSFile(this);
|
||||||
System.IO.File.WriteAllBytes(filepath, dds);
|
File.WriteAllBytes(filepath, dds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
@ -526,10 +534,10 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var filepath = System.IO.Path.Combine(ddsfolder, filename);
|
var filepath = Path.Combine(ddsfolder, filename);
|
||||||
if (System.IO.File.Exists(filepath))
|
if (File.Exists(filepath))
|
||||||
{
|
{
|
||||||
var dds = System.IO.File.ReadAllBytes(filepath);
|
var dds = File.ReadAllBytes(filepath);
|
||||||
var tex = DDSIO.GetTexture(dds);
|
var tex = DDSIO.GetTexture(dds);
|
||||||
if (tex != null)
|
if (tex != null)
|
||||||
{
|
{
|
||||||
|
@ -74,6 +74,7 @@ namespace CodeWalker.GameFiles
|
|||||||
GTAV1 = 0x7755555555996996, // GTAV - used by most drawables
|
GTAV1 = 0x7755555555996996, // GTAV - used by most drawables
|
||||||
GTAV2 = 0x030000000199A006, // GTAV - used on cloth?
|
GTAV2 = 0x030000000199A006, // GTAV - used on cloth?
|
||||||
GTAV3 = 0x0300000001996006, // GTAV - used on cloth?
|
GTAV3 = 0x0300000001996006, // GTAV - used on cloth?
|
||||||
|
GTAV4 = 0x7655555555996996, // GTAV - used by FragGlassWindow
|
||||||
|
|
||||||
//Types4 = 0x0000000007097007, // Max Payne 3
|
//Types4 = 0x0000000007097007, // Max Payne 3
|
||||||
//Types5 = 0x0700000007097977, // Max Payne 3
|
//Types5 = 0x0700000007097977, // Max Payne 3
|
||||||
|
@ -708,7 +708,6 @@ namespace CodeWalker
|
|||||||
shader.Unknown_24h = 0;
|
shader.Unknown_24h = 0;
|
||||||
shader.Unknown_26h = 0;
|
shader.Unknown_26h = 0;
|
||||||
shader.Unknown_28h = 0;
|
shader.Unknown_28h = 0;
|
||||||
shader.Unknown_2Ch = 0;
|
|
||||||
|
|
||||||
|
|
||||||
switch (spsName)
|
switch (spsName)
|
||||||
|
@ -41,6 +41,14 @@ namespace CodeWalker
|
|||||||
uint.TryParse(val, out i);
|
uint.TryParse(val, out i);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
public static ulong GetULongAttribute(XmlNode node, string attribute)
|
||||||
|
{
|
||||||
|
if (node == null) return 0;
|
||||||
|
string val = node.Attributes[attribute]?.InnerText;
|
||||||
|
ulong i;
|
||||||
|
ulong.TryParse(val, out i);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
public static float GetFloatAttribute(XmlNode node, string attribute)
|
public static float GetFloatAttribute(XmlNode node, string attribute)
|
||||||
{
|
{
|
||||||
if (node == null) return 0;
|
if (node == null) return 0;
|
||||||
@ -199,7 +207,7 @@ namespace CodeWalker
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static byte[] GetRawByteArray(XmlNode node)
|
public static byte[] GetRawByteArray(XmlNode node, int fromBase = 16)
|
||||||
{
|
{
|
||||||
if (node == null) return new byte[0];
|
if (node == null) return new byte[0];
|
||||||
var data = new List<byte>();
|
var data = new List<byte>();
|
||||||
@ -210,16 +218,16 @@ namespace CodeWalker
|
|||||||
{
|
{
|
||||||
var str = split[i];
|
var str = split[i];
|
||||||
if (string.IsNullOrEmpty(str)) continue;
|
if (string.IsNullOrEmpty(str)) continue;
|
||||||
var val = Convert.ToByte(str, 16);
|
var val = Convert.ToByte(str, fromBase);
|
||||||
data.Add(val);
|
data.Add(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return data.ToArray();
|
return data.ToArray();
|
||||||
}
|
}
|
||||||
public static byte[] GetChildRawByteArray(XmlNode node, string name)
|
public static byte[] GetChildRawByteArray(XmlNode node, string name, int fromBase = 16)
|
||||||
{
|
{
|
||||||
var cnode = node.SelectSingleNode(name);
|
var cnode = node.SelectSingleNode(name);
|
||||||
return GetRawByteArray(cnode);
|
return GetRawByteArray(cnode, fromBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ushort[] GetRawUshortArray(XmlNode node)
|
public static ushort[] GetRawUshortArray(XmlNode node)
|
||||||
@ -450,6 +458,18 @@ namespace CodeWalker
|
|||||||
return GetRawVector4Array(cnode);
|
return GetRawVector4Array(cnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Matrix GetMatrix(XmlNode node)
|
||||||
|
{
|
||||||
|
if (node == null) return Matrix.Identity;
|
||||||
|
var arr = GetRawFloatArray(node);
|
||||||
|
if ((arr == null) || (arr.Length != 16)) return Matrix.Identity;
|
||||||
|
return new Matrix(arr);
|
||||||
|
}
|
||||||
|
public static Matrix GetChildMatrix(XmlNode node, string name)
|
||||||
|
{
|
||||||
|
var cnode = node.SelectSingleNode(name);
|
||||||
|
return GetMatrix(cnode);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user