Archived

This topic is now archived and is closed to further replies.

Walter Byers

Texture coordinate transformations

Recommended Posts

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

Share this post


Link to post
Share on other sites
Thanks for answering such a simple question. I understand what I was doing wrong. I forgot to take in account there is only 2 coordinates and how matrices perform coordinate translations. I guess I must go back to Linear Algebra and brush up a bit.

Share this post


Link to post
Share on other sites