Community
FBX Forum
Welcome to Autodesk’s FBX Forums. Share your knowledge, ask questions, and explore popular FBX topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get UV coord per vertex

9 REPLIES 9
Reply
Message 1 of 10
Anonymous
2072 Views, 9 Replies

How to get UV coord per vertex

Hello Everyone,
I export a scene with multiple mesh from maya (multiple materials per mesh).
I'm faced a problem when import this scene with FBX SDK because my game engine supports only UV coord per vertex (not by polygon vertex) and one material per mesh.

First of all I have been split all my meshes with
KFbxGeometryConverter::SplitMeshesPerMaterial.

Now the material mapping is by mesh. But the sub-meshes still have UV coord per polygon vertex.

Can someone tell me how can I resolve this problem please ?

Thanks in advance
9 REPLIES 9
Message 2 of 10
Anonymous
in reply to: Anonymous

I reply myself because I find a solution. This can also help other people.
Fo having UV coord per vertex,
For each sub-mesh (mesh obtained after applyng SplitMeshPerMaterial) use the following function
KFbxMesh::SplitPoints(KFbxLayerElement::eDIFFUSE_TEXTURES)

Note that SplitPoints can be used only for the sub-mesh not the original mesh (as I have infinite loop acting like that)

Now I have vertex, normals, UV, tangents per vertex.
But only part of my problem are resolved : there are no bones and blendShapes associated with the sub-meshes. So you can still help me.

Thanks
Message 3 of 10
KaibaSeto
in reply to: Anonymous

SplitPoints seems is split points by PolygonVertex. Not merging the points sharing the same uv together. For my FBX plugin, I duplicate the points my self to minimize the count of control points count.
Or do you find a way to split by vertex sharing the same uv?
Message 4 of 10
Anonymous
in reply to: Anonymous

Hello,
I find a solution
Follow this link
Message 5 of 10
KaibaSeto
in reply to: Anonymous

No. That's not what I look for. This will convert the by polygon vertex to by control points. Yet, it doesn't minimize the control points count. The control points count is just the polygon vertex count in this method. I doesn't merge the control points sharing the same UV.
If you want UV per vertex, the solution is simply what you want. But it's not the best solution. It's possible to minimize the vertex count.
Message 6 of 10
Anonymous
in reply to: Anonymous

Hello,
Yet, it doesn’t minimize the control points count. The control points count is just the polygon vertex count in this method.

No, if you take a great look to the code you can see that the following do all you want :
// check if we already processed this control point
if (lProcessedCP.Get((FbxHandle)lCP) == 0)
{
FbxVector2 uv = pUVs->GetDirectArray().GetAt(lCP);
lNewUVs.Add(uv);
lNewIndexToDirect.Add(lCP);
lProcessedCP.SetItem((FbxHandle)lCP, (FbxHandle)true);
}
Message 7 of 10
KaibaSeto
in reply to: Anonymous

Not exactly. This is just to re-map all the uv to new control points & make the mode to by control points. It didn't minimize the vertices count. I doesn't merge the vertex share the same uv together.
Message 8 of 10
Anonymous
in reply to: Anonymous

Not exactly. This is just to re-map all the uv to new control points & make the mode to by control points. It didn’t minimize the vertices count. I doesn’t merge the vertex share the same uv together.

I don't understand what you're looking for but the algorithm minimize the vertices count.
Let's take an example : A mesh with 4 triangles (6 Control Points and 12 vertices)

- Polygon0 : 102
- Polygon1 : 203
- Polygon2 : 523
- Polygon3 : 453

Initially UVArray have size 12 (Per Vertex Mapping)

After apply the algorithm above :
UVArray will have size 6 (One for each Control Point)

You can't minimize further the UVArray size.
Note that 2 vertices share same UV if they point towards the same CP.
Message 9 of 10
KaibaSeto
in reply to: Anonymous

-Before applyng SplitPoints
CP array size = 1900
Indices array size = 10992
UV array size = 10992
-After applyng SplitPoints
CP array size = 10992
Indices array size = 10992
UV array size = 10992
-After applying your solution
CP array size = 10992
Indices array size = 10992
UV array size = xxxx;(minimized)
No exactly. Your solution only re-map the UV. It minimize the UV array count. But not the control points count.
But what I need is
CP array size = xxxx;(minimized, & the size is uv array size)
UV array size = xxxx;(minimized, & the size is cp array size)

Yet, I've solved it with a temp KArrayTemplate. Thanks anyway.
Message 10 of 10
KaibaSeto
in reply to: Anonymous

-Before applyng SplitPoints
CP array size = 1900
Indices array size = 10992
UV array size = 10992
-After applyng SplitPoints
CP array size = 10992
Indices array size = 10992
UV array size = 10992
-After applying your solution
CP array size = 10992
Indices array size = 10992
UV array size = xxxx;(minimized)
No exactly. Your solution only re-map the UV. It minimize the UV array count. But not the control points count.
But what I need is
CP array size = xxxx;(minimized, & the size is uv array size)
UV array size = xxxx;(minimized, & the size is cp array size)

Yet, I've solved it with a temp KArrayTemplate. Thanks anyway.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report