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: 

SplitMeshPerMaterial

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
904 Views, 5 Replies

SplitMeshPerMaterial

Hello,
Could you please show me, how to use this function ?

I have tried it with mesh, which has more materials, but nothing changed .. still one mesh, one child node

thank you very much for help :)
5 REPLIES 5
Message 2 of 6
viviane.rochon
in reply to: Anonymous

Hi wh1sp3r,

To use this function:
KFbxGeometryConverter lConverter(pSdkManager)
lConverter.SplitMeshPerMaterial(lMesh)


Note that the original mesh stays unchanged. The new meshes are created under the same node. So if you do
pNode->GetNodeAttributeCount()

before and after the call to SplitMeshPerMaterial, you should see a difference in the number: there will be the old mesh, plus one new mesh (node attribute) for each material.

I refer you to the documentation for this function:

It will work only on mesh that have material mapped "per-face" (Mapping Mode is KFbxLayerElement::eBY_POLYGON).
It does NOT work on meshes with material mapped per-vertex/per-edge/etc.
It will create as many meshes on output that there are materials applied to it.
If one mesh have some polygons with material A, some polygons with material B,
and some polygons with NO material, it should create 3 meshes after calling this function.
The newly created meshes should be attached to the same KFbxNode that hold the original KFbxMesh.
The original KFbxMesh STAY UNCHANGED.
Now, the new mesh will have Normals, UVs, vertex color, material and textures.


Viviane, FBX Team


Viviane Rochon Montplaisir
Message 3 of 6
Anonymous
in reply to: Anonymous

Hi wh1sp3r,
I have to say that the method is initiated and pretty specific for some internal project.

Actually, if more than one materials assign to a mesh(by polygon),
after calling SplitMeshPerMaterial,
the mesh could be spitted numbers of mesh which have only one material.
And the spitted mesh are connected to original node.
However, the original mesh is also connected to the node.
The structure looks like:
//Before SplitMeshPerMaterial
Node
|_OriginalMesh

//After SplitMeshPerMaterial:
Node
|_OriginalMesh
|_newSplitMesh0
|_newSplitMesh1
|_newSplitMesh2
|_...

Does it answer your question?


Please also see the comments of .h file.

/** Split Mesh Per Material.
* Each split mesh only has a single material on it.
* \param pMesh The mesh that contains the smoothing to be converted.
* \return \c true on success, \c false otherwise.
* \remarks It will work only on mesh that have material mapped "per-face" (Mapping Mode is KFbxLayerElement::eBY_POLYGON).
* It does NOT work on meshes with material mapped per-vertex/per-edge/etc.
* It will create as many meshes on output that there are materials applied to it.
* If one mesh have some polygons with material A, some polygons with material B,
* and some polygons with NO material, it should create 3 meshes after calling this function.
* The newly created meshes should be attached to the same KFbxNode that hold the original KFbxMesh.
* The original KFbxMesh STAY UNCHANGED.
* Now, the new mesh will have Normals, UVs, vertex color, material and textures.
*/
Message 4 of 6
Anonymous
in reply to: Anonymous

ok, thank you for answer

i see, value changed, but i would like to get MESH pointer for splited part, how can i manage it ? I don'T see any GetMesh(i) or GetMeshCount anywhere.
Message 5 of 6
Anonymous
in reply to: Anonymous

Opps, I reply at the same time with Viviane. Thanks Viviane.:-)

Please use the following methods. Find more details in kfbxnode.h
int GetNodeAttributeCount()
KFbxNodeAttribute* GetNodeAttributeByIndex(int pIndex)
Message 6 of 6
Anonymous
in reply to: Anonymous

I'm facing a similar problem in FBX SDK 2017.1; I call SplitMeshPerMaterial(). But in the split meshes all my transformations are identity.

 

So:

 

converter->SplitMeshPerMaterial(pMesh,false/*replace*/);
for(int c = 0; c < pMesh->GetNode()->GetNodeAttributeCount(); ++c)
{
  if(pMesh->GetNode()->GetNodeAttributeByIndex(c)->GetAttributeType() == FbxNodeAttribute::eMesh && 
     pMesh->GetNode()->GetNodeAttributeByIndex(c)!=pMesh)
  {
    FbxMesh *mesh=(FbxMesh*)pMesh->GetNode()->GetNodeAttributeByIndex(c));
    FbxVector4 trans=mesh->GetNode()->GetGeometricTranslation(FbxNode::eSourcePivot);
  }

 

Here, 'trans' is always zeroes. Any idea how I can fix that?

 

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

Post to forums  

Autodesk Design & Make Report