mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-22 23:12:59 +08:00
YFT/XML conversion progress
This commit is contained in:
parent
88b4785a10
commit
de3aa9f83b
@ -169,6 +169,13 @@ namespace CodeWalker.GameFiles
|
|||||||
public YbnFile OwnerYbn { get; set; }
|
public YbnFile OwnerYbn { get; set; }
|
||||||
public object Owner { get; set; }
|
public object Owner { get; set; }
|
||||||
public string OwnerName { get; set; }
|
public string OwnerName { get; set; }
|
||||||
|
public bool OwnerIsFragment
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ((Owner is FragPhysicsLOD) || (Owner is FragPhysArchetype) || (Owner is FragDrawable));
|
||||||
|
}
|
||||||
|
}
|
||||||
public string GetName()
|
public string GetName()
|
||||||
{
|
{
|
||||||
string n = OwnerName;
|
string n = OwnerName;
|
||||||
@ -417,8 +424,11 @@ namespace CodeWalker.GameFiles
|
|||||||
YbnXml.SelfClosingTag(sb, indent, "CompositePosition " + FloatUtil.GetVector3XmlString(Position));
|
YbnXml.SelfClosingTag(sb, indent, "CompositePosition " + FloatUtil.GetVector3XmlString(Position));
|
||||||
YbnXml.SelfClosingTag(sb, indent, "CompositeRotation " + FloatUtil.GetVector4XmlString(Orientation.ToVector4()));
|
YbnXml.SelfClosingTag(sb, indent, "CompositeRotation " + FloatUtil.GetVector4XmlString(Orientation.ToVector4()));
|
||||||
YbnXml.SelfClosingTag(sb, indent, "CompositeScale " + FloatUtil.GetVector3XmlString(Scale));
|
YbnXml.SelfClosingTag(sb, indent, "CompositeScale " + FloatUtil.GetVector3XmlString(Scale));
|
||||||
YbnXml.StringTag(sb, indent, "CompositeFlags1", CompositeFlags1.Flags1.ToString());
|
if (!Parent.OwnerIsFragment)
|
||||||
YbnXml.StringTag(sb, indent, "CompositeFlags2", CompositeFlags1.Flags2.ToString());
|
{
|
||||||
|
YbnXml.StringTag(sb, indent, "CompositeFlags1", CompositeFlags1.Flags1.ToString());
|
||||||
|
YbnXml.StringTag(sb, indent, "CompositeFlags2", CompositeFlags1.Flags2.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public virtual void ReadXml(XmlNode node)
|
public virtual void ReadXml(XmlNode node)
|
||||||
@ -444,11 +454,14 @@ namespace CodeWalker.GameFiles
|
|||||||
Position = Xml.GetChildVector3Attributes(node, "CompositePosition");
|
Position = Xml.GetChildVector3Attributes(node, "CompositePosition");
|
||||||
Orientation = Xml.GetChildVector4Attributes(node, "CompositeRotation").ToQuaternion();
|
Orientation = Xml.GetChildVector4Attributes(node, "CompositeRotation").ToQuaternion();
|
||||||
Scale = Xml.GetChildVector3Attributes(node, "CompositeScale");
|
Scale = Xml.GetChildVector3Attributes(node, "CompositeScale");
|
||||||
var f = new BoundCompositeChildrenFlags();
|
if (!Parent.OwnerIsFragment)
|
||||||
f.Flags1 = Xml.GetChildEnumInnerText<EBoundCompositeFlags>(node, "CompositeFlags1");
|
{
|
||||||
f.Flags2 = Xml.GetChildEnumInnerText<EBoundCompositeFlags>(node, "CompositeFlags2");
|
var f = new BoundCompositeChildrenFlags();
|
||||||
CompositeFlags1 = f;
|
f.Flags1 = Xml.GetChildEnumInnerText<EBoundCompositeFlags>(node, "CompositeFlags1");
|
||||||
CompositeFlags2 = f;
|
f.Flags2 = Xml.GetChildEnumInnerText<EBoundCompositeFlags>(node, "CompositeFlags2");
|
||||||
|
CompositeFlags1 = f;
|
||||||
|
CompositeFlags2 = f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void WriteXmlNode(Bounds b, StringBuilder sb, int indent, string name = "Bounds")
|
public static void WriteXmlNode(Bounds b, StringBuilder sb, int indent, string name = "Bounds")
|
||||||
@ -1206,7 +1219,7 @@ namespace CodeWalker.GameFiles
|
|||||||
CalculateQuantum();
|
CalculateQuantum();
|
||||||
UpdateEdgeIndices();
|
UpdateEdgeIndices();
|
||||||
UpdateTriangleAreas();
|
UpdateTriangleAreas();
|
||||||
|
UpdateUnknown1Counts();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IResourceBlock[] GetReferences()
|
public override IResourceBlock[] GetReferences()
|
||||||
@ -1847,6 +1860,17 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateUnknown1Counts()
|
||||||
|
{
|
||||||
|
if (Unknown1Data?.Items != null)
|
||||||
|
{
|
||||||
|
Unknown1Counts = new uint[8];
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
Unknown1Counts[i] = (i < Unknown1Data.Items.Length) ? (uint)(Unknown1Data.Items[i]?.Length ?? 0) : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool DeletePolygon(BoundPolygon p)
|
public bool DeletePolygon(BoundPolygon p)
|
||||||
{
|
{
|
||||||
@ -2513,7 +2537,14 @@ namespace CodeWalker.GameFiles
|
|||||||
YbnXml.OpenTag(sb, indent, "Children");
|
YbnXml.OpenTag(sb, indent, "Children");
|
||||||
foreach (var child in c)
|
foreach (var child in c)
|
||||||
{
|
{
|
||||||
Bounds.WriteXmlNode(child, sb, cind, "Item");
|
if (c == null)
|
||||||
|
{
|
||||||
|
YbnXml.SelfClosingTag(sb, cind, "Item");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Bounds.WriteXmlNode(child, sb, cind, "Item");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
YbnXml.CloseTag(sb, indent, "Children");
|
YbnXml.CloseTag(sb, indent, "Children");
|
||||||
}
|
}
|
||||||
@ -2531,8 +2562,15 @@ namespace CodeWalker.GameFiles
|
|||||||
var blist = new List<Bounds>();
|
var blist = new List<Bounds>();
|
||||||
foreach (XmlNode inode in cnodes)
|
foreach (XmlNode inode in cnodes)
|
||||||
{
|
{
|
||||||
var b = Bounds.ReadXmlNode(inode, Owner, this);
|
if (inode.HasChildNodes)
|
||||||
blist.Add(b);
|
{
|
||||||
|
var b = Bounds.ReadXmlNode(inode, Owner, this);
|
||||||
|
blist.Add(b);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
blist.Add(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var arr = blist.ToArray();
|
var arr = blist.ToArray();
|
||||||
Children = new ResourcePointerArray64<Bounds>();
|
Children = new ResourcePointerArray64<Bounds>();
|
||||||
@ -2651,6 +2689,12 @@ namespace CodeWalker.GameFiles
|
|||||||
ChildrenFlags2 = null;
|
ChildrenFlags2 = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (OwnerIsFragment)//don't use flags in fragments
|
||||||
|
{
|
||||||
|
ChildrenFlags1 = null;
|
||||||
|
ChildrenFlags2 = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var cf1 = new List<BoundCompositeChildrenFlags>();
|
var cf1 = new List<BoundCompositeChildrenFlags>();
|
||||||
var cf2 = new List<BoundCompositeChildrenFlags>();
|
var cf2 = new List<BoundCompositeChildrenFlags>();
|
||||||
@ -3988,7 +4032,7 @@ namespace CodeWalker.GameFiles
|
|||||||
{
|
{
|
||||||
var collist = new List<uint[]>();
|
var collist = new List<uint[]>();
|
||||||
var rowlist = new List<uint>();
|
var rowlist = new List<uint>();
|
||||||
var str = node.InnerText;
|
var str = node.InnerText.Trim();
|
||||||
var split = str.Split('\n');
|
var split = str.Split('\n');
|
||||||
for (int i = 0; i < split.Length; i++)
|
for (int i = 0; i < split.Length; i++)
|
||||||
{
|
{
|
||||||
@ -4110,11 +4154,11 @@ namespace CodeWalker.GameFiles
|
|||||||
this.Unknown_14h = reader.ReadUInt32();
|
this.Unknown_14h = reader.ReadUInt32();
|
||||||
this.Unknown_18h = reader.ReadUInt32();
|
this.Unknown_18h = reader.ReadUInt32();
|
||||||
this.Unknown_1Ch = reader.ReadUInt32();
|
this.Unknown_1Ch = reader.ReadUInt32();
|
||||||
this.BoundingBoxMin = reader.ReadStruct<Vector4>();
|
this.BoundingBoxMin = reader.ReadVector4();
|
||||||
this.BoundingBoxMax = reader.ReadStruct<Vector4>();
|
this.BoundingBoxMax = reader.ReadVector4();
|
||||||
this.BoundingBoxCenter = reader.ReadStruct<Vector4>();
|
this.BoundingBoxCenter = reader.ReadVector4();
|
||||||
this.QuantumInverse = reader.ReadStruct<Vector4>();
|
this.QuantumInverse = reader.ReadVector4();
|
||||||
this.Quantum = reader.ReadStruct<Vector4>();
|
this.Quantum = reader.ReadVector4();
|
||||||
this.Trees = reader.ReadBlock<ResourceSimpleList64_s<BVHTreeInfo_s>>();
|
this.Trees = reader.ReadBlock<ResourceSimpleList64_s<BVHTreeInfo_s>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,10 +465,6 @@ namespace CodeWalker.GameFiles
|
|||||||
foreach (var x in Parameters)
|
foreach (var x in Parameters)
|
||||||
{
|
{
|
||||||
offset += 16;
|
offset += 16;
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var x in Parameters)
|
|
||||||
{
|
|
||||||
offset += 16 * x.DataType;
|
offset += 16 * x.DataType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -756,7 +752,6 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
else if (type == "Array")
|
else if (type == "Array")
|
||||||
{
|
{
|
||||||
p.DataType = 2;
|
|
||||||
var vecs = new List<Vector4>();
|
var vecs = new List<Vector4>();
|
||||||
var inodes = pnode.SelectNodes("Value");
|
var inodes = pnode.SelectNodes("Value");
|
||||||
foreach (XmlNode inode in inodes)
|
foreach (XmlNode inode in inodes)
|
||||||
@ -768,6 +763,7 @@ namespace CodeWalker.GameFiles
|
|||||||
vecs.Add(new Vector4(fx, fy, fz, fw));
|
vecs.Add(new Vector4(fx, fy, fz, fw));
|
||||||
}
|
}
|
||||||
p.Data = vecs.ToArray();
|
p.Data = vecs.ToArray();
|
||||||
|
p.DataType = (byte)vecs.Count;
|
||||||
}
|
}
|
||||||
plist.Add(p);
|
plist.Add(p);
|
||||||
hlist.Add(h);
|
hlist.Add(h);
|
||||||
@ -3830,10 +3826,10 @@ namespace CodeWalker.GameFiles
|
|||||||
// read structure data
|
// read structure data
|
||||||
this.ShaderGroupPointer = reader.ReadUInt64();
|
this.ShaderGroupPointer = reader.ReadUInt64();
|
||||||
this.SkeletonPointer = reader.ReadUInt64();
|
this.SkeletonPointer = reader.ReadUInt64();
|
||||||
this.BoundingCenter = reader.ReadStruct<Vector3>();
|
this.BoundingCenter = reader.ReadVector3();
|
||||||
this.BoundingSphereRadius = reader.ReadSingle();
|
this.BoundingSphereRadius = reader.ReadSingle();
|
||||||
this.BoundingBoxMin = reader.ReadStruct<Vector4>();
|
this.BoundingBoxMin = reader.ReadVector4();
|
||||||
this.BoundingBoxMax = reader.ReadStruct<Vector4>();
|
this.BoundingBoxMax = reader.ReadVector4();
|
||||||
this.DrawableModelsHighPointer = reader.ReadUInt64();
|
this.DrawableModelsHighPointer = reader.ReadUInt64();
|
||||||
this.DrawableModelsMediumPointer = reader.ReadUInt64();
|
this.DrawableModelsMediumPointer = reader.ReadUInt64();
|
||||||
this.DrawableModelsLowPointer = reader.ReadUInt64();
|
this.DrawableModelsLowPointer = reader.ReadUInt64();
|
||||||
@ -3879,39 +3875,8 @@ namespace CodeWalker.GameFiles
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
var allModels = new List<DrawableModel>();
|
BuildAllModels();
|
||||||
if (DrawableModelsHigh != null) allModels.AddRange(DrawableModelsHigh.data_items);
|
BuildVertexDecls();
|
||||||
if (DrawableModelsMedium != null) allModels.AddRange(DrawableModelsMedium.data_items);
|
|
||||||
if (DrawableModelsLow != null) allModels.AddRange(DrawableModelsLow.data_items);
|
|
||||||
if (DrawableModelsVeryLow != null) allModels.AddRange(DrawableModelsVeryLow.data_items);
|
|
||||||
if ((DrawableModelsX != null) && (DrawableModelsX != DrawableModelsHigh))
|
|
||||||
{
|
|
||||||
allModels.AddRange(DrawableModelsX.data_items);
|
|
||||||
}
|
|
||||||
AllModels = allModels.ToArray();
|
|
||||||
|
|
||||||
|
|
||||||
var vds = new Dictionary<ulong, VertexDeclaration>();
|
|
||||||
foreach (DrawableModel model in AllModels)
|
|
||||||
{
|
|
||||||
foreach (var geom in model.Geometries.data_items)
|
|
||||||
{
|
|
||||||
var info = geom.VertexBuffer.Info;
|
|
||||||
var declid = info.GetDeclarationId();
|
|
||||||
|
|
||||||
if (!vds.ContainsKey(declid))
|
|
||||||
{
|
|
||||||
vds.Add(declid, info);
|
|
||||||
}
|
|
||||||
//else //debug test
|
|
||||||
//{
|
|
||||||
// if ((VertexDecls[declid].Stride != info.Stride)||(VertexDecls[declid].Types != info.Types))
|
|
||||||
// {
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
VertexDecls = new Dictionary<ulong, VertexDeclaration>(vds);
|
|
||||||
|
|
||||||
AssignGeometryShaders(ShaderGroup);
|
AssignGeometryShaders(ShaderGroup);
|
||||||
|
|
||||||
@ -4248,6 +4213,8 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
BuildRenderMasks();
|
BuildRenderMasks();
|
||||||
|
BuildAllModels();
|
||||||
|
BuildVertexDecls();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IResourceBlock[] GetReferences()
|
public override IResourceBlock[] GetReferences()
|
||||||
@ -4267,15 +4234,15 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
public void AssignGeometryShaders(ShaderGroup shaderGrp)
|
public void AssignGeometryShaders(ShaderGroup shaderGrp)
|
||||||
{
|
{
|
||||||
if (shaderGrp != null)
|
//if (shaderGrp != null)
|
||||||
{
|
//{
|
||||||
ShaderGroup = shaderGrp;
|
// ShaderGroup = shaderGrp;
|
||||||
}
|
//}
|
||||||
|
|
||||||
//map the shaders to the geometries
|
//map the shaders to the geometries
|
||||||
if (ShaderGroup != null)
|
if (shaderGrp != null)
|
||||||
{
|
{
|
||||||
var shaders = ShaderGroup.Shaders.data_items;
|
var shaders = shaderGrp.Shaders.data_items;
|
||||||
foreach (DrawableModel model in AllModels)
|
foreach (DrawableModel model in AllModels)
|
||||||
{
|
{
|
||||||
if (model?.Geometries?.data_items == null) continue;
|
if (model?.Geometries?.data_items == null) continue;
|
||||||
@ -4296,6 +4263,47 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void BuildAllModels()
|
||||||
|
{
|
||||||
|
var allModels = new List<DrawableModel>();
|
||||||
|
if (DrawableModelsHigh != null) allModels.AddRange(DrawableModelsHigh.data_items);
|
||||||
|
if (DrawableModelsMedium != null) allModels.AddRange(DrawableModelsMedium.data_items);
|
||||||
|
if (DrawableModelsLow != null) allModels.AddRange(DrawableModelsLow.data_items);
|
||||||
|
if (DrawableModelsVeryLow != null) allModels.AddRange(DrawableModelsVeryLow.data_items);
|
||||||
|
if ((DrawableModelsX != null) && (DrawableModelsX != DrawableModelsHigh))
|
||||||
|
{
|
||||||
|
allModels.AddRange(DrawableModelsX.data_items);
|
||||||
|
}
|
||||||
|
AllModels = allModels.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BuildVertexDecls()
|
||||||
|
{
|
||||||
|
var vds = new Dictionary<ulong, VertexDeclaration>();
|
||||||
|
foreach (DrawableModel model in AllModels)
|
||||||
|
{
|
||||||
|
foreach (var geom in model.Geometries.data_items)
|
||||||
|
{
|
||||||
|
var info = geom.VertexBuffer.Info;
|
||||||
|
var declid = info.GetDeclarationId();
|
||||||
|
|
||||||
|
if (!vds.ContainsKey(declid))
|
||||||
|
{
|
||||||
|
vds.Add(declid, info);
|
||||||
|
}
|
||||||
|
//else //debug test
|
||||||
|
//{
|
||||||
|
// if ((VertexDecls[declid].Stride != info.Stride)||(VertexDecls[declid].Types != info.Types))
|
||||||
|
// {
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
VertexDecls = new Dictionary<ulong, VertexDeclaration>(vds);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void BuildRenderMasks()
|
public void BuildRenderMasks()
|
||||||
{
|
{
|
||||||
var hmask = BuildRenderMask(DrawableModelsHigh?.data_items);
|
var hmask = BuildRenderMask(DrawableModelsHigh?.data_items);
|
||||||
|
@ -191,23 +191,8 @@ namespace CodeWalker.GameFiles
|
|||||||
if (VehicleGlassWindows != null)
|
if (VehicleGlassWindows != null)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
//for vehicle wheels, the shaderGroup in the model seems to be missing, but have to use the main drawable's shaders.
|
|
||||||
if ((Drawable != null) && (PhysicsLODGroup != null) && (PhysicsLODGroup.PhysicsLOD1 != null))
|
|
||||||
{
|
|
||||||
var pl1 = PhysicsLODGroup.PhysicsLOD1;
|
|
||||||
if ((pl1.Children != null) && (pl1.Children.data_items != null))
|
|
||||||
{
|
|
||||||
for (int i = 0; i < pl1.Children.data_items.Length; i++)
|
|
||||||
{
|
|
||||||
var pch = pl1.Children.data_items[i];
|
|
||||||
if ((pch.Drawable1 != null))
|
|
||||||
{
|
|
||||||
pch.Drawable1.AssignGeometryShaders(Drawable.ShaderGroup);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
AssignChildrenShaders();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -454,6 +439,7 @@ namespace CodeWalker.GameFiles
|
|||||||
Unknown_B8h = Xml.GetChildIntAttribute(node, "UnknownB8", "value");
|
Unknown_B8h = Xml.GetChildIntAttribute(node, "UnknownB8", "value");
|
||||||
Unknown_BCh = Xml.GetChildIntAttribute(node, "UnknownBC", "value");
|
Unknown_BCh = Xml.GetChildIntAttribute(node, "UnknownBC", "value");
|
||||||
Unknown_C0h = Xml.GetChildIntAttribute(node, "UnknownC0", "value");
|
Unknown_C0h = Xml.GetChildIntAttribute(node, "UnknownC0", "value");
|
||||||
|
Unknown_C4h = Xml.GetChildIntAttribute(node, "UnknownC4", "value");
|
||||||
Unknown_CCh = Xml.GetChildFloatAttribute(node, "UnknownCC", "value");
|
Unknown_CCh = Xml.GetChildFloatAttribute(node, "UnknownCC", "value");
|
||||||
Unknown_D0h = Xml.GetChildFloatAttribute(node, "UnknownD0", "value");
|
Unknown_D0h = Xml.GetChildFloatAttribute(node, "UnknownD0", "value");
|
||||||
Unknown_D4h = Xml.GetChildFloatAttribute(node, "UnknownD4", "value");
|
Unknown_D4h = Xml.GetChildFloatAttribute(node, "UnknownD4", "value");
|
||||||
@ -512,6 +498,9 @@ namespace CodeWalker.GameFiles
|
|||||||
LightAttributes.data_items = XmlMeta.ReadItemArray<LightAttributes_s>(node, "Lights");
|
LightAttributes.data_items = XmlMeta.ReadItemArray<LightAttributes_s>(node, "Lights");
|
||||||
Cloths = new ResourcePointerList64<EnvironmentCloth>();
|
Cloths = new ResourcePointerList64<EnvironmentCloth>();
|
||||||
Cloths.data_items = XmlMeta.ReadItemArray<EnvironmentCloth>(node, "Cloths");
|
Cloths.data_items = XmlMeta.ReadItemArray<EnvironmentCloth>(node, "Cloths");
|
||||||
|
|
||||||
|
AssignChildrenSkeletonsAndBounds();
|
||||||
|
AssignChildrenShaders();
|
||||||
}
|
}
|
||||||
public static void WriteXmlNode(FragType f, StringBuilder sb, int indent, string ddsfolder, string name = "Fragment")
|
public static void WriteXmlNode(FragType f, StringBuilder sb, int indent, string ddsfolder, string name = "Fragment")
|
||||||
{
|
{
|
||||||
@ -528,6 +517,105 @@ namespace CodeWalker.GameFiles
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void AssignChildrenShaders()
|
||||||
|
{
|
||||||
|
if (PhysicsLODGroup == null) return;
|
||||||
|
|
||||||
|
//for things like vehicle wheels, the shaderGroup in the model is missing, so use the main drawable's shaders.
|
||||||
|
var pdrwbl = Drawable ?? Drawable2;
|
||||||
|
var pskel = pdrwbl?.Skeleton;
|
||||||
|
|
||||||
|
void assigndr(FragDrawable dr, BoundComposite pbcmp, int i)
|
||||||
|
{
|
||||||
|
if (dr == null) return;
|
||||||
|
if (pdrwbl == null) return;
|
||||||
|
dr.OwnerDrawable = pdrwbl;//this is also the signal for XML export to skip the skeleton and bounds
|
||||||
|
dr.AssignGeometryShaders(pdrwbl.ShaderGroup);
|
||||||
|
|
||||||
|
//// just testing
|
||||||
|
//if (dr.Skeleton != pskel)
|
||||||
|
//{ }//no hit
|
||||||
|
//var pbch = pbcmp?.Children?.data_items;
|
||||||
|
//if (pbch != null)
|
||||||
|
//{
|
||||||
|
// if (i >= pbch.Length)
|
||||||
|
// { }//no hit
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// if (pbch[i] != dr.Bound)
|
||||||
|
// { }//no hit
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{ }//no hit
|
||||||
|
};
|
||||||
|
void assign(FragPhysicsLOD lod)
|
||||||
|
{
|
||||||
|
var children = lod?.Children?.data_items;
|
||||||
|
var pbcmp1 = (lod?.Archetype1?.Bound ?? pdrwbl?.Bound) as BoundComposite;
|
||||||
|
var pbcmp2 = (lod?.Archetype2?.Bound ?? pdrwbl?.Bound) as BoundComposite;
|
||||||
|
|
||||||
|
//if (lod?.Archetype1?.Bound != lod?.Bound)
|
||||||
|
//{ }//no hit!
|
||||||
|
//if (lod?.Archetype2?.Bound != lod?.Bound)
|
||||||
|
//{ }//hit
|
||||||
|
|
||||||
|
if (children == null) return;
|
||||||
|
for (int i = 0; i < children.Length; i++)
|
||||||
|
{
|
||||||
|
var child = children[i];
|
||||||
|
assigndr(child?.Drawable1, pbcmp1, i);
|
||||||
|
assigndr(child?.Drawable2, pbcmp2, i);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assign(PhysicsLODGroup.PhysicsLOD1);
|
||||||
|
assign(PhysicsLODGroup.PhysicsLOD2);
|
||||||
|
assign(PhysicsLODGroup.PhysicsLOD3);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AssignChildrenSkeletonsAndBounds()
|
||||||
|
{
|
||||||
|
if (PhysicsLODGroup == null) return;
|
||||||
|
|
||||||
|
var pdrwbl = Drawable ?? Drawable2;
|
||||||
|
var pskel = pdrwbl?.Skeleton;
|
||||||
|
|
||||||
|
void assignskb(FragDrawable dr, BoundComposite pbcmp, int i)
|
||||||
|
{
|
||||||
|
if (dr == null) return;
|
||||||
|
if (pdrwbl == null) return;
|
||||||
|
var pbch = pbcmp?.Children?.data_items;
|
||||||
|
dr.Skeleton = pskel;
|
||||||
|
dr.Bound = ((pbch != null) && (i < pbch.Length)) ? pbch[i] : null;
|
||||||
|
};
|
||||||
|
void assign(FragPhysicsLOD lod)
|
||||||
|
{
|
||||||
|
if (lod == null) return;
|
||||||
|
lod.Bound = lod.Archetype1?.Bound;
|
||||||
|
var children = lod.Children?.data_items;
|
||||||
|
var pbcmp1 = (lod.Archetype1?.Bound ?? pdrwbl?.Bound) as BoundComposite;
|
||||||
|
var pbcmp2 = (lod.Archetype2?.Bound ?? pdrwbl?.Bound) as BoundComposite;
|
||||||
|
if (children == null) return;
|
||||||
|
for (int i = 0; i < children.Length; i++)
|
||||||
|
{
|
||||||
|
var child = children[i];
|
||||||
|
assignskb(child?.Drawable1, pbcmp1, i);
|
||||||
|
assignskb(child?.Drawable2, pbcmp2, i);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assign(PhysicsLODGroup.PhysicsLOD1);
|
||||||
|
assign(PhysicsLODGroup.PhysicsLOD2);
|
||||||
|
assign(PhysicsLODGroup.PhysicsLOD3);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public override IResourceBlock[] GetReferences()
|
public override IResourceBlock[] GetReferences()
|
||||||
{
|
{
|
||||||
var list = new List<IResourceBlock>(base.GetReferences());
|
var list = new List<IResourceBlock>(base.GetReferences());
|
||||||
@ -592,7 +680,7 @@ namespace CodeWalker.GameFiles
|
|||||||
public FragType OwnerFragment { get; set; } //for handy use
|
public FragType OwnerFragment { get; set; } //for handy use
|
||||||
public EnvironmentCloth OwnerCloth { get; set; }
|
public EnvironmentCloth OwnerCloth { get; set; }
|
||||||
public FragPhysTypeChild OwnerFragmentPhys { get; set; }
|
public FragPhysTypeChild OwnerFragmentPhys { get; set; }
|
||||||
|
public FragDrawable OwnerDrawable { get; set; } //if inheriting shaders, skeletons and bounds
|
||||||
|
|
||||||
private ResourceSystemStructBlock<ulong> FragMatricesIndsBlock = null; //used for saving only
|
private ResourceSystemStructBlock<ulong> FragMatricesIndsBlock = null; //used for saving only
|
||||||
private ResourceSystemStructBlock<Matrix> FragMatricesBlock = null;
|
private ResourceSystemStructBlock<Matrix> FragMatricesBlock = null;
|
||||||
@ -604,7 +692,7 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
// read structure data
|
// read structure data
|
||||||
this.Unknown_0A8h = reader.ReadUInt64();
|
this.Unknown_0A8h = reader.ReadUInt64();
|
||||||
this.FragMatrix = reader.ReadStruct<Matrix>();
|
this.FragMatrix = reader.ReadMatrix();
|
||||||
this.BoundPointer = reader.ReadUInt64();
|
this.BoundPointer = reader.ReadUInt64();
|
||||||
this.FragMatricesIndsPointer = reader.ReadUInt64();
|
this.FragMatricesIndsPointer = reader.ReadUInt64();
|
||||||
this.FragMatricesIndsCount = reader.ReadUInt16();
|
this.FragMatricesIndsCount = reader.ReadUInt16();
|
||||||
@ -633,6 +721,12 @@ namespace CodeWalker.GameFiles
|
|||||||
Bound.Owner = this;
|
Bound.Owner = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if (Bound is BoundComposite bcmp)
|
||||||
|
//{//no hit
|
||||||
|
// if ((bcmp.ChildrenFlags1 != null) || (bcmp.ChildrenFlags2 != null))
|
||||||
|
// { }//no hit
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (FragMatricesInds != null)
|
if (FragMatricesInds != null)
|
||||||
@ -720,13 +814,25 @@ namespace CodeWalker.GameFiles
|
|||||||
YftXml.CloseTag(sb, indent, "Matrices");
|
YftXml.CloseTag(sb, indent, "Matrices");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var skel = Skeleton;
|
||||||
|
var bnds = Bound;
|
||||||
|
if (OwnerDrawable != null) //don't export skeleton or bounds if this is a frag child!
|
||||||
|
{
|
||||||
|
Skeleton = null;
|
||||||
|
Bound = null;
|
||||||
|
}
|
||||||
|
|
||||||
base.WriteXml(sb, indent, ddsfolder);
|
base.WriteXml(sb, indent, ddsfolder);
|
||||||
|
|
||||||
Bounds.WriteXmlNode(Bound, sb, indent);
|
Bounds.WriteXmlNode(Bound, sb, indent);
|
||||||
|
|
||||||
|
Skeleton = skel;
|
||||||
|
Bound = bnds;
|
||||||
}
|
}
|
||||||
public override void ReadXml(XmlNode node, string ddsfolder)
|
public override void ReadXml(XmlNode node, string ddsfolder)
|
||||||
{
|
{
|
||||||
Name = Xml.GetChildInnerText(node, "Name");
|
Name = Xml.GetChildInnerText(node, "Name"); if (string.IsNullOrEmpty(Name)) Name = null;
|
||||||
FragMatrix = Xml.GetChildMatrix(node, "Matrix");
|
FragMatrix = Xml.GetChildMatrix(node, "Matrix");
|
||||||
|
|
||||||
var msnode = node.SelectSingleNode("Matrices");
|
var msnode = node.SelectSingleNode("Matrices");
|
||||||
@ -914,13 +1020,13 @@ namespace CodeWalker.GameFiles
|
|||||||
public override void Read(ResourceDataReader reader, params object[] parameters)
|
public override void Read(ResourceDataReader reader, params object[] parameters)
|
||||||
{
|
{
|
||||||
// read structure data
|
// read structure data
|
||||||
this.Matrix = reader.ReadStruct<Matrix>();
|
this.Matrix = reader.ReadMatrix();
|
||||||
this.VertexDeclaration.Read(reader);
|
this.VertexDeclaration.Read(reader);
|
||||||
this.Unknown_50h = reader.ReadSingle();
|
this.Unknown_50h = reader.ReadSingle();
|
||||||
this.Unknown_54h = reader.ReadUInt16();
|
this.Unknown_54h = reader.ReadUInt16();
|
||||||
this.Flags = reader.ReadUInt16();
|
this.Flags = reader.ReadUInt16();
|
||||||
this.Vector1 = reader.ReadStruct<Vector3>();
|
this.Vector1 = reader.ReadVector3();
|
||||||
this.Vector2 = reader.ReadStruct<Vector3>();
|
this.Vector2 = reader.ReadVector3();
|
||||||
|
|
||||||
//if (Unknown_50h > 1.0f)
|
//if (Unknown_50h > 1.0f)
|
||||||
//{ }//no hit
|
//{ }//no hit
|
||||||
@ -1026,7 +1132,7 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
public void Read(ResourceDataReader reader)
|
public void Read(ResourceDataReader reader)
|
||||||
{
|
{
|
||||||
Matrix = reader.ReadStruct<Matrix>();
|
Matrix = reader.ReadMatrix();
|
||||||
UnkUint1 = reader.ReadUInt32(); //0x56475743 "VGWC"
|
UnkUint1 = reader.ReadUInt32(); //0x56475743 "VGWC"
|
||||||
ItemID = reader.ReadUInt16();
|
ItemID = reader.ReadUInt16();
|
||||||
UnkUshort1 = reader.ReadUInt16();
|
UnkUshort1 = reader.ReadUInt16();
|
||||||
@ -1381,8 +1487,8 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
public void ReadXml(XmlNode node)
|
public void ReadXml(XmlNode node)
|
||||||
{
|
{
|
||||||
Data1 = Xml.GetChildRawByteArray(node, "Data1", 10);
|
Data1 = Xml.GetChildRawByteArray(node, "Data1", 10); if ((Data1?.Length ?? 0) == 0) Data1 = null;
|
||||||
Data2 = Xml.GetChildRawByteArray(node, "Data2", 10);
|
Data2 = Xml.GetChildRawByteArray(node, "Data2", 10); if ((Data2?.Length ?? 0) == 0) Data2 = null;
|
||||||
Start1 = (byte)Xml.GetChildUIntAttribute(node, "Start1", "value");
|
Start1 = (byte)Xml.GetChildUIntAttribute(node, "Start1", "value");
|
||||||
End1 = (byte)(Start1 + (Data1?.Length ?? 0) - 1);
|
End1 = (byte)(Start1 + (Data1?.Length ?? 0) - 1);
|
||||||
if (Data2 != null)
|
if (Data2 != null)
|
||||||
@ -1449,7 +1555,7 @@ namespace CodeWalker.GameFiles
|
|||||||
//{ }//no hit
|
//{ }//no hit
|
||||||
|
|
||||||
//// just testing
|
//// just testing
|
||||||
//BuildOffsets();
|
BuildOffsets();
|
||||||
}
|
}
|
||||||
public override void Write(ResourceDataWriter writer, params object[] parameters)
|
public override void Write(ResourceDataWriter writer, params object[] parameters)
|
||||||
{
|
{
|
||||||
@ -1508,6 +1614,7 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Items = ilist.ToArray();
|
Items = ilist.ToArray();
|
||||||
|
ItemCount = (ushort)ilist.Count;
|
||||||
|
|
||||||
BuildOffsets();
|
BuildOffsets();
|
||||||
}
|
}
|
||||||
@ -1517,7 +1624,7 @@ namespace CodeWalker.GameFiles
|
|||||||
public void BuildOffsets()
|
public void BuildOffsets()
|
||||||
{
|
{
|
||||||
var offs = new List<ItemOffsetStruct>();
|
var offs = new List<ItemOffsetStruct>();
|
||||||
var bc = 16u + (uint)ItemOffsets.Length*8u;
|
var bc = 16u;
|
||||||
if (Items != null)
|
if (Items != null)
|
||||||
{
|
{
|
||||||
foreach (var item in Items)
|
foreach (var item in Items)
|
||||||
@ -1533,6 +1640,7 @@ namespace CodeWalker.GameFiles
|
|||||||
{
|
{
|
||||||
offs.Add(new ItemOffsetStruct());
|
offs.Add(new ItemOffsetStruct());
|
||||||
}
|
}
|
||||||
|
bc += (uint)offs.Count * 8u;
|
||||||
}
|
}
|
||||||
|
|
||||||
//// just testing
|
//// just testing
|
||||||
@ -1755,15 +1863,15 @@ namespace CodeWalker.GameFiles
|
|||||||
this.Unknown_1Ch = reader.ReadSingle();
|
this.Unknown_1Ch = reader.ReadSingle();
|
||||||
this.ArticulatedBodyTypePointer = reader.ReadUInt64();
|
this.ArticulatedBodyTypePointer = reader.ReadUInt64();
|
||||||
this.ChildrenUnkFloatsPointer = reader.ReadUInt64();
|
this.ChildrenUnkFloatsPointer = reader.ReadUInt64();
|
||||||
this.Unknown_30h = reader.ReadStruct<Vector4>();
|
this.Unknown_30h = reader.ReadVector4();
|
||||||
this.Unknown_40h = reader.ReadStruct<Vector4>();
|
this.Unknown_40h = reader.ReadVector4();
|
||||||
this.Unknown_50h = reader.ReadStruct<Vector4>();
|
this.Unknown_50h = reader.ReadVector4();
|
||||||
this.Unknown_60h = reader.ReadStruct<Vector4>();
|
this.Unknown_60h = reader.ReadVector4();
|
||||||
this.Unknown_70h = reader.ReadStruct<Vector4>();
|
this.Unknown_70h = reader.ReadVector4();
|
||||||
this.Unknown_80h = reader.ReadStruct<Vector4>();
|
this.Unknown_80h = reader.ReadVector4();
|
||||||
this.Unknown_90h = reader.ReadStruct<Vector4>();
|
this.Unknown_90h = reader.ReadVector4();
|
||||||
this.Unknown_A0h = reader.ReadStruct<Vector4>();
|
this.Unknown_A0h = reader.ReadVector4();
|
||||||
this.Unknown_B0h = reader.ReadStruct<Vector4>();
|
this.Unknown_B0h = reader.ReadVector4();
|
||||||
this.GroupNamesPointer = reader.ReadUInt64();
|
this.GroupNamesPointer = reader.ReadUInt64();
|
||||||
this.GroupsPointer = reader.ReadUInt64();
|
this.GroupsPointer = reader.ReadUInt64();
|
||||||
this.ChildrenPointer = reader.ReadUInt64();
|
this.ChildrenPointer = reader.ReadUInt64();
|
||||||
@ -1829,6 +1937,12 @@ namespace CodeWalker.GameFiles
|
|||||||
Bound.Owner = this;
|
Bound.Owner = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if (Bound is BoundComposite bcmp)
|
||||||
|
//{
|
||||||
|
// if ((bcmp.ChildrenFlags1 != null) || (bcmp.ChildrenFlags2 != null))
|
||||||
|
// { }//no hit
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
//if (Unknown_04h != 1)
|
//if (Unknown_04h != 1)
|
||||||
//{ }//no hit
|
//{ }//no hit
|
||||||
@ -1901,6 +2015,16 @@ namespace CodeWalker.GameFiles
|
|||||||
this.ChildrenCount = (byte)(this.Children != null ? this.Children.Count : 0);
|
this.ChildrenCount = (byte)(this.Children != null ? this.Children.Count : 0);
|
||||||
this.ChildrenCount2 = this.ChildrenCount;
|
this.ChildrenCount2 = this.ChildrenCount;
|
||||||
|
|
||||||
|
if ((Groups?.data_items != null) && (GroupNames != null))
|
||||||
|
{
|
||||||
|
var gnplist = new List<ulong>();
|
||||||
|
foreach (var grp in Groups?.data_items)
|
||||||
|
{
|
||||||
|
gnplist.Add((ulong)grp.FilePosition + 128);//manually write group names pointers as offsets to the groups
|
||||||
|
}
|
||||||
|
GroupNames.data_pointers = gnplist.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// write structure data
|
// write structure data
|
||||||
writer.Write(this.VFT);
|
writer.Write(this.VFT);
|
||||||
@ -2005,10 +2129,10 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
YftXml.CloseTag(sb, indent, "Children");
|
YftXml.CloseTag(sb, indent, "Children");
|
||||||
}
|
}
|
||||||
if (Bound != null)
|
//if (Bound != null)
|
||||||
{
|
//{
|
||||||
Bounds.WriteXmlNode(Bound, sb, indent);
|
// Bounds.WriteXmlNode(Bound, sb, indent);
|
||||||
}
|
//}
|
||||||
if (UnknownData1 != null)
|
if (UnknownData1 != null)
|
||||||
{
|
{
|
||||||
YftXml.WriteRawArray(sb, UnknownData1, indent, "UnknownData1", "");
|
YftXml.WriteRawArray(sb, UnknownData1, indent, "UnknownData1", "");
|
||||||
@ -2086,17 +2210,16 @@ namespace CodeWalker.GameFiles
|
|||||||
Children = new ResourcePointerArray64<FragPhysTypeChild>();
|
Children = new ResourcePointerArray64<FragPhysTypeChild>();
|
||||||
Children.data_items = clist.ToArray();
|
Children.data_items = clist.ToArray();
|
||||||
}
|
}
|
||||||
var bnode = node.SelectSingleNode("Bounds");
|
//var bnode = node.SelectSingleNode("Bounds");
|
||||||
if (bnode != null)
|
//if (bnode != null)
|
||||||
{
|
//{
|
||||||
Bound = Bounds.ReadXmlNode(bnode, this);
|
// Bound = Bounds.ReadXmlNode(bnode, this);
|
||||||
}
|
//}
|
||||||
var ud1 = Xml.GetChildRawByteArray(node, "UnknownData1", 10);
|
var ud1 = Xml.GetChildRawByteArray(node, "UnknownData1", 10);
|
||||||
var ud2 = Xml.GetChildRawByteArray(node, "UnknownData2", 10);
|
var ud2 = Xml.GetChildRawByteArray(node, "UnknownData2", 10);
|
||||||
UnknownData1 = ((ud1?.Length ?? 0) > 0) ? ud1 : null;
|
UnknownData1 = ((ud1?.Length ?? 0) > 0) ? ud1 : null;
|
||||||
UnknownData2 = ((ud2?.Length ?? 0) > 0) ? ud2 : null;
|
UnknownData2 = ((ud2?.Length ?? 0) > 0) ? ud2 : null;
|
||||||
|
|
||||||
|
|
||||||
BuildChildrenData();
|
BuildChildrenData();
|
||||||
BuildGroupsData();
|
BuildGroupsData();
|
||||||
}
|
}
|
||||||
@ -2193,7 +2316,11 @@ namespace CodeWalker.GameFiles
|
|||||||
UnknownData2Block = new ResourceSystemStructBlock<byte>(UnknownData2);
|
UnknownData2Block = new ResourceSystemStructBlock<byte>(UnknownData2);
|
||||||
list.Add(UnknownData2Block);
|
list.Add(UnknownData2Block);
|
||||||
}
|
}
|
||||||
if (GroupNames != null) list.Add(GroupNames);
|
if (GroupNames != null)
|
||||||
|
{
|
||||||
|
GroupNames.ManualPointerOverride = (Groups != null); //we'll just write a set of pointers into the Groups
|
||||||
|
list.Add(GroupNames);
|
||||||
|
}
|
||||||
return list.ToArray();
|
return list.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2820,14 +2947,14 @@ namespace CodeWalker.GameFiles
|
|||||||
this.Unknown_50h = reader.ReadSingle();
|
this.Unknown_50h = reader.ReadSingle();
|
||||||
this.Unknown_54h = reader.ReadSingle();
|
this.Unknown_54h = reader.ReadSingle();
|
||||||
this.Unknown_58h = reader.ReadUInt64();
|
this.Unknown_58h = reader.ReadUInt64();
|
||||||
this.Unknown_60h = reader.ReadStruct<Vector4>();
|
this.Unknown_60h = reader.ReadVector4();
|
||||||
this.Unknown_70h = reader.ReadStruct<Vector4>();
|
this.Unknown_70h = reader.ReadVector4();
|
||||||
this.Unknown_80h = reader.ReadStruct<Vector4>();
|
this.Unknown_80h = reader.ReadVector4();
|
||||||
this.Unknown_90h = reader.ReadStruct<Vector4>();
|
this.Unknown_90h = reader.ReadVector4();
|
||||||
this.Unknown_A0h = reader.ReadStruct<Vector4>();
|
this.Unknown_A0h = reader.ReadVector4();
|
||||||
this.Unknown_B0h = reader.ReadStruct<Vector4>();
|
this.Unknown_B0h = reader.ReadVector4();
|
||||||
this.Unknown_C0h = reader.ReadStruct<Vector4>();
|
this.Unknown_C0h = reader.ReadVector4();
|
||||||
this.Unknown_D0h = reader.ReadStruct<Vector4>();
|
this.Unknown_D0h = reader.ReadVector4();
|
||||||
|
|
||||||
// read reference data
|
// read reference data
|
||||||
this.Name = reader.ReadStringAt(this.NamePointer);
|
this.Name = reader.ReadStringAt(this.NamePointer);
|
||||||
@ -2838,6 +2965,12 @@ namespace CodeWalker.GameFiles
|
|||||||
Bound.Owner = this;
|
Bound.Owner = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if (Bound is BoundComposite bcmp)
|
||||||
|
//{
|
||||||
|
// if ((bcmp.ChildrenFlags1 != null) || (bcmp.ChildrenFlags2 != null))
|
||||||
|
// { }//no hit
|
||||||
|
//}
|
||||||
|
|
||||||
//switch (VFT)
|
//switch (VFT)
|
||||||
//{
|
//{
|
||||||
// case 0x4062a988:
|
// case 0x4062a988:
|
||||||
|
@ -1490,9 +1490,10 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ulong[] data_pointers { get; private set; }
|
public ulong[] data_pointers { get; set; }
|
||||||
public T[] data_items { get; set; }
|
public T[] data_items { get; set; }
|
||||||
|
|
||||||
|
public bool ManualPointerOverride { get; set; } = false;//use this to manually write data_pointers
|
||||||
|
|
||||||
private ResourceSystemStructBlock<T>[] data_blocks = null;
|
private ResourceSystemStructBlock<T>[] data_blocks = null;
|
||||||
|
|
||||||
@ -1518,20 +1519,23 @@ namespace CodeWalker.GameFiles
|
|||||||
public override void Write(ResourceDataWriter writer, params object[] parameters)
|
public override void Write(ResourceDataWriter writer, params object[] parameters)
|
||||||
{
|
{
|
||||||
// update...
|
// update...
|
||||||
var list = new List<ulong>();
|
if (ManualPointerOverride == false)
|
||||||
if (data_blocks != null)
|
|
||||||
{
|
{
|
||||||
foreach (var x in data_blocks)
|
var list = new List<ulong>();
|
||||||
|
if (data_blocks != null)
|
||||||
{
|
{
|
||||||
list.Add((ulong)x.FilePosition);
|
foreach (var x in data_blocks)
|
||||||
|
{
|
||||||
|
list.Add((ulong)x.FilePosition);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
//foreach (var x in data_items)
|
||||||
|
// if (x != null)
|
||||||
|
// data_pointers.Add((uint)x.Position);
|
||||||
|
// else
|
||||||
|
// data_pointers.Add((uint)0);
|
||||||
|
data_pointers = list.ToArray();
|
||||||
}
|
}
|
||||||
//foreach (var x in data_items)
|
|
||||||
// if (x != null)
|
|
||||||
// data_pointers.Add((uint)x.Position);
|
|
||||||
// else
|
|
||||||
// data_pointers.Add((uint)0);
|
|
||||||
data_pointers = list.ToArray();
|
|
||||||
|
|
||||||
// write...
|
// write...
|
||||||
foreach (var x in data_pointers)
|
foreach (var x in data_pointers)
|
||||||
@ -1543,19 +1547,22 @@ namespace CodeWalker.GameFiles
|
|||||||
{
|
{
|
||||||
var list = new List<IResourceBlock>();
|
var list = new List<IResourceBlock>();
|
||||||
|
|
||||||
var blocks = new List<ResourceSystemStructBlock<T>>();
|
if (ManualPointerOverride == false)
|
||||||
if (data_items != null)
|
|
||||||
{
|
{
|
||||||
foreach (var x in data_items)
|
var blocks = new List<ResourceSystemStructBlock<T>>();
|
||||||
|
if (data_items != null)
|
||||||
{
|
{
|
||||||
var block = new ResourceSystemStructBlock<T>(new[] { x });
|
foreach (var x in data_items)
|
||||||
blocks.Add(block);
|
{
|
||||||
list.Add(block);
|
var block = new ResourceSystemStructBlock<T>(new[] { x });
|
||||||
|
blocks.Add(block);
|
||||||
|
list.Add(block);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
data_blocks = blocks.ToArray();
|
||||||
|
//foreach (var x in data_items)
|
||||||
|
// list.Add(x);
|
||||||
}
|
}
|
||||||
data_blocks = blocks.ToArray();
|
|
||||||
//foreach (var x in data_items)
|
|
||||||
// list.Add(x);
|
|
||||||
|
|
||||||
return list.ToArray();
|
return list.ToArray();
|
||||||
}
|
}
|
||||||
|
@ -678,7 +678,7 @@ namespace CodeWalker.Forms
|
|||||||
MoveCameraToView(dr.BoundingCenter, dr.BoundingSphereRadius);
|
MoveCameraToView(dr.BoundingCenter, dr.BoundingSphereRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateModelsUI(yft.Fragment.Drawable);
|
UpdateModelsUI(yft.Fragment?.Drawable, yft.Fragment);
|
||||||
}
|
}
|
||||||
public void LoadModel(YbnFile ybn)
|
public void LoadModel(YbnFile ybn)
|
||||||
{
|
{
|
||||||
@ -952,54 +952,9 @@ namespace CodeWalker.Forms
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void UpdateModelsUI(DrawableBase drawable)
|
private void UpdateModelsUI(DrawableBase drawable, object detailsObject = null)
|
||||||
{
|
{
|
||||||
DetailsPropertyGrid.SelectedObject = drawable;
|
DetailsPropertyGrid.SelectedObject = detailsObject ?? drawable;
|
||||||
|
|
||||||
DrawableDrawFlags.Clear();
|
|
||||||
Renderer.SelectionModelDrawFlags.Clear();
|
|
||||||
Renderer.SelectionGeometryDrawFlags.Clear();
|
|
||||||
ModelsTreeView.Nodes.Clear();
|
|
||||||
ModelsTreeView.ShowRootLines = false;
|
|
||||||
TexturesTreeView.Nodes.Clear();
|
|
||||||
if (drawable != null)
|
|
||||||
{
|
|
||||||
AddDrawableModelsTreeNodes(drawable.DrawableModelsHigh, "High Detail", true);
|
|
||||||
AddDrawableModelsTreeNodes(drawable.DrawableModelsMedium, "Medium Detail", false);
|
|
||||||
AddDrawableModelsTreeNodes(drawable.DrawableModelsLow, "Low Detail", false);
|
|
||||||
AddDrawableModelsTreeNodes(drawable.DrawableModelsVeryLow, "Very Low Detail", false);
|
|
||||||
//AddSelectionDrawableModelsTreeNodes(item.Drawable.DrawableModelsX, "X Detail", false);
|
|
||||||
|
|
||||||
var fdrawable = drawable as FragDrawable;
|
|
||||||
if (fdrawable != null)
|
|
||||||
{
|
|
||||||
var plod1 = fdrawable.OwnerFragment?.PhysicsLODGroup?.PhysicsLOD1;
|
|
||||||
if ((plod1 != null) && (plod1.Children?.data_items != null))
|
|
||||||
{
|
|
||||||
foreach (var child in plod1.Children.data_items)
|
|
||||||
{
|
|
||||||
var cdrwbl = child.Drawable1;
|
|
||||||
if ((cdrwbl != null) && (cdrwbl.AllModels?.Length > 0))
|
|
||||||
{
|
|
||||||
if (cdrwbl.Owner is FragDrawable) continue; //it's a copied drawable... eg a wheel
|
|
||||||
|
|
||||||
var dname = child.GroupName;
|
|
||||||
AddDrawableModelsTreeNodes(cdrwbl.DrawableModelsHigh, dname + " - High Detail", true);
|
|
||||||
AddDrawableModelsTreeNodes(cdrwbl.DrawableModelsMedium, dname + " - Medium Detail", false);
|
|
||||||
AddDrawableModelsTreeNodes(cdrwbl.DrawableModelsLow, dname + " - Low Detail", false);
|
|
||||||
AddDrawableModelsTreeNodes(cdrwbl.DrawableModelsVeryLow, dname + " - Very Low Detail", false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void UpdateModelsUI(FragType frag)
|
|
||||||
{
|
|
||||||
DetailsPropertyGrid.SelectedObject = frag;
|
|
||||||
|
|
||||||
var drawable = frag.Drawable;
|
|
||||||
|
|
||||||
DrawableDrawFlags.Clear();
|
DrawableDrawFlags.Clear();
|
||||||
Renderer.SelectionModelDrawFlags.Clear();
|
Renderer.SelectionModelDrawFlags.Clear();
|
||||||
|
Loading…
Reference in New Issue
Block a user