Updated the plugin to be compatible with version 2011.2 of the FBX SDK

This commit is contained in:
Michael PLATINGS 2010-04-14 16:43:50 +00:00
parent b6a5754127
commit d5fafcecbd
11 changed files with 134 additions and 120 deletions

View File

@ -92,7 +92,6 @@ public:
~CleanUpFbx()
{
KFbxIOSettings::IOSettingsRef().FreeIOSettings();
m_pSdkManager->Destroy();
}
};
@ -214,6 +213,8 @@ ReaderWriterFBX::readNode(const std::string& filenameInit,
CleanUpFbx cleanUpFbx(pSdkManager);
pSdkManager->SetIOSettings(KFbxIOSettings::Create(pSdkManager, IOSROOT));
KFbxScene* pScene = KFbxScene::Create(pSdkManager, "");
// The FBX SDK interprets the filename as UTF-8
@ -223,14 +224,9 @@ ReaderWriterFBX::readNode(const std::string& filenameInit,
std::string utf8filename(osgDB::convertStringFromCurrentCodePageToUTF8(filename));
#endif
int fileFormat;
if (!pSdkManager->GetIOPluginRegistry()->DetectFileFormat(utf8filename.c_str(), fileFormat))
{
return ReadResult::FILE_NOT_HANDLED;
}
KFbxImporter* lImporter = KFbxImporter::Create(pSdkManager, "");
if (!lImporter->Initialize(utf8filename.c_str(), fileFormat))
if (!lImporter->Initialize(utf8filename.c_str(), -1, pSdkManager->GetIOSettings()))
{
return std::string(lImporter->GetLastErrorString());
}
@ -291,7 +287,7 @@ ReaderWriterFBX::readNode(const std::string& filenameInit,
std::map<KFbxNode*, osg::Node*> nodeMap;
BindMatrixMap boneBindMatrices;
std::map<KFbxNode*, osgAnimation::Skeleton*> skeletonMap;
ReadResult res = readFbxNode(*pSdkManager, pNode, pAnimationManager,
ReadResult res = readFbxNode(*pSdkManager, *pScene, pNode, pAnimationManager,
bIsBone, nLightCount, fbxMaterialToOsgStateSet, nodeMap,
boneBindMatrices, fbxSkeletons, skeletonMap, *localOptions);
@ -407,6 +403,8 @@ osgDB::ReaderWriter::WriteResult ReaderWriterFBX::writeNode(
CleanUpFbx cleanUpFbx(pSdkManager);
pSdkManager->SetIOSettings(KFbxIOSettings::Create(pSdkManager, IOSROOT));
bool useFbxRoot = false;
if (options)
{
@ -416,9 +414,7 @@ osgDB::ReaderWriter::WriteResult ReaderWriterFBX::writeNode(
{
if (opt == "Embedded")
{
IOSREF.SetBoolProp(EXP_FBX_EMBEDDED, true);
if (KFbxIOSettings::IOSettingsRef().IsIOSettingsAllocated())
KFbxIOSettings::IOSettingsRef().AllocateIOSettings(*pSdkManager);
pSdkManager->GetIOSettings()->SetBoolProp(EXP_FBX_EMBEDDED, true);
}
else if (opt == "UseFbxRoot")
{

View File

@ -6,6 +6,7 @@
///////////////////////////////////////////////////////////////////////////
// OSG reader plugin for the ".fbx" format.
// See http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=6837478
// This plugin requires the FBX SDK version 2011.2
class ReaderWriterFBX : public osgDB::ReaderWriter
{

View File

@ -513,7 +513,7 @@ WriterNodeVisitor::setLayerTextureAndMaterial(KFbxMesh* mesh)
}
}
mesh->GetLayer(0)->SetMaterials(lMaterialLayer);
mesh->GetLayer(0)->SetDiffuseTextures(lTextureDiffuseLayer);
mesh->GetLayer(0)->SetTextures(KFbxLayerElement::eDIFFUSE_TEXTURES, lTextureDiffuseLayer);
}
void
@ -654,7 +654,7 @@ void WriterNodeVisitor::buildFaces(const osg::Geode& geo,
lLayer = mesh->GetLayer(0);
}
setLayerTextureAndMaterial(mesh);
lLayer->GetDiffuseTextures()->GetIndexArray().SetCount(listTriangles.size());
lLayer->GetTextures(KFbxLayerElement::eDIFFUSE_TEXTURES)->GetIndexArray().SetCount(listTriangles.size());
lLayer->GetMaterials()->GetIndexArray().SetCount(listTriangles.size());
unsigned int i = 0;
@ -667,7 +667,7 @@ void WriterNodeVisitor::buildFaces(const osg::Geode& geo,
else
{
mesh->BeginPolygon(i);
lLayer->GetDiffuseTextures()->GetIndexArray().SetAt(i, it->first.material);
lLayer->GetTextures(KFbxLayerElement::eDIFFUSE_TEXTURES)->GetIndexArray().SetAt(i, it->first.material);
lLayer->GetMaterials()->GetIndexArray().SetAt(i, it->first.material);
}
addPolygon(mesh, index_vert, it->first, it->second);
@ -721,13 +721,6 @@ void WriterNodeVisitor::apply(osg::Geode& node)
KFbxNode* nodeFBX = KFbxNode::Create(_pSdkManager, node.getName().empty() ? "DefaultName" : node.getName().c_str());
_curFbxNode->AddChild(nodeFBX);
_curFbxNode = nodeFBX;
if (false)
{
KFbxProperty lProperty = KFbxProperty::Create(_curFbxNode, "nameGeode", DTString, "label2");
std::ostringstream oss;
oss << node.getName().c_str() << ".metaData";
lProperty.Set(new KString(oss.str().c_str()), eSTRING);
}
unsigned int count = node.getNumDrawables();
ListTriangle listTriangles;
bool texcoords = false;
@ -760,13 +753,6 @@ void WriterNodeVisitor::apply(osg::Group& node)
KFbxNode* nodeFBX = KFbxNode::Create(_pSdkManager, node.getName().empty() ? "DefaultName" : node.getName().c_str());
_curFbxNode->AddChild(nodeFBX);
_curFbxNode = nodeFBX;
if (false)
{
KFbxProperty lProperty = KFbxProperty::Create(_curFbxNode, "nameGeode", DTString, "label2");
std::ostringstream oss;
oss << node.getName().c_str() << ".metaData";
lProperty.Set(new KString(oss.str().c_str()), eSTRING);
}
traverse(node);
_curFbxNode = parent;
}
@ -776,13 +762,6 @@ void WriterNodeVisitor::apply(osg::MatrixTransform& node)
KFbxNode* parent = _curFbxNode;
_curFbxNode = KFbxNode::Create(_pSdkManager, node.getName().empty() ? "DefaultName" : node.getName().c_str());
parent->AddChild(_curFbxNode);
if (false)
{
KFbxProperty lProperty = KFbxProperty::Create(_curFbxNode, "nameGeode", DTString, "label2");
std::ostringstream oss;
oss << node.getName().c_str() << ".metaData";
lProperty.Set(new KString(oss.str().c_str()), eSTRING);
}
const osg::Matrix& matrix = node.getMatrix();
osg::Vec3d pos, scl;

View File

@ -22,10 +22,11 @@ osg::Quat makeQuat(const osg::Vec3& radians, ERotationOrder fbxRotOrder)
return makeQuat(degrees, fbxRotOrder);
}
void readKeys(KFCurve* curveX, KFCurve* curveY, KFCurve* curveZ,
void readKeys(KFbxAnimCurve* curveX, KFbxAnimCurve* curveY, KFbxAnimCurve* curveZ,
const fbxDouble3& defaultValue,
std::vector<osgAnimation::TemplateKeyframe<osg::Vec3> >& keyFrameCntr, float scalar = 1.0f)
{
KFCurve* curves[3] = {curveX, curveY, curveZ};
KFbxAnimCurve* curves[3] = {curveX, curveY, curveZ};
typedef std::set<double> TimeSet;
typedef std::map<double, float> TimeFloatMap;
@ -34,19 +35,19 @@ void readKeys(KFCurve* curveX, KFCurve* curveY, KFCurve* curveZ,
for (int nCurve = 0; nCurve < 3; ++nCurve)
{
KFCurve* pCurve = curves[nCurve];
KFbxAnimCurve* pCurve = curves[nCurve];
int nKeys = pCurve->KeyGetCount();
int nKeys = pCurve ? pCurve->KeyGetCount() : 0;
if (!nKeys)
{
times.insert(0.0);
curveTimeMap[nCurve][0.0] = static_cast<float>(pCurve->GetValue()) * scalar;
curveTimeMap[nCurve][0.0] = defaultValue[nCurve] * scalar;
}
for (int i = 0; i < nKeys; ++i)
{
KFCurveKey key = pCurve->KeyGet(i);
KFbxAnimCurveKey key = pCurve->KeyGet(i);
double fTime = key.GetTime().GetSecondDouble();
times.insert(fTime);
curveTimeMap[nCurve][fTime] = static_cast<float>(key.GetValue()) * scalar;
@ -69,8 +70,10 @@ void readKeys(KFCurve* curveX, KFCurve* curveY, KFCurve* curveZ,
}
}
osgAnimation::Channel* readFbxChannels(KFCurve* curveX, KFCurve* curveY,
KFCurve* curveZ, const char* targetName, const char* channelName)
osgAnimation::Channel* readFbxChannels(KFbxAnimCurve* curveX, KFbxAnimCurve* curveY,
KFbxAnimCurve* curveZ,
const fbxDouble3& defaultValue,
const char* targetName, const char* channelName)
{
if (!(curveX && curveX->KeyGetCount()) &&
!(curveY && curveY->KeyGetCount()) &&
@ -85,27 +88,29 @@ osgAnimation::Channel* readFbxChannels(KFCurve* curveX, KFCurve* curveY,
pChannel->setTargetName(targetName);
pChannel->setName(channelName);
readKeys(curveX, curveY, curveZ, *pKeyFrameCntr);
readKeys(curveX, curveY, curveZ, defaultValue, *pKeyFrameCntr);
return pChannel;
}
osgAnimation::Channel* readFbxChannels(
KFbxTypedProperty<fbxDouble3>& fbxProp, const char* pTakeName,
KFbxTypedProperty<fbxDouble3>& fbxProp, KFbxAnimLayer* pAnimLayer,
const char* targetName, const char* channelName)
{
if (!fbxProp.IsValid()) return 0;
return readFbxChannels(
fbxProp.GetKFCurve("X", pTakeName),
fbxProp.GetKFCurve("Y", pTakeName),
fbxProp.GetKFCurve("Z", pTakeName),
fbxProp.GetCurve<KFbxAnimCurve>(pAnimLayer, "X"),
fbxProp.GetCurve<KFbxAnimCurve>(pAnimLayer, "Y"),
fbxProp.GetCurve<KFbxAnimCurve>(pAnimLayer, "Z"),
fbxProp.Get(),
targetName, channelName);
}
osgAnimation::Channel* readFbxChannelsQuat(
KFCurve* curveX, KFCurve* curveY, KFCurve* curveZ, const char* targetName,
ERotationOrder rotOrder)
KFbxAnimCurve* curveX, KFbxAnimCurve* curveY, KFbxAnimCurve* curveZ,
const fbxDouble3& defaultValue,
const char* targetName, ERotationOrder rotOrder)
{
if (!(curveX && curveX->KeyGetCount()) &&
!(curveY && curveY->KeyGetCount()) &&
@ -119,7 +124,7 @@ osgAnimation::Channel* readFbxChannelsQuat(
pChannel->setName("quaternion");
typedef std::vector<osgAnimation::TemplateKeyframe<osg::Vec3> > KeyFrameCntr;
KeyFrameCntr eulerFrameCntr;
readKeys(curveX, curveY, curveZ, eulerFrameCntr, static_cast<float>(osg::PI / 180.0));
readKeys(curveX, curveY, curveZ, defaultValue, eulerFrameCntr, static_cast<float>(osg::PI / 180.0));
osgAnimation::QuatSphericalLinearSampler::KeyframeContainerType& quatFrameCntr =
*pChannel->getOrCreateSampler()->getOrCreateKeyframeContainer();
@ -178,14 +183,9 @@ osgAnimation::Animation* addChannels(
}
osgAnimation::Animation* readFbxAnimation(KFbxNode* pNode,
const char* pTakeName, const char* targetName,
KFbxAnimLayer* pAnimLayer, const char* pTakeName, const char* targetName,
osg::ref_ptr<osgAnimation::AnimationManagerBase>& pAnimManager)
{
if (!pTakeName)
{
return 0;
}
ERotationOrder rotOrder = pNode->RotationOrder.IsValid() ? pNode->RotationOrder.Get() : eEULER_XYZ;
osgAnimation::Channel* pTranslationChannel = 0;
@ -196,40 +196,56 @@ osgAnimation::Animation* readFbxAnimation(KFbxNode* pNode,
fbxDouble3 fbxBaseValue = pNode->LclRotation.Get();
pRotationChannel = readFbxChannelsQuat(
pNode->LclRotation.GetKFCurve(KFCURVENODE_R_X, pTakeName),
pNode->LclRotation.GetKFCurve(KFCURVENODE_R_Y, pTakeName),
pNode->LclRotation.GetKFCurve(KFCURVENODE_R_Z, pTakeName),
pNode->LclRotation.GetCurve<KFbxAnimCurve>(pAnimLayer, KFCURVENODE_R_X),
pNode->LclRotation.GetCurve<KFbxAnimCurve>(pAnimLayer, KFCURVENODE_R_Y),
pNode->LclRotation.GetCurve<KFbxAnimCurve>(pAnimLayer, KFCURVENODE_R_Z),
pNode->LclRotation.Get(),
targetName, rotOrder);
}
if (pNode->LclTranslation.IsValid())
{
pTranslationChannel = readFbxChannels(
pNode->LclTranslation.GetKFCurve(KFCURVENODE_T_X, pTakeName),
pNode->LclTranslation.GetKFCurve(KFCURVENODE_T_Y, pTakeName),
pNode->LclTranslation.GetKFCurve(KFCURVENODE_T_Z, pTakeName),
pNode->LclTranslation.GetCurve<KFbxAnimCurve>(pAnimLayer, KFCURVENODE_T_X),
pNode->LclTranslation.GetCurve<KFbxAnimCurve>(pAnimLayer, KFCURVENODE_T_Y),
pNode->LclTranslation.GetCurve<KFbxAnimCurve>(pAnimLayer, KFCURVENODE_T_Z),
pNode->LclTranslation.Get(),
targetName, "translate");
}
osgAnimation::Channel* pScaleChannel = readFbxChannels(
pNode->LclScaling, pTakeName, targetName, "scale");
pNode->LclScaling, pAnimLayer, targetName, "scale");
return addChannels(pTranslationChannel, pRotationChannel, pScaleChannel, pAnimManager, pTakeName);
}
std::string readFbxAnimation(KFbxNode* pNode,
KFbxScene& fbxScene,
osg::ref_ptr<osgAnimation::AnimationManagerBase>& pAnimManager,
const char* targetName)
{
std::string result;
for (int i = 1; i < pNode->GetTakeNodeCount(); ++i)
{
const char* pTakeName = pNode->GetTakeNodeName(i);
if (osgAnimation::Animation* pAnimation = readFbxAnimation(
pNode, pTakeName, targetName, pAnimManager))
{
result = targetName;
}
for (int i = 0; i < fbxScene.GetSrcObjectCount(FBX_TYPE(KFbxAnimStack)); ++i)
{
KFbxAnimStack* pAnimStack = KFbxCast<KFbxAnimStack>(fbxScene.GetSrcObject(FBX_TYPE(KFbxAnimStack), i));
int nbAnimLayers = pAnimStack->GetMemberCount(FBX_TYPE(KFbxAnimLayer));
const char* pTakeName = pAnimStack->GetName();
if (!pTakeName || !*pTakeName)
continue;
for (int j = 0; j < nbAnimLayers; j++)
{
KFbxAnimLayer* pAnimLayer = pAnimStack->GetMember(FBX_TYPE(KFbxAnimLayer), j);
if (osgAnimation::Animation* pAnimation = readFbxAnimation(
pNode, pAnimLayer, pTakeName, targetName, pAnimManager))
{
result = targetName;
}
}
}
return result;
}

View File

@ -4,7 +4,8 @@
#include <fbxfilesdk/fbxfilesdk_def.h>
std::string readFbxAnimation(
FBXFILESDK_NAMESPACE::KFbxNode*,
KFbxNode*,
KFbxScene& fbxScene,
osg::ref_ptr<osgAnimation::AnimationManagerBase>&,
const char* targetName);

View File

@ -5,6 +5,6 @@
#include <osgDB/ReaderWriter>
osgDB::ReaderWriter::ReadResult readFbxCamera(
FBXFILESDK_NAMESPACE::KFbxNode* pNode);
KFbxNode* pNode);
#endif

View File

@ -5,6 +5,6 @@
#include <osgDB/ReaderWriter>
osgDB::ReaderWriter::ReadResult readFbxLight(
FBXFILESDK_NAMESPACE::KFbxNode* pNode, int& nLightCount);
KFbxNode* pNode, int& nLightCount);
#endif

View File

@ -239,42 +239,57 @@ void addChannel(
pAnimation->addChannel(pChannel);
}
void readAnimation(KFbxNode* pNode, const std::string& targetName,
void readAnimation(KFbxNode* pNode, KFbxScene& fbxScene, const std::string& targetName,
osg::ref_ptr<osgAnimation::AnimationManagerBase>& pAnimationManager,
KFbxMesh* pMesh, int nShape)
{
for (int i = 1; i < pNode->GetTakeNodeCount(); ++i)
for (int i = 0; i < fbxScene.GetSrcObjectCount(FBX_TYPE(KFbxAnimStack)); ++i)
{
KFbxAnimStack* pAnimStack = KFbxCast<KFbxAnimStack>(fbxScene.GetSrcObject(FBX_TYPE(KFbxAnimStack), i));
int nbAnimLayers = pAnimStack->GetMemberCount(FBX_TYPE(KFbxAnimLayer));
const char* pTakeName = pAnimStack->GetName();
if (!pTakeName || !*pTakeName)
continue;
for (int j = 0; j < nbAnimLayers; j++)
{
KFbxAnimLayer* pAnimLayer = pAnimStack->GetMember(FBX_TYPE(KFbxAnimLayer), j);
KFbxAnimCurve* pCurve = pMesh->GetShapeChannel(nShape, pAnimLayer);
if (!pCurve)
{
continue;
}
int nKeys = pCurve->KeyGetCount();
if (!nKeys)
{
continue;
}
osgAnimation::FloatLinearChannel* pChannel = new osgAnimation::FloatLinearChannel;
std::vector<osgAnimation::TemplateKeyframe<float> >& keyFrameCntr = *pChannel->getOrCreateSampler()->getOrCreateKeyframeContainer();
for (int k = 0; k < nKeys; ++k)
{
KFbxAnimCurveKey key = pCurve->KeyGet(k);
double fTime = key.GetTime().GetSecondDouble();
float fValue = static_cast<float>(key.GetValue() * 0.01);
keyFrameCntr.push_back(osgAnimation::FloatKeyframe(fTime,fValue));
}
pChannel->setTargetName(targetName);
std::stringstream ss;
ss << nShape;
pChannel->setName(ss.str());
addChannel(pChannel, pAnimationManager, pTakeName);
}
}
{
const char* pTakeName = pNode->GetTakeNodeName(i);
KFCurve* pCurve = pMesh->GetShapeChannel(nShape, false, pTakeName);
if (!pCurve)
{
continue;
}
int nKeys = pCurve->KeyGetCount();
if (!nKeys)
{
continue;
}
osgAnimation::FloatLinearChannel* pChannel = new osgAnimation::FloatLinearChannel;
std::vector<osgAnimation::TemplateKeyframe<float> >& keyFrameCntr = *pChannel->getOrCreateSampler()->getOrCreateKeyframeContainer();
for (int k = 0; k < nKeys; ++k)
{
KFCurveKey key = pCurve->KeyGet(k);
double fTime = key.GetTime().GetSecondDouble();
float fValue = static_cast<float>(key.GetValue() * 0.01);
keyFrameCntr.push_back(osgAnimation::FloatKeyframe(fTime,fValue));
}
pChannel->setTargetName(targetName);
std::stringstream ss;
ss << nShape;
pChannel->setName(ss.str());
addChannel(pChannel, pAnimationManager, pTakeName);
}
}
@ -334,6 +349,7 @@ void addColorArrayElement(osg::Array& a, const KFbxColor& c)
}
osgDB::ReaderWriter::ReadResult readMesh(KFbxSdkManager& pSdkManager,
KFbxScene& fbxScene,
KFbxNode* pNode, KFbxMesh* fbxMesh,
osg::ref_ptr<osgAnimation::AnimationManagerBase>& pAnimationManager,
std::vector<StateSetContent>& stateSetList,
@ -455,7 +471,7 @@ osgDB::ReaderWriter::ReadResult readMesh(KFbxSdkManager& pSdkManager,
}
}
for (int i = 0; i < pGeode->getNumDrawables(); ++i)
for (unsigned i = 0; i < pGeode->getNumDrawables(); ++i)
{
osg::Geometry* pGeometry = pGeode->getDrawable(i)->asGeometry();
if (pGeode->getNumDrawables() > 1)
@ -480,7 +496,7 @@ osgDB::ReaderWriter::ReadResult readMesh(KFbxSdkManager& pSdkManager,
osg::ref_ptr<osgAnimation::RigGeometry> > GeometryRigGeometryMap;
GeometryRigGeometryMap old2newGeometryMap;
for (int i = 0; i < pGeode->getNumDrawables(); ++i)
for (unsigned i = 0; i < pGeode->getNumDrawables(); ++i)
{
osg::Geometry* pGeometry = pGeode->getDrawable(i)->asGeometry();
@ -545,7 +561,7 @@ osgDB::ReaderWriter::ReadResult readMesh(KFbxSdkManager& pSdkManager,
}
else if (geomType == GEOMETRY_MORPH)
{
for (int i = 0; i < pGeode->getNumDrawables(); ++i)
for (unsigned i = 0; i < pGeode->getNumDrawables(); ++i)
{
osg::Geometry* pGeometry = pGeode->getDrawable(i)->asGeometry();
@ -579,7 +595,7 @@ osgDB::ReaderWriter::ReadResult readMesh(KFbxSdkManager& pSdkManager,
pMorphTarget->setName(fbxMesh->GetShapeName(j));
morph.addMorphTarget(pMorphTarget, 0.0f);
readAnimation(pNode, morph.getName(), pAnimationManager, fbxMesh, j);
readAnimation(pNode, fbxScene, morph.getName(), pAnimationManager, fbxMesh, j);
}
}
@ -686,6 +702,7 @@ osgDB::ReaderWriter::ReadResult readMesh(KFbxSdkManager& pSdkManager,
}
osgDB::ReaderWriter::ReadResult readFbxMesh(KFbxSdkManager& pSdkManager,
KFbxScene& fbxScene,
KFbxNode* pNode,
osg::ref_ptr<osgAnimation::AnimationManagerBase>& pAnimationManager,
std::vector<StateSetContent>& stateSetList,
@ -701,6 +718,6 @@ osgDB::ReaderWriter::ReadResult readFbxMesh(KFbxSdkManager& pSdkManager,
return osgDB::ReaderWriter::ReadResult::ERROR_IN_READING_FILE;
}
return readMesh(pSdkManager, pNode, lMesh, pAnimationManager, stateSetList,
return readMesh(pSdkManager, fbxScene, pNode, lMesh, pAnimationManager, stateSetList,
pNode->GetName(), boneBindMatrices, fbxSkeletons, skeletonMap, options);
}

View File

@ -6,8 +6,9 @@
#include <osg/Material>
#include "fbxRNode.h"
osgDB::ReaderWriter::ReadResult readFbxMesh(
FBXFILESDK_NAMESPACE::KFbxSdkManager& pSdkManager,
FBXFILESDK_NAMESPACE::KFbxNode* pNode,
KFbxSdkManager& pSdkManager,
KFbxScene& fbxScene,
KFbxNode* pNode,
osg::ref_ptr<osgAnimation::AnimationManagerBase>& pAnimationManager,
std::vector<StateSetContent>&,
BindMatrixMap& boneBindMatrices,

View File

@ -318,7 +318,9 @@ osg::Group* createGroupNode(KFbxSdkManager& pSdkManager, KFbxNode* pNode,
}
osgDB::ReaderWriter::ReadResult readFbxNode(
KFbxSdkManager& pSdkManager, KFbxNode* pNode,
KFbxSdkManager& pSdkManager,
KFbxScene& fbxScene,
KFbxNode* pNode,
osg::ref_ptr<osgAnimation::AnimationManagerBase>& pAnimationManager,
bool& bIsBone, int& nLightCount,
FbxMaterialToOsgStateSet& fbxMaterialToOsgStateSet,
@ -381,7 +383,7 @@ osgDB::ReaderWriter::ReadResult readFbxNode(
bool bChildIsBone = false;
osgDB::ReaderWriter::ReadResult childResult = readFbxNode(
pSdkManager, pChildNode, pAnimationManager,
pSdkManager, fbxScene, pChildNode, pAnimationManager,
bChildIsBone, nLightCount, fbxMaterialToOsgStateSet, nodeMap,
boneBindMatrices, fbxSkeletons, skeletonMap, options);
if (childResult.error())
@ -402,7 +404,7 @@ osgDB::ReaderWriter::ReadResult readFbxNode(
}
}
std::string animName = readFbxAnimation(pNode, pAnimationManager, pNode->GetName());
std::string animName = readFbxAnimation(pNode, fbxScene, pAnimationManager, pNode->GetName());
osg::Matrix localMatrix;
makeLocalMatrix(pNode, localMatrix);
@ -430,7 +432,7 @@ osgDB::ReaderWriter::ReadResult readFbxNode(
case KFbxNodeAttribute::eMESH:
{
size_t bindMatrixCount = boneBindMatrices.size();
osgDB::ReaderWriter::ReadResult meshRes = readFbxMesh(pSdkManager,
osgDB::ReaderWriter::ReadResult meshRes = readFbxMesh(pSdkManager, fbxScene,
pNode, pAnimationManager, stateSetList, boneBindMatrices,
fbxSkeletons, skeletonMap, options);
if (meshRes.error())

View File

@ -15,8 +15,9 @@ osgAnimation::Skeleton* getSkeleton(KFbxNode*,
std::map<KFbxNode*, osgAnimation::Skeleton*>&);
osgDB::ReaderWriter::ReadResult readFbxNode(
FBXFILESDK_NAMESPACE::KFbxSdkManager& pSdkManager,
FBXFILESDK_NAMESPACE::KFbxNode* pNode,
KFbxSdkManager& pSdkManager,
KFbxScene& fbxScene,
KFbxNode* pNode,
osg::ref_ptr<osgAnimation::AnimationManagerBase>& pAnimationManager,
bool& bIsBone,
int& nLightCount,