Added QuaternionBox to allow editing of quaternions as Euler angles as well as quaternions

This commit is contained in:
dexy 2021-11-08 09:57:29 +11:00
parent 432b42504e
commit 8ac37258c3
12 changed files with 635 additions and 194 deletions

View File

@ -8,6 +8,8 @@
<ItemGroup>
<PackageReference Include="DockPanelSuite.ThemeVS2015" Version="3.0.6" />
<PackageReference Include="SharpDX" Version="4.2.0" />
<PackageReference Include="SharpDX.Mathematics" Version="4.2.0" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,152 @@

namespace CodeWalker.WinForms
{
partial class QuaternionBox
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.QuaternionTextBox = new System.Windows.Forms.TextBox();
this.EulerXUpDown = new System.Windows.Forms.NumericUpDown();
this.EulerYUpDown = new System.Windows.Forms.NumericUpDown();
this.EulerZUpDown = new System.Windows.Forms.NumericUpDown();
this.NormalizeButton = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.EulerXUpDown)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.EulerYUpDown)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.EulerZUpDown)).BeginInit();
this.SuspendLayout();
//
// QuaternionTextBox
//
this.QuaternionTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.QuaternionTextBox.Location = new System.Drawing.Point(0, 2);
this.QuaternionTextBox.Name = "QuaternionTextBox";
this.QuaternionTextBox.Size = new System.Drawing.Size(190, 20);
this.QuaternionTextBox.TabIndex = 0;
this.QuaternionTextBox.Text = "0, 0, 0, 1";
this.QuaternionTextBox.TextChanged += new System.EventHandler(this.QuaternionTextBox_TextChanged);
//
// EulerXUpDown
//
this.EulerXUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.EulerXUpDown.DecimalPlaces = 2;
this.EulerXUpDown.Location = new System.Drawing.Point(196, 2);
this.EulerXUpDown.Maximum = new decimal(new int[] {
360,
0,
0,
0});
this.EulerXUpDown.Minimum = new decimal(new int[] {
360,
0,
0,
-2147483648});
this.EulerXUpDown.Name = "EulerXUpDown";
this.EulerXUpDown.Size = new System.Drawing.Size(56, 20);
this.EulerXUpDown.TabIndex = 1;
this.EulerXUpDown.ValueChanged += new System.EventHandler(this.EulerXUpDown_ValueChanged);
//
// EulerYUpDown
//
this.EulerYUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.EulerYUpDown.DecimalPlaces = 2;
this.EulerYUpDown.Location = new System.Drawing.Point(258, 2);
this.EulerYUpDown.Maximum = new decimal(new int[] {
360,
0,
0,
0});
this.EulerYUpDown.Minimum = new decimal(new int[] {
360,
0,
0,
-2147483648});
this.EulerYUpDown.Name = "EulerYUpDown";
this.EulerYUpDown.Size = new System.Drawing.Size(56, 20);
this.EulerYUpDown.TabIndex = 2;
this.EulerYUpDown.ValueChanged += new System.EventHandler(this.EulerYUpDown_ValueChanged);
//
// EulerZUpDown
//
this.EulerZUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.EulerZUpDown.DecimalPlaces = 2;
this.EulerZUpDown.Location = new System.Drawing.Point(320, 2);
this.EulerZUpDown.Maximum = new decimal(new int[] {
360,
0,
0,
0});
this.EulerZUpDown.Minimum = new decimal(new int[] {
360,
0,
0,
-2147483648});
this.EulerZUpDown.Name = "EulerZUpDown";
this.EulerZUpDown.Size = new System.Drawing.Size(56, 20);
this.EulerZUpDown.TabIndex = 3;
this.EulerZUpDown.ValueChanged += new System.EventHandler(this.EulerZUpDown_ValueChanged);
//
// NormalizeButton
//
this.NormalizeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.NormalizeButton.Location = new System.Drawing.Point(382, 0);
this.NormalizeButton.Name = "NormalizeButton";
this.NormalizeButton.Size = new System.Drawing.Size(68, 23);
this.NormalizeButton.TabIndex = 4;
this.NormalizeButton.Text = "Normalize";
this.NormalizeButton.UseVisualStyleBackColor = true;
this.NormalizeButton.Click += new System.EventHandler(this.NormalizeButton_Click);
//
// QuaternionBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.NormalizeButton);
this.Controls.Add(this.EulerZUpDown);
this.Controls.Add(this.EulerYUpDown);
this.Controls.Add(this.EulerXUpDown);
this.Controls.Add(this.QuaternionTextBox);
this.Margin = new System.Windows.Forms.Padding(0);
this.Name = "QuaternionBox";
this.Size = new System.Drawing.Size(450, 24);
((System.ComponentModel.ISupportInitialize)(this.EulerXUpDown)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.EulerYUpDown)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.EulerZUpDown)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox QuaternionTextBox;
private System.Windows.Forms.NumericUpDown EulerXUpDown;
private System.Windows.Forms.NumericUpDown EulerYUpDown;
private System.Windows.Forms.NumericUpDown EulerZUpDown;
private System.Windows.Forms.Button NormalizeButton;
}
}

View File

@ -0,0 +1,205 @@
using SharpDX;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CodeWalker.WinForms
{
public partial class QuaternionBox : UserControl
{
public QuaternionBox()
{
InitializeComponent();
}
public Quaternion Value
{
get
{
return _Value;
}
set
{
_Value = value;
UpdateFromValue();
}
}
private Quaternion _Value = Quaternion.Identity;
private bool suppressEvents = false;
public event EventHandler ValueChanged;
private void RaiseValueChanged()
{
if (suppressEvents) return;
if (ValueChanged == null) return;
ValueChanged(this, null);
}
private void UpdateFromValue()
{
suppressEvents = true;
UpdateTextBox();
UpdateEulerUpDowns();
suppressEvents = false;
}
private void UpdateFromTextBox()
{
if (suppressEvents) return;
suppressEvents = true;
_Value = ParseQuaternionString(QuaternionTextBox.Text);
UpdateEulerUpDowns();
suppressEvents = false;
RaiseValueChanged();
}
private void UpdateFromEuler()
{
if (suppressEvents) return;
suppressEvents = true;
_Value = GetQuaternion(EulerXUpDown.Value, EulerYUpDown.Value, EulerZUpDown.Value);
UpdateTextBox();
suppressEvents = false;
RaiseValueChanged();
}
private void UpdateTextBox()
{
QuaternionTextBox.Text = GetQuaternionString(_Value);
}
private void UpdateEulerUpDowns()
{
var e = GetEulerAngles(_Value);
EulerXUpDown.Value = (decimal)e.X;
EulerYUpDown.Value = (decimal)e.Y;
EulerZUpDown.Value = (decimal)e.Z;
}
private void Normalize()
{
_Value.Normalize();
UpdateFromValue();
RaiseValueChanged();
}
private static Quaternion ParseQuaternionString(string s)
{
bool tryParseFloat(string str, out float f)
{
if (float.TryParse(str, NumberStyles.Any, CultureInfo.InvariantCulture, out f))
{
return true;
}
return false;
}
Quaternion q = Quaternion.Identity;
string[] ss = s.Split(',');
if (ss.Length > 0)
{
tryParseFloat(ss[0].Trim(), out q.X);
}
if (ss.Length > 1)
{
tryParseFloat(ss[1].Trim(), out q.Y);
}
if (ss.Length > 2)
{
tryParseFloat(ss[2].Trim(), out q.Z);
}
if (ss.Length > 3)
{
tryParseFloat(ss[3].Trim(), out q.W);
}
return q;
}
private static string GetQuaternionString(Quaternion q, string d = ", ")
{
var c = CultureInfo.InvariantCulture;
return q.X.ToString(c) + d + q.Y.ToString(c) + d + q.Z.ToString(c) + d + q.W.ToString(c);
}
private static Vector3 GetEulerAngles(Quaternion q)
{
var x = q.X;
var y = q.Y;
var z = q.Z;
var w = q.W;
var xx = x * x;
var yy = y * y;
var zz = z * z;
var ww = w * w;
var ls = xx + yy + zz + ww;
var st = x * w - y * z;
var sv = ls * 0.499f;
var rd = 180.0f / (float)Math.PI;
if (st > sv)
{
return new Vector3(90, (float)Math.Atan2(y, x) * 2.0f * rd, 0);
}
else if (st < -sv)
{
return new Vector3(-90, (float)Math.Atan2(y, x) * -2.0f * rd, 0);
}
else
{
return new Vector3(
(float)Math.Asin(2.0f * st) * rd,
(float)Math.Atan2(2.0f * (y * w + x * z), 1.0f - 2.0f * (xx + yy)) * rd,
(float)Math.Atan2(2.0f * (x * y + z * w), 1.0f - 2.0f * (xx + zz)) * rd
);
}
}
private static Quaternion GetQuaternion(decimal x, decimal y, decimal z)
{
var deg = new Vector3((float)x, (float)y, (float)z);
var rads = deg * (float)(Math.PI / 180.0);
return Quaternion.RotationYawPitchRoll(rads.Y, rads.X, rads.Z);
}
private void QuaternionTextBox_TextChanged(object sender, EventArgs e)
{
UpdateFromTextBox();
}
private void EulerXUpDown_ValueChanged(object sender, EventArgs e)
{
UpdateFromEuler();
}
private void EulerYUpDown_ValueChanged(object sender, EventArgs e)
{
UpdateFromEuler();
}
private void EulerZUpDown_ValueChanged(object sender, EventArgs e)
{
UpdateFromEuler();
}
private void NormalizeButton_Click(object sender, EventArgs e)
{
Normalize();
}
}
}

View File

@ -0,0 +1,120 @@
<?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.
-->
<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">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -31,12 +31,12 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditMultiPanel));
this.ScaleTextBox = new System.Windows.Forms.TextBox();
this.label23 = new System.Windows.Forms.Label();
this.RotationTextBox = new System.Windows.Forms.TextBox();
this.PositionTextBox = new System.Windows.Forms.TextBox();
this.label24 = new System.Windows.Forms.Label();
this.label25 = new System.Windows.Forms.Label();
this.ItemsListBox = new System.Windows.Forms.ListBox();
this.label1 = new System.Windows.Forms.Label();
this.RotationQuatBox = new CodeWalker.WinForms.QuaternionBox();
this.SuspendLayout();
//
// ScaleTextBox
@ -58,16 +58,6 @@
this.label23.TabIndex = 17;
this.label23.Text = "Scale:";
//
// RotationTextBox
//
this.RotationTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.RotationTextBox.Location = new System.Drawing.Point(75, 38);
this.RotationTextBox.Name = "RotationTextBox";
this.RotationTextBox.Size = new System.Drawing.Size(478, 20);
this.RotationTextBox.TabIndex = 16;
this.RotationTextBox.TextChanged += new System.EventHandler(this.RotationTextBox_TextChanged);
//
// PositionTextBox
//
this.PositionTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
@ -104,7 +94,7 @@
this.ItemsListBox.Location = new System.Drawing.Point(75, 108);
this.ItemsListBox.Name = "ItemsListBox";
this.ItemsListBox.Size = new System.Drawing.Size(202, 355);
this.ItemsListBox.TabIndex = 19;
this.ItemsListBox.TabIndex = 21;
this.ItemsListBox.SelectedIndexChanged += new System.EventHandler(this.ItemsListBox_SelectedIndexChanged);
//
// label1
@ -116,16 +106,27 @@
this.label1.TabIndex = 20;
this.label1.Text = "Items:";
//
// RotationQuatBox
//
this.RotationQuatBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.RotationQuatBox.Location = new System.Drawing.Point(75, 36);
this.RotationQuatBox.Margin = new System.Windows.Forms.Padding(0);
this.RotationQuatBox.Name = "RotationQuatBox";
this.RotationQuatBox.Size = new System.Drawing.Size(478, 24);
this.RotationQuatBox.TabIndex = 16;
this.RotationQuatBox.ValueChanged += new System.EventHandler(this.RotationQuatBox_ValueChanged);
//
// EditMultiPanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(565, 505);
this.Controls.Add(this.RotationQuatBox);
this.Controls.Add(this.label1);
this.Controls.Add(this.ItemsListBox);
this.Controls.Add(this.ScaleTextBox);
this.Controls.Add(this.label23);
this.Controls.Add(this.RotationTextBox);
this.Controls.Add(this.PositionTextBox);
this.Controls.Add(this.label24);
this.Controls.Add(this.label25);
@ -141,11 +142,11 @@
private System.Windows.Forms.TextBox ScaleTextBox;
private System.Windows.Forms.Label label23;
private System.Windows.Forms.TextBox RotationTextBox;
private System.Windows.Forms.TextBox PositionTextBox;
private System.Windows.Forms.Label label24;
private System.Windows.Forms.Label label25;
private System.Windows.Forms.ListBox ItemsListBox;
private System.Windows.Forms.Label label1;
private WinForms.QuaternionBox RotationQuatBox;
}
}

View File

@ -1,4 +1,5 @@
using System;
using SharpDX;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -47,7 +48,7 @@ namespace CodeWalker.Project.Panels
if (Items == null)
{
PositionTextBox.Text = string.Empty;
RotationTextBox.Text = string.Empty;
RotationQuatBox.Value = Quaternion.Identity;
ScaleTextBox.Text = string.Empty;
ItemsListBox.Items.Clear();
}
@ -57,7 +58,7 @@ namespace CodeWalker.Project.Panels
PositionTextBox.Text = FloatUtil.GetVector3String(MultiItem.MultipleSelectionCenter);
RotationTextBox.Text = FloatUtil.GetVector4String(MultiItem.MultipleSelectionRotation.ToVector4());
RotationQuatBox.Value = MultiItem.MultipleSelectionRotation;
ScaleTextBox.Text = FloatUtil.GetVector3String(MultiItem.MultipleSelectionScale);
ItemsListBox.Items.Clear();
foreach (var item in Items)
@ -90,21 +91,20 @@ namespace CodeWalker.Project.Panels
}
private void RotationTextBox_TextChanged(object sender, EventArgs e)
private void RotationQuatBox_ValueChanged(object sender, EventArgs e)
{
if (Items == null) return;
if (populatingui) return;
var v = FloatUtil.ParseVector4String(RotationTextBox.Text);
var q = RotationQuatBox.Value;
var wf = ProjectForm.WorldForm;
if (wf != null)
{
wf.BeginInvoke(new Action(() =>
{
wf.ChangeMultiRotation(Items, v.ToQuaternion(), false);
wf.ChangeMultiRotation(Items, q, false);
}));
}
}
private void ScaleTextBox_TextChanged(object sender, EventArgs e)

View File

@ -126,7 +126,6 @@
this.ScenarioEntityPointSpawnTypeHashLabel = new System.Windows.Forms.Label();
this.ScenarioEntityPointSpawnTypeTextBox = new System.Windows.Forms.TextBox();
this.label120 = new System.Windows.Forms.Label();
this.ScenarioEntityPointRotationTextBox = new System.Windows.Forms.TextBox();
this.label118 = new System.Windows.Forms.Label();
this.ScenarioEntityPointGoToButton = new System.Windows.Forms.Button();
this.ScenarioEntityPointPositionTextBox = new System.Windows.Forms.TextBox();
@ -224,6 +223,7 @@
this.label154 = new System.Windows.Forms.Label();
this.ScenarioClusterPointTypeComboBox = new System.Windows.Forms.ComboBox();
this.label155 = new System.Windows.Forms.Label();
this.ScenarioEntityPointRotationQuatBox = new CodeWalker.WinForms.QuaternionBox();
this.ScenarioTabControl.SuspendLayout();
this.ScenarioPointTabPage.SuspendLayout();
this.ScenarioPointOuterPanel.SuspendLayout();
@ -1012,6 +1012,7 @@
this.ScenarioEntityPointPanel.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.ScenarioEntityPointPanel.Controls.Add(this.ScenarioEntityPointRotationQuatBox);
this.ScenarioEntityPointPanel.Controls.Add(this.ScenarioEntityPointNameHashLabel);
this.ScenarioEntityPointPanel.Controls.Add(this.ScenarioEntityPointNameTextBox);
this.ScenarioEntityPointPanel.Controls.Add(this.ScenarioEntityPointFlagsCheckedListBox);
@ -1047,7 +1048,6 @@
this.ScenarioEntityPointPanel.Controls.Add(this.ScenarioEntityPointSpawnTypeHashLabel);
this.ScenarioEntityPointPanel.Controls.Add(this.ScenarioEntityPointSpawnTypeTextBox);
this.ScenarioEntityPointPanel.Controls.Add(this.label120);
this.ScenarioEntityPointPanel.Controls.Add(this.ScenarioEntityPointRotationTextBox);
this.ScenarioEntityPointPanel.Controls.Add(this.label118);
this.ScenarioEntityPointPanel.Controls.Add(this.ScenarioEntityPointGoToButton);
this.ScenarioEntityPointPanel.Controls.Add(this.ScenarioEntityPointPositionTextBox);
@ -1437,16 +1437,6 @@
this.label120.TabIndex = 13;
this.label120.Text = "Spawn type:";
//
// ScenarioEntityPointRotationTextBox
//
this.ScenarioEntityPointRotationTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.ScenarioEntityPointRotationTextBox.Location = new System.Drawing.Point(109, 27);
this.ScenarioEntityPointRotationTextBox.Name = "ScenarioEntityPointRotationTextBox";
this.ScenarioEntityPointRotationTextBox.Size = new System.Drawing.Size(313, 20);
this.ScenarioEntityPointRotationTextBox.TabIndex = 9;
this.ScenarioEntityPointRotationTextBox.TextChanged += new System.EventHandler(this.ScenarioEntityPointRotationTextBox_TextChanged);
//
// label118
//
this.label118.AutoSize = true;
@ -2584,6 +2574,17 @@
this.label155.TabIndex = 10;
this.label155.Text = "Type:";
//
// ScenarioEntityPointRotationQuatBox
//
this.ScenarioEntityPointRotationQuatBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.ScenarioEntityPointRotationQuatBox.Location = new System.Drawing.Point(109, 25);
this.ScenarioEntityPointRotationQuatBox.Margin = new System.Windows.Forms.Padding(0);
this.ScenarioEntityPointRotationQuatBox.Name = "ScenarioEntityPointRotationQuatBox";
this.ScenarioEntityPointRotationQuatBox.Size = new System.Drawing.Size(387, 24);
this.ScenarioEntityPointRotationQuatBox.TabIndex = 9;
this.ScenarioEntityPointRotationQuatBox.ValueChanged += new System.EventHandler(this.ScenarioEntityPointRotationQuatBox_ValueChanged);
//
// EditScenarioNodePanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -2746,7 +2747,6 @@
private System.Windows.Forms.Label ScenarioEntityPointSpawnTypeHashLabel;
private System.Windows.Forms.TextBox ScenarioEntityPointSpawnTypeTextBox;
private System.Windows.Forms.Label label120;
private System.Windows.Forms.TextBox ScenarioEntityPointRotationTextBox;
private System.Windows.Forms.Label label118;
private System.Windows.Forms.Button ScenarioEntityPointGoToButton;
private System.Windows.Forms.TextBox ScenarioEntityPointPositionTextBox;
@ -2844,5 +2844,6 @@
private System.Windows.Forms.Label label154;
private System.Windows.Forms.ComboBox ScenarioClusterPointTypeComboBox;
private System.Windows.Forms.Label label155;
private WinForms.QuaternionBox ScenarioEntityPointRotationQuatBox;
}
}

View File

@ -327,7 +327,7 @@ namespace CodeWalker.Project.Panels
ScenarioEntityPointNameTextBox.Text = "";
ScenarioEntityPointNameHashLabel.Text = "Hash: 0";
ScenarioEntityPointPositionTextBox.Text = "";
ScenarioEntityPointRotationTextBox.Text = "";
ScenarioEntityPointRotationQuatBox.Value = Quaternion.Identity;
ScenarioEntityPointSpawnTypeTextBox.Text = "";
ScenarioEntityPointSpawnTypeHashLabel.Text = "Hash: 0";
ScenarioEntityPointPedTypeTextBox.Text = "";
@ -362,7 +362,7 @@ namespace CodeWalker.Project.Panels
ScenarioEntityPointNameTextBox.Text = p.NameHash.ToString();
ScenarioEntityPointNameHashLabel.Text = "Hash: " + p.NameHash.Hash.ToString();
ScenarioEntityPointPositionTextBox.Text = FloatUtil.GetVector3String(p.OffsetPosition);
ScenarioEntityPointRotationTextBox.Text = FloatUtil.GetVector4String(p.OffsetRotation);
ScenarioEntityPointRotationQuatBox.Value = p.OffsetRotation.ToQuaternion();
ScenarioEntityPointSpawnTypeTextBox.Text = p.SpawnType.ToString();
ScenarioEntityPointSpawnTypeHashLabel.Text = "Hash: " + p.SpawnType.Hash.ToString();
ScenarioEntityPointPedTypeTextBox.Text = p.PedType.ToString();
@ -1266,19 +1266,20 @@ namespace CodeWalker.Project.Panels
}
}
private void ScenarioEntityPointRotationTextBox_TextChanged(object sender, EventArgs e)
private void ScenarioEntityPointRotationQuatBox_ValueChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentScenarioNode == null) return;
if (CurrentScenarioNode.EntityPoint == null) return;
Vector4 v = FloatUtil.ParseVector4String(ScenarioEntityPointRotationTextBox.Text);
Quaternion q = ScenarioEntityPointRotationQuatBox.Value;
Vector4 v = q.ToVector4();
bool change = false;
lock (ProjectForm.ProjectSyncRoot)
{
if (CurrentScenarioNode.EntityPoint.OffsetRotation != v)
{
CurrentScenarioNode.EntityPoint.OffsetRotation = v;
CurrentScenarioNode.Orientation = new Quaternion(v);
CurrentScenarioNode.Orientation = q;
ProjectForm.SetScenarioHasChanged(true);
change = true;
}
@ -2394,8 +2395,5 @@ namespace CodeWalker.Project.Panels
}
}
}
}
}

View File

@ -77,17 +77,17 @@
this.CenterGeomTextBox = new System.Windows.Forms.TextBox();
this.label17 = new System.Windows.Forms.Label();
this.CompositeFlagsTabPage = new System.Windows.Forms.TabPage();
this.CompFlags1CheckedListBox = new System.Windows.Forms.CheckedListBox();
this.label21 = new System.Windows.Forms.Label();
this.label22 = new System.Windows.Forms.Label();
this.CompFlags2CheckedListBox = new System.Windows.Forms.CheckedListBox();
this.label21 = new System.Windows.Forms.Label();
this.CompFlags1CheckedListBox = new System.Windows.Forms.CheckedListBox();
this.CompositeXformTabPage = new System.Windows.Forms.TabPage();
this.CompScaleTextBox = new System.Windows.Forms.TextBox();
this.label23 = new System.Windows.Forms.Label();
this.CompRotationTextBox = new System.Windows.Forms.TextBox();
this.CompPositionTextBox = new System.Windows.Forms.TextBox();
this.label24 = new System.Windows.Forms.Label();
this.label25 = new System.Windows.Forms.Label();
this.CompRotationQuatBox = new CodeWalker.WinForms.QuaternionBox();
this.BoundsTabControl.SuspendLayout();
this.BoundsTabPage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.UnkTypeUpDown)).BeginInit();
@ -632,60 +632,6 @@
this.CompositeFlagsTabPage.Text = "Composite Flags";
this.CompositeFlagsTabPage.UseVisualStyleBackColor = true;
//
// CompFlags1CheckedListBox
//
this.CompFlags1CheckedListBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.CompFlags1CheckedListBox.CheckOnClick = true;
this.CompFlags1CheckedListBox.FormattingEnabled = true;
this.CompFlags1CheckedListBox.Items.AddRange(new object[] {
"0 - Unknown",
"1 - Map Weapon",
"2 - Map Dynamic",
"3 - Map Animal",
"4 - Map Cover",
"5 - Map Vehicle",
"6 - Vehicle Not BVH",
"7 - Vehicle BVH",
"8 - Vehicle Box",
"9 - Ped",
"10 - Ragdoll",
"11 - Animal",
"12 - Animal Ragdoll",
"13 - Object",
"14 - Object Env Cloth",
"15 - Plant",
"16 - Projectile",
"17 - Explosion",
"18 - Pickup",
"19 - Foliage",
"20 - Forklift Forks",
"21 - Test Weapon",
"22 - Test Camera",
"23 - Test AI",
"24 - Test Script",
"25 - Test Vehicle Wheel",
"26 - Glass",
"27 - Map River",
"28 - Smoke",
"29 - Unsmashed",
"30 - Map Stairs",
"31 - Map Deep Surface"});
this.CompFlags1CheckedListBox.Location = new System.Drawing.Point(53, 3);
this.CompFlags1CheckedListBox.Name = "CompFlags1CheckedListBox";
this.CompFlags1CheckedListBox.Size = new System.Drawing.Size(174, 484);
this.CompFlags1CheckedListBox.TabIndex = 32;
this.CompFlags1CheckedListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.CompFlags1CheckedListBox_ItemCheck);
//
// label21
//
this.label21.AutoSize = true;
this.label21.Location = new System.Drawing.Point(3, 3);
this.label21.Name = "label21";
this.label21.Size = new System.Drawing.Size(44, 13);
this.label21.TabIndex = 33;
this.label21.Text = "Flags 1:";
//
// label22
//
this.label22.AutoSize = true;
@ -740,11 +686,65 @@
this.CompFlags2CheckedListBox.TabIndex = 34;
this.CompFlags2CheckedListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.CompFlags2CheckedListBox_ItemCheck);
//
// label21
//
this.label21.AutoSize = true;
this.label21.Location = new System.Drawing.Point(3, 3);
this.label21.Name = "label21";
this.label21.Size = new System.Drawing.Size(44, 13);
this.label21.TabIndex = 33;
this.label21.Text = "Flags 1:";
//
// CompFlags1CheckedListBox
//
this.CompFlags1CheckedListBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.CompFlags1CheckedListBox.CheckOnClick = true;
this.CompFlags1CheckedListBox.FormattingEnabled = true;
this.CompFlags1CheckedListBox.Items.AddRange(new object[] {
"0 - Unknown",
"1 - Map Weapon",
"2 - Map Dynamic",
"3 - Map Animal",
"4 - Map Cover",
"5 - Map Vehicle",
"6 - Vehicle Not BVH",
"7 - Vehicle BVH",
"8 - Vehicle Box",
"9 - Ped",
"10 - Ragdoll",
"11 - Animal",
"12 - Animal Ragdoll",
"13 - Object",
"14 - Object Env Cloth",
"15 - Plant",
"16 - Projectile",
"17 - Explosion",
"18 - Pickup",
"19 - Foliage",
"20 - Forklift Forks",
"21 - Test Weapon",
"22 - Test Camera",
"23 - Test AI",
"24 - Test Script",
"25 - Test Vehicle Wheel",
"26 - Glass",
"27 - Map River",
"28 - Smoke",
"29 - Unsmashed",
"30 - Map Stairs",
"31 - Map Deep Surface"});
this.CompFlags1CheckedListBox.Location = new System.Drawing.Point(53, 3);
this.CompFlags1CheckedListBox.Name = "CompFlags1CheckedListBox";
this.CompFlags1CheckedListBox.Size = new System.Drawing.Size(174, 484);
this.CompFlags1CheckedListBox.TabIndex = 32;
this.CompFlags1CheckedListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.CompFlags1CheckedListBox_ItemCheck);
//
// CompositeXformTabPage
//
this.CompositeXformTabPage.Controls.Add(this.CompRotationQuatBox);
this.CompositeXformTabPage.Controls.Add(this.CompScaleTextBox);
this.CompositeXformTabPage.Controls.Add(this.label23);
this.CompositeXformTabPage.Controls.Add(this.CompRotationTextBox);
this.CompositeXformTabPage.Controls.Add(this.CompPositionTextBox);
this.CompositeXformTabPage.Controls.Add(this.label24);
this.CompositeXformTabPage.Controls.Add(this.label25);
@ -774,16 +774,6 @@
this.label23.TabIndex = 11;
this.label23.Text = "Scale:";
//
// CompRotationTextBox
//
this.CompRotationTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.CompRotationTextBox.Location = new System.Drawing.Point(72, 38);
this.CompRotationTextBox.Name = "CompRotationTextBox";
this.CompRotationTextBox.Size = new System.Drawing.Size(500, 20);
this.CompRotationTextBox.TabIndex = 10;
this.CompRotationTextBox.TextChanged += new System.EventHandler(this.CompRotationTextBox_TextChanged);
//
// CompPositionTextBox
//
this.CompPositionTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
@ -812,6 +802,17 @@
this.label25.TabIndex = 7;
this.label25.Text = "Position:";
//
// CompRotationQuatBox
//
this.CompRotationQuatBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.CompRotationQuatBox.Location = new System.Drawing.Point(72, 36);
this.CompRotationQuatBox.Margin = new System.Windows.Forms.Padding(0);
this.CompRotationQuatBox.Name = "CompRotationQuatBox";
this.CompRotationQuatBox.Size = new System.Drawing.Size(500, 24);
this.CompRotationQuatBox.TabIndex = 10;
this.CompRotationQuatBox.ValueChanged += new System.EventHandler(this.CompRotationQuatBox_ValueChanged);
//
// EditYbnBoundsPanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -898,9 +899,9 @@
private System.Windows.Forms.TabPage CompositeXformTabPage;
private System.Windows.Forms.TextBox CompScaleTextBox;
private System.Windows.Forms.Label label23;
private System.Windows.Forms.TextBox CompRotationTextBox;
private System.Windows.Forms.TextBox CompPositionTextBox;
private System.Windows.Forms.Label label24;
private System.Windows.Forms.Label label25;
private WinForms.QuaternionBox CompRotationQuatBox;
}
}

View File

@ -1,4 +1,5 @@
using CodeWalker.GameFiles;
using SharpDX;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -102,7 +103,7 @@ namespace CodeWalker.Project.Panels
SetCheckedListBoxValues(CompFlags1CheckedListBox, 0);
SetCheckedListBoxValues(CompFlags2CheckedListBox, 0);
CompPositionTextBox.Text = string.Empty;
CompRotationTextBox.Text = string.Empty;
CompRotationQuatBox.Value = Quaternion.Identity;
CompScaleTextBox.Text = string.Empty;
VertexCountLabel.Text = "0 vertices";
PolyCountLabel.Text = "0 polygons";
@ -167,7 +168,7 @@ namespace CodeWalker.Project.Panels
SetCheckedListBoxValues(CompFlags1CheckedListBox, (uint)b.CompositeFlags1.Flags1);
SetCheckedListBoxValues(CompFlags2CheckedListBox, (uint)b.CompositeFlags1.Flags2);
CompPositionTextBox.Text = FloatUtil.GetVector3String(b.Position);
CompRotationTextBox.Text = FloatUtil.GetVector4String(b.Orientation.ToVector4());
CompRotationQuatBox.Value = b.Orientation;
CompScaleTextBox.Text = FloatUtil.GetVector3String(b.Scale);
}
else
@ -177,7 +178,7 @@ namespace CodeWalker.Project.Panels
SetCheckedListBoxValues(CompFlags1CheckedListBox, 0);
SetCheckedListBoxValues(CompFlags2CheckedListBox, 0);
CompPositionTextBox.Text = string.Empty;
CompRotationTextBox.Text = string.Empty;
CompRotationQuatBox.Value = Quaternion.Identity;
CompScaleTextBox.Text = string.Empty;
}
@ -571,11 +572,11 @@ namespace CodeWalker.Project.Panels
}
}
private void CompRotationTextBox_TextChanged(object sender, EventArgs e)
private void CompRotationQuatBox_ValueChanged(object sender, EventArgs e)
{
if (CollisionBounds == null) return;
if (populatingui) return;
var q = FloatUtil.ParseVector4String(CompRotationTextBox.Text).ToQuaternion();
var q = CompRotationQuatBox.Value;
lock (ProjectForm.ProjectSyncRoot)
{
if (CollisionBounds.Orientation != q)

View File

@ -31,6 +31,7 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditYmapEntityPanel));
this.EntityTabControl = new System.Windows.Forms.TabControl();
this.EntityGeneralTabPage = new System.Windows.Forms.TabPage();
this.EntityRotationQuatBox = new CodeWalker.WinForms.QuaternionBox();
this.EntityEditArchetypeButton = new System.Windows.Forms.Button();
this.EntityFlagsCheckedListBox = new System.Windows.Forms.CheckedListBox();
this.label13 = new System.Windows.Forms.Label();
@ -62,10 +63,8 @@
this.EntityArchetypeTextBox = new System.Windows.Forms.TextBox();
this.label16 = new System.Windows.Forms.Label();
this.EntityPositionTextBox = new System.Windows.Forms.TextBox();
this.EntityNormalizeRotationButton = new System.Windows.Forms.Button();
this.EntityGoToButton = new System.Windows.Forms.Button();
this.label17 = new System.Windows.Forms.Label();
this.EntityRotationTextBox = new System.Windows.Forms.TextBox();
this.EntityLodTabPage = new System.Windows.Forms.TabPage();
this.label20 = new System.Windows.Forms.Label();
this.EntityParentIndexTextBox = new System.Windows.Forms.TextBox();
@ -74,13 +73,12 @@
this.EntityExtensionsTabPage = new System.Windows.Forms.TabPage();
this.label1 = new System.Windows.Forms.Label();
this.EntityPivotTabPage = new System.Windows.Forms.TabPage();
this.EntityPivotRotationQuatBox = new CodeWalker.WinForms.QuaternionBox();
this.label95 = new System.Windows.Forms.Label();
this.EntityPivotEditCheckBox = new System.Windows.Forms.CheckBox();
this.label93 = new System.Windows.Forms.Label();
this.EntityPivotPositionTextBox = new System.Windows.Forms.TextBox();
this.EntityPivotRotationNormalizeButton = new System.Windows.Forms.Button();
this.label94 = new System.Windows.Forms.Label();
this.EntityPivotRotationTextBox = new System.Windows.Forms.TextBox();
this.EntityMiloTabPage = new System.Windows.Forms.TabPage();
this.MiloFlagsTextBox = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
@ -118,6 +116,7 @@
//
// EntityGeneralTabPage
//
this.EntityGeneralTabPage.Controls.Add(this.EntityRotationQuatBox);
this.EntityGeneralTabPage.Controls.Add(this.EntityEditArchetypeButton);
this.EntityGeneralTabPage.Controls.Add(this.EntityFlagsCheckedListBox);
this.EntityGeneralTabPage.Controls.Add(this.label13);
@ -149,10 +148,8 @@
this.EntityGeneralTabPage.Controls.Add(this.EntityArchetypeTextBox);
this.EntityGeneralTabPage.Controls.Add(this.label16);
this.EntityGeneralTabPage.Controls.Add(this.EntityPositionTextBox);
this.EntityGeneralTabPage.Controls.Add(this.EntityNormalizeRotationButton);
this.EntityGeneralTabPage.Controls.Add(this.EntityGoToButton);
this.EntityGeneralTabPage.Controls.Add(this.label17);
this.EntityGeneralTabPage.Controls.Add(this.EntityRotationTextBox);
this.EntityGeneralTabPage.Location = new System.Drawing.Point(4, 22);
this.EntityGeneralTabPage.Name = "EntityGeneralTabPage";
this.EntityGeneralTabPage.Padding = new System.Windows.Forms.Padding(3);
@ -161,6 +158,17 @@
this.EntityGeneralTabPage.Text = "General";
this.EntityGeneralTabPage.UseVisualStyleBackColor = true;
//
// EntityRotationQuatBox
//
this.EntityRotationQuatBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.EntityRotationQuatBox.Location = new System.Drawing.Point(93, 33);
this.EntityRotationQuatBox.Margin = new System.Windows.Forms.Padding(0);
this.EntityRotationQuatBox.Name = "EntityRotationQuatBox";
this.EntityRotationQuatBox.Size = new System.Drawing.Size(456, 24);
this.EntityRotationQuatBox.TabIndex = 5;
this.EntityRotationQuatBox.ValueChanged += new System.EventHandler(this.EntityRotationQuatBox_ValueChanged);
//
// EntityEditArchetypeButton
//
this.EntityEditArchetypeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
@ -185,7 +193,7 @@
"8 - Unk04",
"16 - Unk05",
"32 - Static entity",
"64 - Object isn't dark at night",
"64 - Object isn\'t dark at night",
"128 - Unk08",
"256 - Unk09",
"512 - Disable embedded light source",
@ -498,17 +506,6 @@
this.EntityPositionTextBox.TabIndex = 2;
this.EntityPositionTextBox.TextChanged += new System.EventHandler(this.EntityPositionTextBox_TextChanged);
//
// EntityNormalizeRotationButton
//
this.EntityNormalizeRotationButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.EntityNormalizeRotationButton.Location = new System.Drawing.Point(481, 33);
this.EntityNormalizeRotationButton.Name = "EntityNormalizeRotationButton";
this.EntityNormalizeRotationButton.Size = new System.Drawing.Size(68, 23);
this.EntityNormalizeRotationButton.TabIndex = 6;
this.EntityNormalizeRotationButton.Text = "Normalize";
this.EntityNormalizeRotationButton.UseVisualStyleBackColor = true;
this.EntityNormalizeRotationButton.Click += new System.EventHandler(this.EntityNormalizeRotationButton_Click);
//
// EntityGoToButton
//
this.EntityGoToButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
@ -529,16 +526,6 @@
this.label17.TabIndex = 4;
this.label17.Text = "Rotation:";
//
// EntityRotationTextBox
//
this.EntityRotationTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.EntityRotationTextBox.Location = new System.Drawing.Point(93, 35);
this.EntityRotationTextBox.Name = "EntityRotationTextBox";
this.EntityRotationTextBox.Size = new System.Drawing.Size(382, 20);
this.EntityRotationTextBox.TabIndex = 5;
this.EntityRotationTextBox.TextChanged += new System.EventHandler(this.EntityRotationTextBox_TextChanged);
//
// EntityLodTabPage
//
this.EntityLodTabPage.Controls.Add(this.label20);
@ -612,13 +599,12 @@
//
// EntityPivotTabPage
//
this.EntityPivotTabPage.Controls.Add(this.EntityPivotRotationQuatBox);
this.EntityPivotTabPage.Controls.Add(this.label95);
this.EntityPivotTabPage.Controls.Add(this.EntityPivotEditCheckBox);
this.EntityPivotTabPage.Controls.Add(this.label93);
this.EntityPivotTabPage.Controls.Add(this.EntityPivotPositionTextBox);
this.EntityPivotTabPage.Controls.Add(this.EntityPivotRotationNormalizeButton);
this.EntityPivotTabPage.Controls.Add(this.label94);
this.EntityPivotTabPage.Controls.Add(this.EntityPivotRotationTextBox);
this.EntityPivotTabPage.Location = new System.Drawing.Point(4, 22);
this.EntityPivotTabPage.Name = "EntityPivotTabPage";
this.EntityPivotTabPage.Size = new System.Drawing.Size(555, 476);
@ -626,6 +612,17 @@
this.EntityPivotTabPage.Text = "Pivot";
this.EntityPivotTabPage.UseVisualStyleBackColor = true;
//
// EntityPivotRotationQuatBox
//
this.EntityPivotRotationQuatBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.EntityPivotRotationQuatBox.Location = new System.Drawing.Point(93, 94);
this.EntityPivotRotationQuatBox.Margin = new System.Windows.Forms.Padding(0);
this.EntityPivotRotationQuatBox.Name = "EntityPivotRotationQuatBox";
this.EntityPivotRotationQuatBox.Size = new System.Drawing.Size(456, 24);
this.EntityPivotRotationQuatBox.TabIndex = 25;
this.EntityPivotRotationQuatBox.ValueChanged += new System.EventHandler(this.EntityPivotRotationQuatBox_ValueChanged);
//
// label95
//
this.label95.Location = new System.Drawing.Point(90, 152);
@ -665,17 +662,6 @@
this.EntityPivotPositionTextBox.TabIndex = 22;
this.EntityPivotPositionTextBox.TextChanged += new System.EventHandler(this.EntityPivotPositionTextBox_TextChanged);
//
// EntityPivotRotationNormalizeButton
//
this.EntityPivotRotationNormalizeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.EntityPivotRotationNormalizeButton.Location = new System.Drawing.Point(481, 94);
this.EntityPivotRotationNormalizeButton.Name = "EntityPivotRotationNormalizeButton";
this.EntityPivotRotationNormalizeButton.Size = new System.Drawing.Size(68, 23);
this.EntityPivotRotationNormalizeButton.TabIndex = 26;
this.EntityPivotRotationNormalizeButton.Text = "Normalize";
this.EntityPivotRotationNormalizeButton.UseVisualStyleBackColor = true;
this.EntityPivotRotationNormalizeButton.Click += new System.EventHandler(this.EntityPivotRotationNormalizeButton_Click);
//
// label94
//
this.label94.AutoSize = true;
@ -685,16 +671,6 @@
this.label94.TabIndex = 24;
this.label94.Text = "Rotation:";
//
// EntityPivotRotationTextBox
//
this.EntityPivotRotationTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.EntityPivotRotationTextBox.Location = new System.Drawing.Point(93, 96);
this.EntityPivotRotationTextBox.Name = "EntityPivotRotationTextBox";
this.EntityPivotRotationTextBox.Size = new System.Drawing.Size(382, 20);
this.EntityPivotRotationTextBox.TabIndex = 25;
this.EntityPivotRotationTextBox.TextChanged += new System.EventHandler(this.EntityPivotRotationTextBox_TextChanged);
//
// EntityMiloTabPage
//
this.EntityMiloTabPage.Controls.Add(this.MiloFlagsTextBox);
@ -862,10 +838,8 @@
private System.Windows.Forms.TextBox EntityArchetypeTextBox;
private System.Windows.Forms.Label label16;
private System.Windows.Forms.TextBox EntityPositionTextBox;
private System.Windows.Forms.Button EntityNormalizeRotationButton;
private System.Windows.Forms.Button EntityGoToButton;
private System.Windows.Forms.Label label17;
private System.Windows.Forms.TextBox EntityRotationTextBox;
private System.Windows.Forms.TabPage EntityLodTabPage;
private System.Windows.Forms.Label label20;
private System.Windows.Forms.TextBox EntityParentIndexTextBox;
@ -877,9 +851,7 @@
private System.Windows.Forms.CheckBox EntityPivotEditCheckBox;
private System.Windows.Forms.Label label93;
private System.Windows.Forms.TextBox EntityPivotPositionTextBox;
private System.Windows.Forms.Button EntityPivotRotationNormalizeButton;
private System.Windows.Forms.Label label94;
private System.Windows.Forms.TextBox EntityPivotRotationTextBox;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TabPage EntityMiloTabPage;
private System.Windows.Forms.CheckedListBox MiloEntitySetsListBox;
@ -893,5 +865,7 @@
private System.Windows.Forms.TextBox MiloFlagsTextBox;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Button EntityEditArchetypeButton;
private WinForms.QuaternionBox EntityRotationQuatBox;
private WinForms.QuaternionBox EntityPivotRotationQuatBox;
}
}

View File

@ -67,7 +67,7 @@ namespace CodeWalker.Project.Panels
EntityFlagsTextBox.Text = string.Empty;
EntityGuidTextBox.Text = string.Empty;
EntityPositionTextBox.Text = string.Empty;
EntityRotationTextBox.Text = string.Empty;
EntityRotationQuatBox.Value = Quaternion.Identity;
EntityScaleXYTextBox.Text = string.Empty;
EntityScaleZTextBox.Text = string.Empty;
EntityParentIndexTextBox.Text = string.Empty;
@ -81,7 +81,7 @@ namespace CodeWalker.Project.Panels
EntityTintValueTextBox.Text = string.Empty;
EntityPivotEditCheckBox.Checked = false;
EntityPivotPositionTextBox.Text = string.Empty;
EntityPivotRotationTextBox.Text = string.Empty;
EntityPivotRotationQuatBox.Value = Quaternion.Identity;
foreach (int i in EntityFlagsCheckedListBox.CheckedIndices)
{
EntityFlagsCheckedListBox.SetItemCheckState(i, CheckState.Unchecked);
@ -100,7 +100,7 @@ namespace CodeWalker.Project.Panels
EntityFlagsTextBox.Text = e.flags.ToString();
EntityGuidTextBox.Text = e.guid.ToString();
EntityPositionTextBox.Text = FloatUtil.GetVector3String(e.position);
EntityRotationTextBox.Text = FloatUtil.GetVector4String(e.rotation);
EntityRotationQuatBox.Value = new Quaternion(e.rotation);
EntityScaleXYTextBox.Text = FloatUtil.ToString(e.scaleXY);
EntityScaleZTextBox.Text = FloatUtil.ToString(e.scaleZ);
EntityParentIndexTextBox.Text = e.parentIndex.ToString();
@ -113,7 +113,7 @@ namespace CodeWalker.Project.Panels
EntityArtificialAOTextBox.Text = e.artificialAmbientOcclusion.ToString();
EntityTintValueTextBox.Text = e.tintValue.ToString();
EntityPivotPositionTextBox.Text = FloatUtil.GetVector3String(CurrentEntity.PivotPosition);
EntityPivotRotationTextBox.Text = FloatUtil.GetVector4String(new Vector4(po.X, po.Y, po.Z, po.W));
EntityPivotRotationQuatBox.Value = po;
for (int i = 0; i < EntityFlagsCheckedListBox.Items.Count; i++)
{
var cv = ((e.flags & (1u << i)) > 0);
@ -394,16 +394,16 @@ namespace CodeWalker.Project.Panels
}
}
private void EntityRotationTextBox_TextChanged(object sender, EventArgs e)
private void EntityRotationQuatBox_ValueChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentEntity == null) return;
Vector4 v = FloatUtil.ParseVector4String(EntityRotationTextBox.Text);
Quaternion q = EntityRotationQuatBox.Value;
Vector4 v = q.ToVector4();
lock (ProjectForm.ProjectSyncRoot)
{
if (CurrentEntity._CEntityDef.rotation != v)
{
Quaternion q = v.ToQuaternion();
var wf = ProjectForm.WorldForm;
if (CurrentEntity.MloParent != null)
@ -643,13 +643,6 @@ namespace CodeWalker.Project.Panels
ProjectForm.WorldForm.GoToPosition(CurrentEntity.Position, Vector3.One * CurrentEntity.BSRadius);
}
private void EntityNormalizeRotationButton_Click(object sender, EventArgs e)
{
Vector4 v = FloatUtil.ParseVector4String(EntityRotationTextBox.Text);
Quaternion q = Quaternion.Normalize(new Quaternion(v));
EntityRotationTextBox.Text = FloatUtil.GetVector4String(new Vector4(q.X, q.Y, q.Z, q.W));
}
private void EntityAddToProjectButton_Click(object sender, EventArgs e)
{
ProjectForm.SetProjectItem(CurrentEntity);
@ -696,12 +689,11 @@ namespace CodeWalker.Project.Panels
}
}
private void EntityPivotRotationTextBox_TextChanged(object sender, EventArgs e)
private void EntityPivotRotationQuatBox_ValueChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentEntity == null) return;
Vector4 v = FloatUtil.ParseVector4String(EntityPivotRotationTextBox.Text);
Quaternion q = new Quaternion(v);
Quaternion q = EntityPivotRotationQuatBox.Value;
lock (ProjectForm.ProjectSyncRoot)
{
if (CurrentEntity.PivotOrientation != q)
@ -721,13 +713,7 @@ namespace CodeWalker.Project.Panels
}
}
}
}
private void EntityPivotRotationNormalizeButton_Click(object sender, EventArgs e)
{
Vector4 v = FloatUtil.ParseVector4String(EntityPivotRotationTextBox.Text);
Quaternion q = Quaternion.Normalize(new Quaternion(v));
EntityPivotRotationTextBox.Text = FloatUtil.GetVector4String(new Vector4(q.X, q.Y, q.Z, q.W));
}
private void MiloGroupIDTextBox_TextChanged(object sender, EventArgs e)