载入中...
搜索中...
未找到
AnimTransformInternal.h
浏览该文件的文档.
1#pragma once
2
4
6
9 // world = parent * local (TRS, scale ignored in rotation path for FK positions)
10 TransformTRS out;
11 // Rotate local translation by parent rotation, then add parent translation * scales.
12 const float qx = parent.qx, qy = parent.qy, qz = parent.qz, qw = parent.qw;
13 const float lx = local.px * parent.sx;
14 const float ly = local.py * parent.sy;
15 const float lz = local.pz * parent.sz;
16 // q * v
17 const float ix = qw * lx + qy * lz - qz * ly;
18 const float iy = qw * ly + qz * lx - qx * lz;
19 const float iz = qw * lz + qx * ly - qy * lx;
20 const float iw = -qx * lx - qy * ly - qz * lz;
21 out.px = parent.px + (ix * qw + iw * -qx + iy * -qz - iz * -qy);
22 out.py = parent.py + (iy * qw + iw * -qy + iz * -qx - ix * -qz);
23 out.pz = parent.pz + (iz * qw + iw * -qz + ix * -qy - iy * -qx);
24
25 // Quaternion multiply parent * local
26 out.qw = parent.qw * local.qw - parent.qx * local.qx - parent.qy * local.qy - parent.qz * local.qz;
27 out.qx = parent.qw * local.qx + parent.qx * local.qw + parent.qy * local.qz - parent.qz * local.qy;
28 out.qy = parent.qw * local.qy - parent.qx * local.qz + parent.qy * local.qw + parent.qz * local.qx;
29 out.qz = parent.qw * local.qz + parent.qx * local.qy - parent.qy * local.qx + parent.qz * local.qw;
31
32 out.sx = parent.sx * local.sx;
33 out.sy = parent.sy * local.sy;
34 out.sz = parent.sz * local.sz;
35 return out;
36}
37
38} // namespace eve::animation::detail
std::string local
std::int32_t parent
float qy
float qx
float qw
float qz
TransformTRS mulTRS(const TransformTRS &parent, const TransformTRS &local)
Mul trs.
Local TRS used by skeletal animation (quaternion xyzw).
Definition AnimMath.h:9
void normalizeRotation()
Normalize rotation.
Definition AnimMath.h:18