!XT (BREAK-16) (Sandbox) Remove double-newlines at the end of files.
[CRYENGINE.git] / Code / Sandbox / Plugins / MeshImporter / FbxUtil.cpp
blob91092099c6cf9f66653af8b5dd51e9590b9b7d1a
1 // Copyright 2001-2018 Crytek GmbH / Crytek Group. All rights reserved.
2 // Utilities for FbxTool.
3 #pragma once
5 #include "StdAfx.h"
6 #include "FbxUtil.h"
7 #include <algorithm>
9 namespace FbxTool
11 static const char* const kDefaultTextureName = "<anonymous>";
13 const char* const* GetSupportedFileExtensions(TIndex& numExtensions)
15 static const char* ppExtensions[] =
17 "fbx",
18 "dxf",
19 "dae",
20 "obj",
21 "3ds"
23 numExtensions = (TIndex)(sizeof(ppExtensions) / sizeof(*ppExtensions));
24 return ppExtensions;
27 string GetNodePath(FbxNode* pNode, const char* szLastName)
29 static const char kSeparator = '/';
30 const char szSeparator[] = { kSeparator, 0 };
31 const char szRootName[] = "<root>";
33 string result;
34 if (pNode != nullptr && !pNode->GetParent())
36 result = szRootName;
38 while (pNode != nullptr && pNode->GetParent() != nullptr)
40 string nodeDescription;
41 const char* const szName = pNode->GetName();
42 if (szName && szName[0])
44 nodeDescription = szName;
46 else
48 int nodeIndex = -1;
49 const FbxNode* const pParent = pNode->GetParent();
50 if (pParent)
52 const int numChildren = pParent->GetChildCount();
53 for (int i = 0; i < numChildren; ++i)
55 if (pParent->GetChild(i) == pNode)
57 nodeIndex = i;
58 break;
62 if (nodeIndex >= 0)
64 char szDescription[100];
65 std::sprintf(szDescription, "<node at index %d>", nodeIndex);
66 nodeDescription = szDescription;
68 else
70 nodeDescription = "<anonymous node>";
73 if (result.empty())
75 result.swap(nodeDescription);
77 else
79 result = nodeDescription + szSeparator + result;
81 pNode = pNode->GetParent();
83 if (result.empty())
85 result = "<null>";
87 if (szLastName && szLastName[0])
89 result = result + szSeparator + szLastName;
91 return result;