|
|
@@ -1,5 +1,3 @@
|
|
|
-#ifdef USE_FBX
|
|
|
-
|
|
|
#include <algorithm>
|
|
|
#include <string>
|
|
|
#include <sstream>
|
|
|
@@ -14,6 +12,9 @@ using std::vector;
|
|
|
using std::map;
|
|
|
using std::ostringstream;
|
|
|
|
|
|
+// Fix bad material names
|
|
|
+static void fixMaterialName(string& name);
|
|
|
+
|
|
|
FBXSceneEncoder::FBXSceneEncoder()
|
|
|
: _groupAnimation(NULL), _autoGroupAnimations(false)
|
|
|
{
|
|
|
@@ -60,11 +61,8 @@ void FBXSceneEncoder::write(const string& filepath, const EncoderArguments& argu
|
|
|
|
|
|
print("Loading Scene.");
|
|
|
loadScene(fbxScene);
|
|
|
- if (arguments.outputMaterialEnabled())
|
|
|
- {
|
|
|
- print("Load materials");
|
|
|
- loadMaterials(fbxScene);
|
|
|
- }
|
|
|
+ print("Load materials");
|
|
|
+ loadMaterials(fbxScene);
|
|
|
print("Loading animations.");
|
|
|
loadAnimations(fbxScene, arguments);
|
|
|
sdkManager->Destroy();
|
|
|
@@ -913,25 +911,6 @@ void FBXSceneEncoder::loadMaterials(FbxScene* fbxScene)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// Fix bad material names
|
|
|
-void fixMaterialName(string& name)
|
|
|
-{
|
|
|
- static int unnamedCount = 0;
|
|
|
-
|
|
|
- for (string::size_type i = 0, len = name.length(); i < len; ++i)
|
|
|
- {
|
|
|
- if (!isalnum(name[i]))
|
|
|
- name[i] = '_';
|
|
|
- }
|
|
|
-
|
|
|
- if (name.length() == 0)
|
|
|
- {
|
|
|
- ostringstream stream;
|
|
|
- stream << "unnamed_" << (++unnamedCount);
|
|
|
- name = stream.str();
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
void FBXSceneEncoder::loadMaterial(FbxNode* fbxNode)
|
|
|
{
|
|
|
Node* node = findNode(fbxNode);
|
|
|
@@ -952,7 +931,16 @@ void FBXSceneEncoder::loadMaterial(FbxNode* fbxNode)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- material = createMaterial(materialName, fbxMaterial, node);
|
|
|
+ if (EncoderArguments::getInstance()->outputMaterialEnabled())
|
|
|
+ {
|
|
|
+ material = createMaterial(materialName, fbxMaterial, node);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // If outputMaterialEnabled() is not enabled then only create the materials for the purpose of writing
|
|
|
+ // the material name in the GPB file. There is no need to load uniforms and samplers for the material.
|
|
|
+ material = new Material(materialName);
|
|
|
+ }
|
|
|
_materials[materialName] = material;
|
|
|
}
|
|
|
|
|
|
@@ -1381,4 +1369,22 @@ void FBXSceneEncoder::triangulateRecursive(FbxNode* fbxNode)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#endif
|
|
|
+// Functions
|
|
|
+
|
|
|
+void fixMaterialName(string& name)
|
|
|
+{
|
|
|
+ static int unnamedCount = 0;
|
|
|
+
|
|
|
+ for (string::size_type i = 0, len = name.length(); i < len; ++i)
|
|
|
+ {
|
|
|
+ if (!isalnum(name[i]))
|
|
|
+ name[i] = '_';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (name.length() == 0)
|
|
|
+ {
|
|
|
+ ostringstream stream;
|
|
|
+ stream << "unnamed_" << (++unnamedCount);
|
|
|
+ name = stream.str();
|
|
|
+ }
|
|
|
+}
|