Sign in to follow this  

Texture Co-Ordinates

This topic is 4140 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 :)

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
Share on other sites
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.

[Code]
// 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);

[/Code]

Share this post


Link to post
Share on other sites

This topic is 4140 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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