views:

257

answers:

0

Hi!

I've been having a very tiresome time when using flash10's Matrix3D class for 2D non-affine transformations. Basically, I have a square in a sprite and four points that form a quadrilateral, and I want to apply a transformation to the sprite to make those points the vertices of the sprite.

There wouldn't be much problem solving this Math problem using 3x3 matrices, like in this case. The problem is that flash's native transform Matrix class doesn't perform non-affine transformations - which means, there is no way to access the u v w fields of the Matrix class.

With flash10's native support to 3D, it was introduced the Matrix3D class, which allows non-affine transformation, but is a mess to work with. Basically whatever you apply on this matrix isn't exactly what will appear on screen, since it will apply a mandatory projection matrix from PerspectiveProjection class. There is no way to disable this projection, and this perspectiveProjection matrix is always a non-inversible matrix(*1). The method described here - at stackoverflow, about flash10 orthographic projection -, of defining the fieldOfView property to near 0, or the focalLengh to a huge number, won't help to nullify the perspective projection for the edge cases that work with non-affine 2d transformations. This means that even though we can make a projection almost-orthographic when working with normal shear/scale/rotation of a Matrix3D, the same PerspectiveProjection on a Matrix3D with non-affine 2d transforms will still have a undesired perspective projection. Would there be any way to nullify this perspectiveProjection? Or maybe a better way to do it? For now I am using a workaround of separating the plane into two triangles, and applying two affine transforms on them.

Thank you very very much! Cauê

(*1) when the focal length equals to 1, the perspective projection matrix has the following form:

--          --
| 1  0  0  0 |
| 0  1  0  0 |
| 0  0  1  0 |
| 0  0  1  0 |
--          --
           ^ No, sadly this wasn't a typo!