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:

@p [transform] : {

@p    type = translate;

@p    delta.x = 5;

@p    [base] : {

@p       type = scale;

@p       factor.z = 1.5;

@p    }

@p }

@p 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.

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

@p matrix M;

@p M.scale (1, 1, 1.5);

@p M.translate (5, 0, 0);

@p 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:

@p local M = matrix ();

@p M:scale (1, 1, 1.5);

@p M:translate (5, 0, 0);

2007-09-19


◀ Back