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)
I don't understand my code (uv-mapping)
Hello
I don't know why my code work as it does. The code looks like this:
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?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement