Animations XML conversion

This commit is contained in:
dexy
2019-11-14 18:58:20 +11:00
Unverified
parent 918ed7fccf
commit 7e43271a67
15 changed files with 2996 additions and 737 deletions
+48 -38
View File
@@ -79,6 +79,8 @@ namespace CodeWalker.Rendering
public Matrix3_s[] BoneTransforms;
public List<Bone> Bones;
public bool EnableRootMotion = false; //used to toggle whether or not to include root motion when playing animations
public override void Init(DrawableBase drawable)
{
@@ -385,39 +387,39 @@ namespace CodeWalker.Rendering
BoneTransforms[i] = bt;
}
//var drawbl = Key;
//if (AllModels == null) return;
//for (int i = 0; i < AllModels.Length; i++)
//{
// var model = AllModels[i];
// if (model?.Geometries == null) continue;
// for (int g = 0; g < model.Geometries.Length; g++)
// {
// var geom = model.Geometries[g];
// var boneids = geom?.DrawableGeom?.BoneIds;
// if (boneids == null) continue;
// if (boneids.Length != Bones.Count)
// {
// var idc = boneids.Length;
// if (geom.BoneTransforms == null)
// {
// geom.BoneTransforms = new Matrix3_s[idc];
// }
// for (int b = 0; b < idc; b++)
// {
// var id = boneids[b];
// if (id < BoneTransforms.Length)
// {
// geom.BoneTransforms[b] = BoneTransforms[id];
// if (id != b)
// { }
// }
// else
// { }
// }
// }
// }
//}
var drawbl = Key;
if (AllModels == null) return;
for (int i = 0; i < AllModels.Length; i++)
{
var model = AllModels[i];
if (model?.Geometries == null) continue;
for (int g = 0; g < model.Geometries.Length; g++)
{
var geom = model.Geometries[g];
var boneids = geom?.DrawableGeom?.BoneIds;
if (boneids == null) continue;
if (boneids.Length != Bones.Count)
{
var idc = boneids.Length;
if (geom.BoneTransforms == null)
{
geom.BoneTransforms = new Matrix3_s[idc];
}
for (int b = 0; b < idc; b++)
{
var id = boneids[b];
if (id < BoneTransforms.Length)
{
geom.BoneTransforms[b] = BoneTransforms[id];
if (id != b)
{ }
}
else
{ }
}
}
}
}
}
@@ -428,6 +430,8 @@ namespace CodeWalker.Rendering
if (CurrentAnimTime == realTime) return;//already updated this!
CurrentAnimTime = realTime;
EnableRootMotion = ClipMapEntry?.EnableRootMotion ?? false;
if (ClipMapEntry != null)
{
UpdateAnim(ClipMapEntry); //animate skeleton/models
@@ -451,6 +455,7 @@ namespace CodeWalker.Rendering
}
private void UpdateAnim(ClipMapEntry cme)
{
if (cme.Next != null)
{
UpdateAnim(cme.Next);
@@ -545,10 +550,13 @@ namespace CodeWalker.Rendering
case 5://root motion vector
if (bone.Tag != 0)
{ }
//v0 = aseq.EvaluateVector(f0);
//v1 = aseq.EvaluateVector(f1);
//v = interpolate ? (v0 * ialpha) + (v1 * falpha) : v0;
//bone.AnimTranslation += v.XYZ();
if (EnableRootMotion)
{
v0 = aseq.EvaluateVector(f0);
v1 = aseq.EvaluateVector(f1);
v = interpolate ? (v0 * ialpha) + (v1 * falpha) : v0;
bone.AnimTranslation += v.XYZ();
}
break;
case 6://quaternion... root rotation?
if (bone.Tag != 0)
@@ -574,6 +582,8 @@ namespace CodeWalker.Rendering
{ }
break;
default:
if (bone.Tag != 0)
{ }
break;
}
}
@@ -832,7 +842,7 @@ namespace CodeWalker.Rendering
public bool isHair = false;
public bool disableRendering = false;
//public Matrix3_s[] BoneTransforms = null;
public Matrix3_s[] BoneTransforms = null;
public static ShaderParamNames[] GetTextureSamplerList()
{
+5 -5
View File
@@ -801,11 +801,11 @@ namespace CodeWalker.Rendering
}
//if (geom.BoneTransforms != null)
//{
// SetBoneMatrices(context, geom.BoneTransforms);
// defaultBoneMatricesBound = false;
//}
if (geom.BoneTransforms != null)
{
SetBoneMatrices(context, geom.BoneTransforms);
defaultBoneMatricesBound = false;
}
}
+5 -5
View File
@@ -358,11 +358,11 @@ namespace CodeWalker.Rendering
}
//if (geom.BoneTransforms != null)
//{
// SetBoneMatrices(context, geom.BoneTransforms);
// defaultBoneMatricesBound = false;
//}
if (geom.BoneTransforms != null)
{
SetBoneMatrices(context, geom.BoneTransforms);
defaultBoneMatricesBound = false;
}
}