Texture coordinate transformations
I’ve encountered a problem with using matrices to transform texture coordinates. Simply put my problem is that I cannot get texture coordinate translations to work. I can get a rotation or scale to work. Here a snippet for my code. It’s very basic.
D3DXMATRIX MatrixScale;
D3DXMATRIX MatrixRotate;
D3DXMATRIX MatrixTranslate;
D3DXMATRIX MatrixFinal;
D3DXMatrixScaling(&MatrixScale, 2.0f, 2.0f, 1.0);
D3DXMatrixRotationZ(&MatrixRotate, 32.0f);
D3DXMatrixTranslation(&MatrixTranslate, 0.1f, 0.1f, 0.0f);
MatrixFinal = MatrixScale * MatrixRotate * MatrixTranslate;
d3dDevice->SetTransform(D3DTS_TEXTURE0, &MatrixFinal);
…
d3dDevice->SetTexture(0, m_d3dTexture);
d3dDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
When I execute my application I can see the texture rotation and scale but not the translation.
I feel like I am missing something that should be obvious. The DirectX 8.1 documentation says that transforming texture coordinates is the same as transforming any other coordinate space.
Walter Byers
Add:
MatrixFinal._31 = MatrixFinal._41;
MatrixFinal._32 = MatrixFinal._42;
MatrixFinal._33 = MatrixFinal._43;
Before setting the matrix via SetTransform
Jim Adams
home.att.net/~rpgbook
Author, Programming Role-Playing Games with DirectX
and Focus On: Advanced Animation with DirectX
MatrixFinal._31 = MatrixFinal._41;
MatrixFinal._32 = MatrixFinal._42;
MatrixFinal._33 = MatrixFinal._43;
Before setting the matrix via SetTransform
Jim Adams
home.att.net/~rpgbook
Author, Programming Role-Playing Games with DirectX
and Focus On: Advanced Animation with DirectX
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement