mirror of
https://github.com/zeldaret/Z64Utils.git
synced 2026-10-05 08:57:22 -04:00
Add info display for skeleton/animation in object analyzer + fix json support
This commit is contained in:
+92
-92
@@ -41,24 +41,24 @@
|
||||
"Vertex"}, -1);
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ObjectAnalyzerForm));
|
||||
this.tabControl1 = new System.Windows.Forms.TabControl();
|
||||
this.tabPage1 = new System.Windows.Forms.TabPage();
|
||||
this.tabPage2 = new System.Windows.Forms.TabPage();
|
||||
this.ucodeTextBox = new System.Windows.Forms.TextBox();
|
||||
this.tabPage3 = new System.Windows.Forms.TabPage();
|
||||
this.tabPage_empty = new System.Windows.Forms.TabPage();
|
||||
this.tabPage_text = new System.Windows.Forms.TabPage();
|
||||
this.textBox_holderInfo = new System.Windows.Forms.TextBox();
|
||||
this.tabPage_texture = new System.Windows.Forms.TabPage();
|
||||
this.pic_texture = new Z64.Forms.TextureBox();
|
||||
this.tabPage4 = new System.Windows.Forms.TabPage();
|
||||
this.tabPage_vtx = new System.Windows.Forms.TabPage();
|
||||
this.listView_vtx = new System.Windows.Forms.ListView();
|
||||
this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.columnHeader8 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.tabPage5 = new System.Windows.Forms.TabPage();
|
||||
this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
|
||||
this.columnHeader5 = new System.Windows.Forms.ColumnHeader();
|
||||
this.columnHeader6 = new System.Windows.Forms.ColumnHeader();
|
||||
this.columnHeader7 = new System.Windows.Forms.ColumnHeader();
|
||||
this.columnHeader8 = new System.Windows.Forms.ColumnHeader();
|
||||
this.tabPage_unknow = new System.Windows.Forms.TabPage();
|
||||
this.hexBox1 = new Be.Windows.Forms.HexBox();
|
||||
this.listView_map = new System.Windows.Forms.ListView();
|
||||
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
|
||||
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
|
||||
this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
|
||||
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.showInDisplayViewerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.addToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@@ -77,11 +77,11 @@
|
||||
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
|
||||
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
|
||||
this.tabControl1.SuspendLayout();
|
||||
this.tabPage2.SuspendLayout();
|
||||
this.tabPage3.SuspendLayout();
|
||||
this.tabPage_text.SuspendLayout();
|
||||
this.tabPage_texture.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pic_texture)).BeginInit();
|
||||
this.tabPage4.SuspendLayout();
|
||||
this.tabPage5.SuspendLayout();
|
||||
this.tabPage_vtx.SuspendLayout();
|
||||
this.tabPage_unknow.SuspendLayout();
|
||||
this.contextMenuStrip1.SuspendLayout();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
@@ -91,11 +91,11 @@
|
||||
this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.tabControl1.Controls.Add(this.tabPage1);
|
||||
this.tabControl1.Controls.Add(this.tabPage2);
|
||||
this.tabControl1.Controls.Add(this.tabPage3);
|
||||
this.tabControl1.Controls.Add(this.tabPage4);
|
||||
this.tabControl1.Controls.Add(this.tabPage5);
|
||||
this.tabControl1.Controls.Add(this.tabPage_empty);
|
||||
this.tabControl1.Controls.Add(this.tabPage_text);
|
||||
this.tabControl1.Controls.Add(this.tabPage_texture);
|
||||
this.tabControl1.Controls.Add(this.tabPage_vtx);
|
||||
this.tabControl1.Controls.Add(this.tabPage_unknow);
|
||||
this.tabControl1.ItemSize = new System.Drawing.Size(47, 18);
|
||||
this.tabControl1.Location = new System.Drawing.Point(377, 27);
|
||||
this.tabControl1.MinimumSize = new System.Drawing.Size(357, 207);
|
||||
@@ -104,52 +104,52 @@
|
||||
this.tabControl1.Size = new System.Drawing.Size(632, 499);
|
||||
this.tabControl1.TabIndex = 8;
|
||||
//
|
||||
// tabPage1
|
||||
// tabPage_empty
|
||||
//
|
||||
this.tabPage1.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage1.Name = "tabPage1";
|
||||
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage1.Size = new System.Drawing.Size(624, 473);
|
||||
this.tabPage1.TabIndex = 0;
|
||||
this.tabPage1.Text = "nothing";
|
||||
this.tabPage1.UseVisualStyleBackColor = true;
|
||||
this.tabPage_empty.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage_empty.Name = "tabPage_empty";
|
||||
this.tabPage_empty.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage_empty.Size = new System.Drawing.Size(624, 473);
|
||||
this.tabPage_empty.TabIndex = 0;
|
||||
this.tabPage_empty.Text = "nothing";
|
||||
this.tabPage_empty.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tabPage2
|
||||
// tabPage_text
|
||||
//
|
||||
this.tabPage2.Controls.Add(this.ucodeTextBox);
|
||||
this.tabPage2.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage2.Name = "tabPage2";
|
||||
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage2.Size = new System.Drawing.Size(624, 473);
|
||||
this.tabPage2.TabIndex = 1;
|
||||
this.tabPage2.Text = "ucode";
|
||||
this.tabPage2.UseVisualStyleBackColor = true;
|
||||
this.tabPage_text.Controls.Add(this.textBox_holderInfo);
|
||||
this.tabPage_text.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage_text.Name = "tabPage_text";
|
||||
this.tabPage_text.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage_text.Size = new System.Drawing.Size(624, 473);
|
||||
this.tabPage_text.TabIndex = 1;
|
||||
this.tabPage_text.Text = "ucode";
|
||||
this.tabPage_text.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ucodeTextBox
|
||||
// textBox_holderInfo
|
||||
//
|
||||
this.ucodeTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
this.textBox_holderInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ucodeTextBox.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.ucodeTextBox.Location = new System.Drawing.Point(6, 6);
|
||||
this.ucodeTextBox.Multiline = true;
|
||||
this.ucodeTextBox.Name = "ucodeTextBox";
|
||||
this.ucodeTextBox.ReadOnly = true;
|
||||
this.ucodeTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
||||
this.ucodeTextBox.Size = new System.Drawing.Size(617, 461);
|
||||
this.ucodeTextBox.TabIndex = 7;
|
||||
this.ucodeTextBox.WordWrap = false;
|
||||
this.textBox_holderInfo.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.textBox_holderInfo.Location = new System.Drawing.Point(6, 6);
|
||||
this.textBox_holderInfo.Multiline = true;
|
||||
this.textBox_holderInfo.Name = "textBox_holderInfo";
|
||||
this.textBox_holderInfo.ReadOnly = true;
|
||||
this.textBox_holderInfo.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
||||
this.textBox_holderInfo.Size = new System.Drawing.Size(617, 461);
|
||||
this.textBox_holderInfo.TabIndex = 7;
|
||||
this.textBox_holderInfo.WordWrap = false;
|
||||
//
|
||||
// tabPage3
|
||||
// tabPage_texture
|
||||
//
|
||||
this.tabPage3.Controls.Add(this.pic_texture);
|
||||
this.tabPage3.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage3.Name = "tabPage3";
|
||||
this.tabPage3.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage3.Size = new System.Drawing.Size(624, 473);
|
||||
this.tabPage3.TabIndex = 2;
|
||||
this.tabPage3.Text = "texture";
|
||||
this.tabPage3.UseVisualStyleBackColor = true;
|
||||
this.tabPage_texture.Controls.Add(this.pic_texture);
|
||||
this.tabPage_texture.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage_texture.Name = "tabPage_texture";
|
||||
this.tabPage_texture.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage_texture.Size = new System.Drawing.Size(624, 473);
|
||||
this.tabPage_texture.TabIndex = 2;
|
||||
this.tabPage_texture.Text = "texture";
|
||||
this.tabPage_texture.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// pic_texture
|
||||
//
|
||||
@@ -165,16 +165,16 @@
|
||||
this.pic_texture.TabIndex = 0;
|
||||
this.pic_texture.TabStop = false;
|
||||
//
|
||||
// tabPage4
|
||||
// tabPage_vtx
|
||||
//
|
||||
this.tabPage4.Controls.Add(this.listView_vtx);
|
||||
this.tabPage4.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage4.Name = "tabPage4";
|
||||
this.tabPage4.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage4.Size = new System.Drawing.Size(624, 473);
|
||||
this.tabPage4.TabIndex = 3;
|
||||
this.tabPage4.Text = "vertex";
|
||||
this.tabPage4.UseVisualStyleBackColor = true;
|
||||
this.tabPage_vtx.Controls.Add(this.listView_vtx);
|
||||
this.tabPage_vtx.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage_vtx.Name = "tabPage_vtx";
|
||||
this.tabPage_vtx.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage_vtx.Size = new System.Drawing.Size(624, 473);
|
||||
this.tabPage_vtx.TabIndex = 3;
|
||||
this.tabPage_vtx.Text = "vertex";
|
||||
this.tabPage_vtx.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// listView_vtx
|
||||
//
|
||||
@@ -187,7 +187,7 @@
|
||||
this.columnHeader6,
|
||||
this.columnHeader7,
|
||||
this.columnHeader8});
|
||||
this.listView_vtx.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.listView_vtx.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.listView_vtx.FullRowSelect = true;
|
||||
this.listView_vtx.HideSelection = false;
|
||||
this.listView_vtx.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
|
||||
@@ -224,16 +224,16 @@
|
||||
this.columnHeader8.Text = "Normal/Color";
|
||||
this.columnHeader8.Width = 149;
|
||||
//
|
||||
// tabPage5
|
||||
// tabPage_unknow
|
||||
//
|
||||
this.tabPage5.Controls.Add(this.hexBox1);
|
||||
this.tabPage5.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage5.Name = "tabPage5";
|
||||
this.tabPage5.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage5.Size = new System.Drawing.Size(624, 473);
|
||||
this.tabPage5.TabIndex = 4;
|
||||
this.tabPage5.Text = "unknow";
|
||||
this.tabPage5.UseVisualStyleBackColor = true;
|
||||
this.tabPage_unknow.Controls.Add(this.hexBox1);
|
||||
this.tabPage_unknow.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage_unknow.Name = "tabPage_unknow";
|
||||
this.tabPage_unknow.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage_unknow.Size = new System.Drawing.Size(624, 473);
|
||||
this.tabPage_unknow.TabIndex = 4;
|
||||
this.tabPage_unknow.Text = "unknow";
|
||||
this.tabPage_unknow.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// hexBox1
|
||||
//
|
||||
@@ -241,7 +241,7 @@
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.hexBox1.ColumnInfoVisible = true;
|
||||
this.hexBox1.Font = new System.Drawing.Font("Consolas", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.hexBox1.Font = new System.Drawing.Font("Consolas", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.hexBox1.LineInfoVisible = true;
|
||||
this.hexBox1.Location = new System.Drawing.Point(6, 6);
|
||||
this.hexBox1.Name = "hexBox1";
|
||||
@@ -262,7 +262,7 @@
|
||||
this.columnHeader2,
|
||||
this.columnHeader3});
|
||||
this.listView_map.ContextMenuStrip = this.contextMenuStrip1;
|
||||
this.listView_map.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.listView_map.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.listView_map.FullRowSelect = true;
|
||||
this.listView_map.HideSelection = false;
|
||||
this.listView_map.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
|
||||
@@ -430,12 +430,12 @@
|
||||
this.Name = "ObjectAnalyzerForm";
|
||||
this.Text = "Object Analyzer";
|
||||
this.tabControl1.ResumeLayout(false);
|
||||
this.tabPage2.ResumeLayout(false);
|
||||
this.tabPage2.PerformLayout();
|
||||
this.tabPage3.ResumeLayout(false);
|
||||
this.tabPage_text.ResumeLayout(false);
|
||||
this.tabPage_text.PerformLayout();
|
||||
this.tabPage_texture.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pic_texture)).EndInit();
|
||||
this.tabPage4.ResumeLayout(false);
|
||||
this.tabPage5.ResumeLayout(false);
|
||||
this.tabPage_vtx.ResumeLayout(false);
|
||||
this.tabPage_unknow.ResumeLayout(false);
|
||||
this.contextMenuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
@@ -447,12 +447,11 @@
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TabControl tabControl1;
|
||||
private System.Windows.Forms.TabPage tabPage1;
|
||||
private System.Windows.Forms.TabPage tabPage2;
|
||||
private System.Windows.Forms.TabPage tabPage3;
|
||||
private System.Windows.Forms.TabPage tabPage_empty;
|
||||
private System.Windows.Forms.TabPage tabPage_texture;
|
||||
private TextureBox pic_texture;
|
||||
private System.Windows.Forms.TabPage tabPage4;
|
||||
private System.Windows.Forms.TabPage tabPage5;
|
||||
private System.Windows.Forms.TabPage tabPage_vtx;
|
||||
private System.Windows.Forms.TabPage tabPage_unknow;
|
||||
private System.Windows.Forms.ListView listView_map;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader1;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader2;
|
||||
@@ -460,7 +459,7 @@
|
||||
private System.Windows.Forms.MenuStrip menuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem findDlistsToolStripMenuItem;
|
||||
private System.Windows.Forms.TextBox ucodeTextBox;
|
||||
private System.Windows.Forms.TextBox textBox_holderInfo;
|
||||
private System.Windows.Forms.ToolStripMenuItem analyzeDlistsToolStripMenuItem;
|
||||
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem showInDisplayViewerToolStripMenuItem;
|
||||
@@ -482,5 +481,6 @@
|
||||
private System.Windows.Forms.OpenFileDialog openFileDialog1;
|
||||
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem exportCToolStripMenuItem;
|
||||
private System.Windows.Forms.TabPage tabPage_text;
|
||||
}
|
||||
}
|
||||
@@ -84,11 +84,11 @@ namespace Z64.Forms
|
||||
var lines = disas.Disassemble();
|
||||
StringWriter sw = new StringWriter();
|
||||
lines.ForEach(s => sw.WriteLine(s));
|
||||
ucodeTextBox.Text = sw.ToString();
|
||||
textBox_holderInfo.Text = sw.ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ucodeTextBox.Text = "ERROR";
|
||||
textBox_holderInfo.Text = "ERROR";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ namespace Z64.Forms
|
||||
var holder = GetCurrentHolder<Z64Object.ObjectHolder>();
|
||||
if (holder == null)
|
||||
{
|
||||
tabControl1.SelectedIndex = 0;
|
||||
tabControl1.SelectedTab = tabPage_empty;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -134,13 +134,13 @@ namespace Z64.Forms
|
||||
{
|
||||
case Z64Object.EntryType.DList:
|
||||
{
|
||||
tabControl1.SelectedIndex = 1;
|
||||
tabControl1.SelectedTab = tabPage_text;
|
||||
UpdateDisassembly();
|
||||
break;
|
||||
}
|
||||
case Z64Object.EntryType.Vertex:
|
||||
{
|
||||
tabControl1.SelectedIndex = 3;
|
||||
tabControl1.SelectedTab = tabPage_vtx;
|
||||
var vtx = (Z64Object.VertexHolder)holder;
|
||||
|
||||
listView_vtx.BeginUpdate();
|
||||
@@ -161,29 +161,100 @@ namespace Z64.Forms
|
||||
}
|
||||
case Z64Object.EntryType.Texture:
|
||||
{
|
||||
tabControl1.SelectedIndex = 2;
|
||||
tabControl1.SelectedTab = tabPage_texture;
|
||||
var tex = (Z64Object.TextureHolder)holder;
|
||||
if ((tex.Format != N64.N64TexFormat.CI4 && tex.Format != N64.N64TexFormat.CI8) || tex.Tlut != null)
|
||||
pic_texture.Image = tex.GetBitmap();
|
||||
break;
|
||||
}
|
||||
case Z64Object.EntryType.Unknown:
|
||||
case Z64Object.EntryType.SkeletonHeader:
|
||||
{
|
||||
tabControl1.SelectedTab = tabPage_text;
|
||||
var skel = (Z64Object.SkeletonHolder)holder;
|
||||
StringWriter sw = new StringWriter();
|
||||
sw.WriteLine($"Limbs: 0x{skel.LimbsSeg.VAddr:X8}");
|
||||
sw.WriteLine($"Limb Count: {skel.LimbCount}");
|
||||
textBox_holderInfo.Text = sw.ToString();
|
||||
break;
|
||||
}
|
||||
case Z64Object.EntryType.FlexSkeletonHeader:
|
||||
case Z64Object.EntryType.SkeletonLimb:
|
||||
{
|
||||
tabControl1.SelectedTab = tabPage_text;
|
||||
var skel = (Z64Object.FlexSkeletonHolder)holder;
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
sw.WriteLine($"Limbs: 0x{skel.LimbsSeg.VAddr:X8}");
|
||||
sw.WriteLine($"Limb Count: {skel.LimbCount}");
|
||||
sw.WriteLine($"DList Count: {skel.DListCount}");
|
||||
|
||||
textBox_holderInfo.Text = sw.ToString();
|
||||
break;
|
||||
}
|
||||
case Z64Object.EntryType.SkeletonLimbs:
|
||||
{
|
||||
tabControl1.SelectedTab = tabPage_text;
|
||||
var limbs = (Z64Object.SkeletonLimbsHolder)holder;
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
sw.WriteLine($"Limbs:");
|
||||
foreach (var limb in limbs.LimbSegments)
|
||||
sw.WriteLine($"0x{limb.VAddr:X8}");
|
||||
|
||||
textBox_holderInfo.Text = sw.ToString();
|
||||
break;
|
||||
}
|
||||
case Z64Object.EntryType.SkeletonLimb:
|
||||
{
|
||||
tabControl1.SelectedTab = tabPage_text;
|
||||
var limb = (Z64Object.SkeletonLimbHolder)holder;
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
sw.WriteLine($"Position: {{ {limb.JointX}, {limb.JointY}, {limb.JointZ} }}");
|
||||
sw.WriteLine($"Child: 0x{limb.Child:X2}");
|
||||
sw.WriteLine($"Sibling: 0x{limb.Sibling:X2}");
|
||||
sw.WriteLine($"DList : 0x{limb.DListSeg.VAddr:X8}");
|
||||
|
||||
textBox_holderInfo.Text = sw.ToString();
|
||||
break;
|
||||
}
|
||||
case Z64Object.EntryType.AnimationHeader:
|
||||
case Z64Object.EntryType.FrameData:
|
||||
{
|
||||
tabControl1.SelectedTab = tabPage_text;
|
||||
var anim = (Z64Object.AnimationHolder)holder;
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
sw.WriteLine($"Frame Count: {anim.FrameCount}");
|
||||
sw.WriteLine($"Frame Data: 0x{anim.FrameData.VAddr:X8}");
|
||||
sw.WriteLine($"Joint Indices: 0x{anim.JointIndices.VAddr:X8}");
|
||||
sw.WriteLine($"Static Index Max: 0x{anim.StaticIndexMax}");
|
||||
|
||||
textBox_holderInfo.Text = sw.ToString();
|
||||
break;
|
||||
}
|
||||
case Z64Object.EntryType.JointIndices:
|
||||
{
|
||||
tabControl1.SelectedIndex = 4;
|
||||
tabControl1.SelectedTab = tabPage_text;
|
||||
var joints = (Z64Object.AnimationJointIndicesHolder)holder;
|
||||
|
||||
var provider = new Be.Windows.Forms.DynamicByteProvider(holder.GetData());;
|
||||
StringWriter sw = new StringWriter();
|
||||
sw.WriteLine($"Joints:");
|
||||
foreach (var joint in joints.JointIndices)
|
||||
sw.WriteLine($"{{ frameData[{joint.X}], frameData[{joint.Y}], frameData[{joint.Z}] }}");
|
||||
|
||||
textBox_holderInfo.Text = sw.ToString();
|
||||
break;
|
||||
}
|
||||
case Z64Object.EntryType.FrameData:
|
||||
case Z64Object.EntryType.Unknown:
|
||||
{
|
||||
tabControl1.SelectedTab = tabPage_unknow;
|
||||
|
||||
var provider = new DynamicByteProvider(holder.GetData());;
|
||||
hexBox1.ByteProvider = provider;
|
||||
hexBox1.LineInfoOffset = new SegmentedAddress(_segment, _obj.OffsetOf(holder)).VAddr;
|
||||
break;
|
||||
}
|
||||
default: tabControl1.SelectedIndex = 0; break;
|
||||
default: tabControl1.SelectedTab = tabPage_empty; break;
|
||||
}
|
||||
listView_map.Focus();
|
||||
}
|
||||
|
||||
@@ -1,64 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
@@ -117,20 +57,8 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>132, 17</value>
|
||||
</metadata>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>287, 17</value>
|
||||
</metadata>
|
||||
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>423, 17</value>
|
||||
</metadata>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<assembly alias="System.Drawing.Common" name="System.Drawing.Common, Version=4.0.2.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing.Common" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
AAABAAUAEBAAAAEAIABoBAAAVgAAABgYAAABACAAiAkAAL4EAAAgIAAAAQAgAKgQAABGDgAAMDAAAAEA
|
||||
IACoJQAA7h4AAAAAAAABACAAYnMAAJZEAAAoAAAAEAAAACAAAAABACAAAAAAAAAEAADCDgAAwg4AAAAA
|
||||
|
||||
+267
-95
@@ -165,13 +165,13 @@ namespace Z64
|
||||
}
|
||||
public class SkeletonLimbHolder : ObjectHolder
|
||||
{
|
||||
public byte[] Raw { get; set; }
|
||||
public const int ENTRY_SIZE = 0xC;
|
||||
|
||||
public short JointX { get; set; }
|
||||
public short JointY { get; set; }
|
||||
public short JointZ { get; set; }
|
||||
public byte Parent { get; set; }
|
||||
public byte Child { get; set; }
|
||||
public byte Sibling { get; set; }
|
||||
public SegmentedAddress DListSeg { get; set; }
|
||||
|
||||
public SkeletonLimbHolder(string name, byte[] data) : base(name)
|
||||
@@ -179,28 +179,40 @@ namespace Z64
|
||||
SetData(data);
|
||||
}
|
||||
|
||||
public override byte[] GetData() => Raw;
|
||||
public override EntryType GetEntryType() => EntryType.SkeletonLimb;
|
||||
|
||||
public override EntryType GetEntryType()
|
||||
public override byte[] GetData()
|
||||
{
|
||||
return EntryType.SkeletonLimb;
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
BinaryStream bw = new BinaryStream(ms, ByteConverter.Big);
|
||||
bw.Write(JointX);
|
||||
bw.Write(JointY);
|
||||
bw.Write(JointZ);
|
||||
bw.Write(Child);
|
||||
bw.Write(Sibling);
|
||||
bw.Write(DListSeg.VAddr);
|
||||
return ms.ToArray().Take((int)ms.Length).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetData(byte[] data)
|
||||
{
|
||||
Raw = data;
|
||||
JointX = ArrayUtil.ReadInt16BE(data, 0);
|
||||
JointY = ArrayUtil.ReadInt16BE(data, 2);
|
||||
JointZ = ArrayUtil.ReadInt16BE(data, 4);
|
||||
Parent = data[6];
|
||||
Child = data[7];
|
||||
DListSeg = new SegmentedAddress(ArrayUtil.ReadUint32BE(data, 8));
|
||||
using (MemoryStream ms = new MemoryStream(data))
|
||||
{
|
||||
BinaryStream br = new BinaryStream(ms, ByteConverter.Big);
|
||||
JointX = br.ReadInt16();
|
||||
JointY = br.ReadInt16();
|
||||
JointZ = br.ReadInt16();
|
||||
Child = br.Read1Byte();
|
||||
Sibling = br.Read1Byte();
|
||||
DListSeg = new SegmentedAddress(br.ReadUInt32());
|
||||
}
|
||||
}
|
||||
public override int GetSize() => Raw.Length;
|
||||
public override int GetSize() => ENTRY_SIZE;
|
||||
}
|
||||
public class SkeletonLimbsHolder : ObjectHolder
|
||||
{
|
||||
public byte[] Raw { get; set; }
|
||||
|
||||
public SegmentedAddress[] LimbSegments { get; set; }
|
||||
|
||||
public SkeletonLimbsHolder(string name, byte[] data) : base(name)
|
||||
@@ -208,85 +220,121 @@ namespace Z64
|
||||
SetData(data);
|
||||
}
|
||||
|
||||
public override byte[] GetData() => Raw;
|
||||
public override EntryType GetEntryType() => EntryType.SkeletonLimbs;
|
||||
|
||||
public override EntryType GetEntryType()
|
||||
public override byte[] GetData()
|
||||
{
|
||||
return EntryType.SkeletonLimbs;
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
BinaryStream bw = new BinaryStream(ms, ByteConverter.Big);
|
||||
|
||||
for (int i = 0; i < LimbSegments.Length; i++)
|
||||
bw.Write(LimbSegments[i].VAddr);
|
||||
|
||||
return ms.GetBuffer().Take((int)ms.Length).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetData(byte[] data)
|
||||
{
|
||||
Raw = data;
|
||||
if ((data.Length % 4) != 0)
|
||||
throw new Z64ObjectException($"Invalid data size (0x{data.Length:X}) should be a multiple of 4");
|
||||
|
||||
LimbSegments = new SegmentedAddress[data.Length / 4];
|
||||
for (int i = 0; i < data.Length/4; i++)
|
||||
using (MemoryStream ms = new MemoryStream(data))
|
||||
{
|
||||
LimbSegments[i] = new SegmentedAddress(ArrayUtil.ReadUint32BE(data, i * 4));
|
||||
BinaryStream br = new BinaryStream(ms, ByteConverter.Big);
|
||||
|
||||
for (int i = 0; i < LimbSegments.Length; i++)
|
||||
LimbSegments[i] = new SegmentedAddress(br.ReadUInt32());
|
||||
}
|
||||
}
|
||||
public override int GetSize() => Raw.Length;
|
||||
public override int GetSize() => LimbSegments.Length * 4;
|
||||
}
|
||||
public class SkeletonHolder : ObjectHolder
|
||||
{
|
||||
public byte[] Raw { get; set; }
|
||||
public const int HEADER_SIZE = 0x8;
|
||||
|
||||
public int LimbCount { get; set; }
|
||||
public byte LimbCount { get; set; }
|
||||
public SegmentedAddress LimbsSeg { get; set; }
|
||||
|
||||
public SkeletonHolder(string name, byte[] data) : base(name)
|
||||
{
|
||||
SetData(data);
|
||||
}
|
||||
public override EntryType GetEntryType() => EntryType.SkeletonHeader;
|
||||
|
||||
public override byte[] GetData() => Raw;
|
||||
|
||||
public override EntryType GetEntryType()
|
||||
public override byte[] GetData()
|
||||
{
|
||||
return EntryType.SkeletonHeader;
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
BinaryStream bw = new BinaryStream(ms, ByteConverter.Big);
|
||||
bw.Write(LimbsSeg.VAddr);
|
||||
bw.Write(LimbCount);
|
||||
bw.Write(new byte[3]); // padding
|
||||
return ms.ToArray().Take((int)ms.Length).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetData(byte[] data)
|
||||
{
|
||||
Raw = data;
|
||||
LimbsSeg = new SegmentedAddress(ArrayUtil.ReadUint32BE(data));
|
||||
LimbCount = data[4];
|
||||
using (var ms = new MemoryStream(data))
|
||||
{
|
||||
BinaryStream br = new BinaryStream(ms, ByteConverter.Big);
|
||||
LimbsSeg = new SegmentedAddress(br.ReadUInt32());
|
||||
LimbCount = br.Read1Byte();
|
||||
}
|
||||
}
|
||||
public override int GetSize() => Raw.Length;
|
||||
public override int GetSize() => HEADER_SIZE;
|
||||
|
||||
}
|
||||
|
||||
public class FlexSkeletonHolder : ObjectHolder
|
||||
{
|
||||
public byte[] Raw { get; set; }
|
||||
public const int HEADER_SIZE = SkeletonHolder.HEADER_SIZE + 0x4;
|
||||
|
||||
public int LimbCount { get; set; }
|
||||
public SegmentedAddress LimbsSeg { get; set; }
|
||||
public int DListCount { get; set; }
|
||||
public byte LimbCount { get; set; }
|
||||
public byte DListCount { get; set; }
|
||||
|
||||
public FlexSkeletonHolder(string name, byte[] data) : base(name)
|
||||
{
|
||||
SetData(data);
|
||||
}
|
||||
public override EntryType GetEntryType() => EntryType.FlexSkeletonHeader;
|
||||
|
||||
public override byte[] GetData() => Raw;
|
||||
|
||||
public override EntryType GetEntryType()
|
||||
public override byte[] GetData()
|
||||
{
|
||||
return EntryType.FlexSkeletonHeader;
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
BinaryStream bw = new BinaryStream(ms, ByteConverter.Big);
|
||||
bw.Write(LimbsSeg.VAddr);
|
||||
bw.Write(LimbCount);
|
||||
bw.Write(new byte[3]); // padding
|
||||
bw.Write(DListCount);
|
||||
bw.Write(new byte[3]); // padding
|
||||
return ms.ToArray().Take((int)ms.Length).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetData(byte[] data)
|
||||
{
|
||||
Raw = data;
|
||||
LimbsSeg = new SegmentedAddress(ArrayUtil.ReadUint32BE(data));
|
||||
LimbCount = data[4];
|
||||
DListCount = data[8];
|
||||
using (var ms = new MemoryStream(data))
|
||||
{
|
||||
BinaryStream br = new BinaryStream(ms, ByteConverter.Big);
|
||||
LimbsSeg = new SegmentedAddress(br.ReadUInt32());
|
||||
LimbCount = br.Read1Byte();
|
||||
br.ReadBytes(3); // padding
|
||||
DListCount = br.Read1Byte();
|
||||
br.ReadBytes(3); // padding
|
||||
}
|
||||
}
|
||||
public override int GetSize() => Raw.Length;
|
||||
public override int GetSize() => HEADER_SIZE;
|
||||
|
||||
}
|
||||
public class AnimationHolder : ObjectHolder
|
||||
{
|
||||
public const int HEADER_SIZE = 0x10;
|
||||
public byte[] Raw { get; set; }
|
||||
|
||||
public short FrameCount { get; set; }
|
||||
@@ -299,92 +347,127 @@ namespace Z64
|
||||
SetData(data);
|
||||
}
|
||||
|
||||
public override byte[] GetData() => Raw;
|
||||
public override EntryType GetEntryType() => EntryType.AnimationHeader;
|
||||
|
||||
public override EntryType GetEntryType()
|
||||
public override byte[] GetData()
|
||||
{
|
||||
return EntryType.AnimationHeader;
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
BinaryStream bw = new BinaryStream(ms, ByteConverter.Big);
|
||||
bw.Write(FrameCount);
|
||||
bw.Write(new byte[2]); // padding
|
||||
bw.Write(FrameData.VAddr);
|
||||
bw.Write(JointIndices.VAddr);
|
||||
bw.Write(StaticIndexMax);
|
||||
return ms.ToArray().Take((int)ms.Length).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetData(byte[] data)
|
||||
{
|
||||
Raw = data;
|
||||
FrameCount = ArrayUtil.ReadInt16BE(data, 0);
|
||||
FrameData = new SegmentedAddress(ArrayUtil.ReadUint32BE(data, 4));
|
||||
JointIndices = new SegmentedAddress(ArrayUtil.ReadUint32BE(data, 8));
|
||||
StaticIndexMax = ArrayUtil.ReadUInt16BE(data, 12);
|
||||
using (var ms = new MemoryStream(data))
|
||||
{
|
||||
BinaryStream br = new BinaryStream(ms, ByteConverter.Big);
|
||||
FrameCount = br.ReadInt16();
|
||||
br.ReadBytes(2); // padding
|
||||
FrameData = new SegmentedAddress(br.ReadUInt32());
|
||||
JointIndices = new SegmentedAddress(br.ReadUInt32());
|
||||
StaticIndexMax = br.ReadUInt16();
|
||||
}
|
||||
}
|
||||
public override int GetSize() => Raw.Length;
|
||||
public override int GetSize() => HEADER_SIZE;
|
||||
}
|
||||
public class AnimationFrameDataHolder : ObjectHolder
|
||||
{
|
||||
public byte[] Raw { get; set; }
|
||||
|
||||
public short[] FrameData { get; set; }
|
||||
|
||||
public AnimationFrameDataHolder(string name, byte[] data) : base(name)
|
||||
{
|
||||
SetData(data);
|
||||
}
|
||||
public override EntryType GetEntryType() => EntryType.FrameData;
|
||||
|
||||
public override byte[] GetData() => Raw;
|
||||
|
||||
public override EntryType GetEntryType()
|
||||
public override byte[] GetData()
|
||||
{
|
||||
return EntryType.FrameData;
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
BinaryStream bw = new BinaryStream(ms, ByteConverter.Big);
|
||||
foreach (var item in FrameData)
|
||||
bw.Write(item);
|
||||
return ms.ToArray().Take((int)ms.Length).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetData(byte[] data)
|
||||
{
|
||||
Raw = data;
|
||||
if ((data.Length % 2) != 0)
|
||||
throw new Z64ObjectException($"Invalid data size (0x{data.Length:X}) should be a multiple of 2");
|
||||
|
||||
FrameData = new short[data.Length / 2];
|
||||
for (int i = 0; i < data.Length / 2; i++)
|
||||
|
||||
using (var ms = new MemoryStream(data))
|
||||
{
|
||||
FrameData[i] = ArrayUtil.ReadInt16BE(data, i * 2);
|
||||
BinaryStream br = new BinaryStream(ms, ByteConverter.Big);
|
||||
|
||||
FrameData = new short[data.Length / 2];
|
||||
for (int i = 0; i < FrameData.Length; i++)
|
||||
FrameData[i] = br.ReadInt16();
|
||||
}
|
||||
}
|
||||
public override int GetSize() => Raw.Length;
|
||||
public override int GetSize() => FrameData.Length * 2;
|
||||
}
|
||||
public class AnimationJointIndicesHolder : ObjectHolder
|
||||
{
|
||||
public const int ENTRY_SIZE = 6;
|
||||
public struct JointIndex
|
||||
{
|
||||
public ushort x, y, z;
|
||||
public ushort X, Y, Z;
|
||||
};
|
||||
|
||||
public byte[] Raw { get; set; }
|
||||
public JointIndex[] JointIndices { get; set; }
|
||||
|
||||
public AnimationJointIndicesHolder(string name, byte[] data) : base(name)
|
||||
{
|
||||
SetData(data);
|
||||
}
|
||||
public override EntryType GetEntryType() => EntryType.JointIndices;
|
||||
|
||||
public override byte[] GetData() => Raw;
|
||||
|
||||
public override EntryType GetEntryType()
|
||||
public override byte[] GetData()
|
||||
{
|
||||
return EntryType.JointIndices;
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
BinaryStream bw = new BinaryStream(ms, ByteConverter.Big);
|
||||
|
||||
for (int i = 0; i < JointIndices.Length; i++)
|
||||
{
|
||||
bw.Write(JointIndices[i].X);
|
||||
bw.Write(JointIndices[i].Y);
|
||||
bw.Write(JointIndices[i].Z);
|
||||
}
|
||||
|
||||
return ms.GetBuffer().Take((int)ms.Length).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetData(byte[] data)
|
||||
{
|
||||
Raw = data;
|
||||
if ((data.Length % 6) != 0)
|
||||
if ((data.Length % ENTRY_SIZE) != 0)
|
||||
throw new Z64ObjectException($"Invalid data size (0x{data.Length:X}) should be a multiple of 6");
|
||||
|
||||
JointIndices = new JointIndex[data.Length / 6];
|
||||
for (int i = 0; i < data.Length / 6; i++)
|
||||
JointIndices = new JointIndex[data.Length / ENTRY_SIZE];
|
||||
using (MemoryStream ms = new MemoryStream(data))
|
||||
{
|
||||
JointIndices[i] =
|
||||
new JointIndex() {
|
||||
x = ArrayUtil.ReadUInt16BE(data, i * 6),
|
||||
y = ArrayUtil.ReadUInt16BE(data, i * 6 + 2),
|
||||
z = ArrayUtil.ReadUInt16BE(data, i * 6 + 4)
|
||||
BinaryStream br = new BinaryStream(ms, ByteConverter.Big);
|
||||
|
||||
for (int i = 0; i < JointIndices.Length; i++)
|
||||
JointIndices[i] = new JointIndex()
|
||||
{
|
||||
X = br.ReadUInt16(),
|
||||
Y = br.ReadUInt16(),
|
||||
Z = br.ReadUInt16()
|
||||
};
|
||||
}
|
||||
}
|
||||
public override int GetSize() => Raw.Length;
|
||||
public override int GetSize() => JointIndices.Length * ENTRY_SIZE;
|
||||
}
|
||||
|
||||
public List<ObjectHolder> Entries { get; set; }
|
||||
@@ -605,46 +688,46 @@ namespace Z64
|
||||
AddVertexHolder(holder, off);
|
||||
return holder;
|
||||
}
|
||||
public SkeletonLimbHolder AddSkeletonLimb(int size, string name = null, int off = -1, int skel_off = -1)
|
||||
public SkeletonLimbHolder AddSkeletonLimb(string name = null, int off = -1, int skel_off = -1)
|
||||
{
|
||||
if (off == -1) off = GetSize();
|
||||
var holder = new SkeletonLimbHolder(name?? $"skel_{skel_off:X8}_limb_{off:X8}", new byte[size]);
|
||||
var holder = new SkeletonLimbHolder(name?? $"skel_{skel_off:X8}_limb_{off:X8}", new byte[SkeletonLimbHolder.ENTRY_SIZE]);
|
||||
return (SkeletonLimbHolder)AddHolder(holder, off);
|
||||
}
|
||||
public SkeletonLimbsHolder AddSkeletonLimbs(int size, string name = null, int off = -1, int skel_off = -1)
|
||||
public SkeletonLimbsHolder AddSkeletonLimbs(int count, string name = null, int off = -1, int skel_off = -1)
|
||||
{
|
||||
if (off == -1) off = GetSize();
|
||||
var holder = new SkeletonLimbsHolder(name?? $"skel_{skel_off:X8}_limbs_{off:X8}", new byte[size]);
|
||||
var holder = new SkeletonLimbsHolder(name?? $"skel_{skel_off:X8}_limbs_{off:X8}", new byte[count * 4]);
|
||||
return (SkeletonLimbsHolder)AddHolder(holder, off);
|
||||
}
|
||||
public SkeletonHolder AddSkeleton(int size, string name = null, int off = -1)
|
||||
public SkeletonHolder AddSkeleton(string name = null, int off = -1)
|
||||
{
|
||||
if (off == -1) off = GetSize();
|
||||
var holder = new SkeletonHolder(name?? $"skel_{off:X8}", new byte[size]);
|
||||
var holder = new SkeletonHolder(name?? $"skel_{off:X8}", new byte[SkeletonHolder.HEADER_SIZE]);
|
||||
return (SkeletonHolder)AddHolder(holder, off);
|
||||
}
|
||||
public FlexSkeletonHolder AddFlexSkeleton(int size, string name = null, int off = -1)
|
||||
public FlexSkeletonHolder AddFlexSkeleton(string name = null, int off = -1)
|
||||
{
|
||||
if (off == -1) off = GetSize();
|
||||
var holder = new FlexSkeletonHolder(name ?? $"skel_{off:X8}", new byte[size]);
|
||||
var holder = new FlexSkeletonHolder(name ?? $"skel_{off:X8}", new byte[FlexSkeletonHolder.HEADER_SIZE]);
|
||||
return (FlexSkeletonHolder)AddHolder(holder, off);
|
||||
}
|
||||
public AnimationHolder AddAnimation(int size, string name = null, int off = -1)
|
||||
public AnimationHolder AddAnimation(string name = null, int off = -1)
|
||||
{
|
||||
if (off == -1) off = GetSize();
|
||||
var holder = new AnimationHolder(name?? $"anim_{off:X8}", new byte[size]);
|
||||
var holder = new AnimationHolder(name?? $"anim_{off:X8}", new byte[AnimationHolder.HEADER_SIZE]);
|
||||
return (AnimationHolder)AddHolder(holder, off);
|
||||
}
|
||||
public AnimationFrameDataHolder AddFrameData(int size, string name = null, int off = -1)
|
||||
public AnimationFrameDataHolder AddFrameData(int count, string name = null, int off = -1)
|
||||
{
|
||||
if (off == -1) off = GetSize();
|
||||
var holder = new AnimationFrameDataHolder(name ?? $"framedata_{off:X8}", new byte[size]);
|
||||
var holder = new AnimationFrameDataHolder(name ?? $"framedata_{off:X8}", new byte[count*2]);
|
||||
return (AnimationFrameDataHolder)AddHolder(holder, off);
|
||||
}
|
||||
public AnimationJointIndicesHolder AddJointIndices(int size, string name = null, int off = -1)
|
||||
public AnimationJointIndicesHolder AddJointIndices(int count, string name = null, int off = -1)
|
||||
{
|
||||
if (off == -1) off = GetSize();
|
||||
var holder = new AnimationJointIndicesHolder(name ?? $"jointindices_{off:X8}", new byte[size]);
|
||||
var holder = new AnimationJointIndicesHolder(name ?? $"jointindices_{off:X8}", new byte[count*AnimationJointIndicesHolder.ENTRY_SIZE]);
|
||||
return (AnimationJointIndicesHolder)AddHolder(holder, off);
|
||||
}
|
||||
|
||||
@@ -797,6 +880,13 @@ namespace Z64
|
||||
public N64TexFormat Format { get; set; }
|
||||
public string Tlut { get; set; }
|
||||
}
|
||||
private class JsonArrayHolder : JsonObjectHolder
|
||||
{
|
||||
public int Count { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
public string GetJSON()
|
||||
{
|
||||
var list = new List<object>();
|
||||
@@ -848,6 +938,51 @@ namespace Z64
|
||||
});
|
||||
break;
|
||||
}
|
||||
case EntryType.SkeletonLimbs:
|
||||
{
|
||||
var holder = (SkeletonLimbsHolder)iter;
|
||||
list.Add(new JsonArrayHolder()
|
||||
{
|
||||
Name = iter.Name,
|
||||
EntryType = iter.GetEntryType(),
|
||||
Count = holder.LimbSegments.Length
|
||||
});
|
||||
break;
|
||||
}
|
||||
case EntryType.JointIndices:
|
||||
{
|
||||
var holder = (AnimationJointIndicesHolder)iter;
|
||||
list.Add(new JsonArrayHolder()
|
||||
{
|
||||
Name = iter.Name,
|
||||
EntryType = iter.GetEntryType(),
|
||||
Count = holder.JointIndices.Length
|
||||
}); ;
|
||||
break;
|
||||
}
|
||||
case EntryType.FrameData:
|
||||
{
|
||||
var holder = (AnimationFrameDataHolder)iter;
|
||||
list.Add(new JsonArrayHolder()
|
||||
{
|
||||
Name = iter.Name,
|
||||
EntryType = iter.GetEntryType(),
|
||||
Count = holder.FrameData.Length
|
||||
});
|
||||
break;
|
||||
}
|
||||
case EntryType.SkeletonHeader:
|
||||
case EntryType.FlexSkeletonHeader:
|
||||
case EntryType.SkeletonLimb:
|
||||
case EntryType.AnimationHeader:
|
||||
{
|
||||
list.Add(new JsonObjectHolder()
|
||||
{
|
||||
Name = iter.Name,
|
||||
EntryType = iter.GetEntryType()
|
||||
});
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new Z64ObjectException($"Invalid entry type ({iter.GetEntryType()})");
|
||||
}
|
||||
@@ -864,7 +999,6 @@ namespace Z64
|
||||
var type = (EntryType)Enum.Parse(typeof(EntryType), iter.GetProperty(nameof(JsonObjectHolder.EntryType)).GetString());
|
||||
switch (type)
|
||||
{
|
||||
|
||||
case EntryType.DList:
|
||||
{
|
||||
var holder = iter.ToObject<JsonUCodeHolder>();
|
||||
@@ -889,6 +1023,44 @@ namespace Z64
|
||||
obj.AddUnknow(holder.Size, holder.Name);
|
||||
break;
|
||||
}
|
||||
case EntryType.SkeletonHeader:
|
||||
{
|
||||
obj.AddSkeleton();
|
||||
break;
|
||||
}
|
||||
case EntryType.FlexSkeletonHeader:
|
||||
{
|
||||
obj.AddFlexSkeleton();
|
||||
break;
|
||||
}
|
||||
case EntryType.SkeletonLimb:
|
||||
{
|
||||
obj.AddSkeletonLimb();
|
||||
break;
|
||||
}
|
||||
case EntryType.AnimationHeader:
|
||||
{
|
||||
obj.AddAnimation();
|
||||
break;
|
||||
}
|
||||
case EntryType.SkeletonLimbs:
|
||||
{
|
||||
var holder = iter.ToObject<JsonArrayHolder>();
|
||||
obj.AddSkeletonLimbs(holder.Count);
|
||||
break;
|
||||
}
|
||||
case EntryType.JointIndices:
|
||||
{
|
||||
var holder = iter.ToObject<JsonArrayHolder>();
|
||||
obj.AddJointIndices(holder.Count);
|
||||
break;
|
||||
}
|
||||
case EntryType.FrameData:
|
||||
{
|
||||
var holder = iter.ToObject<JsonArrayHolder>();
|
||||
obj.AddFrameData(holder.Count);
|
||||
break;
|
||||
}
|
||||
default: throw new Z64ObjectException($"Invalid entry type ({type})");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,12 +334,9 @@ namespace Z64
|
||||
|
||||
public static void FindSkeletons(Z64Object obj, byte[] data, int segmentId)
|
||||
{
|
||||
const int SKELETON_HEADER_SIZE = 0x8;
|
||||
const int FLEX_SKELETON_HEADER_SIZE = SKELETON_HEADER_SIZE + 0x4;
|
||||
const int SKELETON_LIMB_SIZE = 0xC; // only supports StandardLimb so far
|
||||
// Search for Skeleton Headers
|
||||
// Structure: SS OO OO OO XX 00 00 00 [XX 00 00 00]
|
||||
for (int i = 0; i < data.Length - SKELETON_HEADER_SIZE; i += 4)
|
||||
for (int i = 0; i < data.Length - Z64Object.SkeletonHolder.HEADER_SIZE; i += 4)
|
||||
{
|
||||
var segment = new SegmentedAddress(ArrayUtil.ReadUint32BE(data, i));
|
||||
// check for segmentId match, check for valid segment offset,
|
||||
@@ -358,17 +355,17 @@ namespace Z64
|
||||
// check for limbs array ending at the start of the skeleton header,
|
||||
// check for limbs array's segmented addresses being 0xC apart from one another
|
||||
if (segment.SegmentOff + nLimbs * 4 == i &&
|
||||
ArrayUtil.ReadUint32BE(limbsData, 4) - ArrayUtil.ReadUint32BE(limbsData, 0) == SKELETON_LIMB_SIZE)
|
||||
ArrayUtil.ReadUint32BE(limbsData, 4) - ArrayUtil.ReadUint32BE(limbsData, 0) == Z64Object.SkeletonLimbHolder.ENTRY_SIZE)
|
||||
{
|
||||
int nNonNullDlists = 0;
|
||||
obj.AddSkeletonLimbs(nLimbs * 4, off: (int)segment.SegmentOff);
|
||||
obj.AddSkeletonLimbs(nLimbs, off: (int)segment.SegmentOff);
|
||||
for (int j = 0; j < nLimbs * 4; j += 4)
|
||||
{
|
||||
SegmentedAddress limbSeg = new SegmentedAddress(ArrayUtil.ReadUint32BE(limbsData, j));
|
||||
if (limbSeg.SegmentId != segmentId)
|
||||
throw new Z64ObjectAnalyzerException(
|
||||
$"Limb segment {limbSeg.Segmented} is not the correct segment id, mis-detected SkeletonHeader?");
|
||||
obj.AddSkeletonLimb(SKELETON_LIMB_SIZE, off: (int)limbSeg.SegmentOff);
|
||||
obj.AddSkeletonLimb(off: (int)limbSeg.SegmentOff);
|
||||
// check if dlist is non-null (dlists may be null in general, this is only for FlexSkeletonHeader detection)
|
||||
if (ArrayUtil.ReadUint32BE(data, (int)(limbSeg.SegmentOff + 0x8)) != 0)
|
||||
nNonNullDlists++;
|
||||
@@ -378,14 +375,14 @@ namespace Z64
|
||||
// check if nothing is already assumed to occupy that space,
|
||||
// check if the number of dlists is equal to the actual number of non-null dlists,
|
||||
// check struct padding
|
||||
if (i < data.Length - FLEX_SKELETON_HEADER_SIZE && obj.IsOffsetFree(i + SKELETON_HEADER_SIZE) &&
|
||||
if (i < data.Length - Z64Object.FlexSkeletonHolder.HEADER_SIZE && obj.IsOffsetFree(i + Z64Object.SkeletonHolder.HEADER_SIZE) &&
|
||||
data[i + 8] == nNonNullDlists && data[i + 9] == 0 && data[i + 10] == 0 && data[i + 11] == 0)
|
||||
{
|
||||
obj.AddFlexSkeleton(FLEX_SKELETON_HEADER_SIZE, off: i);
|
||||
obj.AddFlexSkeleton(off: i);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.AddSkeleton(SKELETON_HEADER_SIZE, off: i);
|
||||
obj.AddSkeleton(off: i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -393,10 +390,9 @@ namespace Z64
|
||||
}
|
||||
public static void FindAnimations(Z64Object obj, byte[] data, int segmentId)
|
||||
{
|
||||
const int ANIMATION_HEADER_SIZE = 0x10;
|
||||
// Search for Animation Headers
|
||||
// Structure: FF FF 00 00 SS OO OO OO SS OO OO OO II II 00 00
|
||||
for (int i = 0; i < data.Length - ANIMATION_HEADER_SIZE; i += 4)
|
||||
for (int i = 0; i < data.Length - Z64Object.AnimationHolder.HEADER_SIZE; i += 4)
|
||||
{
|
||||
var frameCount = ArrayUtil.ReadInt16BE(data, i);
|
||||
// check positive nonzero frame count, check struct padding zeroes
|
||||
@@ -438,9 +434,9 @@ namespace Z64
|
||||
continue;
|
||||
jointIndicesSize -= (jointIndicesSize % 6);
|
||||
}
|
||||
obj.AddAnimation(ANIMATION_HEADER_SIZE, off: i);
|
||||
obj.AddFrameData(frameDataSize, off:(int)frameDataSeg.SegmentOff);
|
||||
obj.AddJointIndices(jointIndicesSize, off:(int)jointIndicesSeg.SegmentOff);
|
||||
obj.AddAnimation(off: i);
|
||||
obj.AddFrameData(frameDataSize/2, off:(int)frameDataSeg.SegmentOff);
|
||||
obj.AddJointIndices(jointIndicesSize/Z64Object.AnimationJointIndicesHolder.ENTRY_SIZE, off:(int)jointIndicesSeg.SegmentOff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user