Page 1 of 1
What units are shearing values?
Posted: Sat Mar 13, 2010 11:45 am
by bibbinator
Hello,
I'm almost done with the exporter for AnimeStudio, but I'm stuck on shearing.
I can't seem to work out how the units specified in the shear x/y fields should be applied to the layer to replicate how it looks in AnimeStudio on our game.
I tried converting the units to relative amounts, and also using them as a multiplier, even tried putting them into a 4x4 matrix, but nothing makes it come out exactly right.
Could somebody explain how AS uses these values internally to shear the layer?
Thanks!
Brett
Posted: Sun Mar 14, 2010 12:34 am
by Genete
The AS units are a bit particular. The vertical dimension is always going from -1 to 1 form the bottom to the top of the view port, regardless any resolution you can stablish to the project settings. The horizontal dimension is fixed to that relationship according to the project settings.
-G
Posted: Sun Mar 14, 2010 2:08 am
by bibbinator
Thanks for your post.
Yes. For translation and other uses of the +/- 1 units it is easy to understand. It basically makes a unit cube viewing volume that is then scaled into whatever units you want. So in my exporter I can easily convert these units to whatever I need.
For shearing though, these units no longer seem to work the same way. If I convert the units based on a unit cube volume it doesn't result in exactly the correct amount of shear. I also tried it as a multiplier and a matrix.
So internally AS is doing something with these units that I can't quite figure out. Hopefully one of the devs can shed some light on this?
I would normally expect shear to appear in a 4x4 column oriented identity matrix here:
1, Sy, 0, 0
Sx, 1, 0, 0
0, 0, 1, 0
0, 0, 0, 1
Where Sy and Sx is the shear amount.
Thanks in advance for any help!
Posted: Sun Mar 14, 2010 10:03 am
by Genete
I guess that you have tried to use:
void GetLayerTransform()
Gets the layer's transformation at a given frame. The layer transform includes things like layer scale, rotation, and translation.
Return value: none
frame (int): frame number
matrix (LM_Matrix): transform matrix to fill in doc
(MohoDoc): the document object
If so, to understand what's the matrix content after a shear you can extract the matrix elements by applying it to some unitary vectors using the Transform members of the matrix object:
void Transform(vec2)
Apply a matrix transformation to a 2D vector object.
vec2 (Vector2): a vector to transform
Return value: none
void Transform(vec3)
Apply a matrix transformation to a 3D vector object.
vec3 (Vector3): a vector to transform
Return value: none
-G
Posted: Sun Mar 14, 2010 10:11 am
by bibbinator
Thanks for your post.
The problem is that I don't know how to get the elements out of an LM_Matrix as they aren't documented. But I guess they're just a table anyway?
But your idea is interesting, I never thought of then transforming a normalized vector to see what it was doing.
Neat idea! Thanks!
Brett
Posted: Sun Mar 14, 2010 10:20 am
by Genete
I never thought of then transforming a normalized vector to see what it was doing.
That's the natural mathematical way to extract any component from a matrix or to know what's the effect of a matrix in a defined direction. For instance, if you want to know if a matrix is modifying the scale in a particular direction just multiply the matrix by a unity vector in that direction and caclulate the modulus of the resulting vector which gives the scale on that direction. Same happen with angles of two vectors etc.
-G
Posted: Sun Mar 14, 2010 10:24 am
by Genete
But I guess they're just a table anyway?
They are member of a class in C++ as far as I know. Its components can be an 4x4 array, a 16x1 vector, or simply 16 float variables. It is whatever the developer wanted it to be and obviously it is hidden to external access by placing them in the private area of the class. Usually you cannot access to private data when use a C++ class unless the developer have created and exposed to the public part of the class some access methods. AFAIK there is not any provided interface to retrieve the matrix components directly.
-G