Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® FBX® / FBX SDK / SplitMeshPerMaterial
  RSS 2.0 ATOM  

SplitMeshPerMaterial
Rate this thread
 
43345
 
Permlink of this thread  
avatar
  • wh1sp3r
  • Posted: 18 May 2010 01:53 AM
  • Total Posts: 12
  • Joined: 10 May 2010 12:41 PM

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 :)



Replies: 0
avatar

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
Maya Data Platform
Autodesk

Replies: 0
avatar

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.
*/



Zhihao, Data Platform - Autodesk

Replies: 0
avatar
  • wh1sp3r
  • Posted: 18 May 2010 03:22 AM

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.



Replies: 0
avatar

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)



Zhihao, Data Platform - Autodesk

Replies: 0