Files
TempleOS-Rijn/Doc/Transform.TXT
T
2018-09-08 21:46:02 +02:00

14 lines
1.8 KiB
Plaintext

$WW,1$$LK,"CDC",A="MN:CDC"$'s have a 4x4 matrix for rotating, scaling, skewing and shifting in 3 dimensions. To make the graphics routines use the transform, you must set the $LK,"DCF_TRANSFORMATION",A="MN:DCF_TRANSFORMATION"$ flag.
The matrix consists of integers that have been scaled 32 bits ($LK,"gr_scale",A="MN:gr_scale"$). See $LK,"::/Demo/Lectures/FixedPoint.CPP"$ to learn why.
See $LK,"GrRotXNew",A="MN:GrRotXNew"$(), $LK,"GrRotYNew",A="MN:GrRotYNew"$(), $LK,"GrRotZNew",A="MN:GrRotZNew"$(), $LK,"GrScaleNew",A="MN:GrScaleNew"$(), $LK,"GrRotXEqu",A="MN:GrRotXEqu"$(), $LK,"GrRotYEqu",A="MN:GrRotYEqu"$(), $LK,"GrRotZEqu",A="MN:GrRotZEqu"$() and $LK,"GrScaleEqu",A="MN:GrScaleEqu"$() to rotate about axes and scale. Combine them with $LK,"GrMulMat",A="MN:GrMulMat"$() and assign them to the $LK,"CDC",A="MN:CDC"$.$FG,2$dc$FG$ with $LK,"GrSetRotMat",A="MN:GrSetRotMat"$(). See $LK,"::/Demo/Graphics/Box.CPP"$.
You can rotate single points using $LK,"GrRot",A="MN:GrRot"$().
The 4th dimension allows a neat trick where you can place pos shifts (translations), into the matrix and $LK,"GrMulMat",A="MN:GrMulMat"$ them to combine rotation/shift operations. Normally, you can't combine pos shift operations. See $LK,"GrSetTranslation",A="MN:GrSetTranslation"$() and $LK,"::/Demo/Graphics/Transform.CPP"$.
Finally, $LK,"CDC",A="MN:CDC"$'s have an $FG,2$x$FG$, $FG,2$y$FG$ and $FG,2$z$FG$ which is an additional shift (translation).
The transformation is implemented as a callback on the $LK,"CDC",A="MN:CDC"$'s $FG,2$transform()$FG$ member. The default $FG,2$transfrom()$FG$ callback is $LK,"GrTransform",A="MN:GrTransform"$(). See $LK,"::/Demo/Games/EagleDive.CPP"$ or $LK,"::/Demo/Games/CastleFrankenstein.CPP"$ to see how to change the $FG,2$transfrom()$FG$ callback for foreshortening.