Jump to content
  • Advertisement
Sign in to follow this  
51mon

I don't understand my code (uv-mapping)

This topic is 4305 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

Hello I don't know why my code work as it does. The code looks like this:
D3DXVECTOR3 vNodePos = *GetPosition(vec_adj_itr->this_node); // get position in 3D
D3DXVECTOR3 vBBoxDimensions = vBBoxMax - vBoxMin;
vNodePos -= (vBBoxDimensions * 0.5f + vBBoxMin);
D3DXVECTOR2 *vNodeUV = GetUV(vec_adj_itr->this_node); // Get pointer to set uv
vNodeUV->x = atan2(D3DXVec3Dot(&vSecondaryAxe1,&vNodePos), D3DXVec3Dot(&vPrimaryAxe,&vNodePos)) / (D3DX_PI * 2.0f) + 0.5f; // Set u based on polar coordinates mapped to [0,1], vSecondaryAxe1 is (1.0f,0.0f,0.0f), vPrimaryAxe is (0.0f,0.0f,1.0f)
vNodeUV->y = atan2(D3DXVec3Dot(&vSecondaryAxe2,&vNodePos), D3DXVec3Dot(&vPrimaryAxe,&vNodePos)) / (D3DX_PI * 2.0f) + 0.5f; // vSecondaryAxe2 is (0.0f,1.0f,0.0f)

It is supposed to sweap around some geometry and assign uv-coordinates evenly, but when processed it looks like this: The texture is a checker pattern, why is it not evenly distributed?

Share this post


Link to post
Share on other sites
Advertisement
OK maybe my code is right after all, but I don't understand this. When I let 3dsmax export a model with tex-coordinates it does'nt tile near the seam, but my code does, how do I fix that?

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!