Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The model matrix is like the other matrices (projection, view) a 4x4 matrix with the same layout. Depending on whether you're using column or row vectors the matrix consists of the x,y,z axis of your local frame and a t1,t2,t3 vector specifying the translation part</p> <p>so for a column vector p the transformation matrix (M) looks like</p> <pre><code>x1, x2, x3, t1, y1, y2, y3, t2, z1, z2, z3, t3, 0, 0, 0, 1 </code></pre> <p>p' = M * p</p> <p>so for row vectors you could try to find out how the matrix layout must be. Also note that if you have row vectors p' = p * M.</p> <p>If you have no rotational component your local frame has the usual x,y,z axis as the rows of the 3x3 submatrix of the model matrix..</p> <pre><code>1 0 0 t1 -&gt; x axis 0 1 0 t2 -&gt; y axis 0 0 1 t3 -&gt; z axis 0 0 0 1 </code></pre> <p>the forth column specifies the translation vector (t1,t2,t3). If you have a point p =</p> <pre><code> 1, 0, 0, 1 </code></pre> <p>in a local coordinate system and you want it to translate +1 in z direction to place it in the world coordinate system the model matrix is simply: </p> <pre><code>1 0 0 0 0 1 0 0 0 0 1 1 0 0 0 1 </code></pre> <p>p' = M * p .. p' is the transformed point in world coordinates.</p> <p>For your example above you could already specify the triangle in (2,2,0), (2,3,0) and (3,2,0) in your local coordinate system. Then the model matrix is trivial. Otherwise you have to find out how you compute rotation etc.. I recommend reading the first few chapters of mathematics for 3d game programming and computer graphics. It's a very simple 3d math book, there you should get the minimal information you need to handle the most of the 3d graphics math.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload