Summary
This blog post covered some of the basic considerations of a transform hierarchy, but this is by no means a comprehensive guide. We only coverd transforms represented by seperate components stored in vectors and quaternions. Godot for example, stores a transform as a basis matrix and an origin vector. Depending on the context of what you are doing, a different storage strategy might be appropriate.
- Affine Transforms
- Uniform Scale Transform
- Non-Uniform Scale Transform
- Transforms With Negative Scale
These are not unique properties of a transform. For example, a transform can be non-uniform scale and negative scale at the same time.
When designing a transform class you should also take into consideration things like interpolation, animation and utility functions transforms should provide. Hopefully this blog provided a solid start to this, or at least helped to demonstrate some of the non obvious, potentially hidden complexity of handling object transforms in games.
Concatination order
What is the correct order to concatenate transforms? Is it parent then child, or child then parent? IE:
Transform CombineTransforms(Transform parent, Transform child) { // OR Transform CombineTransforms(Transform child, Transform parent) {
Almost all of the math i write concatenates right to left, so i do transform concatination in that order as well: CombineTransforms(Transform child, Transform parent)
. I suggest following the conventions of the math library you are using.