Closed CKiOne closed 1 year ago
I assume you're setting the world matrix of a child node.
glTF nodes don't have a world matrix, only a local matrix.
The World Matrix property exposed by SharpGLTF is built from the local matrices of the node chain.
In order to set the world matrix of a child node, internally, the library calculates the INVERSE matrix of the parent node, and multiplies it by the matrix you're setting. This is how the local matrix of the child node is evaluated. Most probably, there's some precission lost in these calculations and, since glTF specification does not allow any value other than 1, it throws an error.
I might look at it to see if I can handle this use case; in the meantime, instead of setting the world matrix, do the math steps yourself with the local matrix, fix the m44 to 1, and set the local matrix of the child node.
Another possibility, that might be odd, but not impossible, is that your matrix truly has a value of 0.999999~ , and it just happens that visual studio is rounding it to 1 when it's displayed in the debugger... if you force M44 to 1 just before setting the world matrix and it works, that will be the case.
in any case, I tried to create a matrix with the values you posted, and I couldn't reproduce the problem, most probably because the floating error is below the values displayed in visual studio so I would need some sort of test project that I could run to debug it myself.
The only place i'm setting the worldmatrix is here
Matrix4x4.Invert(parentMatrix, out Matrix4x4 invertedParentMatrix)
resolves to:
Can you dump your (the non inverted) parent matrix to bytes?
you can use System.BitConverter to get the bytes from a float.
It should be fixed in the Alpha 27 nuget packages.
Oh, thank you, I will check it. Sorry, I was in holliday.
Hi, i set worldMatrix of a child node:
then I get following error:
System.ArgumentException: M44 (Parameter 'M44 0.9999999 must be equal to 1.')
My values are:
and
![image](https://user-images.githubusercontent.com/1086380/191296179-d05ea06b-d516-4288-abf4-2b6b74eb2860.png)
That should give me a matrix with 0 0 0 1 last row.