mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2026-05-17 06:44:49 +08:00
Animations XML conversion
This commit is contained in:
+48
-38
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user