Texture Co-Ordinates

Started by
2 comments, last by 95CKILMA 17 years, 8 months ago
K im getting my bearings with textures and meshes now, in using managed direct-x and C#. But i was wondering if anyone could tell me, if i set 1 texture co-ord e.g the first vertex co-ord to 1,0 will the other vertex's in the mesh just follow on without me having to set all the co-ords? the reason i want this is i wish to be-able to off-set a texture from its normal position i hope this is somewhat clear, and hope somone can help thx :)
Advertisement
No, each UV coordinate is a point in 2D (or 3D for volume textures) space. Changing one point does not affect the others.

You can, however, apply a transformation to UVs.

// Create a transform matrix for a 2D coord.  Note, it's not the same as a regular 4x4 matrix.D3DXMATRIX matrix;D3DXMatrixIdentity(&matrix);matrix._11 = scaleu;matrix._22 = scalev;matrix._31 = offsetu;matrix._32 = offsetv;// Enable transform on stage 0 for a 2D coordinate.pDev->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);pDev->SetTransform(D3DTS_TEXTURE0, &matrix);// Render// Disable transform on stage 0.pDev->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLED);
thx 4 this mate, im transfering into c# and hopfull be done tonight after i get back from work
Thx again 4 the code mate it works a treat, ive converted it over to c# now which has helped with the understanding :). So to finish the topic 4 future users heres the c# for it in the same format as before.


// Create a transform matrix for a 2D coord. Note, it's not the same as a regular 4x4 matrix.
Matrix matrix = Matrix.Identity;
matrix.M11 = scaleu;
matrix.M22 = scalev;
matrix.M31 = offsetu;
matrix.M32 = offsetv;

// Enable transform on stage 0 for a 2D coordinate.
device.SetTextureStageState(0, TextureStageStates.TextureTransform, (int)TextureTransform.Count2);
device.SetTransform(TransformType.Texture0, matrix);

// Render

// Disable transform on stage 0.
device.SetTextureStageState(0, TextureStageStates.TextureTransform, (int)TextureTransform.Disable);

This topic is closed to new replies.

Advertisement