Call for Submission
NAB 2012 Best of the Best Show Reel
Submit your work today!
  • 1/3
You are here: Forum Home / Autodesk® FBX® / FBX SDK / UV's mapping out of order
  RSS 2.0 ATOM  

UV's mapping out of order
Rate this thread
 
36421
 
Permlink of this thread   Subscribe to this thread
avatar
  • ksr
  • Posted: 06 November 2009 01:23 PM
  • Total Posts: 2
  • Joined: 16 October 2009 05:34 PM

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
<VertexPosNorTextempVertices;
 
KFbxVector4pMeshVertices = new KFbxVector4[m_pFbxMesh->GetControlPointsCount()];
 
memcpy(pMeshVerticesm_pFbxMesh->GetControlPoints()m_pFbxMesh->GetControlPointsCount()*sizeof(KFbxVector4))

 for( int  i 
=0im_pFbxMesh->GetPolygonCount() i++ )
 {
 for( int j 
=0jm_pFbxMesh->GetPolygonSize(i) j++ )
 {
 int vertInd 
m_pFbxMesh->GetPolygonVertex(  ij)
 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 0tempCountertempVertices.size() ++tempCounter)
 {
 bool contains  
false;
//check for duplicate vertices
 
for(int vertexCounter 0vertexCounter 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 Attachment
Replies: 0
avatar

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

Replies: 4
/img/forum/dark/default_avatar.png

I have this problem too; Here is the code I am using:
KFbxAxisSystem SceneAxisSystem = m_pScene->GetGlobalSettings().GetAxisSystem()
KFbxAxisSystem OurAxisSystem(KFbxAxisSystem::DirectX)
if( SceneAxisSystem != OurAxisSystem )
{
OurAxisSystem.ConvertScene(m_pScene);
}
but ,it is no use;

Author: gameatp

Replied: 08 May 2011 01:04 AM  
/img/forum/dark/default_avatar.png

I have this problem too; Here is the code I am using:
KFbxAxisSystem SceneAxisSystem = m_pScene->GetGlobalSettings().GetAxisSystem()
KFbxAxisSystem OurAxisSystem(KFbxAxisSystem::DirectX)
if( SceneAxisSystem != OurAxisSystem )
{
OurAxisSystem.ConvertScene(m_pScene);
}
but ,it is no use;

Author: gameatp

Replied: 08 May 2011 01:04 AM  
/img/forum/dark/default_avatar.png

I have this problem too; Here is the code I am using:
KFbxAxisSystem SceneAxisSystem = m_pScene->GetGlobalSettings().GetAxisSystem()
KFbxAxisSystem OurAxisSystem(KFbxAxisSystem::DirectX)
if( SceneAxisSystem != OurAxisSystem )
{
OurAxisSystem.ConvertScene(m_pScene);
}
but ,it is no use;

Author: gameatp

Replied: 08 May 2011 01:04 AM  
/img/forum/dark/default_avatar.png

I have this problem too; Here is the code I am using:
KFbxAxisSystem SceneAxisSystem = m_pScene->GetGlobalSettings().GetAxisSystem()
KFbxAxisSystem OurAxisSystem(KFbxAxisSystem::DirectX)
if( SceneAxisSystem != OurAxisSystem )
{
OurAxisSystem.ConvertScene(m_pScene);
}
but ,it is no use;

Author: gameatp

Replied: 08 May 2011 01:04 AM  
avatar

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

Replies: 3
/img/forum/dark/default_avatar.png

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  
/img/forum/dark/default_avatar.png

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  
/img/forum/dark/default_avatar.png

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: