[DiscordArchive] Lacks interpolation ?
[DiscordArchive] Lacks interpolation ?
Archived author: Titi • Posted: 2025-06-12T13:01:32.211000+00:00
Original source
Lacks interpolation ?
Archived author: Saty • Posted: 2025-06-12T15:33:05.192000+00:00
Original source
Very much yes xD But for 9 days of work it's pretty good already I would say.
I mean this is the worst it will be, only gonna improve from here <:kekw:1301383133899522078>
Archived author: Saty • Posted: 2025-06-12T15:33:46.939000+00:00
Original source
Nope. Probably did it wrong tho somehow. Need to check again
Archived author: Saty • Posted: 2025-06-12T17:59:02.132000+00:00
Original source
```cs
if (modelBone.Rotation.Timestamps.Count > 0)
{
var rotationtimestamps = modelBone.Rotation.Timestamps[CurrentSequence];
for (int j = 1; j < rotationtimestamps.Count; j++)
{
if (currentMilliseconds >= rotationtimestamps[j - 1] && currentMilliseconds < rotationtimestamps[j])
{
var startRaw = modelBone.Rotation.Values[CurrentSequence][j - 1];
Quaternion start = new Quaternion(startRaw.Y, startRaw.Z, -startRaw.X, -startRaw.W);
var endRaw = modelBone.Rotation.Values[CurrentSequence][j];
Quaternion end = new Quaternion(endRaw.Y, endRaw.Z, -endRaw.X, -endRaw.W);
var t = (currentMilliseconds - rotationtimestamps[j - 1]) / (float)(rotationtimestamps[j] - rotationtimestamps[j - 1]);
switch (modelBone.Translation.InterpolationType)
{
case M2Track<M2Lib.types.C3Vector>.InterpolationTypes.Instant:
{
desiredRotation = start;
}
break;
case M2Track<M2Lib.types.C3Vector>.InterpolationTypes.Linear:
{
desiredRotation = math.nlerp(start, end, t);
}
break;
case M2Track<M2Lib.types.C3Vector>.InterpolationTypes.Bezier:
{
// TODO implement bezier!!!
desiredRotation = math.nlerp(start, end, t);
}
break;
case M2Track<M2Lib.types.C3Vector>.InterpolationTypes.Hermite:
{
// TODO implement hermite!!!!
desiredRotation = math.nlerp(start, end, t);
}
break;
}
}
}
}
```
Anyone with a few more braincells than me maybe sees why the rotation might be so jittery? (Bezier and Hermite not used in the login model)
Archived author: Saty • Posted: 2025-06-12T18:01:09.137000+00:00
Original source
Position is buttery smooth, tested everything without positioning and it still jitters.
I have a feeling this might be:
a) A unity bug
b) Something not taken into account from the parent
Like with positions the coordinates from objects with a parent are relative, while objects without parent are absolute...
Maybe same case here? Am to stupid for quaternion math tho
Archived author: Titi • Posted: 2025-06-12T18:01:18.880000+00:00
Original source
first change the => to a >, you don't want two different times to have the same value
`if (currentMilliseconds >= rotationtimestamps[j - 1]`
Archived author: Saty • Posted: 2025-06-12T18:02:03.002000+00:00
Original source
You sure? That skips frame 1 tho
Archived author: Titi • Posted: 2025-06-12T18:02:09.228000+00:00
Original source
it could mess up with the other check just being a <
Archived author: Titi • Posted: 2025-06-12T18:02:40.348000+00:00
Original source
ah yeah, maybe hackfix for frame 0
Archived author: Saty • Posted: 2025-06-12T18:04:01.897000+00:00
Original source
nlerp btw being:
```cs
public static quaternion nlerp(quaternion q1, quaternion q2, float t)
{
return normalize(q1.value + t * (chgsign(q2.value, dot(q1, q2)) - q1.value));
}
```