I have a fbx with embeded textures which some are unless. I want to remove them from fbx to reduce the size.
Case One: some textures are not referenced by nay materials. How to find them out and remove it?
Case Tow: remove the fbx node with relevant material and textures. I use `fbxnode.DisconnectAllDstObject` and `fbxnode.DisconnectAllSrcObject` but those methods seem not work
Thanks!
Solved! Go to Solution.
Solved by regalir. Go to Solution.
Hi,
One solution for your case 1: can be:
FbxArray<FbxObject*> candidate_to_destroy;
for (int t = 0, count = lScene->GetSrcObjectCount<FbxTexture>(); t < count; t++)
{
FbxTexture* tex = lScene->GetSrcObject<FbxTexture>(t);
if (tex->GetDstPropertyCount() == 0)
{
candidate_to_destroy.Add(tex);
// the Texture object is not connected to any property
// Now get all the connected FbxVideo objects
for (int v = 0, vcount = tex->GetSrcObjectCount<FbxVideo>(); v < vcount; v++)
{
FbxVideo* vid = tex->GetSrcObject<FbxVideo>(v);
FbxObject* d1 = NULL;
FbxObject* d2 = NULL;
bool cant_delete = false;
switch (vid->GetDstObjectCount())
{
case 2:
d2 = vid->GetDstObject(1);
case 1:
d1 = vid->GetDstObject(0);
break;
default:
cant_delete = true;
}
if (cant_delete)
continue;
// make sure the only 2 destination connections are to the scene and tex
if ((d1 == tex && (d2 == NULL || d2 == lScene)) || (d1 == lScene && d2 == tex))
{
candidate_to_destroy.Add(vid);
}
}
}
}
for (int i = 0; i < candidate_to_destroy.GetCount(); i++)
{
candidate_to_destroy[i]->Destroy();
}
remark that the same approach can also be applied for FbxSurfaceMaterials (or almost any other type of objects), the general idea when you want to remove objects from the scene is to make sure there are no other connections to it. The Destroy() method takes care of disconnecting and, when possible, automatically delete other connected objects. (for example: when destroying an FbxNode, the FbxMesh connected to it will also be destroyed if it its last reference). An FbxSurfaceMaterial however, because it is most likely shared by several objects is only disconnected.
For case 2: you can simply do:
node->Destroy();
to remove the FbxNode from the scene and then use a similar loop as above to find "orphan" materials (meaning that they don't have multiple connections anymore). Note that FbxObjects often have a DstConnection to the scene as well as connections to other objects.
Hope this helped!
Thank You for giving this topic
In 1996, Kaydara released a new native file format with Filmbox 1.5 called FBX, which used an object-based model, allowing for the storing of action, along with 2D, 3D, audio, and video data. The format saw wider hold up from other 3D software packages such as Cinema 4D, Softimage, Power Animator, LightWave, 3D Studio MAX, and Turbo CAD.
Muslin Kurti Manufacturers | Palazzo Manufacturers | Festival Kurti Manufacturers | Kurti Manufacturers | Chanderi Salwar Suit Manufacturers
Can't find what you're looking for? Ask the community or share your knowledge.