From Laurens Voerman, "Autodesk released a new version of their FBX Software Development Kit (web page http://usa.autodesk.com/adsk/servlet/pc/item?siteID=123112&id=10775847).
The API has changed quite a bit, so lots of changes had to be made in the osg readerwriter. The preious version of the FBX SDK (2013.3) already deprecated a lot of the names and functions. The code I submit now still compiles against 2013.3 (possibly needs a #define FBX_NEW_API). Not sure if that's useful, but it might ease the transition."
This commit is contained in:
@@ -33,7 +33,7 @@ enum GeometryType
|
||||
GEOMETRY_MORPH
|
||||
};
|
||||
|
||||
osg::Vec3d convertVec3(const KFbxVector4& v)
|
||||
osg::Vec3d convertVec3(const FbxVector4& v)
|
||||
{
|
||||
return osg::Vec3d(
|
||||
v[0],
|
||||
@@ -42,16 +42,16 @@ osg::Vec3d convertVec3(const KFbxVector4& v)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool layerElementValid(const KFbxLayerElementTemplate<T>* pLayerElement)
|
||||
bool layerElementValid(const FbxLayerElementTemplate<T>* pLayerElement)
|
||||
{
|
||||
if (!pLayerElement)
|
||||
return false;
|
||||
|
||||
switch (pLayerElement->GetMappingMode())
|
||||
{
|
||||
case KFbxLayerElement::eBY_CONTROL_POINT:
|
||||
case KFbxLayerElement::eBY_POLYGON_VERTEX:
|
||||
case KFbxLayerElement::eBY_POLYGON:
|
||||
case FbxLayerElement::eByControlPoint:
|
||||
case FbxLayerElement::eByPolygonVertex:
|
||||
case FbxLayerElement::eByPolygon:
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
@@ -59,8 +59,8 @@ bool layerElementValid(const KFbxLayerElementTemplate<T>* pLayerElement)
|
||||
|
||||
switch (pLayerElement->GetReferenceMode())
|
||||
{
|
||||
case KFbxLayerElement::eDIRECT:
|
||||
case KFbxLayerElement::eINDEX_TO_DIRECT:
|
||||
case FbxLayerElement::eDirect:
|
||||
case FbxLayerElement::eIndexToDirect:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
@@ -70,28 +70,28 @@ bool layerElementValid(const KFbxLayerElementTemplate<T>* pLayerElement)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int getVertexIndex(const KFbxLayerElementTemplate<T>* pLayerElement,
|
||||
const KFbxMesh* fbxMesh,
|
||||
int getVertexIndex(const FbxLayerElementTemplate<T>* pLayerElement,
|
||||
const FbxMesh* fbxMesh,
|
||||
int nPolygon, int nPolyVertex, int nMeshVertex)
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
switch (pLayerElement->GetMappingMode())
|
||||
{
|
||||
case KFbxLayerElement::eBY_CONTROL_POINT:
|
||||
case FbxLayerElement::eByControlPoint:
|
||||
index = fbxMesh->GetPolygonVertex(nPolygon, nPolyVertex);
|
||||
break;
|
||||
case KFbxLayerElement::eBY_POLYGON_VERTEX:
|
||||
case FbxLayerElement::eByPolygonVertex:
|
||||
index = nMeshVertex;
|
||||
break;
|
||||
case KFbxLayerElement::eBY_POLYGON:
|
||||
case FbxLayerElement::eByPolygon:
|
||||
index = nPolygon;
|
||||
break;
|
||||
default:
|
||||
OSG_WARN << "getVertexIndex: unsupported FBX mapping mode" << std::endl;
|
||||
}
|
||||
|
||||
if (pLayerElement->GetReferenceMode() == KFbxLayerElement::eDIRECT)
|
||||
if (pLayerElement->GetReferenceMode() == FbxLayerElement::eDirect)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
@@ -100,16 +100,16 @@ int getVertexIndex(const KFbxLayerElementTemplate<T>* pLayerElement,
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int getPolygonIndex(const KFbxLayerElementTemplate<T>* pLayerElement, int nPolygon)
|
||||
int getPolygonIndex(const FbxLayerElementTemplate<T>* pLayerElement, int nPolygon)
|
||||
{
|
||||
if (pLayerElement &&
|
||||
pLayerElement->GetMappingMode() == KFbxLayerElement::eBY_POLYGON)
|
||||
pLayerElement->GetMappingMode() == FbxLayerElement::eByPolygon)
|
||||
{
|
||||
switch (pLayerElement->GetReferenceMode())
|
||||
{
|
||||
case KFbxLayerElement::eDIRECT:
|
||||
case FbxLayerElement::eDirect:
|
||||
return nPolygon;
|
||||
case KFbxLayerElement::eINDEX_TO_DIRECT:
|
||||
case FbxLayerElement::eIndexToDirect:
|
||||
return pLayerElement->GetIndexArray().GetAt(nPolygon);
|
||||
default:
|
||||
break;
|
||||
@@ -120,8 +120,8 @@ int getPolygonIndex(const KFbxLayerElementTemplate<T>* pLayerElement, int nPolyg
|
||||
}
|
||||
|
||||
template <typename FbxT>
|
||||
FbxT getElement(const KFbxLayerElementTemplate<FbxT>* pLayerElement,
|
||||
const KFbxMesh* fbxMesh,
|
||||
FbxT getElement(const FbxLayerElementTemplate<FbxT>* pLayerElement,
|
||||
const FbxMesh* fbxMesh,
|
||||
int nPolygon, int nPolyVertex, int nMeshVertex)
|
||||
{
|
||||
return pLayerElement->GetDirectArray().GetAt(getVertexIndex(
|
||||
@@ -361,15 +361,15 @@ void addChannel(
|
||||
pAnimation->addChannel(pChannel);
|
||||
}
|
||||
|
||||
void readAnimation(KFbxNode* pNode, KFbxScene& fbxScene, const std::string& targetName,
|
||||
void readAnimation(FbxNode* pNode, FbxScene& fbxScene, const std::string& targetName,
|
||||
osg::ref_ptr<osgAnimation::AnimationManagerBase>& pAnimationManager,
|
||||
KFbxMesh* pMesh, int nBlendShape, int nBlendShapeChannel, int nShape)
|
||||
FbxMesh* pMesh, int nBlendShape, int nBlendShapeChannel, int nShape)
|
||||
{
|
||||
for (int i = 0; i < fbxScene.GetSrcObjectCount(FBX_TYPE(KFbxAnimStack)); ++i)
|
||||
for (int i = 0; i < fbxScene.GetSrcObjectCount<FbxAnimStack>(); ++i)
|
||||
{
|
||||
KFbxAnimStack* pAnimStack = KFbxCast<KFbxAnimStack>(fbxScene.GetSrcObject(FBX_TYPE(KFbxAnimStack), i));
|
||||
FbxAnimStack* pAnimStack = FbxCast<FbxAnimStack>(fbxScene.GetSrcObject<FbxAnimStack>(i));
|
||||
|
||||
int nbAnimLayers = pAnimStack->GetMemberCount(FBX_TYPE(KFbxAnimLayer));
|
||||
int nbAnimLayers = pAnimStack->GetMemberCount<FbxAnimLayer>();
|
||||
|
||||
const char* pTakeName = pAnimStack->GetName();
|
||||
|
||||
@@ -378,9 +378,9 @@ void readAnimation(KFbxNode* pNode, KFbxScene& fbxScene, const std::string& targ
|
||||
|
||||
for (int j = 0; j < nbAnimLayers; j++)
|
||||
{
|
||||
KFbxAnimLayer* pAnimLayer = pAnimStack->GetMember(FBX_TYPE(KFbxAnimLayer), j);
|
||||
FbxAnimLayer* pAnimLayer = pAnimStack->GetMember<FbxAnimLayer>(j);
|
||||
|
||||
KFbxAnimCurve* pCurve = pMesh->GetShapeChannel(nBlendShape, nBlendShapeChannel, pAnimLayer, false);
|
||||
FbxAnimCurve* pCurve = pMesh->GetShapeChannel(nBlendShape, nBlendShapeChannel, pAnimLayer, false);
|
||||
|
||||
if (!pCurve)
|
||||
{
|
||||
@@ -398,7 +398,7 @@ void readAnimation(KFbxNode* pNode, KFbxScene& fbxScene, const std::string& targ
|
||||
|
||||
for (int k = 0; k < nKeys; ++k)
|
||||
{
|
||||
KFbxAnimCurveKey key = pCurve->KeyGet(k);
|
||||
FbxAnimCurveKey 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));
|
||||
@@ -415,7 +415,7 @@ void readAnimation(KFbxNode* pNode, KFbxScene& fbxScene, const std::string& targ
|
||||
|
||||
void addBindMatrix(
|
||||
BindMatrixMap& boneBindMatrices,
|
||||
KFbxNode* pBone,
|
||||
FbxNode* pBone,
|
||||
const osg::Matrix& bindMatrix,
|
||||
osgAnimation::RigGeometry* pRigGeometry)
|
||||
{
|
||||
@@ -423,7 +423,7 @@ void addBindMatrix(
|
||||
BindMatrixMap::key_type(pBone, pRigGeometry), bindMatrix));
|
||||
}
|
||||
|
||||
void addVec2ArrayElement(osg::Array& a, const KFbxVector2& v)
|
||||
void addVec2ArrayElement(osg::Array& a, const FbxVector2& v)
|
||||
{
|
||||
if (a.getType() == osg::Array::Vec2dArrayType)
|
||||
{
|
||||
@@ -437,7 +437,7 @@ void addVec2ArrayElement(osg::Array& a, const KFbxVector2& v)
|
||||
}
|
||||
}
|
||||
|
||||
void addVec3ArrayElement(osg::Array& a, const KFbxVector4& v)
|
||||
void addVec3ArrayElement(osg::Array& a, const FbxVector4& v)
|
||||
{
|
||||
if (a.getType() == osg::Array::Vec3dArrayType)
|
||||
{
|
||||
@@ -452,7 +452,7 @@ void addVec3ArrayElement(osg::Array& a, const KFbxVector4& v)
|
||||
}
|
||||
}
|
||||
|
||||
void addColorArrayElement(osg::Array& a, const KFbxColor& c)
|
||||
void addColorArrayElement(osg::Array& a, const FbxColor& c)
|
||||
{
|
||||
if (a.getType() == osg::Array::Vec4dArrayType)
|
||||
{
|
||||
@@ -475,13 +475,13 @@ std::string getUVChannelForTextureMap(std::vector<StateSetContent>& stateSetList
|
||||
// TODO: what if more than one channel for the same map type?
|
||||
for (unsigned int i = 0; i < stateSetList.size(); i++)
|
||||
{
|
||||
if (0 == strcmp(pName, KFbxSurfaceMaterial::sDiffuse))
|
||||
if (0 == strcmp(pName, FbxSurfaceMaterial::sDiffuse))
|
||||
return stateSetList[i].diffuseChannel;
|
||||
if (0 == strcmp(pName, KFbxSurfaceMaterial::sTransparentColor))
|
||||
if (0 == strcmp(pName, FbxSurfaceMaterial::sTransparentColor))
|
||||
return stateSetList[i].opacityChannel;
|
||||
if (0 == strcmp(pName, KFbxSurfaceMaterial::sReflection))
|
||||
if (0 == strcmp(pName, FbxSurfaceMaterial::sReflection))
|
||||
return stateSetList[i].reflectionChannel;
|
||||
if (0 == strcmp(pName, KFbxSurfaceMaterial::sEmissive))
|
||||
if (0 == strcmp(pName, FbxSurfaceMaterial::sEmissive))
|
||||
return stateSetList[i].emissiveChannel;
|
||||
// more here...
|
||||
}
|
||||
@@ -490,17 +490,17 @@ std::string getUVChannelForTextureMap(std::vector<StateSetContent>& stateSetList
|
||||
}
|
||||
|
||||
// scans mesh layers looking for the UV element corresponding to the specified channel name...
|
||||
const KFbxLayerElementUV* getUVElementForChannel(std::string uvChannelName,
|
||||
KFbxLayerElement::ELayerElementType elementType, KFbxMesh* pFbxMesh)
|
||||
const FbxLayerElementUV* getUVElementForChannel(std::string uvChannelName,
|
||||
FbxLayerElement::EType elementType, FbxMesh* pFbxMesh)
|
||||
{
|
||||
// scan layers for specified UV channel...
|
||||
for (int cLayerIndex = 0; cLayerIndex < pFbxMesh->GetLayerCount(); cLayerIndex++)
|
||||
{
|
||||
const KFbxLayer* pFbxLayer = pFbxMesh->GetLayer(cLayerIndex);
|
||||
const FbxLayer* pFbxLayer = pFbxMesh->GetLayer(cLayerIndex);
|
||||
if (!pFbxLayer)
|
||||
continue;
|
||||
|
||||
if (const KFbxLayerElementUV* uv = pFbxLayer->GetUVs())
|
||||
if (const FbxLayerElementUV* uv = pFbxLayer->GetUVs())
|
||||
{
|
||||
if (0 == uvChannelName.compare(uv->GetName()))
|
||||
return uv;
|
||||
@@ -509,11 +509,11 @@ const KFbxLayerElementUV* getUVElementForChannel(std::string uvChannelName,
|
||||
|
||||
for (int cLayerIndex = 0; cLayerIndex < pFbxMesh->GetLayerCount(); cLayerIndex++)
|
||||
{
|
||||
const KFbxLayer* pFbxLayer = pFbxMesh->GetLayer(cLayerIndex);
|
||||
const FbxLayer* pFbxLayer = pFbxMesh->GetLayer(cLayerIndex);
|
||||
if (!pFbxLayer)
|
||||
continue;
|
||||
|
||||
if (const KFbxLayerElementUV* uv = pFbxLayer->GetUVs(elementType))
|
||||
if (const FbxLayerElementUV* uv = pFbxLayer->GetUVs(elementType))
|
||||
{
|
||||
return uv;
|
||||
}
|
||||
@@ -526,17 +526,17 @@ typedef std::pair<osg::Geometry*, int> GIPair;
|
||||
typedef std::multimap<int, GIPair> FbxToOsgVertexMap;
|
||||
typedef std::map<GIPair, int> OsgToFbxNormalMap;
|
||||
|
||||
void readMeshTriangle(const KFbxMesh * fbxMesh, int i /*polygonIndex*/,
|
||||
void readMeshTriangle(const FbxMesh * fbxMesh, int i /*polygonIndex*/,
|
||||
int posInPoly0, int posInPoly1, int posInPoly2,
|
||||
int meshVertex0, int meshVertex1, int meshVertex2,
|
||||
FbxToOsgVertexMap& fbxToOsgVertMap,
|
||||
OsgToFbxNormalMap& osgToFbxNormMap,
|
||||
const KFbxVector4* pFbxVertices,
|
||||
const KFbxLayerElementNormal* pFbxNormals,
|
||||
const KFbxLayerElementUV* pFbxUVs_diffuse,
|
||||
const KFbxLayerElementUV* pFbxUVs_opacity,
|
||||
const KFbxLayerElementUV* pFbxUVs_emissive,
|
||||
const KFbxLayerElementVertexColor* pFbxColors,
|
||||
const FbxVector4* pFbxVertices,
|
||||
const FbxLayerElementNormal* pFbxNormals,
|
||||
const FbxLayerElementUV* pFbxUVs_diffuse,
|
||||
const FbxLayerElementUV* pFbxUVs_opacity,
|
||||
const FbxLayerElementUV* pFbxUVs_emissive,
|
||||
const FbxLayerElementVertexColor* pFbxColors,
|
||||
osg::Geometry* pGeometry,
|
||||
osg::Array* pVertices,
|
||||
osg::Array* pNormals,
|
||||
@@ -605,9 +605,9 @@ void readMeshTriangle(const KFbxMesh * fbxMesh, int i /*polygonIndex*/,
|
||||
}
|
||||
|
||||
/// Says if a quad should be split using vertices 02 (or else 13)
|
||||
bool quadSplit02(const KFbxMesh * fbxMesh, int i /*polygonIndex*/,
|
||||
bool quadSplit02(const FbxMesh * fbxMesh, int i /*polygonIndex*/,
|
||||
int posInPoly0, int posInPoly1, int posInPoly2, int posInPoly3,
|
||||
const KFbxVector4* pFbxVertices)
|
||||
const FbxVector4* pFbxVertices)
|
||||
{
|
||||
// Algorithm may be a bit dumb. If you got a faster one, feel free to change.
|
||||
// Here we test each of the 4 triangles and see if there is one in the opposite direction.
|
||||
@@ -659,8 +659,8 @@ struct PolygonRef
|
||||
typedef std::vector<PolygonRef> PolygonRefList;
|
||||
|
||||
osgDB::ReaderWriter::ReadResult OsgFbxReader::readMesh(
|
||||
KFbxNode* pNode,
|
||||
KFbxMesh* fbxMesh,
|
||||
FbxNode* pNode,
|
||||
FbxMesh* fbxMesh,
|
||||
std::vector<StateSetContent>& stateSetList,
|
||||
const char* szName)
|
||||
{
|
||||
@@ -669,16 +669,16 @@ osgDB::ReaderWriter::ReadResult OsgFbxReader::readMesh(
|
||||
osg::Geode* pGeode = new osg::Geode;
|
||||
pGeode->setName(szName);
|
||||
|
||||
const KFbxLayerElementNormal* pFbxNormals = 0;
|
||||
const KFbxLayerElementVertexColor* pFbxColors = 0;
|
||||
const KFbxLayerElementMaterial* pFbxMaterials = 0;
|
||||
const FbxLayerElementNormal* pFbxNormals = 0;
|
||||
const FbxLayerElementVertexColor* pFbxColors = 0;
|
||||
const FbxLayerElementMaterial* pFbxMaterials = 0;
|
||||
|
||||
const KFbxVector4* pFbxVertices = fbxMesh->GetControlPoints();
|
||||
const FbxVector4* pFbxVertices = fbxMesh->GetControlPoints();
|
||||
|
||||
// scan layers for Normals, Colors and Materials elements (this will get the first available elements)...
|
||||
for (int cLayerIndex = 0; cLayerIndex < fbxMesh->GetLayerCount(); cLayerIndex++)
|
||||
{
|
||||
const KFbxLayer* pFbxLayer = fbxMesh->GetLayer(cLayerIndex);
|
||||
const FbxLayer* pFbxLayer = fbxMesh->GetLayer(cLayerIndex);
|
||||
if (!pFbxLayer)
|
||||
continue;
|
||||
|
||||
@@ -692,15 +692,15 @@ osgDB::ReaderWriter::ReadResult OsgFbxReader::readMesh(
|
||||
}
|
||||
|
||||
// look for UV elements (diffuse, opacity, reflection, emissive, ...) and get their channels names...
|
||||
std::string diffuseChannel = getUVChannelForTextureMap(stateSetList, KFbxSurfaceMaterial::sDiffuse);
|
||||
std::string opacityChannel = getUVChannelForTextureMap(stateSetList, KFbxSurfaceMaterial::sTransparentColor);
|
||||
std::string emissiveChannel = getUVChannelForTextureMap(stateSetList, KFbxSurfaceMaterial::sEmissive);
|
||||
std::string diffuseChannel = getUVChannelForTextureMap(stateSetList, FbxSurfaceMaterial::sDiffuse);
|
||||
std::string opacityChannel = getUVChannelForTextureMap(stateSetList, FbxSurfaceMaterial::sTransparentColor);
|
||||
std::string emissiveChannel = getUVChannelForTextureMap(stateSetList, FbxSurfaceMaterial::sEmissive);
|
||||
// look for more UV elements here...
|
||||
|
||||
// UV elements...
|
||||
const KFbxLayerElementUV* pFbxUVs_diffuse = getUVElementForChannel(diffuseChannel, KFbxLayerElement::eDIFFUSE_TEXTURES, fbxMesh);
|
||||
const KFbxLayerElementUV* pFbxUVs_opacity = getUVElementForChannel(opacityChannel, KFbxLayerElement::eTRANSPARENT_TEXTURES, fbxMesh);
|
||||
const KFbxLayerElementUV* pFbxUVs_emissive = getUVElementForChannel(emissiveChannel, KFbxLayerElement::eEMISSIVE_TEXTURES, fbxMesh);
|
||||
const FbxLayerElementUV* pFbxUVs_diffuse = getUVElementForChannel(diffuseChannel, FbxLayerElement::eTextureDiffuse, fbxMesh);
|
||||
const FbxLayerElementUV* pFbxUVs_opacity = getUVElementForChannel(opacityChannel, FbxLayerElement::eTextureTransparency, fbxMesh);
|
||||
const FbxLayerElementUV* pFbxUVs_emissive = getUVElementForChannel(emissiveChannel, FbxLayerElement::eTextureEmissive, fbxMesh);
|
||||
// more UV elements here...
|
||||
|
||||
// check elements validity...
|
||||
@@ -714,8 +714,8 @@ osgDB::ReaderWriter::ReadResult OsgFbxReader::readMesh(
|
||||
|
||||
int nPolys = fbxMesh->GetPolygonCount();
|
||||
|
||||
int nDeformerCount = fbxMesh->GetDeformerCount(KFbxDeformer::eSKIN);
|
||||
int nDeformerBlendShapeCount = fbxMesh->GetDeformerCount(KFbxDeformer::eBLENDSHAPE);
|
||||
int nDeformerCount = fbxMesh->GetDeformerCount(FbxDeformer::eSkin);
|
||||
int nDeformerBlendShapeCount = fbxMesh->GetDeformerCount(FbxDeformer::eBlendShape);
|
||||
|
||||
GeometryType geomType = GEOMETRY_STATIC;
|
||||
|
||||
@@ -941,17 +941,17 @@ osgDB::ReaderWriter::ReadResult OsgFbxReader::readMesh(
|
||||
|
||||
for (int i = 0; i < nDeformerCount; ++i)
|
||||
{
|
||||
KFbxSkin* pSkin = (KFbxSkin*)fbxMesh->GetDeformer(i, KFbxDeformer::eSKIN);
|
||||
FbxSkin* pSkin = (FbxSkin*)fbxMesh->GetDeformer(i, FbxDeformer::eSkin);
|
||||
int nClusters = pSkin->GetClusterCount();
|
||||
for (int j = 0; j < nClusters; ++j)
|
||||
{
|
||||
KFbxCluster* pCluster = (KFbxCluster*)pSkin->GetCluster(j);
|
||||
FbxCluster* pCluster = pSkin->GetCluster(j);
|
||||
//assert(KFbxCluster::eNORMALIZE == pCluster->GetLinkMode());
|
||||
KFbxNode* pBone = pCluster->GetLink();
|
||||
FbxNode* pBone = pCluster->GetLink();
|
||||
|
||||
KFbxXMatrix transformLink;
|
||||
FbxAMatrix transformLink;
|
||||
pCluster->GetTransformLinkMatrix(transformLink);
|
||||
KFbxXMatrix transformLinkInverse = transformLink.Inverse();
|
||||
FbxAMatrix transformLinkInverse = transformLink.Inverse();
|
||||
const double* pTransformLinkInverse = transformLinkInverse;
|
||||
osg::Matrix bindMatrix(pTransformLinkInverse);
|
||||
|
||||
@@ -998,12 +998,12 @@ osgDB::ReaderWriter::ReadResult OsgFbxReader::readMesh(
|
||||
//read morph geometry
|
||||
for (int nBlendShape = 0; nBlendShape < nDeformerBlendShapeCount; ++nBlendShape)
|
||||
{
|
||||
KFbxBlendShape* pBlendShape = KFbxCast<KFbxBlendShape>(fbxMesh->GetDeformer(nBlendShape, KFbxDeformer::eBLENDSHAPE));
|
||||
FbxBlendShape* pBlendShape = FbxCast<FbxBlendShape>(fbxMesh->GetDeformer(nBlendShape, FbxDeformer::eBlendShape));
|
||||
const int nBlendShapeChannelCount = pBlendShape->GetBlendShapeChannelCount();
|
||||
|
||||
for (int nBlendShapeChannel = 0; nBlendShapeChannel < nBlendShapeChannelCount; ++nBlendShapeChannel)
|
||||
{
|
||||
KFbxBlendShapeChannel* pBlendShapeChannel = pBlendShape->GetBlendShapeChannel(nBlendShapeChannel);
|
||||
FbxBlendShapeChannel* pBlendShapeChannel = pBlendShape->GetBlendShapeChannel(nBlendShapeChannel);
|
||||
if (!pBlendShapeChannel->GetTargetShapeCount()) continue;
|
||||
|
||||
//Assume one shape
|
||||
@@ -1011,10 +1011,10 @@ osgDB::ReaderWriter::ReadResult OsgFbxReader::readMesh(
|
||||
{
|
||||
OSG_WARN << "Multiple FBX Target Shapes, only the first will be used" << std::endl;
|
||||
}
|
||||
const KFbxGeometryBase* pMorphShape = pBlendShapeChannel->GetTargetShape(0);
|
||||
const FbxGeometryBase* pMorphShape = pBlendShapeChannel->GetTargetShape(0);
|
||||
|
||||
const KFbxLayerElementNormal* pFbxShapeNormals = 0;
|
||||
if (const KFbxLayer* pFbxShapeLayer = pMorphShape->GetLayer(0))
|
||||
const FbxLayerElementNormal* pFbxShapeNormals = 0;
|
||||
if (const FbxLayer* pFbxShapeLayer = pMorphShape->GetLayer(0))
|
||||
{
|
||||
pFbxShapeNormals = pFbxShapeLayer->GetNormals();
|
||||
if (!layerElementValid(pFbxShapeNormals)) pFbxShapeNormals = 0;
|
||||
@@ -1043,25 +1043,25 @@ osgDB::ReaderWriter::ReadResult OsgFbxReader::readMesh(
|
||||
int nMorphTarget = 0;
|
||||
for (int nBlendShape = 0; nBlendShape < nDeformerBlendShapeCount; ++nBlendShape)
|
||||
{
|
||||
KFbxBlendShape* pBlendShape = KFbxCast<KFbxBlendShape>(fbxMesh->GetDeformer(nBlendShape, KFbxDeformer::eBLENDSHAPE));
|
||||
FbxBlendShape* pBlendShape = FbxCast<FbxBlendShape>(fbxMesh->GetDeformer(nBlendShape, FbxDeformer::eBlendShape));
|
||||
const int nBlendShapeChannelCount = pBlendShape->GetBlendShapeChannelCount();
|
||||
|
||||
for (int nBlendShapeChannel = 0; nBlendShapeChannel < nBlendShapeChannelCount; ++nBlendShapeChannel)
|
||||
{
|
||||
KFbxBlendShapeChannel* pBlendShapeChannel = pBlendShape->GetBlendShapeChannel(nBlendShapeChannel);
|
||||
FbxBlendShapeChannel* pBlendShapeChannel = pBlendShape->GetBlendShapeChannel(nBlendShapeChannel);
|
||||
if (!pBlendShapeChannel->GetTargetShapeCount()) continue;
|
||||
|
||||
//Assume one shape again
|
||||
const KFbxGeometryBase* pMorphShape = pBlendShapeChannel->GetTargetShape(0);
|
||||
const FbxGeometryBase* pMorphShape = pBlendShapeChannel->GetTargetShape(0);
|
||||
|
||||
const KFbxLayerElementNormal* pFbxShapeNormals = 0;
|
||||
if (const KFbxLayer* pFbxShapeLayer = pMorphShape->GetLayer(0))
|
||||
const FbxLayerElementNormal* pFbxShapeNormals = 0;
|
||||
if (const FbxLayer* pFbxShapeLayer = pMorphShape->GetLayer(0))
|
||||
{
|
||||
pFbxShapeNormals = pFbxShapeLayer->GetNormals();
|
||||
if (!layerElementValid(pFbxShapeNormals)) pFbxShapeNormals = 0;
|
||||
}
|
||||
|
||||
const KFbxVector4* pControlPoints = pMorphShape->GetControlPoints();
|
||||
const FbxVector4* pControlPoints = pMorphShape->GetControlPoints();
|
||||
int nControlPoints = pMorphShape->GetControlPointsCount();
|
||||
for (int fbxIndex = 0; fbxIndex < nControlPoints; ++fbxIndex)
|
||||
{
|
||||
@@ -1111,7 +1111,7 @@ osgDB::ReaderWriter::ReadResult OsgFbxReader::readMesh(
|
||||
}
|
||||
}
|
||||
|
||||
KFbxXMatrix fbxGeometricTransform;
|
||||
FbxAMatrix fbxGeometricTransform;
|
||||
fbxGeometricTransform.SetTRS(
|
||||
pNode->GeometricTranslation.Get(),
|
||||
pNode->GeometricRotation.Get(),
|
||||
@@ -1121,10 +1121,10 @@ osgDB::ReaderWriter::ReadResult OsgFbxReader::readMesh(
|
||||
|
||||
if (geomType == GEOMETRY_RIG)
|
||||
{
|
||||
KFbxSkin* pSkin = (KFbxSkin*)fbxMesh->GetDeformer(0, KFbxDeformer::eSKIN);
|
||||
FbxSkin* pSkin = (FbxSkin*)fbxMesh->GetDeformer(0, FbxDeformer::eSkin);
|
||||
if (pSkin->GetClusterCount())
|
||||
{
|
||||
KFbxXMatrix fbxTransformMatrix;
|
||||
FbxAMatrix fbxTransformMatrix;
|
||||
pSkin->GetCluster(0)->GetTransformMatrix(fbxTransformMatrix);
|
||||
const double* pTransformMatrix = fbxTransformMatrix;
|
||||
osgGeometricTransform.postMult(osg::Matrix(pTransformMatrix));
|
||||
@@ -1143,7 +1143,7 @@ osgDB::ReaderWriter::ReadResult OsgFbxReader::readMesh(
|
||||
if (geomType == GEOMETRY_RIG)
|
||||
{
|
||||
//Add the geometry to the skeleton ancestor of one of the bones.
|
||||
KFbxSkin* pSkin = (KFbxSkin*)fbxMesh->GetDeformer(0, KFbxDeformer::eSKIN);
|
||||
FbxSkin* pSkin = (FbxSkin*)fbxMesh->GetDeformer(0, FbxDeformer::eSkin);
|
||||
if (pSkin->GetClusterCount())
|
||||
{
|
||||
osgAnimation::Skeleton* pSkeleton = getSkeleton(
|
||||
@@ -1156,10 +1156,10 @@ osgDB::ReaderWriter::ReadResult OsgFbxReader::readMesh(
|
||||
return osgDB::ReaderWriter::ReadResult(pResult);
|
||||
}
|
||||
|
||||
osgDB::ReaderWriter::ReadResult OsgFbxReader::readFbxMesh(KFbxNode* pNode,
|
||||
osgDB::ReaderWriter::ReadResult OsgFbxReader::readFbxMesh(FbxNode* pNode,
|
||||
std::vector<StateSetContent>& stateSetList)
|
||||
{
|
||||
KFbxMesh* lMesh = KFbxCast<KFbxMesh>(pNode->GetNodeAttribute());
|
||||
FbxMesh* lMesh = FbxCast<FbxMesh>(pNode->GetNodeAttribute());
|
||||
|
||||
if (!lMesh)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user