Jump to content
  • Advertisement
Sign in to follow this  
95CKILMA

Texture Co-Ordinates

This topic is 4354 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
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);

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.


// 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);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!