Updated FBX SDK to 2017.0.1
This commit is contained in:
@@ -47,7 +47,7 @@ KRAnimationLayer *LoadAnimationLayer(KRContext &context, FbxAnimLayer *pAnimLaye
|
|||||||
void LoadNode(FbxScene* pFbxScene, KRNode *parent_node, FbxGeometryConverter *pGeometryConverter, FbxNode* pNode);
|
void LoadNode(FbxScene* pFbxScene, KRNode *parent_node, FbxGeometryConverter *pGeometryConverter, FbxNode* pNode);
|
||||||
//void BakeNode(KFbxNode* pNode);
|
//void BakeNode(KFbxNode* pNode);
|
||||||
void LoadMaterial(KRContext &context, FbxSurfaceMaterial *pMaterial);
|
void LoadMaterial(KRContext &context, FbxSurfaceMaterial *pMaterial);
|
||||||
void LoadMesh(KRContext &context, FbxScene* pFbxScene, FbxGeometryConverter *pGeometryConverter, FbxMesh* pSourceMesh);
|
void LoadMesh(KRContext &context, FbxScene* pFbxScene, FbxGeometryConverter *pGeometryConverter, FbxMesh* pMesh);
|
||||||
KRNode *LoadMesh(KRNode *parent_node, FbxScene* pFbxScene, FbxGeometryConverter *pGeometryConverter, FbxNode* pNode);
|
KRNode *LoadMesh(KRNode *parent_node, FbxScene* pFbxScene, FbxGeometryConverter *pGeometryConverter, FbxNode* pNode);
|
||||||
KRNode *LoadLight(KRNode *parent_node, FbxNode* pNode);
|
KRNode *LoadLight(KRNode *parent_node, FbxNode* pNode);
|
||||||
KRNode *LoadSkeleton(KRNode *parent_node, FbxScene* pScene, FbxNode* pNode);
|
KRNode *LoadSkeleton(KRNode *parent_node, FbxScene* pScene, FbxNode* pNode);
|
||||||
@@ -114,6 +114,9 @@ void KRResource::LoadFbx(KRContext &context, const std::string& path)
|
|||||||
|
|
||||||
// Load the scene.
|
// Load the scene.
|
||||||
lResult = LoadScene(lSdkManager, pFbxScene, path.c_str());
|
lResult = LoadScene(lSdkManager, pFbxScene, path.c_str());
|
||||||
|
|
||||||
|
// Triangulate the scene.
|
||||||
|
lResult = pGeometryConverter->Triangulate(pFbxScene, true);
|
||||||
|
|
||||||
FbxNode* pNode = pFbxScene->GetRootNode();
|
FbxNode* pNode = pFbxScene->GetRootNode();
|
||||||
|
|
||||||
@@ -216,7 +219,7 @@ void InitializeSdkObjects(FbxManager*& pSdkManager, FbxScene*& pScene)
|
|||||||
|
|
||||||
// Load plugins from the executable directory
|
// Load plugins from the executable directory
|
||||||
FbxString lPath = FbxGetApplicationDirectory();
|
FbxString lPath = FbxGetApplicationDirectory();
|
||||||
#if TARGET_OS_WIN32
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
FbxString lExtension = "dll";
|
FbxString lExtension = "dll";
|
||||||
#elif TARGET_OS_MAC
|
#elif TARGET_OS_MAC
|
||||||
FbxString lExtension = "dylib";
|
FbxString lExtension = "dylib";
|
||||||
@@ -1182,21 +1185,19 @@ void LoadMaterial(KRContext &context, FbxSurfaceMaterial *pMaterial) {
|
|||||||
KRContext::Log(KRContext::LOG_LEVEL_WARNING, "Unable to convert material: %s", pMaterial->GetName());
|
KRContext::Log(KRContext::LOG_LEVEL_WARNING, "Unable to convert material: %s", pMaterial->GetName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FbxProperty pProperty;
|
FbxProperty pProperty;
|
||||||
|
|
||||||
// Diffuse Map Texture
|
// Diffuse Map Texture
|
||||||
pProperty = pMaterial->FindProperty(FbxSurfaceMaterial::sDiffuse);
|
pProperty = pMaterial->FindProperty(FbxSurfaceMaterial::sDiffuse);
|
||||||
if(pProperty.GetSrcObjectCount(FbxLayeredTexture::ClassId) > 0) {
|
if(pProperty.GetSrcObjectCount(FbxCriteria::ObjectType(FbxLayeredTexture::ClassId)) > 0) {
|
||||||
KRContext::Log(KRContext::LOG_LEVEL_WARNING, "Layered textures not supported.");
|
KRContext::Log(KRContext::LOG_LEVEL_WARNING, "Layered textures not supported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
int texture_count = pProperty.GetSrcObjectCount(FbxTexture::ClassId);
|
int texture_count = pProperty.GetSrcObjectCount(FbxCriteria::ObjectType(FbxTexture::ClassId));
|
||||||
if(texture_count > 1) {
|
if(texture_count > 1) {
|
||||||
KRContext::Log(KRContext::LOG_LEVEL_WARNING, "Multiple diffuse textures not supported.");
|
KRContext::Log(KRContext::LOG_LEVEL_WARNING, "Multiple diffuse textures not supported.");
|
||||||
} else if(texture_count == 1) {
|
} else if(texture_count == 1) {
|
||||||
FbxTexture* pTexture = FbxCast <FbxTexture> (pProperty.GetSrcObject(FbxTexture::ClassId,0));
|
FbxTexture* pTexture = FbxCast <FbxTexture> (pProperty.GetSrcObject(FbxCriteria::ObjectType(FbxTexture::ClassId),0));
|
||||||
assert(!pTexture->GetSwapUV());
|
assert(!pTexture->GetSwapUV());
|
||||||
assert(pTexture->GetCroppingTop() == 0);
|
assert(pTexture->GetCroppingTop() == 0);
|
||||||
assert(pTexture->GetCroppingLeft() == 0);
|
assert(pTexture->GetCroppingLeft() == 0);
|
||||||
@@ -1217,14 +1218,14 @@ void LoadMaterial(KRContext &context, FbxSurfaceMaterial *pMaterial) {
|
|||||||
|
|
||||||
// Specular Map Texture
|
// Specular Map Texture
|
||||||
pProperty = pMaterial->FindProperty(FbxSurfaceMaterial::sSpecular);
|
pProperty = pMaterial->FindProperty(FbxSurfaceMaterial::sSpecular);
|
||||||
if(pProperty.GetSrcObjectCount(FbxLayeredTexture::ClassId) > 0) {
|
if(pProperty.GetSrcObjectCount(FbxCriteria::ObjectType(FbxLayeredTexture::ClassId)) > 0) {
|
||||||
KRContext::Log(KRContext::LOG_LEVEL_INFORMATION, "Layered textures not supported.");
|
KRContext::Log(KRContext::LOG_LEVEL_INFORMATION, "Layered textures not supported.");
|
||||||
}
|
}
|
||||||
texture_count = pProperty.GetSrcObjectCount(FbxTexture::ClassId);
|
texture_count = pProperty.GetSrcObjectCount(FbxCriteria::ObjectType(FbxTexture::ClassId));
|
||||||
if(texture_count > 1) {
|
if(texture_count > 1) {
|
||||||
KRContext::Log(KRContext::LOG_LEVEL_INFORMATION, "Multiple specular textures not supported.");
|
KRContext::Log(KRContext::LOG_LEVEL_INFORMATION, "Multiple specular textures not supported.");
|
||||||
} else if(texture_count == 1) {
|
} else if(texture_count == 1) {
|
||||||
FbxTexture* pTexture = FbxCast <FbxTexture> (pProperty.GetSrcObject(FbxTexture::ClassId,0));
|
FbxTexture* pTexture = FbxCast <FbxTexture> (pProperty.GetSrcObject(FbxCriteria::ObjectType(FbxTexture::ClassId),0));
|
||||||
FbxFileTexture *pFileTexture = FbxCast<FbxFileTexture>(pTexture);
|
FbxFileTexture *pFileTexture = FbxCast<FbxFileTexture>(pTexture);
|
||||||
if(pFileTexture) {
|
if(pFileTexture) {
|
||||||
new_material->setSpecularMap(KRResource::GetFileBase(pFileTexture->GetFileName()), KRVector2(pTexture->GetScaleU(), pTexture->GetScaleV()), KRVector2(pTexture->GetTranslationU(), pTexture->GetTranslationV()));
|
new_material->setSpecularMap(KRResource::GetFileBase(pFileTexture->GetFileName()), KRVector2(pTexture->GetScaleU(), pTexture->GetScaleV()), KRVector2(pTexture->GetTranslationU(), pTexture->GetTranslationV()));
|
||||||
@@ -1233,7 +1234,7 @@ void LoadMaterial(KRContext &context, FbxSurfaceMaterial *pMaterial) {
|
|||||||
|
|
||||||
// Normal Map Texture
|
// Normal Map Texture
|
||||||
pProperty = pMaterial->FindProperty(FbxSurfaceMaterial::sNormalMap);
|
pProperty = pMaterial->FindProperty(FbxSurfaceMaterial::sNormalMap);
|
||||||
if(pProperty.GetSrcObjectCount(FbxLayeredTexture::ClassId) > 0) {
|
if(pProperty.GetSrcObjectCount(FbxCriteria::ObjectType(FbxLayeredTexture::ClassId)) > 0) {
|
||||||
KRContext::Log(KRContext::LOG_LEVEL_INFORMATION, "Layered textures not supported.");
|
KRContext::Log(KRContext::LOG_LEVEL_INFORMATION, "Layered textures not supported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1260,9 +1261,7 @@ void LoadMaterial(KRContext &context, FbxSurfaceMaterial *pMaterial) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void LoadMesh(KRContext &context, FbxScene* pFbxScene, FbxGeometryConverter *pGeometryConverter, FbxMesh* pSourceMesh) {
|
void LoadMesh(KRContext &context, FbxScene* pFbxScene, FbxGeometryConverter *pGeometryConverter, FbxMesh* pMesh) {
|
||||||
FbxMesh* pMesh = pGeometryConverter->TriangulateMesh(pSourceMesh);
|
|
||||||
|
|
||||||
KRMesh::mesh_info mi;
|
KRMesh::mesh_info mi;
|
||||||
mi.format = KRMesh::KRENGINE_MODEL_FORMAT_TRIANGLES;
|
mi.format = KRMesh::KRENGINE_MODEL_FORMAT_TRIANGLES;
|
||||||
|
|
||||||
@@ -1378,7 +1377,7 @@ void LoadMesh(KRContext &context, FbxScene* pFbxScene, FbxGeometryConverter *pGe
|
|||||||
int normal_count = pMesh->GetElementNormalCount();
|
int normal_count = pMesh->GetElementNormalCount();
|
||||||
int tangent_count = pMesh->GetElementTangentCount();
|
int tangent_count = pMesh->GetElementTangentCount();
|
||||||
int elementmaterial_count = pMesh->GetElementMaterialCount();
|
int elementmaterial_count = pMesh->GetElementMaterialCount();
|
||||||
int material_count = pSourceMesh->GetNode()->GetMaterialCount(); // FINDME, TODO - To support instancing, material names should be stored in the instance rather than the mesh
|
int material_count = pMesh->GetNode()->GetMaterialCount(); // FINDME, TODO - To support instancing, material names should be stored in the instance rather than the mesh
|
||||||
|
|
||||||
// std::vector<std::vector<float> > bone_weights;
|
// std::vector<std::vector<float> > bone_weights;
|
||||||
// std::vector<std::vector<int> > bone_indexes;
|
// std::vector<std::vector<int> > bone_indexes;
|
||||||
@@ -1397,7 +1396,7 @@ void LoadMesh(KRContext &context, FbxScene* pFbxScene, FbxGeometryConverter *pGe
|
|||||||
bool need_tangents = false;
|
bool need_tangents = false;
|
||||||
|
|
||||||
for(int iMaterial=0; iMaterial < material_count; iMaterial++) {
|
for(int iMaterial=0; iMaterial < material_count; iMaterial++) {
|
||||||
FbxSurfaceMaterial *pMaterial = pSourceMesh->GetNode()->GetMaterial(iMaterial);
|
FbxSurfaceMaterial *pMaterial = pMesh->GetNode()->GetMaterial(iMaterial);
|
||||||
|
|
||||||
KRMaterial *material = context.getMaterialManager()->getMaterial(pMaterial->GetName());
|
KRMaterial *material = context.getMaterialManager()->getMaterial(pMaterial->GetName());
|
||||||
if(material) {
|
if(material) {
|
||||||
@@ -1541,7 +1540,7 @@ void LoadMesh(KRContext &context, FbxScene* pFbxScene, FbxGeometryConverter *pGe
|
|||||||
|
|
||||||
delete control_point_weights;
|
delete control_point_weights;
|
||||||
|
|
||||||
KRMesh *new_mesh = new KRMesh(context, pSourceMesh->GetNode()->GetName());
|
KRMesh *new_mesh = new KRMesh(context, pMesh->GetNode()->GetName());
|
||||||
new_mesh->LoadData(mi, true, need_tangents);
|
new_mesh->LoadData(mi, true, need_tangents);
|
||||||
|
|
||||||
context.getMeshManager()->addModel(new_mesh);
|
context.getMeshManager()->addModel(new_mesh);
|
||||||
|
|||||||
@@ -110,12 +110,12 @@
|
|||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)3rdparty\glew\glew-1.13.0\include;F:\boost\boost_1_61_0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)3rdparty\glew\glew-1.13.0\include;F:\boost\boost_1_61_0;c:\Program Files\Autodesk\FBX\FBX SDK\2017.0.1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)3rdparty\glew\glew-1.13.0\include;F:\boost\boost_1_61_0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)3rdparty\glew\glew-1.13.0\include;F:\boost\boost_1_61_0;c:\Program Files\Autodesk\FBX\FBX SDK\2017.0.1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user