Transforms
March 23, 2022Less than 1 minute
Transforms
Understand what a transform is
Understand how to combine transforms
转移子物体到父物体的空间中
Convert between transforms and matrices
Understand how to apply transforms to points and vectors
获得一个点在一个transform
空间的位置。
http://gabormakesgames.com/transforms.html
Transform combine(const Transform& a, const Transform& b) {
Transform out;
out.scale = a.scale * b.scale;
out.rotation = b.rotation * a.rotation;
out.position = a.rotation * (a.scale * b.position);
out.position = a.position + out.position;
return out;
}
Matrix combine(Transform transform) {
Matrix localMatrix = ToMatrix(transform);
Matrix parentMatrix = ToMatrix(transform.parent);
return localMatrix * parentMatrix;
Matrix GetInParentMatrix(Transform transform) {
Matrix localMatrix = ToMatrix(transform);
Matrix localParentMatrix = ToMatrix(transform.parent);
return localParentMatrix * localMatrix;
}