root/OpenSceneGraph/trunk/src/osgWrappers/deprecated-dotosg/osg/CameraView.cpp @ 13041

Revision 13041, 2.9 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1#include <osg/CameraView>
2#include <osg/io_utils>
3#include <osg/Notify>
4
5#include "osgDB/Registry"
6#include "osgDB/Input"
7#include "osgDB/Output"
8
9using namespace osg;
10using namespace osgDB;
11
12// forward declare functions to use later.
13bool CameraView_readLocalData(Object& obj, Input& fr);
14bool CameraView_writeLocalData(const Object& obj, Output& fw);
15
16// register the read and write functions with the osgDB::Registry.
17REGISTER_DOTOSGWRAPPER(CameraView)
18(
19    new osg::CameraView,
20    "CameraView",
21    "Object Node Transform CameraView Group",
22    &CameraView_readLocalData,
23    &CameraView_writeLocalData,
24    DotOsgWrapper::READ_AND_WRITE
25);
26
27bool CameraView_readLocalData(Object& obj, Input& fr)
28{
29    bool iteratorAdvanced = false;
30
31    CameraView& cameraview = static_cast<CameraView&>(obj);
32
33    if (fr.matchSequence("position %f %f %f"))
34    {
35        osg::Vec3d pos;
36        fr[1].getFloat(pos[0]);
37        fr[2].getFloat(pos[1]);
38        fr[3].getFloat(pos[2]);
39
40        cameraview.setPosition(pos);
41
42        fr += 4;
43        iteratorAdvanced = true;
44    }
45
46    if (fr.matchSequence("attitude %f %f %f %f"))
47    {
48        osg::Quat att;
49        fr[1].getFloat(att[0]);
50        fr[2].getFloat(att[1]);
51        fr[3].getFloat(att[2]);
52        fr[4].getFloat(att[3]);
53
54        cameraview.setAttitude(att);
55
56        fr += 5;
57        iteratorAdvanced = true;
58    }
59
60    if (fr.matchSequence("fieldOfView %f"))
61    {
62        double fov;
63        fr[1].getFloat(fov);
64        cameraview.setFieldOfView(fov);
65
66        fr += 2;
67        iteratorAdvanced = true;
68    }
69
70
71    if (fr.matchSequence("fieldOfViewMode %w"))
72    {
73        if      (fr[1].matchWord("UNCONSTRAINED")) cameraview.setFieldOfViewMode(osg::CameraView::UNCONSTRAINED);
74        else if (fr[1].matchWord("HORIZONTAL")) cameraview.setFieldOfViewMode(osg::CameraView::HORIZONTAL);
75        else if (fr[1].matchWord("VERTICAL")) cameraview.setFieldOfViewMode(osg::CameraView::VERTICAL);
76
77        fr += 2;
78        iteratorAdvanced = true;
79    }
80
81
82    if (fr.matchSequence("focalLength %f"))
83    {
84        double fl;
85        fr[1].getFloat(fl);
86        cameraview.setFocalLength(fl);
87
88        fr += 2;
89        iteratorAdvanced = true;
90    }
91
92    return iteratorAdvanced;
93}
94
95
96bool CameraView_writeLocalData(const Object& obj, Output& fw)
97{
98    const CameraView& cameraview = static_cast<const CameraView&>(obj);
99
100    fw.indent()<<"position "<<cameraview.getPosition()<<std::endl;
101    fw.indent()<<"attitude "<<cameraview.getAttitude()<<std::endl;
102
103    fw.indent()<<"fieldOfView "<<cameraview.getFieldOfView()<<std::endl;
104    fw.indent()<<"fieldOfViewMode ";
105    switch(cameraview.getFieldOfViewMode())
106    {
107        case(osg::CameraView::UNCONSTRAINED): fw <<"UNCONSTRAINED"<<std::endl; break;
108        case(osg::CameraView::HORIZONTAL): fw <<"HORIZONTAL"<<std::endl; break;
109        case(osg::CameraView::VERTICAL): fw <<"VERTICAL"<<std::endl; break;
110    }
111
112    fw.indent()<<"focalLength "<<cameraview.getFocalLength()<<std::endl;
113
114    return true;
115}
Note: See TracBrowser for help on using the browser.