How to scale a Texture on a vertex?

Started by
5 comments, last by To_N 21 years, 1 month ago
Hi there struct VERTEX { float x,y,z; float nx,ny,nz; float tu,tv; }; #define FVF_VERTEX (D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1) Thix is my FVF Vertex declaration. My question is now, how to scale a texture on thix vertex. u v coordinates work fine. Thx in advance... Tobias Noell / Germany
Advertisement
change the uv coords. If your UV work fine, just cut them in half. If 1.0 for a U works, change it to .5
TechleadEnilno, the Ultima 2 projectwww.dr-code.org/enilno
Not sure if this is what you mean, but for my terrain, for example, if I want the texture to repeat three times, I do something like:

vertex->tu = x/(map_size/3);
vertex->tv = y/(map_size/3);

I guess, in essence, this is scaling the texture across the map by 33% (or so).
It all depends on your map size.

If your map size is 3, this will be a one time texture.
TechleadEnilno, the Ultima 2 projectwww.dr-code.org/enilno
Thanks for the fast answers, my problem was that i added values for all u and v coordinates af a polygon, which resultet as a texture shifting.
One last question:
How to scale, shift and rotate a texture, later i want to have 4 values, two for u/v shifting, two for u/v scaling and one for texture rotation, how to compute the u/v values for this?
Thx in advance

Tobias Noell / Germany
If you''re wanting to offset, scale, and rotate the UVs on the fly (changing from frame to frame) you''ll probably not want to adjust the actual UVs. Instead, use a texture tranform.

pDevice->SetTransform(D3DTS_TEXTURE0, pMatrix);pDevice->SetTextureStageState(D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2); 

Note that the matrix, despite being 4x4 is treated as 3x3 when using COUNT2, so you''re rotation would be roll, and translation would have to be placed in _31, and _32 manually instead of the standard _41, _42, _43 that the translation functions would use.
Thx for your answer but I only need it to store once, so that the user can adjust these values once in my leveleditor and that an algorithm computes of the useres scale / rotation / shift coice the u v values. Any idea?

This topic is closed to new replies.

Advertisement