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:
Robert Osfield
2013-06-03 14:27:14 +00:00
parent 375e7c2d57
commit 82ecbe98da
13 changed files with 464 additions and 401 deletions

View File

@@ -10,9 +10,9 @@
#include "fbxReader.h"
osgDB::ReaderWriter::ReadResult OsgFbxReader::readFbxLight(KFbxNode* pNode, int& nLightCount)
osgDB::ReaderWriter::ReadResult OsgFbxReader::readFbxLight(FbxNode* pNode, int& nLightCount)
{
const KFbxLight* fbxLight = KFbxCast<KFbxLight>(pNode->GetNodeAttribute());
const FbxLight* fbxLight = FbxCast<FbxLight>(pNode->GetNodeAttribute());
if (!fbxLight)
{
@@ -22,24 +22,24 @@ osgDB::ReaderWriter::ReadResult OsgFbxReader::readFbxLight(KFbxNode* pNode, int&
osg::Light* osgLight = new osg::Light;
osg::LightSource* osgLightSource = new osg::LightSource;
osgLight->setLightNum(nLightCount++);
osgLightSource->setLight(osgLight);
osgLight->setLightNum(nLightCount++);
KFbxLight::ELightType fbxLightType = fbxLight->LightType.IsValid() ?
fbxLight->LightType.Get() : KFbxLight::ePOINT;
FbxLight::EType fbxLightType = fbxLight->LightType.IsValid() ?
fbxLight->LightType.Get() : FbxLight::ePoint;
osgLight->setPosition(osg::Vec4(0,0,0,fbxLightType != KFbxLight::eDIRECTIONAL));
osgLight->setPosition(osg::Vec4(0,0,0,fbxLightType != FbxLight::eDirectional));
if (fbxLightType == KFbxLight::eSPOT)
if (fbxLightType == FbxLight::eSpot)
{
double coneAngle = fbxLight->ConeAngle.IsValid() ? fbxLight->ConeAngle.Get() : 45.0;
double hotSpot = fbxLight->HotSpot.IsValid() ? fbxLight->HotSpot.Get() : 45.0;
double coneAngle = fbxLight->OuterAngle.Get();
double hotSpot = fbxLight->InnerAngle.Get();
const float MIN_HOTSPOT = 0.467532f;
osgLight->setSpotCutoff(static_cast<float>(coneAngle));
//Approximate the hotspot using the GL light exponent.
//This formula maps a hotspot of 180 to exponent 0 (uniform light
// This formula maps a hotspot of 180 to exponent 0 (uniform light
// distribution) and a hotspot of 45 to exponent 1 (effective light
// intensity is attenuated by the cosine of the angle between the
// direction of the light and the direction from the light to the vertex
@@ -56,13 +56,13 @@ osgDB::ReaderWriter::ReadResult OsgFbxReader::readFbxLight(KFbxNode* pNode, int&
switch (fbxLight->DecayType.Get())
{
case KFbxLight::eNONE:
case FbxLight::eNone:
break;
case KFbxLight::eLINEAR:
case FbxLight::eLinear:
osgLight->setLinearAttenuation(fbxDecayStart);
break;
case KFbxLight::eQUADRATIC:
case KFbxLight::eCUBIC:
case FbxLight::eQuadratic:
case FbxLight::eCubic:
osgLight->setQuadraticAttenuation(fbxDecayStart);
break;
}
@@ -72,7 +72,7 @@ osgDB::ReaderWriter::ReadResult OsgFbxReader::readFbxLight(KFbxNode* pNode, int&
osg::Vec3f osgAmbient(0.0f, 0.0f, 0.0f);
if (fbxLight->Color.IsValid())
{
fbxDouble3 fbxColor = fbxLight->Color.Get();
FbxDouble3 fbxColor = fbxLight->Color.Get();
osgDiffuseSpecular.set(
static_cast<float>(fbxColor[0]),
static_cast<float>(fbxColor[1]),
@@ -84,7 +84,7 @@ osgDB::ReaderWriter::ReadResult OsgFbxReader::readFbxLight(KFbxNode* pNode, int&
}
if (fbxLight->ShadowColor.IsValid())
{
fbxDouble3 fbxShadowColor = fbxLight->ShadowColor.Get();
FbxDouble3 fbxShadowColor = fbxLight->ShadowColor.Get();
osgAmbient.set(
static_cast<float>(fbxShadowColor[0]),
static_cast<float>(fbxShadowColor[1]),