пятница, 13 июля 2012 г.

I don't need flash.geom.Matrix3D class anymore

I don't like native math classes for several reasons. For example, I don't have control over it and I can't say exactly is it my error or class implementation error when something going wrong. And according to this post Bugs in Vector3D and Matrix3D there're a lot of bugs. Also every matrix.transformVector() call creates new vector instance. Also in some cases I need 3x3 matrix instead of 4x4 for 3D math.
One day I decided to beg off from Matrix3D class and use my own implementation. But you may say it's impossible, since Stage3D API need this class to pass matrix data to AGAL. Yes, it is. But there's another way to pass same data. Recall when you call (poem :-))
context.setProgramConstantsFromMatrix(0, matrix);
and you want to add one more matrix, you set it at ID 4 - NOT at ID 1. Furthermore in AGAL you can access to attributes va0, va1, va2, va3. This means that Stage3D passes matrix as 4 vectors. So can we!

As you know, there is a difference between multiplying vector by matrix and matrix by vector. In my framework I chose matrix with row layout so I multiply vector by matrix (v * m). Next, if I pass rows of my matrix through context.setProgramConstantsFromVector() I will not get desired result. It's because data storage for matrices in AGAL organized in different way. In order to make things work I need to transpose my matrix or simply pass to context.setProgramConstantsFromVector() matrix columns. That's all.

Комментариев нет:

Отправить комментарий