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

Started by
1 comment, last by 51mon 17 years, 7 months ago
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?
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?

Never mind, wrapping mode was the ghost

This topic is closed to new replies.

Advertisement