Show
Ignore:
Timestamp:
09/19/14 12:35:23 (13 days ago)
Author:
robert
Message:

Moved widgets from VolumeEditorWidget? to TransferFunctionWidget?, and widget utilities into WidgetUtils?.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgPlugins/fbx/fbxRAnimation.cpp

    r13041 r13466  
    1111#endif 
    1212#include <fbxsdk.h> 
    13 #include <fbxfilesdk/fbxfilesdk_nsuse.h> 
    14  
    1513#include "fbxReader.h" 
    1614 
    17 osg::Quat makeQuat(const fbxDouble3&, ERotationOrder); 
    18  
    19 osg::Quat makeQuat(const osg::Vec3& radians, ERotationOrder fbxRotOrder) 
    20 { 
    21     fbxDouble3 degrees( 
     15osg::Quat makeQuat(const FbxDouble3&, EFbxRotationOrder); 
     16 
     17osg::Quat makeQuat(const osg::Vec3& radians, EFbxRotationOrder fbxRotOrder) 
     18{ 
     19    FbxDouble3 degrees( 
    2220        osg::RadiansToDegrees(radians.x()), 
    2321        osg::RadiansToDegrees(radians.y()), 
     
    2624} 
    2725 
    28 void readKeys(KFbxAnimCurve* curveX, KFbxAnimCurve* curveY, KFbxAnimCurve* curveZ, 
    29               const fbxDouble3& defaultValue, 
     26void readKeys(FbxAnimCurve* curveX, FbxAnimCurve* curveY, FbxAnimCurve* curveZ, 
     27              const FbxDouble3& defaultValue, 
    3028              std::vector<osgAnimation::TemplateKeyframe<osg::Vec3> >& keyFrameCntr, float scalar = 1.0f) 
    3129{ 
    32     KFbxAnimCurve* curves[3] = {curveX, curveY, curveZ}; 
     30    FbxAnimCurve* curves[3] = {curveX, curveY, curveZ}; 
    3331 
    3432    typedef std::set<double> TimeSet; 
     
    3937    for (int nCurve = 0; nCurve < 3; ++nCurve) 
    4038    { 
    41         KFbxAnimCurve* pCurve = curves[nCurve]; 
     39        FbxAnimCurve* pCurve = curves[nCurve]; 
    4240 
    4341        int nKeys = pCurve ? pCurve->KeyGetCount() : 0; 
     
    5149        for (int i = 0; i < nKeys; ++i) 
    5250        { 
    53             KFbxAnimCurveKey key = pCurve->KeyGet(i); 
     51            FbxAnimCurveKey key = pCurve->KeyGet(i); 
    5452            double fTime = key.GetTime().GetSecondDouble(); 
    5553            times.insert(fTime); 
     
    7472} 
    7573 
    76 void readKeys(KFbxAnimCurve* curveX, KFbxAnimCurve* curveY, KFbxAnimCurve* curveZ, 
    77               const fbxDouble3& defaultValue, 
     74void readKeys(FbxAnimCurve* curveX, FbxAnimCurve* curveY, FbxAnimCurve* curveZ, 
     75              const FbxDouble3& defaultValue, 
    7876              std::vector<osgAnimation::Vec3CubicBezierKeyframe>& keyFrameCntr, float scalar = 1.0f) 
    7977{ 
    80     KFbxAnimCurve* curves[3] = {curveX, curveY, curveZ}; 
     78    FbxAnimCurve* curves[3] = {curveX, curveY, curveZ}; 
    8179 
    8280    typedef std::set<double> TimeSet; 
     
    8785    for (int nCurve = 0; nCurve < 3; ++nCurve) 
    8886    { 
    89         KFbxAnimCurve* pCurve = curves[nCurve]; 
     87        FbxAnimCurve* pCurve = curves[nCurve]; 
    9088 
    9189        int nKeys = pCurve ? pCurve->KeyGetCount() : 0; 
     
    102100            float val = pCurve->KeyGetValue(i); 
    103101            times.insert(fTime); 
    104             KFCurveTangeantInfo leftTangent = pCurve->KeyGetLeftDerivativeInfo(i); 
    105             KFCurveTangeantInfo rightTangent = pCurve->KeyGetRightDerivativeInfo(i); 
     102            FbxAnimCurveTangentInfo leftTangent = pCurve->KeyGetLeftDerivativeInfo(i); 
     103            FbxAnimCurveTangentInfo rightTangent = pCurve->KeyGetRightDerivativeInfo(i); 
    106104 
    107105            if (i > 0) 
     
    177175} 
    178176 
    179 osgAnimation::Channel* readFbxChannels(KFbxAnimCurve* curveX, KFbxAnimCurve* curveY, 
    180     KFbxAnimCurve* curveZ, 
    181     const fbxDouble3& defaultValue, 
     177osgAnimation::Channel* readFbxChannels(FbxAnimCurve* curveX, FbxAnimCurve* curveY, 
     178    FbxAnimCurve* curveZ, 
     179    const FbxDouble3& defaultValue, 
    182180    const char* targetName, const char* channelName) 
    183181{ 
     
    189187    } 
    190188 
    191     KFbxAnimCurveDef::EInterpolationType interpolationType = KFbxAnimCurveDef::eINTERPOLATION_CONSTANT; 
     189    FbxAnimCurveDef::EInterpolationType interpolationType = FbxAnimCurveDef::eInterpolationConstant; 
    192190    if (curveX && curveX->KeyGetCount()) interpolationType = curveX->KeyGetInterpolation(0); 
    193191    else if (curveY && curveY->KeyGetCount()) interpolationType = curveY->KeyGetInterpolation(0); 
     
    196194    osgAnimation::Channel* pChannel = 0; 
    197195 
    198     if (interpolationType == KFbxAnimCurveDef::eINTERPOLATION_CUBIC) 
     196    if (interpolationType == FbxAnimCurveDef::eInterpolationCubic) 
    199197    { 
    200198        osgAnimation::Vec3CubicBezierKeyframeContainer* pKeyFrameCntr = new osgAnimation::Vec3CubicBezierKeyframeContainer; 
     
    211209        readKeys(curveX, curveY, curveZ, defaultValue, *pKeyFrameCntr); 
    212210 
    213         if (interpolationType == KFbxAnimCurveDef::eINTERPOLATION_CONSTANT) 
     211        if (interpolationType == FbxAnimCurveDef::eInterpolationConstant) 
    214212        { 
    215213            osgAnimation::Vec3StepChannel* pStepChannel = new osgAnimation::Vec3StepChannel; 
     
    232230 
    233231osgAnimation::Channel* readFbxChannels( 
    234     KFbxTypedProperty<fbxDouble3>& fbxProp, KFbxAnimLayer* pAnimLayer, 
     232    FbxPropertyT<FbxDouble3>& fbxProp, FbxAnimLayer* pAnimLayer, 
    235233    const char* targetName, const char* channelName) 
    236234{ 
     
    238236 
    239237    return readFbxChannels( 
    240         fbxProp.GetCurve<KFbxAnimCurve>(pAnimLayer, "X"), 
    241         fbxProp.GetCurve<KFbxAnimCurve>(pAnimLayer, "Y"), 
    242         fbxProp.GetCurve<KFbxAnimCurve>(pAnimLayer, "Z"), 
     238        fbxProp.GetCurve(pAnimLayer, "X"), 
     239        fbxProp.GetCurve(pAnimLayer, "Y"), 
     240        fbxProp.GetCurve(pAnimLayer, "Z"), 
    243241        fbxProp.Get(), 
    244242        targetName, channelName); 
     
    246244 
    247245osgAnimation::Channel* readFbxChannelsQuat( 
    248     KFbxAnimCurve* curveX, KFbxAnimCurve* curveY, KFbxAnimCurve* curveZ, 
    249     const fbxDouble3& defaultValue, 
    250     const char* targetName, ERotationOrder rotOrder) 
     246    FbxAnimCurve* curveX, FbxAnimCurve* curveY, FbxAnimCurve* curveZ, 
     247    const FbxDouble3& defaultValue, 
     248    const char* targetName, EFbxRotationOrder rotOrder) 
    251249{ 
    252250    if (!(curveX && curveX->KeyGetCount()) && 
     
    325323 
    326324void readFbxRotationAnimation(osgAnimation::Channel* channels[3], 
    327     KFbxNode* pNode, 
    328     KFbxAnimLayer* pAnimLayer, const char* targetName) 
     325    FbxNode* pNode, 
     326    FbxAnimLayer* pAnimLayer, const char* targetName) 
    329327{ 
    330328    if (!pNode->LclRotation.IsValid()) 
     
    333331    } 
    334332 
    335     ERotationOrder rotOrder = pNode->RotationOrder.IsValid() ? pNode->RotationOrder.Get() : eEULER_XYZ; 
     333    EFbxRotationOrder rotOrder = pNode->RotationOrder.IsValid() ? pNode->RotationOrder.Get() : eEulerXYZ; 
    336334 
    337335    if (pNode->QuaternionInterpolate.IsValid() && pNode->QuaternionInterpolate.Get()) 
    338336    { 
    339337        channels[0] = readFbxChannelsQuat( 
    340             pNode->LclRotation.GetCurve<KFbxAnimCurve>(pAnimLayer, KFCURVENODE_R_X), 
    341             pNode->LclRotation.GetCurve<KFbxAnimCurve>(pAnimLayer, KFCURVENODE_R_Y), 
    342             pNode->LclRotation.GetCurve<KFbxAnimCurve>(pAnimLayer, KFCURVENODE_R_Z), 
     338            pNode->LclRotation.GetCurve(pAnimLayer, FBXSDK_CURVENODE_COMPONENT_X), 
     339            pNode->LclRotation.GetCurve(pAnimLayer, FBXSDK_CURVENODE_COMPONENT_Y), 
     340            pNode->LclRotation.GetCurve(pAnimLayer, FBXSDK_CURVENODE_COMPONENT_Z), 
    343341            pNode->LclRotation.Get(), 
    344342            targetName, rotOrder); 
     
    346344    else 
    347345    { 
    348         const char* curveNames[3] = {KFCURVENODE_R_X, KFCURVENODE_R_Y, KFCURVENODE_R_Z}; 
    349  
    350         fbxDouble3 fbxPropValue = pNode->LclRotation.Get(); 
     346        const char* curveNames[3] = {FBXSDK_CURVENODE_COMPONENT_X, FBXSDK_CURVENODE_COMPONENT_Y, FBXSDK_CURVENODE_COMPONENT_Z}; 
     347 
     348        FbxDouble3 fbxPropValue = pNode->LclRotation.Get(); 
    351349        fbxPropValue[0] = osg::DegreesToRadians(fbxPropValue[0]); 
    352350        fbxPropValue[1] = osg::DegreesToRadians(fbxPropValue[1]); 
     
    355353        for (int i = 0; i < 3; ++i) 
    356354        { 
    357             KFbxAnimCurve* curve = pNode->LclRotation.GetCurve<KFbxAnimCurve>(pAnimLayer, curveNames[i]); 
     355            FbxAnimCurve* curve = pNode->LclRotation.GetCurve(pAnimLayer, curveNames[i]); 
    358356            if (!curve) 
    359357            { 
     
    361359            } 
    362360 
    363             KFbxAnimCurveDef::EInterpolationType interpolationType = KFbxAnimCurveDef::eINTERPOLATION_CONSTANT; 
     361            FbxAnimCurveDef::EInterpolationType interpolationType = FbxAnimCurveDef::eInterpolationConstant; 
    364362            if (curve && curve->KeyGetCount()) interpolationType = curve->KeyGetInterpolation(0); 
    365363 
    366             if (interpolationType == KFbxAnimCurveDef::eINTERPOLATION_CUBIC) 
     364            if (interpolationType == FbxAnimCurveDef::eInterpolationCubic) 
    367365            { 
    368366                osgAnimation::FloatCubicBezierKeyframeContainer* pKeyFrameCntr = new osgAnimation::FloatCubicBezierKeyframeContainer; 
     
    372370                    double fTime = curve->KeyGetTime(j).GetSecondDouble(); 
    373371                    float angle = curve->KeyGetValue(j); 
    374                     //KFbxAnimCurveDef::EWeightedMode tangentWeightMode = curve->KeyGet(j).GetTangentWeightMode(); 
    375  
    376                     KFCurveTangeantInfo leftTangent = curve->KeyGetLeftDerivativeInfo(j); 
    377                     KFCurveTangeantInfo rightTangent = curve->KeyGetRightDerivativeInfo(j); 
     372                    //FbxAnimCurveDef::EWeightedMode tangentWeightMode = curve->KeyGet(j).GetTangentWeightMode(); 
     373 
     374                    FbxAnimCurveTangentInfo leftTangent = curve->KeyGetLeftDerivativeInfo(j); 
     375                    FbxAnimCurveTangentInfo rightTangent = curve->KeyGetRightDerivativeInfo(j); 
    378376                    if (j > 0) 
    379377                    { 
     
    406404                for (int j = 0; j < curve->KeyGetCount(); ++j) 
    407405                { 
    408                     KFbxAnimCurveKey key = curve->KeyGet(j); 
     406                    FbxAnimCurveKey key = curve->KeyGet(j); 
    409407                    keys->push_back(osgAnimation::FloatKeyframe( 
    410408                        key.GetTime().GetSecondDouble(), 
     
    412410                } 
    413411 
    414                 if (interpolationType == KFbxAnimCurveDef::eINTERPOLATION_CONSTANT) 
     412                if (interpolationType == FbxAnimCurveDef::eInterpolationConstant) 
    415413                { 
    416414                    osgAnimation::FloatStepChannel* pStepChannel = new osgAnimation::FloatStepChannel(); 
     
    432430} 
    433431 
    434 osgAnimation::Animation* readFbxAnimation(KFbxNode* pNode, 
    435     KFbxAnimLayer* pAnimLayer, const char* pTakeName, const char* targetName, 
     432osgAnimation::Animation* readFbxAnimation(FbxNode* pNode, 
     433    FbxAnimLayer* pAnimLayer, const char* pTakeName, const char* targetName, 
    436434    osg::ref_ptr<osgAnimation::AnimationManagerBase>& pAnimManager) 
    437435{ 
     
    444442    { 
    445443        pTranslationChannel = readFbxChannels( 
    446             pNode->LclTranslation.GetCurve<KFbxAnimCurve>(pAnimLayer, KFCURVENODE_T_X), 
    447             pNode->LclTranslation.GetCurve<KFbxAnimCurve>(pAnimLayer, KFCURVENODE_T_Y), 
    448             pNode->LclTranslation.GetCurve<KFbxAnimCurve>(pAnimLayer, KFCURVENODE_T_Z), 
     444            pNode->LclTranslation.GetCurve(pAnimLayer, FBXSDK_CURVENODE_COMPONENT_X), 
     445            pNode->LclTranslation.GetCurve(pAnimLayer, FBXSDK_CURVENODE_COMPONENT_Y), 
     446            pNode->LclTranslation.GetCurve(pAnimLayer, FBXSDK_CURVENODE_COMPONENT_Z), 
    449447            pNode->LclTranslation.Get(), 
    450448            targetName, "translate"); 
     
    457455} 
    458456 
    459 std::string OsgFbxReader::readFbxAnimation(KFbxNode* pNode, const char* targetName) 
     457std::string OsgFbxReader::readFbxAnimation(FbxNode* pNode, const char* targetName) 
    460458{ 
    461459    std::string result; 
    462     for (int i = 0; i < fbxScene.GetSrcObjectCount(FBX_TYPE(KFbxAnimStack)); ++i) 
    463     { 
    464         KFbxAnimStack* pAnimStack = KFbxCast<KFbxAnimStack>(fbxScene.GetSrcObject(FBX_TYPE(KFbxAnimStack), i)); 
    465  
    466         int nbAnimLayers = pAnimStack->GetMemberCount(FBX_TYPE(KFbxAnimLayer)); 
     460    for (int i = 0; i < fbxScene.GetSrcObjectCount<FbxAnimStack>(); ++i) 
     461    { 
     462        FbxAnimStack* pAnimStack = FbxCast<FbxAnimStack>(fbxScene.GetSrcObject<FbxAnimStack>(i)); 
     463 
     464        int nbAnimLayers = pAnimStack->GetMemberCount<FbxAnimLayer>(); 
    467465 
    468466        const char* pTakeName = pAnimStack->GetName(); 
     
    473471        for (int j = 0; j < nbAnimLayers; j++) 
    474472        { 
    475             KFbxAnimLayer* pAnimLayer = pAnimStack->GetMember(FBX_TYPE(KFbxAnimLayer), j); 
     473            FbxAnimLayer* pAnimLayer = pAnimStack->GetMember<FbxAnimLayer>(j); 
    476474            osgAnimation::Animation* pAnimation = ::readFbxAnimation(pNode, pAnimLayer, pTakeName, targetName, pAnimationManager); 
    477475            if (pAnimation)