// M is a D3DMATRIX being set to translate texture
// coordinates in the U and V directions.
// 1 0 0 0
// 0 1 0 0
// du dv 1 0 (du and dv change each frame)
// 0 0 0 1
D3DMATRIX M = D3DXMatrixIdentity(); // declared in d3dutil.h
M._31 = du;
M._32 = dv;
Texture Coordinate Transformations (rotate? scale?)
After some excessive experimenting with lightmaps and stuff, im trying to use matrices to transform the 2D texture coordinates on my vertices. RendersStates, Vertex formats and TextureStageStates are not my problem here, but I dont know how to rotate or scale my texture coordinates. Im using C#, but due to lack of Managed documentation, let me quote what the C++ docs have to say about texture coordinate transformations;
Appearently, there are no functions (like Matrix.Translate, Matrix.Rotate and Matrix.Scaling) to make matrices for texture coordinates. The existing functions are all for 3D transformations and these do not work for texture coordinates, even Matrix.Transformation2D doesnt work. So, how do I scale and rotate my texture coordinates?
3D transformations DO work !
FinalMatrix = Matrix.Rotate * Matrix.Scaling * Matrix.Translate2d
(note: Remember to multiply in the above order)
Matrix.Translate2d (du = x, dv = y) =// 1 0 0 0// 0 1 0 0// du dv 1 0 (du and dv change each frame)// 0 0 0 1
FinalMatrix = Matrix.Rotate * Matrix.Scaling * Matrix.Translate2d
(note: Remember to multiply in the above order)
Are you saying I should position by setting M31 and M32 manually and rotate/scale with the standard methods? Because there is no Matrix.Translate2D method, there is only Matrix.Transformation2D but it does not give the appropriate result.
Yes, set M31 and M32 manually and rotate/scale with the standard methods :)
(set M31 and M32 manually = write a new function = Translate2d)
(set M31 and M32 manually = write a new function = Translate2d)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement