root/OpenSceneGraph/trunk/src/osgPlugins/ive/CameraView.cpp @ 13041

Revision 13041, 2.2 kB (checked in by robert, 3 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/**********************************************************************
2 *
3 *    FILE:            CameraView.cpp
4 *
5 *    DESCRIPTION:    Read/Write osg::CameraView in binary format to disk.
6 *
7 *    CREATED BY:        Auto generated by iveGenerate
8 *                    and later modified by Rune Schmidt Jensen.
9 *
10 *    HISTORY:        Created 25.3.2003
11 *
12 *    Copyright 2003 VR-C
13 **********************************************************************/
14
15#include "Exception.h"
16#include "CameraView.h"
17#include "Transform.h"
18
19using namespace ive;
20
21void CameraView::write(DataOutputStream* out)
22{
23    // Write CameraView's identification.
24    out->writeInt(IVECAMERAVIEW);
25    // If the osg class is inherited by any other class we should also write this to file.
26    osg::Transform*  trans = dynamic_cast<osg::Transform*>(this);
27    if(trans)
28    {
29        ((ive::Transform*)(trans))->write(out);
30    }
31    else
32        out_THROW_EXCEPTION("CameraView::write(): Could not cast this osg::CameraView to an osg::Transform.");
33
34    // Write CameraView's properties.
35    out->writeVec3(getPosition());
36    out->writeQuat(getAttitude());
37    out->writeDouble(getFieldOfView());
38    out->writeInt(getFieldOfViewMode());
39    out->writeDouble(getFocalLength());
40}
41
42void CameraView::read(DataInputStream* in){
43    // Peek on CameraView's identification.
44    int id = in->peekInt();
45    if(id == IVECAMERAVIEW)
46    {
47        // Read CameraView's identification.
48        id = in->readInt();
49        // If the osg class is inherited by any other class we should also read this from file.
50        osg::Transform*  trans = dynamic_cast<osg::Transform*>(this);
51        if(trans)
52        {
53            ((ive::Transform*)(trans))->read(in);
54        }
55        else
56            in_THROW_EXCEPTION("CameraView::read(): Could not cast this osg::CameraView to an osg::Transform.");
57
58        // Read CameraView's properties
59        setPosition(in->readVec3());
60        setAttitude(in->readQuat());
61        setFieldOfView(in->readDouble());
62        setFieldOfViewMode((FieldOfViewMode)in->readInt());
63        setFocalLength(in->readDouble());
64    }
65    else
66    {
67        in_THROW_EXCEPTION("CameraView::read(): Expected CameraView identification.");
68    }
69}
Note: See TracBrowser for help on using the browser.