Transforms


Throughout Venture the Void, I had to construct matrix transforms "in reverse"; that is, I used a functional model for specifying a transform, so that the "inner" transforms would be performed first. Example:

[transform] : {

   type = translate;

   delta.x = 5;

   [base] : {

      type = scale;

      factor.z = 1.5;

   }

}

This transform definition, which results in one 4x4 matrix, has the effect of taking whatever object you are applying it to, first scaling along the z-axis by 1.5, then translating along the x-axis by 5. The normal way to "think" of it, though, is how I've described it; in a linear order. The great thing about matrix transforms is that they compose this way, so that you can stack say several hundred together into one matrix and you only have to apply it once.

But what would be perhaps more intuitive would be a procedural model:

matrix M;

M.scale (1, 1, 1.5);

M.translate (5, 0, 0);

For lui, I'm now at a place where I have to create an API for matrix transforms; there are a lot of "quick and dirty" ways to do it, but I think I will opt for somehow implementing the linear, procedural syntax. Not sure how it'll work, exactly, although the code above seems reasonable enough. Translated to lua, it would be:

local M = matrix ();

M:scale (1, 1, 1.5);

M:translate (5, 0, 0);

2007-09-19


◀ Back