v0 = (-1, -1, 0)
v1 = (-1. 1. 0)
v2 = (1, 1, 0)
v3 = (1, -1, 0)
I rotated these vertices at 30 degrees arount X axis. so x components remain same. y and z components are in [-1, 1]. after that I added 1 to z components and multiplied z components by 0.5. then all xyz components are in range [-1, 1], [-1, 1], [0, 1], respectively. but half of image is clipped. what's the matter?
It works! But I thought context.setProgramConstantsFromMatrix() uploads the matrix row by row.
vc0 = row[0] of transform
vc1 = row[1] of transform
vc2 = row[2] of transform
vc3 = row[3] of transform
Then isn't this correct? (v is vertex position)
v.x = dot product of vc0 and v
v.y = dot product of vc1 and v
v.z = dot product of vc2 and v
v.w = dot product of vc3 and v
I figured all out. What I described above is correct.
AGAL's m44 operation is performed as follow:
m44 dst, v, M (v is 4x1 vector, M is 4x4 matrix)
dst <- M * v
But flash.geom.Matrix3D performs this: (this time v is 1x4 vector, not 4x1)
dst <- v * M
flash.geom.Matrix3D class' appendXXX/prependXXX methods are implemented to support latter case. For example Matrix3D setup translation matrix as follow(a, b, c is amount of movement in x, y, z axis):
1 0 0 0
0 1 0 0
0 0 1 0
a b c 1
But to perform translation in stage3d, the matrix should be(just transpose of the matrix above):
1 0 0 a
0 1 0 b
0 0 1 c
0 0 0 1
That's the reason why forth parameter of context.setProgramConstantsFromMatrix() should be true when I use flash.geom.Matrix3D to make a transform matrix in stage3d.
alternatively you can let transposedMatrix to false if you perform Matrix3D.transpose before sending it to context.setProgramConstantsFromMatrix ()
rawData before Matrix3D.transpose ();
1, 0, 0, 0,
0, -1, 6.1, 0,
0, -1.2, -0.5, 0,
0, 0, 0.5, 1
after
1, 0, 0, 0,
0, -1, -1.2, 0,
0, 6.1, -0.5, 0.5,
0, 0, 0, 1
it acts the way you mentionned above
otherwise, why not using the &~1 trick to gain some more fps
context.configureBackBuffer(stage.stageWidth&~1, stage.stageHeight&~1, 4, false)