templeos-info/public/Wb/Doc/Transform.DD.HTML

57 lines
5.6 KiB
Plaintext
Raw Normal View History

2024-03-23 13:40:50 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="generator" content="TempleOS V5.03">
<meta name="viewport" content="width=device-width">
2024-03-23 13:40:50 +00:00
<link rel="stylesheet" href="/style/templeos.css">
<script src="/script/templeos.js"></script>
<style type="text/css">
.cF0{color:#000000;background-color:#ffffff;}
.cF1{color:#0000aa;background-color:#ffffff;}
.cF2{color:#00aa00;background-color:#ffffff;}
.cF3{color:#00aaaa;background-color:#ffffff;}
.cF4{color:#aa0000;background-color:#ffffff;}
.cF5{color:#aa00aa;background-color:#ffffff;}
.cF6{color:#aa5500;background-color:#ffffff;}
.cF7{color:#aaaaaa;background-color:#ffffff;}
.cF8{color:#555555;background-color:#ffffff;}
.cF9{color:#5555ff;background-color:#ffffff;}
.cFA{color:#55ff55;background-color:#ffffff;}
.cFB{color:#55ffff;background-color:#ffffff;}
.cFC{color:#ff5555;background-color:#ffffff;}
.cFD{color:#ff55ff;background-color:#ffffff;}
.cFE{color:#ffff55;background-color:#ffffff;}
.cFF{color:#ffffff;background-color:#ffffff;}
</style>
</head>
<body>
<pre id="content">
2024-03-24 21:24:44 +00:00
<a name="l1"></a><a href="/Wb/Kernel/KernelA.HH.HTML#l3599"><span class=cF4>CDC</span></a><span class=cF0>'s have a 4x4 matrix for rotating, scaling, skewing and shifting in 3
2024-03-23 13:40:50 +00:00
<a name="l2"></a>dimensions. To make the graphics routines use the transform, you must set the </span><span class=cF4>
2024-03-24 21:24:44 +00:00
<a name="l3"></a></span><a href="/Wb/Kernel/KernelA.HH.HTML#l3569"><span class=cF4>DCF_TRANSFORMATION</span></a><span class=cF0> flag.
2024-03-23 13:40:50 +00:00
<a name="l4"></a>
2024-03-24 21:24:44 +00:00
<a name="l5"></a>The matrix consists of ints that have been scaled 32 bits (</span><a href="/Wb/Adam/Gr/GrDC.HC.HTML#l4"><span class=cF4>GR_SCALE</span></a><span class=cF0>). See </span><span class=cF4>
<a name="l6"></a></span><a href="/Wb/Demo/Lectures/FixedPoint.HC.HTML#l1"><span class=cF4>::/Demo/Lectures/FixedPoint.HC</span></a><span class=cF0> to learn why.
2024-03-23 13:40:50 +00:00
<a name="l7"></a>
2024-03-24 21:24:44 +00:00
<a name="l8"></a>See </span><a href="/Wb/Adam/Gr/GrDC.HC.HTML#l24"><span class=cF4>Mat4x4IdentEqu</span></a><span class=cF0>(), </span><a href="/Wb/Adam/Gr/GrDC.HC.HTML#l34"><span class=cF4>Mat4x4IdentNew</span></a><span class=cF0>(), </span><a href="/Wb/Adam/Gr/GrMath.HC.HTML#l102"><span class=cF4>Mat4x4Equ</span></a><span class=cF0>() and </span><a href="/Wb/Adam/Gr/GrMath.HC.HTML#l108"><span class=cF4>Mat4x4New</span></a><span class=cF0>(). See </span><span class=cF4>
<a name="l9"></a></span><a href="/Wb/Adam/Gr/GrMath.HC.HTML#l113"><span class=cF4>Mat4x4RotX</span></a><span class=cF0>(), </span><a href="/Wb/Adam/Gr/GrMath.HC.HTML#l127"><span class=cF4>Mat4x4RotY</span></a><span class=cF0>(), </span><a href="/Wb/Adam/Gr/GrMath.HC.HTML#l141"><span class=cF4>Mat4x4RotZ</span></a><span class=cF0>() and </span><a href="/Wb/Adam/Gr/GrMath.HC.HTML#l155"><span class=cF4>Mat4x4Scale</span></a><span class=cF0>() to rotate about axes
<a name="l10"></a>and scale. Combine them with </span><a href="/Wb/Adam/Gr/GrMath.HC.HTML#l80"><span class=cF4>Mat4x4MulMat4x4Equ</span></a><span class=cF0>()/</span><a href="/Wb/Adam/Gr/GrMath.HC.HTML#l96"><span class=cF4>Mat4x4MulMat4x4New</span></a><span class=cF0>() and
<a name="l11"></a>assign them to the </span><a href="/Wb/Kernel/KernelA.HH.HTML#l3599"><span class=cF4>CDC</span></a><span class=cF0>.</span><span class=cF2>dc</span><span class=cF0> with </span><a href="/Wb/Adam/Gr/GrDC.HC.HTML#l47"><span class=cF4>DCMat4x4Set</span></a><span class=cF0>(). See </span><a href="/Wb/Demo/Graphics/Box.HC.HTML#l1"><span class=cF4>::/Demo/Graphics/Box.HC</span></a><span class=cF0>.
2024-03-23 13:40:50 +00:00
<a name="l12"></a>
2024-03-24 21:24:44 +00:00
<a name="l13"></a>You can rotate single points using </span><a href="/Wb/Adam/Gr/GrDC.HC.HTML#l6"><span class=cF4>Mat4x4MulXYZ</span></a><span class=cF0>().
2024-03-23 13:40:50 +00:00
<a name="l14"></a>
<a name="l15"></a>The 4th dimension allows a neat trick where you can place pos shifts
2024-03-24 21:24:44 +00:00
<a name="l16"></a>(translations), into the matrix and </span><a href="/Wb/Adam/Gr/GrMath.HC.HTML#l80"><span class=cF4>Mat4x4MulMat4x4Equ</span></a><span class=cF0>/</span><a href="/Wb/Adam/Gr/GrMath.HC.HTML#l96"><span class=cF4>Mat4x4MulMat4x4New</span></a><span class=cF0> them
2024-03-23 13:40:50 +00:00
<a name="l17"></a>to combine rotation/shift operations. Normally, you can't combine pos shift
2024-03-24 21:24:44 +00:00
<a name="l18"></a>operations. See </span><a href="/Wb/Adam/Gr/GrMath.HC.HTML#l176"><span class=cF4>Mat4x4TranslationEqu</span></a><span class=cF0>() and </span><a href="/Wb/Demo/Graphics/Transform.HC.HTML#l1"><span class=cF4>::/Demo/Graphics/Transform.HC</span></a><span class=cF0>.
2024-03-23 13:40:50 +00:00
<a name="l19"></a>
2024-03-24 21:24:44 +00:00
<a name="l20"></a>Finally, </span><a href="/Wb/Kernel/KernelA.HH.HTML#l3599"><span class=cF4>CDC</span></a><span class=cF0>'s have an </span><span class=cF2>x</span><span class=cF0>, </span><span class=cF2>y</span><span class=cF0> and </span><span class=cF2>z</span><span class=cF0> which is an additional shift (translation).
2024-03-23 13:40:50 +00:00
<a name="l21"></a>
2024-03-24 21:24:44 +00:00
<a name="l22"></a>The transformation is implemented as a callback on the </span><a href="/Wb/Kernel/KernelA.HH.HTML#l3599"><span class=cF4>CDC</span></a><span class=cF0>'s </span><span class=cF2>transform()</span><span class=cF0> member.
<a name="l23"></a> The default </span><span class=cF2>transform()</span><span class=cF0> callback is </span><a href="/Wb/Adam/Gr/GrDC.HC.HTML#l15"><span class=cF4>DCTransform</span></a><span class=cF0>(). See </span><span class=cF4>
<a name="l24"></a></span><a href="/Wb/Demo/Games/Talons.HC.HTML#l1"><span class=cF4>::/Demo/Games/Talons.HC</span></a><span class=cF0> or </span><a href="/Wb/Demo/Games/CastleFrankenstein.HC.HTML#l1"><span class=cF4>::/Demo/Games/CastleFrankenstein.HC</span></a><span class=cF0> to see how to
2024-03-23 13:40:50 +00:00
<a name="l25"></a>change the </span><span class=cF2>transform()</span><span class=cF0> callback for foreshortening.
</span></pre></body>
</html>