Transformation allow you to change the place where things are drawn in the world. For example, the function to draw blocks can only draw axis-parallel blocks, but by first setting a rotation transformation you can create rotated blocks. Also sprites are always drawn parallel to the xy-plane, but by setting a transformation you can change this. There are two types of functions, functions that set the transformation and functions that add transformations, and they are listed below:
- d3d_transform_set_identity
- d3d_transform_set_translation
- d3d_transform_set_scaling
- d3d_transform_set_rotation_x
- d3d_transform_set_rotation_y
- d3d_transform_set_rotation_z
- d3d_transform_set_rotation_axis
- d3d_transform_add_translation
- d3d_transform_add_scaling
- d3d_transform_add_rotation_x
- d3d_transform_add_rotation_y
- d3d_transform_add_rotation_z
- d3d_transform_add_rotation_axis
Sometimes you temporarily want to save the current transformation, for example to add an additional transformation and then restore the old one (this often happens when drawing hierarchical models). To this end you can push the current transformation on a stack and later pop it from the stack to make it the current transformation again. The following functions exist for this:
Finally, you have a function that can be used to get the x, y, and z values for the transformed vertex:
An alternative way to create transforms (and for multiple transforms this is far more efficient) is to use the matrix functions. These permit you to get the values of different matrices (view, projection and world), as well as create your own then multiply them or change their values and apply them again. The available matrix functions are listed below: