Direct3D equivalent of Open GL texture matrix manipulation?

Started by
0 comments, last by ET3D 17 years, 9 months ago
I have some Open GL code I'm porting to Direct3D that has a textured quad where the texture is animated the opposite of the quad. For example, if the quad is rotated 90 degrees CW, the texture is rotated 90 degrees CW, given the effect that the quad has moved but the texture has stayed in place. I accomplish this in Open GL by glMatrixMode( GL_TEXTURE ), then calling glTranslatef(), glRotatef() and glScalef() which modifies the texture matrix. Simple eh? But I'm failing to do the same in Direct3D. If anyone can give some insight to the following questions, it'd be grand: 1) Do I need to add additional values to my vertex format (beyond tu and tv)? Currently I have: Vertex3D { float x, y, z; DWORD diffuse; float tu, tv; } 2) Should I simply do my own calculations for tu, tv or should I use SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 )? 3) If I use the above SetTextureStageState(), do I still need texture coordinate values in the vertex format? Thanks for your time, Christoph
Advertisement
You can use a texture matrix by setting it using, device->SetTransform(D3DTS_TEXTURE0, &matrix) and setting the texture stage state you mentioned. Matrix calculations are normally done using D3DX functions, such as D3DXMatrixTranslation (see the D3D docs for more) and multiplied together to form one matrix.

This topic is closed to new replies.

Advertisement