Skip to content

Silk.NET.Assimp Quaternions are incorrect #796

@Kermalis

Description

@Kermalis

Summary

Upon parsing Quaternions from NodeAnim*, I was stumbling upon incorrect Quaternions. The aiQuaterniont struct puts W first, but System.Numerics.Quaternion is X first. So it appears Silk.NET is casting those aiQuaternionT* to System.Numerics.Quaternion or something, which results in W being at X which is wrong.

Here's my workaround for parsing them:

NodeAnim* chan = a->MChannels[j];

var positions = new (float, Vector3)[chan->MNumPositionKeys];
for (int k = 0; k < positions.Length; k++)
{
    VectorKey pos = chan->MPositionKeys[k];
    positions[k] = ((float)pos.MTime, pos.MValue);
}
var rotations = new (float, Quaternion)[chan->MNumRotationKeys];
for (int k = 0; k < rotations.Length; k++)
{
    QuatKey rot = chan->MRotationKeys[k];
    rotations[k] = ((float)rot.MTime, new Quaternion(rot.MValue.Y, rot.MValue.Z, rot.MValue.W, rot.MValue.X)); // HERE: Incorrectly casted by library, so order is shifted by one field
}
var scales = new (float, Vector3)[chan->MNumScalingKeys];
for (int k = 0; k < scales.Length; k++)
{
    VectorKey scl = chan->MScalingKeys[k];
    scales[k] = ((float)scl.MTime, scl.MValue);
}

Comments

  • Platform: Desktop
  • Framework Version: .NET 6.0
  • API: OpenGL 3.3 Core

I'm not sure if this is unique to NodeAnim or if it applies all over the library, so it needs some looking into

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions