YFT/XML conversion progress

This commit is contained in:
dexy 2020-01-23 18:36:34 +11:00
parent 4854afa037
commit 7bc7d9612a
7 changed files with 288 additions and 54 deletions

View File

@ -1740,6 +1740,15 @@ namespace CodeWalker.GameFiles
if (Polygons == null)
{ return; }
for (int i = 0; i < Polygons.Length; i++)
{
var poly = Polygons[i];
if (poly != null)
{
poly.Index = i;
}
}
var edgedict = new Dictionary<BoundEdgeRef, BoundEdge>();
foreach (var poly in Polygons)
{
@ -2397,8 +2406,8 @@ namespace CodeWalker.GameFiles
// reference data
public ResourcePointerArray64<Bounds> Children { get; set; }
public Matrix[] ChildrenTransformation1 { get; set; }
public Matrix[] ChildrenTransformation2 { get; set; }
public Matrix4F_s[] ChildrenTransformation1 { get; set; }
public Matrix4F_s[] ChildrenTransformation2 { get; set; }
public AABB_s[] ChildrenBoundingBoxes { get; set; }
public BoundCompositeChildrenFlags[] ChildrenFlags1 { get; set; }
public BoundCompositeChildrenFlags[] ChildrenFlags2 { get; set; }
@ -2406,8 +2415,8 @@ namespace CodeWalker.GameFiles
public BVH BVH { get; set; }
private ResourceSystemStructBlock<Matrix> ChildrenTransformation1Block = null;
private ResourceSystemStructBlock<Matrix> ChildrenTransformation2Block = null;
private ResourceSystemStructBlock<Matrix4F_s> ChildrenTransformation1Block = null;
private ResourceSystemStructBlock<Matrix4F_s> ChildrenTransformation2Block = null;
private ResourceSystemStructBlock<AABB_s> ChildrenBoundingBoxesBlock = null;
private ResourceSystemStructBlock<BoundCompositeChildrenFlags> ChildrenFlags1Block = null;
private ResourceSystemStructBlock<BoundCompositeChildrenFlags> ChildrenFlags2Block = null;
@ -2435,8 +2444,8 @@ namespace CodeWalker.GameFiles
this.ChildrenCount1
);
this.ChildrenTransformation1 = reader.ReadStructsAt<Matrix>(this.ChildrenTransformation1Pointer, this.ChildrenCount1);
this.ChildrenTransformation2 = reader.ReadStructsAt<Matrix>(this.ChildrenTransformation2Pointer, this.ChildrenCount1);
this.ChildrenTransformation1 = reader.ReadStructsAt<Matrix4F_s>(this.ChildrenTransformation1Pointer, this.ChildrenCount1);
this.ChildrenTransformation2 = reader.ReadStructsAt<Matrix4F_s>(this.ChildrenTransformation2Pointer, this.ChildrenCount1);
this.ChildrenBoundingBoxes = reader.ReadStructsAt<AABB_s>(this.ChildrenBoundingBoxesPointer, this.ChildrenCount1);
this.ChildrenFlags1 = reader.ReadStructsAt<BoundCompositeChildrenFlags>(this.ChildrenFlags1Pointer, this.ChildrenCount1);
this.ChildrenFlags2 = reader.ReadStructsAt<BoundCompositeChildrenFlags>(this.ChildrenFlags2Pointer, this.ChildrenCount1);
@ -2458,8 +2467,7 @@ namespace CodeWalker.GameFiles
{
child.Parent = this;
var xform = ((childTransforms != null) && (i < childTransforms.Length)) ? childTransforms[i] : Matrix.Identity;
xform.Column4 = new Vector4(0.0f, 0.0f, 0.0f, 1.0f);
var xform = ((childTransforms != null) && (i < childTransforms.Length)) ? childTransforms[i].ToMatrix() : Matrix.Identity;
child.Transform = xform;
child.TransformInv = Matrix.Invert(xform);
child.CompositeFlags1 = ((ChildrenFlags1 != null) && (i < ChildrenFlags1.Length)) ? ChildrenFlags1[i] : new BoundCompositeChildrenFlags();
@ -2471,6 +2479,64 @@ namespace CodeWalker.GameFiles
}
}
//if (ChildrenTransformation1 != null)
//{
// foreach (var m in ChildrenTransformation1)
// {
// switch (m.Flags1)
// {
// case 0:
// case 0x7f800001: //only in yft's!
// case 0x80000000: //only in yft's! = -0
// break;
// default:
// break;//no hit
// }
// switch (m.Flags2)
// {
// case 1:
// case 0: //only in yft's!
// case 0x7f800001: //only in yft's!
// case 0x80000000: //only in yft's! = -0
// break;
// default:
// break;//no hit
// }
// switch (m.Flags3)
// {
// case 1:
// case 0: //only in yft's!
// case 0x7f800001: //only in yft's!
// case 0x80000000: //only in yft's! = -0
// break;
// default:
// break;//no hit
// }
// switch (m.Flags4)
// {
// case 0:
// case 0x7f800001: //only in yft's!
// case 0x42f9c6a4: //only in yft! = 124.888f
// case 0x42f94c3a: //only in yft! = 124.649f
// case 0x42f33400: //only in yft! = 121.602f
// case 0x42f4793c: //only in yft! = 122.237f
// case 0x42f2d6a2: //only in yft! = 121.419f
// case 0x42eca103:
// case 0x42ede882:
// case 0x42e6ec74:
// case 0x42e26655:
// case 0x42e2ac9e:
// case 0x42eb1c90:
// case 0x4474bd4d:
// case 0x433b2027:
// break;
// default:
// break;//+ more! in yft's! it really seems like a float...
// }
// }
//}
//if ((ChildrenTransformation1 != null) && (ChildrenTransformation2 != null))
//{
// //if (ChildrenTransformation1.Length != ChildrenTransformation2.Length)
@ -2597,12 +2663,12 @@ namespace CodeWalker.GameFiles
if (Children != null) list.Add(Children);
if (ChildrenTransformation1 != null)
{
ChildrenTransformation1Block = new ResourceSystemStructBlock<Matrix>(ChildrenTransformation1);
ChildrenTransformation1Block = new ResourceSystemStructBlock<Matrix4F_s>(ChildrenTransformation1);
list.Add(ChildrenTransformation1Block);
}
if (ChildrenTransformation2 != null)
{
ChildrenTransformation2Block = new ResourceSystemStructBlock<Matrix>(ChildrenTransformation2);
ChildrenTransformation2Block = new ResourceSystemStructBlock<Matrix4F_s>(ChildrenTransformation2);
list.Add(ChildrenTransformation2Block);
}
if (ChildrenBoundingBoxes != null)
@ -2749,16 +2815,32 @@ namespace CodeWalker.GameFiles
return;
}
var ct1 = new List<Matrix>();
var ct2 = new List<Matrix>();
var ct1 = new List<Matrix4F_s>();
var ct2 = new List<Matrix4F_s>();
foreach (var child in Children.data_items)
{
var m = Matrix.Identity;
var m = Matrix4F_s.Identity;
if (child != null)
{
m = child.Transform;
m = new Matrix4F_s(child.Transform);
}
m.Column4 = new Vector4(0.0f, float.Epsilon, float.Epsilon, 0.0f);//is this right? TODO: check!
if (OwnerIsFragment)
{
m.Flags1 = 0x7f800001;
m.Flags2 = 0x7f800001;
m.Flags3 = 0x7f800001;
m.Flags4 = 0x7f800001;
}
else
{
//m.Column4 = new Vector4(0.0f, float.Epsilon, float.Epsilon, 0.0f);//is this right? TODO: check!
m.Flags1 = 0;
m.Flags2 = 1;
m.Flags3 = 1;
m.Flags4 = 0;
}
ct1.Add(m);
ct2.Add(m);
}
@ -2864,8 +2946,8 @@ namespace CodeWalker.GameFiles
if (Children == null) Children = new ResourcePointerArray64<Bounds>();
var children = Children.data_items?.ToList() ?? new List<Bounds>();
var transforms1 = ChildrenTransformation1?.ToList() ?? new List<Matrix>();
var transforms2 = ChildrenTransformation2?.ToList() ?? new List<Matrix>();
var transforms1 = ChildrenTransformation1?.ToList() ?? new List<Matrix4F_s>();
var transforms2 = ChildrenTransformation2?.ToList() ?? new List<Matrix4F_s>();
var bboxes = ChildrenBoundingBoxes?.ToList() ?? new List<AABB_s>();
var flags1 = ChildrenFlags1?.ToList();
var flags2 = ChildrenFlags2?.ToList();
@ -2874,8 +2956,8 @@ namespace CodeWalker.GameFiles
child.Parent = this;
children.Add(child);
transforms1.Add(Matrix.Identity);
transforms2.Add(Matrix.Identity);
transforms1.Add(Matrix4F_s.Identity);
transforms2.Add(Matrix4F_s.Identity);
bboxes.Add(new AABB_s());//will get updated later
flags1?.Add(new BoundCompositeChildrenFlags());
flags2?.Add(new BoundCompositeChildrenFlags());

View File

@ -3728,8 +3728,10 @@ namespace CodeWalker.GameFiles
public ulong SkeletonPointer { get; set; }
public Vector3 BoundingCenter { get; set; }
public float BoundingSphereRadius { get; set; }
public Vector4 BoundingBoxMin { get; set; }
public Vector4 BoundingBoxMax { get; set; }
public Vector3 BoundingBoxMin { get; set; }
public uint Unknown_3Ch { get; set; } = 0x7f800001;
public Vector3 BoundingBoxMax { get; set; }
public uint Unknown_4Ch { get; set; } = 0x7f800001;
public ulong DrawableModelsHighPointer { get; set; }
public ulong DrawableModelsMediumPointer { get; set; }
public ulong DrawableModelsLowPointer { get; set; }
@ -3838,8 +3840,10 @@ namespace CodeWalker.GameFiles
this.SkeletonPointer = reader.ReadUInt64();
this.BoundingCenter = reader.ReadVector3();
this.BoundingSphereRadius = reader.ReadSingle();
this.BoundingBoxMin = reader.ReadVector4();
this.BoundingBoxMax = reader.ReadVector4();
this.BoundingBoxMin = reader.ReadVector3();
this.Unknown_3Ch = reader.ReadUInt32();
this.BoundingBoxMax = reader.ReadVector3();
this.Unknown_4Ch = reader.ReadUInt32();
this.DrawableModelsHighPointer = reader.ReadUInt64();
this.DrawableModelsMediumPointer = reader.ReadUInt64();
this.DrawableModelsLowPointer = reader.ReadUInt64();
@ -3895,6 +3899,22 @@ namespace CodeWalker.GameFiles
////just testing!!!
//switch (Unknown_3Ch)
//{
// case 0x7f800001:
// case 0: //only in yft's!
// break;
// default:
// break;
//}
//switch (Unknown_4Ch)
//{
// case 0x7f800001:
// case 0: //only in yft's!
// break;
// default:
// break;
//}
//if ((DrawableModelsHigh?.data_items != null) != (Unknown_80h != 0))
//{ }//no hit
//if ((DrawableModelsMedium?.data_items != null) != (Unknown_84h != 0))
@ -4081,7 +4101,9 @@ namespace CodeWalker.GameFiles
writer.Write(this.BoundingCenter);
writer.Write(this.BoundingSphereRadius);
writer.Write(this.BoundingBoxMin);
writer.Write(this.Unknown_3Ch);
writer.Write(this.BoundingBoxMax);
writer.Write(this.Unknown_4Ch);
writer.Write(this.DrawableModelsHighPointer);
writer.Write(this.DrawableModelsMediumPointer);
writer.Write(this.DrawableModelsLowPointer);
@ -4104,8 +4126,8 @@ namespace CodeWalker.GameFiles
{
YdrXml.SelfClosingTag(sb, indent, "BoundingSphereCenter " + FloatUtil.GetVector3XmlString(BoundingCenter));
YdrXml.ValueTag(sb, indent, "BoundingSphereRadius", FloatUtil.ToString(BoundingSphereRadius));
YdrXml.SelfClosingTag(sb, indent, "BoundingBoxMin " + FloatUtil.GetVector4XmlString(BoundingBoxMin));
YdrXml.SelfClosingTag(sb, indent, "BoundingBoxMax " + FloatUtil.GetVector4XmlString(BoundingBoxMax));
YdrXml.SelfClosingTag(sb, indent, "BoundingBoxMin " + FloatUtil.GetVector3XmlString(BoundingBoxMin));
YdrXml.SelfClosingTag(sb, indent, "BoundingBoxMax " + FloatUtil.GetVector3XmlString(BoundingBoxMax));
YdrXml.ValueTag(sb, indent, "LodDistHigh", FloatUtil.ToString(LodDistHigh));
YdrXml.ValueTag(sb, indent, "LodDistMed", FloatUtil.ToString(LodDistMed));
YdrXml.ValueTag(sb, indent, "LodDistLow", FloatUtil.ToString(LodDistLow));
@ -4158,8 +4180,8 @@ namespace CodeWalker.GameFiles
{
BoundingCenter = Xml.GetChildVector3Attributes(node, "BoundingSphereCenter");
BoundingSphereRadius = Xml.GetChildFloatAttribute(node, "BoundingSphereRadius", "value");
BoundingBoxMin = Xml.GetChildVector4Attributes(node, "BoundingBoxMin");
BoundingBoxMax = Xml.GetChildVector4Attributes(node, "BoundingBoxMax");
BoundingBoxMin = Xml.GetChildVector3Attributes(node, "BoundingBoxMin");
BoundingBoxMax = Xml.GetChildVector3Attributes(node, "BoundingBoxMax");
LodDistHigh = Xml.GetChildFloatAttribute(node, "LodDistHigh", "value");
LodDistMed = Xml.GetChildFloatAttribute(node, "LodDistMed", "value");
LodDistLow = Xml.GetChildFloatAttribute(node, "LodDistLow", "value");

View File

@ -656,7 +656,7 @@ namespace CodeWalker.GameFiles
// structure data
public ulong Unknown_0A8h; // 0x0000000000000000
public Matrix FragMatrix { get; set; }
public Matrix4F_s FragMatrix { get; set; }
public ulong BoundPointer { get; set; }
public ulong FragMatricesIndsPointer { get; set; }
public ushort FragMatricesIndsCount { get; set; }
@ -677,7 +677,7 @@ namespace CodeWalker.GameFiles
// reference data
public Bounds Bound { get; set; }
public ulong[] FragMatricesInds { get; set; }
public Matrix[] FragMatrices { get; set; }
public Matrix4F_s[] FragMatrices { get; set; }
public string Name { get; set; }
public FragType OwnerFragment { get; set; } //for handy use
@ -686,7 +686,7 @@ namespace CodeWalker.GameFiles
public FragDrawable OwnerDrawable { get; set; } //if inheriting shaders, skeletons and bounds
private ResourceSystemStructBlock<ulong> FragMatricesIndsBlock = null; //used for saving only
private ResourceSystemStructBlock<Matrix> FragMatricesBlock = null;
private ResourceSystemStructBlock<Matrix4F_s> FragMatricesBlock = null;
private string_r NameBlock = null;
public override void Read(ResourceDataReader reader, params object[] parameters)
@ -695,7 +695,7 @@ namespace CodeWalker.GameFiles
// read structure data
this.Unknown_0A8h = reader.ReadUInt64();
this.FragMatrix = reader.ReadMatrix();
this.FragMatrix = reader.ReadStruct<Matrix4F_s>();
this.BoundPointer = reader.ReadUInt64();
this.FragMatricesIndsPointer = reader.ReadUInt64();
this.FragMatricesIndsCount = reader.ReadUInt16();
@ -716,7 +716,7 @@ namespace CodeWalker.GameFiles
// read reference data
Bound = reader.ReadBlockAt<Bounds>(BoundPointer);
FragMatricesInds = reader.ReadUlongsAt(FragMatricesIndsPointer, FragMatricesIndsCount);
FragMatrices = reader.ReadStructsAt<Matrix>(FragMatricesPointer, FragMatricesCapacity);
FragMatrices = reader.ReadStructsAt<Matrix4F_s>(FragMatricesPointer, FragMatricesCapacity);
Name = reader.ReadStringAt(NamePointer);
if (Bound != null)
@ -765,6 +765,29 @@ namespace CodeWalker.GameFiles
//if (Unknown_148h != 0)
//{ }//no hit
//if (FragMatrix.Flags1 != 0x7f800001)
//{ }//no hit
//if (FragMatrix.Flags2 != 0x7f800001)
//{ }//no hit
//if (FragMatrix.Flags3 != 0x7f800001)
//{ }//no hit
//if (FragMatrix.Flags4 != 0x7f800001)
//{ }//no hit
//if (FragMatrices != null)
//{
// foreach (var fm in FragMatrices)
// {
// if (fm.Flags1 != 0x7f800001)
// { }//no hit
// if (fm.Flags2 != 0x7f800001)
// { }//no hit
// if (fm.Flags3 != 0x7f800001)
// { }//no hit
// if (fm.Flags4 != 0x7f800001)
// { }//no hit
// }
//}
}
public override void Write(ResourceDataWriter writer, params object[] parameters)
{
@ -780,7 +803,7 @@ namespace CodeWalker.GameFiles
// write structure data
writer.Write(this.Unknown_0A8h);
writer.Write(this.FragMatrix);
writer.WriteStruct(this.FragMatrix);
writer.Write(this.BoundPointer);
writer.Write(this.FragMatricesIndsPointer);
writer.Write(this.FragMatricesIndsCount);
@ -801,7 +824,7 @@ namespace CodeWalker.GameFiles
public override void WriteXml(StringBuilder sb, int indent, string ddsfolder)
{
YftXml.StringTag(sb, indent, "Name", YftXml.XmlEscape(Name));
YftXml.WriteRawArray(sb, FragMatrix.ToArray(), indent, "Matrix", "", FloatUtil.ToString, 4);
YftXml.WriteRawArray(sb, FragMatrix.ToArray(), indent, "Matrix", "", FloatUtil.ToString, 3);
if ((FragMatrices != null) && (FragMatrices.Length > 0))
{
YftXml.OpenTag(sb, indent, "Matrices capacity=\"" + FragMatrices.Length.ToString() + "\"");
@ -811,7 +834,7 @@ namespace CodeWalker.GameFiles
{
var idx = ((FragMatricesInds != null) && (i < FragMatricesInds.Length)) ? FragMatricesInds[i] : 0;
YftXml.OpenTag(sb, cind, "Item id=\"" + idx.ToString() + "\"");
YftXml.WriteRawArrayContent(sb, FragMatrices[i].ToArray(), cind + 1, FloatUtil.ToString, 4);
YftXml.WriteRawArrayContent(sb, FragMatrices[i].ToArray(), cind + 1, FloatUtil.ToString, 3);
YftXml.CloseTag(sb, cind, "Item");
}
YftXml.CloseTag(sb, indent, "Matrices");
@ -836,26 +859,26 @@ namespace CodeWalker.GameFiles
public override void ReadXml(XmlNode node, string ddsfolder)
{
Name = Xml.GetChildInnerText(node, "Name"); if (string.IsNullOrEmpty(Name)) Name = null;
FragMatrix = Xml.GetChildMatrix(node, "Matrix");
FragMatrix = new Matrix4F_s(Xml.GetChildRawFloatArray(node, "Matrix"));
var msnode = node.SelectSingleNode("Matrices");
if (msnode != null)
{
var mats = new List<Matrix>();
var mats = new List<Matrix4F_s>();
var matinds = new List<ulong>();
var cap = Xml.GetIntAttribute(msnode, "capacity");
var inodes = msnode.SelectNodes("Item");
foreach (XmlNode inode in inodes)
{
var id = Xml.GetULongAttribute(inode, "id");
var mat = Xml.GetMatrix(inode);
var mat = new Matrix4F_s(Xml.GetRawFloatArray(inode));
matinds.Add(id);
mats.Add(mat);
}
for (int i = mats.Count; i < cap; i++)
{
matinds.Add(0);
mats.Add(new Matrix(float.NaN));
mats.Add(new Matrix4F_s(float.NaN));
}
FragMatrices = mats.ToArray();
FragMatricesInds = matinds.ToArray();
@ -895,7 +918,7 @@ namespace CodeWalker.GameFiles
}
if (FragMatrices != null)
{
FragMatricesBlock = new ResourceSystemStructBlock<Matrix>(FragMatrices);
FragMatricesBlock = new ResourceSystemStructBlock<Matrix4F_s>(FragMatrices);
list.Add(FragMatricesBlock);
}
if (Name != null)
@ -1544,21 +1567,29 @@ namespace CodeWalker.GameFiles
Items[i] = u;
coffset += reader.Position - rpos;
var padd = (int)(16 - (coffset % 16)) % 16;
var padd = (16 - (coffset % 16)) % 16;
if (padd > 0)
{
u.Padding = reader.ReadBytes(padd);
u.Padding = reader.ReadBytes((int)padd);
coffset += padd;
//foreach (var b in u.Padding)
//{
// if (b != 0)
// { }
//}
}
}
//if (coffset != TotalLength)
//{ }
//if (Unknown_4h != 112)
//{ }//no hit
//if (UnkUint0 != 0)
//{ }//no hit
//// just testing
BuildOffsets();
//BuildOffsets();
}
public override void Write(ResourceDataWriter writer, params object[] parameters)
{
@ -1582,7 +1613,7 @@ namespace CodeWalker.GameFiles
item.Write(writer);
coffset += writer.Position - rpos;
var padd = (int)(16 - (coffset % 16)) % 16;
var padd = (16 - (coffset % 16)) % 16;
if (padd > 0)
{
writer.Write(new byte[padd]);
@ -1590,6 +1621,9 @@ namespace CodeWalker.GameFiles
}
}
//if (coffset != TotalLength)
//{ }
}
public void WriteXml(StringBuilder sb, int indent)
{
@ -1630,6 +1664,7 @@ namespace CodeWalker.GameFiles
var bc = 16u;
if (Items != null)
{
bc += (uint)((Items.Length + (Items.Length & 1)) * 8);
foreach (var item in Items)
{
var off = new ItemOffsetStruct();
@ -1639,11 +1674,10 @@ namespace CodeWalker.GameFiles
bc += item.TotalLength;
bc += (16 - (bc % 16)) % 16;//account for padding
}
if ((offs.Count % 2) != 0)
if ((offs.Count & 1) != 0)
{
offs.Add(new ItemOffsetStruct());
}
bc += (uint)offs.Count * 8u;
}
//// just testing

View File

@ -164,6 +164,102 @@ namespace CodeWalker.GameFiles
}
[TypeConverter(typeof(ExpandableObjectConverter))] public struct Matrix4F_s
{
public Vector3 Column1 { get; set; }
public uint Flags1 { get; set; }
public Vector3 Column2 { get; set; }
public uint Flags2 { get; set; }
public Vector3 Column3 { get; set; }
public uint Flags3 { get; set; }
public Vector3 Column4 { get; set; }
public uint Flags4 { get; set; }
public Matrix4F_s(bool identity)
{
if (identity)
{
Column1 = Vector3.UnitX;
Column2 = Vector3.UnitY;
Column3 = Vector3.UnitZ;
Column4 = Vector3.Zero;
}
else
{
Column1 = Vector3.Zero;
Column2 = Vector3.Zero;
Column3 = Vector3.Zero;
Column4 = Vector3.Zero;
}
Flags1 = 0x7f800001;
Flags2 = 0x7f800001;
Flags3 = 0x7f800001;
Flags4 = 0x7f800001;
}
public Matrix4F_s(float v)
{
Column1 = new Vector3(v);
Column2 = new Vector3(v);
Column3 = new Vector3(v);
Column4 = new Vector3(v);
Flags1 = 0x7f800001;
Flags2 = 0x7f800001;
Flags3 = 0x7f800001;
Flags4 = 0x7f800001;
}
public Matrix4F_s(float[] a)
{
if ((a != null) && (a.Length == 12))
{
Column1 = new Vector3(a[0], a[1], a[2]);
Column2 = new Vector3(a[3], a[4], a[5]);
Column3 = new Vector3(a[6], a[7], a[8]);
Column4 = new Vector3(a[9], a[10], a[11]);
}
else
{
Column1 = Vector3.UnitX;
Column2 = Vector3.UnitY;
Column3 = Vector3.UnitZ;
Column4 = Vector3.Zero;
}
Flags1 = 0x7f800001;
Flags2 = 0x7f800001;
Flags3 = 0x7f800001;
Flags4 = 0x7f800001;
}
public Matrix4F_s(Matrix m)
{
Column1 = new Vector3(m.M11, m.M12, m.M13);
Column2 = new Vector3(m.M21, m.M22, m.M23);
Column3 = new Vector3(m.M31, m.M32, m.M33);
Column4 = new Vector3(m.M41, m.M42, m.M43);
Flags1 = 0x7f800001;
Flags2 = 0x7f800001;
Flags3 = 0x7f800001;
Flags4 = 0x7f800001;
}
public float[] ToArray()
{
return new[] { Column1.X, Column1.Y, Column1.Z, Column2.X, Column2.Y, Column2.Z, Column3.X, Column3.Y, Column3.Z, Column4.X, Column4.Y, Column4.Z };
}
public Matrix ToMatrix()
{
return new Matrix(Column1.X, Column1.Y, Column1.Z, 0, Column2.X, Column2.Y, Column2.Z, 0, Column3.X, Column3.Y, Column3.Z, 0, Column4.X, Column4.Y, Column4.Z, 1);
}
public static Matrix4F_s Identity { get { return new Matrix4F_s(true); } }
public static Matrix4F_s Zero { get { return new Matrix4F_s(false); } }
}
[TypeConverter(typeof(ExpandableObjectConverter))] public struct AABB_s
{
public Vector4 Min { get; set; }

View File

@ -158,8 +158,8 @@ namespace CodeWalker
d.ShaderGroup = sgrp;
d.BoundingCenter = bsCen;
d.BoundingSphereRadius = bsRad;
d.BoundingBoxMin = new Vector4(bbMin, float.NaN);
d.BoundingBoxMax = new Vector4(bbMax, float.NaN);
d.BoundingBoxMin = bbMin;
d.BoundingBoxMax = bbMax;
d.LodDistHigh = 9998;//lod dist defaults
d.LodDistMed = 9998;
d.LodDistLow = 9998;

View File

@ -1413,8 +1413,8 @@ namespace CodeWalker.Rendering
rinst.Position = Vector3.Zero;
rinst.CamRel = Vector3.Zero;
rinst.Distance = 0.0f;
rinst.BBMin = skydomeydr.BoundingBoxMin.XYZ();
rinst.BBMax = skydomeydr.BoundingBoxMax.XYZ();
rinst.BBMin = skydomeydr.BoundingBoxMin;
rinst.BBMax = skydomeydr.BoundingBoxMax;
rinst.BSCenter = Vector3.Zero;
rinst.Radius = skydomeydr.BoundingSphereRadius;
rinst.Orientation = Quaternion.Identity;
@ -2887,8 +2887,8 @@ namespace CodeWalker.Rendering
Vector3 scale = Vector3.One;
Quaternion orientation = Quaternion.Identity;
uint tintPaletteIndex = 0;
Vector3 bbmin = (arche != null) ? arche.BBMin : rndbl.Key.BoundingBoxMin.XYZ();
Vector3 bbmax = (arche != null) ? arche.BBMax : rndbl.Key.BoundingBoxMax.XYZ();
Vector3 bbmin = (arche != null) ? arche.BBMin : rndbl.Key.BoundingBoxMin;
Vector3 bbmax = (arche != null) ? arche.BBMax : rndbl.Key.BoundingBoxMax;
Vector3 bscen = (arche != null) ? arche.BSCenter : rndbl.Key.BoundingCenter;
float radius = (arche != null) ? arche.BSRadius : rndbl.Key.BoundingSphereRadius;
float distance = 0;// (camrel + bscen).Length();

View File

@ -2315,8 +2315,8 @@ namespace CodeWalker
{
bsph.Center = camrel + drawable.BoundingCenter;
bsph.Radius = drawable.BoundingSphereRadius;
bbox.Minimum = drawable.BoundingBoxMin.XYZ() * scale;
bbox.Maximum = drawable.BoundingBoxMax.XYZ() * scale;
bbox.Minimum = drawable.BoundingBoxMin * scale;
bbox.Maximum = drawable.BoundingBoxMax * scale;
}
bool mousespherehit = camera.MouseRay.Intersects(ref bsph);