mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-22 15:02:54 +08:00
Animations now playing sequences correctly
This commit is contained in:
parent
d60234469a
commit
87092996f8
@ -804,13 +804,6 @@ namespace CodeWalker.GameFiles
|
||||
public AnimSequence[] Sequences { get; set; }
|
||||
|
||||
|
||||
// //Original testing parsed data
|
||||
//public SequencePart1[] FrameData { get; set; }
|
||||
//public ushort[] Part2 { get; set; }
|
||||
//public int Part2Count { get; set; }
|
||||
//public int Part2Offset { get; set; }
|
||||
//public static Dictionary<ushort, int> SeqDict = new Dictionary<ushort, int>();
|
||||
|
||||
|
||||
class AnimChannelListItem
|
||||
{
|
||||
@ -845,77 +838,6 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
this.Data = reader.ReadBytes((int)DataLength);
|
||||
|
||||
#region //old dexyfex testing code
|
||||
/*
|
||||
if (Unused_08h != 0)
|
||||
{ }
|
||||
if (Unused_14h != 0)
|
||||
{ }
|
||||
if (UnkLength != (DataLength + 32)) //sometimes this is true
|
||||
{ }
|
||||
if ((FrameLength % 4) > 0)
|
||||
{ }
|
||||
int offset = (int)FrameOffset;
|
||||
if (FrameLength > 0)
|
||||
{
|
||||
FrameData = new SequencePart1[NumFrames];
|
||||
for (int i = 0; i < NumFrames; i++)
|
||||
{
|
||||
var sp = new SequencePart1();
|
||||
sp.Init(Data, offset, FrameLength);
|
||||
FrameData[i] = sp;
|
||||
offset += FrameLength;
|
||||
}
|
||||
}
|
||||
else if (NumFrames != 0)
|
||||
{ }
|
||||
int brem = (int)DataLength - offset;
|
||||
int p2cnt = brem / 2;
|
||||
if (p2cnt > 0)
|
||||
{
|
||||
Part2Offset = offset;
|
||||
Part2Count = p2cnt;
|
||||
Part2 = new ushort[p2cnt];
|
||||
for (int i = 0; i < p2cnt; i++)
|
||||
{
|
||||
Part2[i] = BitConverter.ToUInt16(Data, offset);
|
||||
offset += 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ }
|
||||
if (offset != DataLength)
|
||||
{ } //no hits here!
|
||||
//if (SeqDict.ContainsKey(Unknown_1Ah)) SeqDict[Unknown_1Ah]++;
|
||||
//else SeqDict[Unknown_1Ah] = 1;
|
||||
if ((Unknown_1Ah != 0) && (Unknown_1Ah > FrameOffset))
|
||||
{ }
|
||||
if ((Unknown_1Ch != 0) && (Unknown_1Ch > FrameOffset))
|
||||
{ }
|
||||
switch (ChunkSize)
|
||||
{
|
||||
case 64: //0x40
|
||||
case 255: //0xFF
|
||||
break;
|
||||
default://no hits
|
||||
break;
|
||||
}
|
||||
switch (Unknown_1Fh_Type)
|
||||
{
|
||||
case 0:
|
||||
case 17: //0x11
|
||||
case 20: //0x14
|
||||
case 21: //0x15
|
||||
case 49: //0x31
|
||||
case 52: //0x34
|
||||
case 53: //0x35
|
||||
break;
|
||||
default: //no hits
|
||||
break;
|
||||
}
|
||||
*/
|
||||
#endregion
|
||||
|
||||
|
||||
int Part2Offset = 0;//replacement calculation from old dexyfex parsing code
|
||||
int offset = (int)FrameOffset + (FrameLength * NumFrames);
|
||||
|
@ -430,11 +430,9 @@ namespace CodeWalker.Rendering
|
||||
var clipanimlist = cme.Clip as ClipAnimationList;
|
||||
if (clipanimlist?.Animations != null)
|
||||
{
|
||||
//float t = clipanimlist.GetPlaybackTime(CurrentAnimTime);
|
||||
foreach (var canim in clipanimlist.Animations)
|
||||
{
|
||||
if (canim?.Animation == null) continue;
|
||||
//UpdateAnim(canim.Animation, t*canim.Rate + canim.StartTime);
|
||||
UpdateAnim(canim.Animation, canim.GetPlaybackTime(CurrentAnimTime));
|
||||
}
|
||||
}
|
||||
@ -458,7 +456,7 @@ namespace CodeWalker.Rendering
|
||||
|
||||
var curPos = (t/duration) * nframes;
|
||||
var frame0 = ((ushort)curPos) % frames;
|
||||
var frame1 = (frame0 + 1) % frames;
|
||||
var frame1 = (frame0 + 1);// % frames;
|
||||
var falpha = (float)(curPos - Math.Floor(curPos));
|
||||
var ialpha = 1.0f - falpha;
|
||||
|
||||
@ -482,45 +480,46 @@ namespace CodeWalker.Rendering
|
||||
if (bone == null)
|
||||
{ continue; }
|
||||
|
||||
var sfl = anim.SequenceFrameLimit;
|
||||
var s = frame0 / sfl;
|
||||
int f0 = frame0 % sfl;
|
||||
int f1 = f0 + 1;
|
||||
|
||||
for (int s = 0; s < anim.Sequences.data_items.Length; s++)
|
||||
var seq = anim.Sequences.data_items[s];
|
||||
var aseq = seq.Sequences[i];
|
||||
switch (track)
|
||||
{
|
||||
var seq = anim.Sequences.data_items[s];
|
||||
var aseq = seq.Sequences[i];
|
||||
switch (track)
|
||||
{
|
||||
case 0: //bone position
|
||||
v0 = aseq.EvaluateVector(frame0);
|
||||
v1 = aseq.EvaluateVector(frame1);
|
||||
v = interpolate ? (v0 * ialpha) + (v1 * falpha) : v0;
|
||||
bone.AnimTranslation = v.XYZ();
|
||||
break;
|
||||
case 1: //bone orientation
|
||||
q0 = new Quaternion(aseq.EvaluateVector(frame0));
|
||||
q1 = new Quaternion(aseq.EvaluateVector(frame1));
|
||||
q = interpolate ? Quaternion.Slerp(q0, q1, falpha) : q0;
|
||||
bone.AnimRotation = q;
|
||||
break;
|
||||
case 2: //scale?
|
||||
break;
|
||||
case 5://vector3...
|
||||
//v0 = aseq.EvaluateVector(frame0);
|
||||
//v1 = aseq.EvaluateVector(frame1);
|
||||
//v = interpolate ? (v0 * ialpha) + (v1 * falpha) : v0;
|
||||
//bone.AnimScale = v.XYZ();
|
||||
break;
|
||||
case 6://quaternion...
|
||||
break;
|
||||
case 134://single float?
|
||||
case 136:
|
||||
case 137:
|
||||
case 138:
|
||||
case 139:
|
||||
case 140:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
case 0: //bone position
|
||||
v0 = aseq.EvaluateVector(f0);
|
||||
v1 = aseq.EvaluateVector(f1);
|
||||
v = interpolate ? (v0 * ialpha) + (v1 * falpha) : v0;
|
||||
bone.AnimTranslation = v.XYZ();
|
||||
break;
|
||||
case 1: //bone orientation
|
||||
q0 = new Quaternion(aseq.EvaluateVector(f0));
|
||||
q1 = new Quaternion(aseq.EvaluateVector(f1));
|
||||
q = interpolate ? Quaternion.Slerp(q0, q1, falpha) : q0;
|
||||
bone.AnimRotation = q;
|
||||
break;
|
||||
case 2: //scale?
|
||||
break;
|
||||
case 5://vector3...
|
||||
//v0 = aseq.EvaluateVector(f0);
|
||||
//v1 = aseq.EvaluateVector(f1);
|
||||
//v = interpolate ? (v0 * ialpha) + (v1 * falpha) : v0;
|
||||
//bone.AnimScale = v.XYZ();
|
||||
break;
|
||||
case 6://quaternion...
|
||||
break;
|
||||
case 134://single float?
|
||||
case 136:
|
||||
case 137:
|
||||
case 138:
|
||||
case 139:
|
||||
case 140:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -562,11 +561,9 @@ namespace CodeWalker.Rendering
|
||||
var clipanimlist = cme.Clip as ClipAnimationList;
|
||||
if (clipanimlist?.Animations != null)
|
||||
{
|
||||
//float t = clipanimlist.GetPlaybackTime(CurrentAnimTime);
|
||||
foreach (var canim in clipanimlist.Animations)
|
||||
{
|
||||
if (canim?.Animation == null) continue;
|
||||
//UpdateAnimUV(canim.Animation, t * canim.Rate + canim.StartTime, rgeom);
|
||||
UpdateAnimUV(canim.Animation, canim.GetPlaybackTime(CurrentAnimTime), rgeom);
|
||||
}
|
||||
}
|
||||
@ -590,7 +587,7 @@ namespace CodeWalker.Rendering
|
||||
|
||||
var curPos = (t / duration) * nframes;
|
||||
var frame0 = ((ushort)curPos) % frames;
|
||||
var frame1 = (frame0 + 1) % frames;
|
||||
var frame1 = (frame0 + 1);// % frames;
|
||||
var falpha = (float)(curPos - Math.Floor(curPos));
|
||||
var ialpha = 1.0f - falpha;
|
||||
|
||||
@ -605,18 +602,20 @@ namespace CodeWalker.Rendering
|
||||
if ((track != 17) && (track != 18))
|
||||
{ continue; }//17 and 18 would be UV0 and UV1
|
||||
|
||||
for (int s = 0; s < anim.Sequences.data_items.Length; s++)
|
||||
var sfl = anim.SequenceFrameLimit;
|
||||
var s = frame0 / sfl;
|
||||
int f0 = frame0 % sfl;
|
||||
int f1 = f0 + 1;
|
||||
|
||||
var seq = anim.Sequences.data_items[s];
|
||||
var aseq = seq.Sequences[i];
|
||||
var v0 = aseq.EvaluateVector(f0);
|
||||
var v1 = aseq.EvaluateVector(f1);
|
||||
var v = interpolate ? (v0 * ialpha) + (v1 * falpha) : v0;
|
||||
switch (track)
|
||||
{
|
||||
var seq = anim.Sequences.data_items[s];
|
||||
var aseq = seq.Sequences[i];
|
||||
var v0 = aseq.EvaluateVector(frame0);
|
||||
var v1 = aseq.EvaluateVector(frame1);
|
||||
var v = interpolate ? (v0 * ialpha) + (v1 * falpha) : v0;
|
||||
switch (track)
|
||||
{
|
||||
case 17: globalAnimUV0 = v; break; //could be overwriting values here...
|
||||
case 18: globalAnimUV1 = v; break;
|
||||
}
|
||||
case 17: globalAnimUV0 = v; break; //could be overwriting values here...
|
||||
case 18: globalAnimUV1 = v; break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user