Skip to main content
gamedev.net
🔒 Locked

Texture Moving

Started by -X-Modena-X- Aug 3, 2001 at 1:02 PM 3 replies 950+ views
Original Post
-X-Modena-X-
-X-Modena-X-
I have been fighting with a program for a couple weeks now. What I have is a cylender. I want to move the texture up and down along the cylender. The texture is alot longer then the circumfrence of the cylender so I can''t just rotate the cylender. I was wondering if anyone could help me out with this problem. The cylender is in .x format with the texture assigned to it. All I need to do is change where exactly the texture is on the cylender.
Funkymunky
Funkymunky
Just shift the texture coordinates
aminouch
aminouch
you can move textures just like any object,
first, you must do that:
D3dDevice->SetTextureStageState( D3DTSS_TRANSFORMFLAGS, //some of the flags here);

then you can directly move your texture:
D3DXMATRIX trans;
D3DXMatrixTranslation( &trans, 0.0f, 0.0f, 10.0f ); // 10 along the Z- axis
-and then you cast the matrix to the textures:
D3dDevice->SetTransform( D3DTS_TEXTURE0, &trans);

just ask if you need more help
http://aminouch.tripod.com


mine from morocco
-X-Modena-X-
-X-Modena-X-
Ok, I just have one more question. What D3DTSS_TRANSFORMFLAGS flags do you use to get the textures to shift? I have been playing around with and I don''t get any errors, but the textures just will not move.
MrFlibble
MrFlibble
quote:
Original post by -X-Modena-X-
Ok, I just have one more question. What D3DTSS_TRANSFORMFLAGS flags do you use to get the textures to shift? I have been playing around with and I don''t get any errors, but the textures just will not move.


If you have a look through the DirectX docs there should
be information on how to do this. One thing to note though
is that texture transformation matrices put the offsets
into row 3 (2 in c) and not 4 (3 in c) as normal view/world
transformations.
i.e. to move a texture up by 0.5 you would need a matrix

1 0 0 0
0 1 0 0
0 0.5 1 0
0 0 0 1

you will also want to put in
D3dDevice->SetTextureStageState( 0, 3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );

To make the device transform the stage 0 texture co-ordinates and
pass them through to the rasterizer.

Hope this helps

MrF.



MrF.
--
Code..reboot..code..reboot..sigh!
MrF.--Code..reboot..code..reboot..sigh!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.