CoolFace
Datasetpublic

hschumann2/TempleOS-Source-Code

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes838downloads
Transform.txt27 linesDownload Raw Back to Doc
1 2CDC's have a 4x4 matrix for rotating, scaling, skewing and shifting in 33dimensions.  To make the graphics routines use the transform, you must set the4DCF_TRANSFORMATION flag.5 6The matrix consists of ints that have been scaled 32 bits (GR_SCALE).  See7::/Demo/Lectures/FixedPoint.HC to learn why.8 9See Mat4x4IdentEqu(), Mat4x4IdentNew(), Mat4x4Equ() and Mat4x4New().  See10Mat4x4RotX(), Mat4x4RotY(), Mat4x4RotZ() and Mat4x4Scale() to rotate about axes11and scale.  Combine them with Mat4x4MulMat4x4Equ()/Mat4x4MulMat4x4New() and12assign them to the CDC.dc with DCMat4x4Set().  See ::/Demo/Graphics/Box.HC.13 14You can rotate single points using Mat4x4MulXYZ().15 16The 4th dimension allows a neat trick where you can place pos shifts17(translations), into the matrix and Mat4x4MulMat4x4Equ/Mat4x4MulMat4x4New them18to combine rotation/shift operations.  Normally, you can't combine pos shift19operations.  See Mat4x4TranslationEqu() and ::/Demo/Graphics/Transform.HC.20 21Finally, CDC's have an x, y and z which is an additional shift (translation).22 23The transformation is implemented as a callback on the CDC's transform() member.24 The default transform() callback is DCTransform().  See25::/Demo/Games/Talons.HC or ::/Demo/Games/CastleFrankenstein.HC to see how to26change the transform() callback for foreshortening.27