Add FixRotation option

This commit is contained in:
Perfare 2018-04-18 10:36:57 +08:00
parent 5354506315
commit ffda15a1a5
8 changed files with 97 additions and 44 deletions

View File

@ -61,6 +61,7 @@
this.allBones = new System.Windows.Forms.CheckBox(); this.allBones = new System.Windows.Forms.CheckBox();
this.allFrames = new System.Windows.Forms.CheckBox(); this.allFrames = new System.Windows.Forms.CheckBox();
this.EulerFilter = new System.Windows.Forms.CheckBox(); this.EulerFilter = new System.Windows.Forms.CheckBox();
this.FixRotation = new System.Windows.Forms.CheckBox();
this.FbxBox.SuspendLayout(); this.FbxBox.SuspendLayout();
this.geometryBox.SuspendLayout(); this.geometryBox.SuspendLayout();
this.advancedBox.SuspendLayout(); this.advancedBox.SuspendLayout();
@ -235,7 +236,7 @@
// //
// fbxOKbutton // fbxOKbutton
// //
this.fbxOKbutton.Location = new System.Drawing.Point(325, 335); this.fbxOKbutton.Location = new System.Drawing.Point(325, 354);
this.fbxOKbutton.Name = "fbxOKbutton"; this.fbxOKbutton.Name = "fbxOKbutton";
this.fbxOKbutton.Size = new System.Drawing.Size(75, 21); this.fbxOKbutton.Size = new System.Drawing.Size(75, 21);
this.fbxOKbutton.TabIndex = 6; this.fbxOKbutton.TabIndex = 6;
@ -246,7 +247,7 @@
// fbxCancel // fbxCancel
// //
this.fbxCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.fbxCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.fbxCancel.Location = new System.Drawing.Point(406, 335); this.fbxCancel.Location = new System.Drawing.Point(406, 354);
this.fbxCancel.Name = "fbxCancel"; this.fbxCancel.Name = "fbxCancel";
this.fbxCancel.Size = new System.Drawing.Size(75, 21); this.fbxCancel.Size = new System.Drawing.Size(75, 21);
this.fbxCancel.TabIndex = 7; this.fbxCancel.TabIndex = 7;
@ -334,6 +335,7 @@
// //
// groupBox2 // groupBox2
// //
this.groupBox2.Controls.Add(this.FixRotation);
this.groupBox2.Controls.Add(this.compatibility); this.groupBox2.Controls.Add(this.compatibility);
this.groupBox2.Controls.Add(this.flatInbetween); this.groupBox2.Controls.Add(this.flatInbetween);
this.groupBox2.Controls.Add(this.boneSize); this.groupBox2.Controls.Add(this.boneSize);
@ -346,7 +348,7 @@
this.groupBox2.Controls.Add(this.EulerFilter); this.groupBox2.Controls.Add(this.EulerFilter);
this.groupBox2.Location = new System.Drawing.Point(267, 124); this.groupBox2.Location = new System.Drawing.Point(267, 124);
this.groupBox2.Name = "groupBox2"; this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(214, 205); this.groupBox2.Size = new System.Drawing.Size(214, 224);
this.groupBox2.TabIndex = 11; this.groupBox2.TabIndex = 11;
this.groupBox2.TabStop = false; this.groupBox2.TabStop = false;
this.groupBox2.Text = "Fbx Binary"; this.groupBox2.Text = "Fbx Binary";
@ -354,7 +356,7 @@
// compatibility // compatibility
// //
this.compatibility.AutoSize = true; this.compatibility.AutoSize = true;
this.compatibility.Location = new System.Drawing.Point(6, 177); this.compatibility.Location = new System.Drawing.Point(6, 199);
this.compatibility.Name = "compatibility"; this.compatibility.Name = "compatibility";
this.compatibility.Size = new System.Drawing.Size(102, 16); this.compatibility.Size = new System.Drawing.Size(102, 16);
this.compatibility.TabIndex = 13; this.compatibility.TabIndex = 13;
@ -364,7 +366,7 @@
// flatInbetween // flatInbetween
// //
this.flatInbetween.AutoSize = true; this.flatInbetween.AutoSize = true;
this.flatInbetween.Location = new System.Drawing.Point(6, 155); this.flatInbetween.Location = new System.Drawing.Point(6, 177);
this.flatInbetween.Name = "flatInbetween"; this.flatInbetween.Name = "flatInbetween";
this.flatInbetween.Size = new System.Drawing.Size(102, 16); this.flatInbetween.Size = new System.Drawing.Size(102, 16);
this.flatInbetween.TabIndex = 12; this.flatInbetween.TabIndex = 12;
@ -373,7 +375,7 @@
// //
// boneSize // boneSize
// //
this.boneSize.Location = new System.Drawing.Point(65, 128); this.boneSize.Location = new System.Drawing.Point(65, 150);
this.boneSize.Name = "boneSize"; this.boneSize.Name = "boneSize";
this.boneSize.Size = new System.Drawing.Size(46, 21); this.boneSize.Size = new System.Drawing.Size(46, 21);
this.boneSize.TabIndex = 11; this.boneSize.TabIndex = 11;
@ -386,7 +388,7 @@
// label2 // label2
// //
this.label2.AutoSize = true; this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(6, 130); this.label2.Location = new System.Drawing.Point(6, 152);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(53, 12); this.label2.Size = new System.Drawing.Size(53, 12);
this.label2.TabIndex = 10; this.label2.TabIndex = 10;
@ -397,7 +399,7 @@
this.skins.AutoSize = true; this.skins.AutoSize = true;
this.skins.Checked = true; this.skins.Checked = true;
this.skins.CheckState = System.Windows.Forms.CheckState.Checked; this.skins.CheckState = System.Windows.Forms.CheckState.Checked;
this.skins.Location = new System.Drawing.Point(6, 105); this.skins.Location = new System.Drawing.Point(6, 127);
this.skins.Name = "skins"; this.skins.Name = "skins";
this.skins.Size = new System.Drawing.Size(54, 16); this.skins.Size = new System.Drawing.Size(54, 16);
this.skins.TabIndex = 8; this.skins.TabIndex = 8;
@ -407,7 +409,7 @@
// label1 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(26, 39); this.label1.Location = new System.Drawing.Point(26, 61);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(95, 12); this.label1.Size = new System.Drawing.Size(95, 12);
this.label1.TabIndex = 7; this.label1.TabIndex = 7;
@ -421,7 +423,7 @@
0, 0,
0, 0,
131072}); 131072});
this.filterPrecision.Location = new System.Drawing.Point(127, 37); this.filterPrecision.Location = new System.Drawing.Point(127, 59);
this.filterPrecision.Name = "filterPrecision"; this.filterPrecision.Name = "filterPrecision";
this.filterPrecision.Size = new System.Drawing.Size(51, 21); this.filterPrecision.Size = new System.Drawing.Size(51, 21);
this.filterPrecision.TabIndex = 6; this.filterPrecision.TabIndex = 6;
@ -436,7 +438,7 @@
this.allBones.AutoSize = true; this.allBones.AutoSize = true;
this.allBones.Checked = true; this.allBones.Checked = true;
this.allBones.CheckState = System.Windows.Forms.CheckState.Checked; this.allBones.CheckState = System.Windows.Forms.CheckState.Checked;
this.allBones.Location = new System.Drawing.Point(6, 83); this.allBones.Location = new System.Drawing.Point(6, 105);
this.allBones.Name = "allBones"; this.allBones.Name = "allBones";
this.allBones.Size = new System.Drawing.Size(72, 16); this.allBones.Size = new System.Drawing.Size(72, 16);
this.allBones.TabIndex = 5; this.allBones.TabIndex = 5;
@ -446,7 +448,7 @@
// allFrames // allFrames
// //
this.allFrames.AutoSize = true; this.allFrames.AutoSize = true;
this.allFrames.Location = new System.Drawing.Point(6, 61); this.allFrames.Location = new System.Drawing.Point(6, 83);
this.allFrames.Name = "allFrames"; this.allFrames.Name = "allFrames";
this.allFrames.Size = new System.Drawing.Size(78, 16); this.allFrames.Size = new System.Drawing.Size(78, 16);
this.allFrames.TabIndex = 4; this.allFrames.TabIndex = 4;
@ -456,20 +458,32 @@
// EulerFilter // EulerFilter
// //
this.EulerFilter.AutoSize = true; this.EulerFilter.AutoSize = true;
this.EulerFilter.Location = new System.Drawing.Point(6, 20); this.EulerFilter.Location = new System.Drawing.Point(6, 42);
this.EulerFilter.Name = "EulerFilter"; this.EulerFilter.Name = "EulerFilter";
this.EulerFilter.Size = new System.Drawing.Size(90, 16); this.EulerFilter.Size = new System.Drawing.Size(90, 16);
this.EulerFilter.TabIndex = 3; this.EulerFilter.TabIndex = 3;
this.EulerFilter.Text = "EulerFilter"; this.EulerFilter.Text = "EulerFilter";
this.EulerFilter.UseVisualStyleBackColor = true; this.EulerFilter.UseVisualStyleBackColor = true;
// //
// FixRotation
//
this.FixRotation.AutoSize = true;
this.FixRotation.Checked = true;
this.FixRotation.CheckState = System.Windows.Forms.CheckState.Checked;
this.FixRotation.Location = new System.Drawing.Point(6, 20);
this.FixRotation.Name = "FixRotation";
this.FixRotation.Size = new System.Drawing.Size(90, 16);
this.FixRotation.TabIndex = 14;
this.FixRotation.Text = "FixRotation";
this.FixRotation.UseVisualStyleBackColor = true;
//
// ExportOptions // ExportOptions
// //
this.AcceptButton = this.fbxOKbutton; this.AcceptButton = this.fbxOKbutton;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.fbxCancel; this.CancelButton = this.fbxCancel;
this.ClientSize = new System.Drawing.Size(495, 369); this.ClientSize = new System.Drawing.Size(495, 384);
this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1); this.Controls.Add(this.groupBox1);
this.Controls.Add(this.fbxCancel); this.Controls.Add(this.fbxCancel);
@ -538,5 +552,6 @@
private System.Windows.Forms.CheckBox allBones; private System.Windows.Forms.CheckBox allBones;
private System.Windows.Forms.CheckBox allFrames; private System.Windows.Forms.CheckBox allFrames;
private System.Windows.Forms.CheckBox EulerFilter; private System.Windows.Forms.CheckBox EulerFilter;
private System.Windows.Forms.CheckBox FixRotation;
} }
} }

View File

@ -35,6 +35,7 @@ namespace AssetStudio
break; break;
} }
} }
FixRotation.Checked = (bool)Properties.Settings.Default["FixRotation"];
EulerFilter.Checked = (bool)Properties.Settings.Default["EulerFilter"]; EulerFilter.Checked = (bool)Properties.Settings.Default["EulerFilter"];
filterPrecision.Value = (decimal)Properties.Settings.Default["filterPrecision"]; filterPrecision.Value = (decimal)Properties.Settings.Default["filterPrecision"];
allFrames.Checked = (bool)Properties.Settings.Default["allFrames"]; allFrames.Checked = (bool)Properties.Settings.Default["allFrames"];
@ -70,6 +71,7 @@ namespace AssetStudio
break; break;
} }
} }
Properties.Settings.Default["FixRotation"] = FixRotation.Checked;
Properties.Settings.Default["EulerFilter"] = EulerFilter.Checked; Properties.Settings.Default["EulerFilter"] = EulerFilter.Checked;
Properties.Settings.Default["filterPrecision"] = filterPrecision.Value; Properties.Settings.Default["filterPrecision"] = filterPrecision.Value;
Properties.Settings.Default["allFrames"] = allFrames.Checked; Properties.Settings.Default["allFrames"] = allFrames.Checked;

View File

@ -322,5 +322,17 @@ namespace AssetStudio.Properties {
this["compatibility"] = value; this["compatibility"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool FixRotation {
get {
return ((bool)(this["FixRotation"]));
}
set {
this["FixRotation"] = value;
}
}
} }
} }

View File

@ -77,5 +77,8 @@
<Setting Name="compatibility" Type="System.Boolean" Scope="User"> <Setting Name="compatibility" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value> <Value Profile="(Default)">False</Value>
</Setting> </Setting>
<Setting Name="FixRotation" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@ -583,21 +583,12 @@ namespace AssetStudio
track.Name = boneName; track.Name = boneName;
iAnim.TrackList.Add(track); iAnim.TrackList.Add(track);
} }
Vector3 prevKey = new Vector3();
foreach (var m_Curve in m_RotationCurve.curve.m_Curve) foreach (var m_Curve in m_RotationCurve.curve.m_Curve)
{ {
var value = Fbx.QuaternionToEuler(new Quaternion(m_Curve.value.X, -m_Curve.value.Y, -m_Curve.value.Z, m_Curve.value.W)); var value = Fbx.QuaternionToEuler(new Quaternion(m_Curve.value.X, -m_Curve.value.Y, -m_Curve.value.Z, m_Curve.value.W));
var inSlope = Fbx.QuaternionToEuler(new Quaternion(m_Curve.inSlope.X, -m_Curve.inSlope.Y, -m_Curve.inSlope.Z, m_Curve.inSlope.W)); var inSlope = Fbx.QuaternionToEuler(new Quaternion(m_Curve.inSlope.X, -m_Curve.inSlope.Y, -m_Curve.inSlope.Z, m_Curve.inSlope.W));
var outSlope = Fbx.QuaternionToEuler(new Quaternion(m_Curve.outSlope.X, -m_Curve.outSlope.Y, -m_Curve.outSlope.Z, m_Curve.outSlope.W)); var outSlope = Fbx.QuaternionToEuler(new Quaternion(m_Curve.outSlope.X, -m_Curve.outSlope.Y, -m_Curve.outSlope.Z, m_Curve.outSlope.W));
track.Rotations.Add(new ImportedKeyframe<Vector3>(m_Curve.time, value, inSlope, outSlope));
ReplaceOutOfBound(ref prevKey, ref value);
prevKey = value;
track.Rotations.Add(new ImportedKeyframe<Vector3>(
m_Curve.time,
value,
inSlope,
outSlope));
} }
} }
foreach (var m_PositionCurve in clip.m_PositionCurves) foreach (var m_PositionCurve in clip.m_PositionCurves)
@ -640,6 +631,21 @@ namespace AssetStudio
new Vector3(m_Curve.outSlope.X, m_Curve.outSlope.Y, m_Curve.outSlope.Z))); new Vector3(m_Curve.outSlope.X, m_Curve.outSlope.Y, m_Curve.outSlope.Z)));
} }
} }
if ((bool)Properties.Settings.Default["FixRotation"])
{
foreach (var track in iAnim.TrackList)
{
var prevKey = new Vector3();
foreach (var rotation in track.Rotations)
{
var value = rotation.value;
ReplaceOutOfBound(ref prevKey, ref value);
prevKey = value;
rotation.value = value;
}
}
}
} }
else else
{ {
@ -724,16 +730,16 @@ namespace AssetStudio
case 2: case 2:
if (track.Rotations == null) if (track.Rotations == null)
{ {
track.Rotations = new Quaternion?[numFrames]; track.Rotations = new Vector3?[numFrames];
} }
track.Rotations[frameIdx] = new Quaternion track.Rotations[frameIdx] = Fbx.QuaternionToEuler(new Quaternion
( (
data[curveIdx++ - dataOffset], data[curveIdx++ - dataOffset],
-data[curveIdx++ - dataOffset], -data[curveIdx++ - dataOffset],
-data[curveIdx++ - dataOffset], -data[curveIdx++ - dataOffset],
data[curveIdx++ - dataOffset] data[curveIdx++ - dataOffset]
); ));
break; break;
case 3: case 3:
if (track.Scalings == null) if (track.Scalings == null)
@ -751,17 +757,14 @@ namespace AssetStudio
case 4: case 4:
if (track.Rotations == null) if (track.Rotations == null)
{ {
track.Rotations = new Quaternion?[numFrames]; track.Rotations = new Vector3?[numFrames];
} }
track.Rotations[frameIdx] = Fbx.EulerToQuaternion track.Rotations[frameIdx] = new Vector3
(
new Vector3
( (
data[curveIdx++ - dataOffset], data[curveIdx++ - dataOffset],
-data[curveIdx++ - dataOffset], -data[curveIdx++ - dataOffset],
-data[curveIdx++ - dataOffset] -data[curveIdx++ - dataOffset]
)
); );
break; break;
default: default:
@ -782,6 +785,26 @@ namespace AssetStudio
} }
} }
} }
if ((bool)Properties.Settings.Default["FixRotation"])
{
foreach (var track in iAnim.TrackList)
{
if (track.Rotations == null)
continue;
var prevKey = new Vector3();
for (var i = 0; i < track.Rotations.Length; i++)
{
var rotation = track.Rotations[i];
if (rotation == null)
continue;
var value = new Vector3(rotation.Value.X, rotation.Value.Y, rotation.Value.Z);
ReplaceOutOfBound(ref prevKey, ref value);
prevKey = value;
track.Rotations[i] = value;
}
}
}
} }
} }
} }
@ -905,10 +928,6 @@ namespace AssetStudio
} }
double newValue = count * 360.0 + cur; double newValue = count * 360.0 + cur;
if (newValue != cur)
{
}
return (float)newValue; return (float)newValue;
} }
} }

View File

@ -82,6 +82,9 @@
<setting name="compatibility" serializeAs="String"> <setting name="compatibility" serializeAs="String">
<value>False</value> <value>False</value>
</setting> </setting>
<setting name="FixRotation" serializeAs="String">
<value>True</value>
</setting>
</AssetStudio.Properties.Settings> </AssetStudio.Properties.Settings>
</userSettings> </userSettings>
</configuration> </configuration>

View File

@ -986,10 +986,9 @@ namespace AssetStudio
lTime.SetSecondDouble(fps * k); lTime.SetSecondDouble(fps * k);
Vector3 rotation = Fbx::QuaternionToEuler(sampleList->Rotations[k].Value); lCurveRX->KeySet(lCurveRX->KeyAdd(lTime), lTime, sampleList->Rotations[k].Value.X);
lCurveRX->KeySet(lCurveRX->KeyAdd(lTime), lTime, rotation.X); lCurveRY->KeySet(lCurveRY->KeyAdd(lTime), lTime, sampleList->Rotations[k].Value.Y);
lCurveRY->KeySet(lCurveRY->KeyAdd(lTime), lTime, rotation.Y); lCurveRZ->KeySet(lCurveRZ->KeyAdd(lTime), lTime, sampleList->Rotations[k].Value.Z);
lCurveRZ->KeySet(lCurveRZ->KeyAdd(lTime), lTime, rotation.Z);
} }
lCurveRX->KeyModifyEnd(); lCurveRX->KeyModifyEnd();
lCurveRY->KeyModifyEnd(); lCurveRY->KeyModifyEnd();

View File

@ -147,7 +147,7 @@ namespace AssetStudio
public class ImportedAnimationSampledTrack : ImportedAnimationTrack public class ImportedAnimationSampledTrack : ImportedAnimationTrack
{ {
public Vector3?[] Scalings; public Vector3?[] Scalings;
public Quaternion?[] Rotations; public Vector3?[] Rotations;
public Vector3?[] Translations; public Vector3?[] Translations;
public float?[] Curve; public float?[] Curve;
} }