The Transform class
A 3D virtual reality scene will be constructed from various objects, each with a position, rotation, and scale in 3D dimensional space defined by a Transform
.
It will also be naturally useful to permit transforms to be grouped hierarchically. This grouping also creates a distinction between local space and world space, where children only keep track of the difference between their translation, rotation, and scale (TRS) and that of their parent (local space). The actual data that we are storing is the local position (we'll use the words position and translation interchangeably), rotation, and scale. Global position, rotation, and scale are computed by combining the local TRS all the way up the chain of parents.
First, let's define the Transform
class. In the Android Studio hierarchy panel, right-click on renderbox/
, go to New | Java Class, and name it Transform
.
Each Transform
may have one or more associated components. Typically there is just one, but it is possible to add...