RotateMatrixByQuaternion
function · cmath · primitive
- Address
0x7bddb0· 333 bytes, up to0x7bdefc- Signature
void __thiscall (NTempest::C44Matrix *this, const NTempest::C4Quaternion *q)- Meaning
- Multiplies a matrix on the left by the rotation matrix of a quaternion (x, y, z, w)
- Confidence
- verified, proof one
- Finding
- models/animation#texture-transforms
- Test
animation::m2_animate_difftest,cmath::quat_mul4
Finding: Texture transforms in models: animation
Each frame each texture transform builds its matrix from identity: when its rotation track has keys,
translate by the centre p = (0.5, 0.5, 0), rotate by the sampled quaternion, translate by −p;
then the same with the sampled scale; then translate by the sampled translation. Each step
multiplies on the left, so for the row vector (u, v, 0, 1) the result is ((uv + t − p) ⊙ s)·Q + p, Q the quaternion's matrix with rows (1 − 2(y² + z²), 2xy + 2zw, 2xz − 2yw), (2xy − 2zw, 1 − 2(x² + z²), 2yz + 2xw) and (2xz + 2yw, 2yz − 2xw, 1 − 2(x² + y²)). The tracks sample at bone 0's
time.
The derivation is in the doc.
Callers 4
- CGGameObject_C::OnModelLoaded objectlayer
- CGGameObject_C::OnCreate objectlayer
- CreateGroupDoodadDef terrain
- CM2Model::Animate models
Callees 1
- MultiplyMatrix4 cmath
Calls and jumps by a bare address, from tables/calls.tsv.