|
Tell us what you think of the site.
|
Autodesk Media & Entertainment User Community
|
Autodesk® 3ds Max®
|
|
Autodesk® Maya®
|
|
Autodesk® Softimage®
|
|
Autodesk® MotionBuilder®
|
|
Autodesk® Mudbox™
|
|
Autodesk® ImageModeler™
|
|
Autodesk® Sketchbook® Pro
|
|
Autodesk® Smoke on Mac®
|
| UV's mapping out of order
|
|
|
Hello,
I’m trying to map a simple texture on a cube in directX. I used the FBX SDK to extract the vertex, normal and UV information ofthe cube. However the cube displayed in my program has the wrong UV mapping. It seems like they are a mirror image of each other and the wrong faces have the wrong part of the texture mapped on it. I have attached a screenshot of the cube in maya and the application I am making.
Here is the code I am using:
KFbxVector4 normal;
KFbxVector2 tex;
m_pFbxMesh->ComputeVertexNormals()
KFbxLayerElementNormal* pNormals = m_pFbxMesh->GetLayer(0,KFbxLayerElement::eNORMAL)->GetNormals()
KFbxLayerElementUV* pUV = m_pFbxMesh->GetLayer( 0 )->GetUVs()
vector<VertexPosNorTex> tempVertices;
KFbxVector4* pMeshVertices = new KFbxVector4[m_pFbxMesh->GetControlPointsCount()];
memcpy(pMeshVertices, m_pFbxMesh->GetControlPoints(), m_pFbxMesh->GetControlPointsCount()*sizeof(KFbxVector4))
for( int i =0; i< m_pFbxMesh->GetPolygonCount() i++ )
{
for( int j =0; j< m_pFbxMesh->GetPolygonSize(i) j++ )
{
int vertInd = m_pFbxMesh->GetPolygonVertex( i, j)
VertexPosNorTex v;
v.pos = D3DXVECTOR3( pMeshVertices[ vertInd ].GetAt( 0 ),
pMeshVertices[ vertInd ].GetAt( 1 ),
pMeshVertices[ vertInd ].GetAt( 2 ))
normal = pNormals->GetDirectArray()[vertInd];
v.normal = D3DXVECTOR3( normal.GetAt( 0 ),
normal.GetAt( 1 ),
normal.GetAt( 2 ))
int meshInd = m_pFbxMesh->GetTextureUVIndex(i, j)
tex = pUV->GetDirectArray().GetAt(meshInd)
v.texC = D3DXVECTOR2(tex.GetAt(0),1.0f -tex.GetAt(1))
tempVertices.push_back(v)
}
}
SAFE_DELETE_ARRAY(pMeshVertices)
//creating the real index and vertex buffer here
int indexBufferCounter = 0;
for(int tempCounter = 0; tempCounter< tempVertices.size() ++tempCounter)
{
bool contains = false; //check for duplicate vertices
for(int vertexCounter = 0; vertexCounter < m_Vertices.size() ++vertexCounter)
{
if(
m_Vertices[vertexCounter].pos == tempVertices[tempCounter].pos
&& m_Vertices[vertexCounter].normal== tempVertices[tempCounter].normal
&& m_Vertices[vertexCounter].texC == tempVertices[tempCounter].texC
)
{
contains = true;
m_Indices.push_back(vertexCounter)
break;
}
}
if(!contains)
{
m_Vertices.push_back(tempVertices[tempCounter])
m_Indices.push_back(indexBufferCounter)
++indexBufferCounter;
}
}
I am doing v.texC = D3DXVECTOR2(tex.GetAt(0),1.0f -tex.GetAt(1)), because the texture mapping is totally wrong if I don’t (could be a difference in the mapping coordinate system of Maya and DX10).
I have tried several combinations to fix this issue, but this is the closest I have got to the result.
Any help would be greatly appreciated.
Thanks in advance
| Attachment
|
|
|
|
|
|
It is because Direct3D uses left-handed axis system, and FBX uses right-handed axis system like OpenGL and Maya. So in Direct3D, your scene appears like a mirror image of what you see in Maya.
Try KFbxAxisSystem::ConvertScene() to modify your scene.
Viviane, Autodesk FBX Team
Viviane Rochon
Maya Data Platform
Autodesk
|
|
|
|
Hi gameatp,
Maybe FAQ question 3.12 might help you?
3.12 How do I convert a scene to left-handed?
FBX SDK does not have a function to convert a scene from Right Handed to Left Handed, for example for a DirectX project. Multiplying the global transform matrix of each node by a left-handed matrix normally fixes this issue.
1, 0, 0, 0
0, 1, 0, 0
0, 0,-1, 0
0, 0, 0, 1
The FBX FAQ is available at this link: http://area.autodesk.com/forum/autodesk-fbx/fbx-sdk/2-fbx-sdk-faq
Cheers,
Viviane
Maya Data Platform
Autodesk
Viviane Rochon
Maya Data Platform
Autodesk
|
|
|
|
|
Thank you, my method is taken directly to the x coordinate of a negative, so that the index of the vertex order from the CCW into CW. There is a skeletal animation x-coordinate of the translation have to take a negative, rotate the four elements y, z axis have to take a negative, or skeletal animation will go wrong
Author: gameatp
|
| Replied: 09 May 2011 02:46 AM
|
|
|
|
|
|
Thank you, my method is taken directly to the x coordinate of a negative, so that the index of the vertex order from the CCW into CW. There is a skeletal animation x-coordinate of the translation have to take a negative, rotate the four elements y, z axis have to take a negative, or skeletal animation will go wrong
Author: gameatp
|
| Replied: 09 May 2011 02:47 AM
|
|
|
|
|
|
Thank you, my method is taken directly to the x coordinate of a negative, so that the index of the vertex order from the CCW into CW. There is a skeletal animation x-coordinate of the translation have to take a negative, rotate the four elements y, z axis have to take a negative, or skeletal animation will go wrong
Author: gameatp
|
| Replied: 09 May 2011 02:47 AM
|
|
|
|
|
| Settings
| Choose Theme color:
|
|
|
|
|
|
|