root/OpenSceneGraph/trunk/src/osgPlugins/fbx/fbxRCamera.cpp @ 12337

Revision 12337, 1.4 kB (checked in by mplatings, 3 years ago)

Updated to use FBX SDK 2012.1

  • Property svn:eol-style set to native
Line 
1#include <osg/CameraView>
2#include <osg/Notify>
3
4#include <osgDB/ReadFile>
5
6#if defined(_MSC_VER)
7#pragma warning( disable : 4505 )
8#pragma warning( default : 4996 )
9#endif
10#include <fbxsdk.h>
11
12#include "fbxReader.h"
13
14osgDB::ReaderWriter::ReadResult OsgFbxReader::readFbxCamera(KFbxNode* pNode)
15{
16    const KFbxCamera* fbxCamera = KFbxCast<KFbxCamera>(pNode->GetNodeAttribute());
17
18    if (!fbxCamera)
19    {
20        return osgDB::ReaderWriter::ReadResult::ERROR_IN_READING_FILE;
21    }
22
23    osg::CameraView* osgCameraView = new osg::CameraView;
24
25    if (fbxCamera->FieldOfView.IsValid())
26    {
27        osgCameraView->setFieldOfView(fbxCamera->FieldOfView.Get());
28    }
29
30    if (fbxCamera->FocalLength.IsValid())
31    {
32        osgCameraView->setFocalLength(fbxCamera->FocalLength.Get());
33    }
34
35    if (fbxCamera->ApertureMode.IsValid())
36    {
37        switch (fbxCamera->ApertureMode.Get())
38        {
39        case KFbxCamera::eHORIZONTAL:
40            osgCameraView->setFieldOfViewMode(osg::CameraView::HORIZONTAL);
41            break;
42        case KFbxCamera::eVERTICAL:
43            osgCameraView->setFieldOfViewMode(osg::CameraView::VERTICAL);
44            break;
45        case KFbxCamera::eHORIZONTAL_AND_VERTICAL:
46        case KFbxCamera::eFOCAL_LENGTH:
47        default:
48            OSG_WARN << "readFbxCamera: Unsupported Camera aperture mode." << std::endl;
49            break;
50        }
51    }
52
53    return osgDB::ReaderWriter::ReadResult(osgCameraView);
54}
Note: See TracBrowser for help on using the browser.