Thursday, December 1, 2022
HomeGame Developmentarithmetic - encode homogeneous transformations on the foundation node of a...

arithmetic – encode homogeneous transformations on the foundation node of a gltf


An alternate of two axes is a mirror operation. So you may want to decide on an axis on which to replicate the thing utilizing its scale triplet, then change the rotation to compensate.

As an example we mirror the thing on the x axis: newScale = (-1, 1, 1) * scale. Now a unit vector that had been pointing towards +x factors towards -x, and one which had been pointing towards +z or +y nonetheless level to these instructions.

We subsequent wish to rotate this object so the previously +x, now -x vector factors to +x, the +z vector factors to +x, and the +y vector factors to +z. (to get the anticipated final result of our x/z swap). That is a 180 diploma rotation concerning the line y = z, or as a quaternion: newRot = (0, 1.0f/sqrt(2), 1.0f/sqrt(2), 0) * rot.

(Right here utilizing * to imply quaternion conjugation, ie. $a * b = aba^{-1}$, and XYZW element order in line with the glTF spec)

However we might simply as simply select to deal with this as a mirror within the y axis as an alternative. Then we might get: newScale = (1, -1, 1) * scale, and unit vectors within the +x and +z instructions would keep put, whereas a unit vector within the +y route will get mapped to -y. To show these round, we might need a +90 diploma rotation across the -x axis: newRot = (-1.0f/sqrt(2), 0, 0, 1.0f/sqrt(2)) * rot.

Or, to spherical issues out, we might deal with it as a mirror within the z axis: newScale = (1, 1, -1) * scale. +x and +y are preserved, and +z maps to -z. So then we might wish to rotate +90 levels across the +x axis to repair this up: newRot = (1.0f/sqrt(2), 0, 0, 1.0f/sqrt(2)) * rot.

After all, the difficulty right here is that mirroring your object flips the winding of all of your triangles. So you might must detect in case your new transformation contains an odd variety of signal flips or axis exchanges (unfavorable determinant when expressed as a matrix), and in that case, swizzle your indices as you load them to get again to the specified winding.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments