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 clone a skinned mesh?

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
artgolf1000
1097 Views, 2 Replies

How to clone a skinned mesh?

Well, clone a static mesh is easy, but how to clone a skinned mesh? the cloned mesh should share the same skeleton with the original mesh, my purpose is making a LOD mesh for the original mesh.

 

I cannot figure it out, can anybody advice me?

 

Here is my code:

// clone the attribute
FbxNodeAttribute* cloned_attribute = (FbxNodeAttribute*)a_pNode->GetNodeAttribute()->Clone();
// clone the node
FbxNode* cloned_node = (FbxNode*)a_pNode->Clone();
// attach the attribute to the node
cloned_node->SetNodeAttribute(cloned_attribute);
// add the cloned node to the parent node 
a_pNode->GetParent()->AddChild(cloned_node);

 

Tags (2)
2 REPLIES 2
Message 2 of 3
artgolf1000
in reply to: artgolf1000

Found a solution:

 

If in the same scene, I can use:

FbxNode* cloned_node = (FbxNode*)FbxCloneManager::Clone(a_pNode);

If in the cloned scene, it will lose animation connections, becomes static mesh, and it may crash when loading.

 

Conclusion: Always works in the same scene.

Message 3 of 3
artgolf1000
in reply to: artgolf1000

The following code is from Robert Goulet:

Here is a sample code that demonstrate how to do it using the FBX SDK:

// Prepare the FBX SDK.
InitializeSdkObjects(lSdkManager, lScene);

// Load the scene.
lResult = LoadScene(lSdkManager, lScene, lInFile.Buffer());

// Get the mesh we want to clone (we assume it is the first node attribute connected to the node)
FbxNode* lNode = FbxCast<FbxNode>(lScene->FindSrcObject("pCylinder1"));
if (lNode)
{
// Get the mesh to clone as the FbxGeometry (all the methods we need to call are here so no 
// need to get the FbxMesh)
FbxGeometry* lsrc=FbxCast<FbxGeometry>(lNode->GetNodeAttribute());

// clone the mesh (and all its deformers. This is implicit and cannot be bypassed)
FbxGeometry* lClone = FbxCast<FbxGeometry>(lSrc->Clone(FbxObject::eDeepClone));

// But we can freely destroy the cloned deformers
for (int d = lClone->GetDeformerCount()-1; d >= 0; d--)
lClone->GetDeformer(d)->Destroy();

// and re-connect using the deformers from the source mesh
for (int d = 0; d < lSrc->GetDeformerCount(); d++)
lClone->AddDeformer(lSrc->GetDeformer(d));

// --- Done! ---
// From this point, it is simply to validate that we have a different cloned mesh
// still connected to the original deformers.

// change vertices positions of the cloned mesh
int nbCtrlPts = lClone->GetControlPointsCount();
FbxVector4* lCtrlPts = lClone->GetControlPoints();
for (int i = 0; i < nbCtrlPts; i++) lCtrlPts[i] *= 2.0;

FbxNode* lN1 = FbxNode::Create(lScene, "cloned");
lN1->AddNodeAttribute(lClone);
lScene->GetRootNode()->AddChild(lN1);
}

// Save the scene.
lResult = SaveScene(lSdkManager, lScene, lFilePath.Buffer(), ASCII);

// Destroy all objects created by the FBX SDK.
DestroySdkObjects(lSdkManager, lResult);

 

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

Post to forums  

Autodesk Design & Make Report