Sign in to follow this  
Thors1982

Rotate a texture around an object

Recommended Posts

I am very new to DirectX in general but I had this great idea... and can't figure it out :-) I have a cylinder with a texture on it, and I would like to rotate that texture around the object... infintely in circles if thats possible. So any ideas for a newb :-) Thanks a lot

Share this post


Link to post
Share on other sites
You could just texture and rotate the cylinder that would give the same effect. For rotating the texture i would guess you would have to move the texture co-ords each frame by how much you want it to be rotated by. I might be wrong if someone would like to correct me. Good luck.

Share this post


Link to post
Share on other sites
Set the IDirect3DDevice9::SetTrasnform to D3DTS_TEXTURE0 if you want to be able to manipulate the texture instead of the object transformation. And the same way you would rotate your object is the same way you can rotate the texture around on the object. By default Direct3D has Texture Transformation disable. So to put it back on and do what you want to do you have to turn it on like so.


d3ddevice->SetTextureStageState(0,D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_COUNT3);
D3DXMATRIA16 Rotate;
static float r=0;
D3DXMatrixRotationY(&Rotate,D3DXToRadian(r));
d3ddevice->SetTransform(D3DTS_TEXTURE0,&Rotate);
r++;
if(r>360)r=0;

Share this post


Link to post
Share on other sites
Actually I got it to work... Here is how much of a newb I am :-p
I didn't know you could use the like transformations on single objects....

I was thinking that it would screw up the mechanics and change the whole "world" and viewport and stuff. But I simply

D3DXMatrixRotationX(&RotateTextX, .3);
D3DXMatrixRotationY(&RotateTextY, (float)clock() / 1500.0f);
D3DXMatrixMultiply(&TextResult, &TextResult, &RotateTextY);
D3DXMatrixMultiply(&TextResult, &TextResult, &RotateTextX);

as im sure... many many of you have done :-)
Thanks for the help anyways

Oh (if anyone is still reading) I highly doubt it makes a difference but my timeGetTime() doesn't work at all in my own programs... works great with the tutorials i downloaded(i included all the headers they did). Instead im using clock() with time.h.

Thanks again :-)

Share this post


Link to post
Share on other sites
Quote:
Original post by Thors1982
Oh (if anyone is still reading) I highly doubt it makes a difference but my timeGetTime() doesn't work at all in my own programs... works great with the tutorials i downloaded(i included all the headers they did). Instead im using clock() with time.h.


Have you included the 'winmm.lib' file.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this