Completed osg::CameraView support in .osg and .ive formats.
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: CameraView.cpp
|
||||
* FILE: CameraView.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::CameraView in binary format to disk.
|
||||
* DESCRIPTION: Read/Write osg::CameraView in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerate
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
* CREATED BY: Auto generated by iveGenerate
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 25.3.2003
|
||||
* HISTORY: Created 25.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
@@ -18,41 +18,52 @@
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void CameraView::write(DataOutputStream* out){
|
||||
// Write CameraView's identification.
|
||||
out->writeInt(IVECAMERAVIEW);
|
||||
// If the osg class is inherited by any other class we should also write this to file.
|
||||
osg::Transform* trans = dynamic_cast<osg::Transform*>(this);
|
||||
if(trans){
|
||||
((ive::Transform*)(trans))->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("CameraView::write(): Could not cast this osg::CameraView to an osg::Transform.");
|
||||
// Write CameraView's properties.
|
||||
|
||||
out->writeVec3(getPosition());
|
||||
out->writeQuat(getAttitude());
|
||||
void CameraView::write(DataOutputStream* out)
|
||||
{
|
||||
// Write CameraView's identification.
|
||||
out->writeInt(IVECAMERAVIEW);
|
||||
// If the osg class is inherited by any other class we should also write this to file.
|
||||
osg::Transform* trans = dynamic_cast<osg::Transform*>(this);
|
||||
if(trans)
|
||||
{
|
||||
((ive::Transform*)(trans))->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("CameraView::write(): Could not cast this osg::CameraView to an osg::Transform.");
|
||||
|
||||
// Write CameraView's properties.
|
||||
out->writeVec3(getPosition());
|
||||
out->writeQuat(getAttitude());
|
||||
out->writeDouble(getFieldOfView());
|
||||
out->writeInt(getFieldOfViewMode());
|
||||
out->writeDouble(getFocalLength());
|
||||
}
|
||||
|
||||
void CameraView::read(DataInputStream* in){
|
||||
// Peek on CameraView's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVECAMERAVIEW){
|
||||
// Read CameraView's identification.
|
||||
id = in->readInt();
|
||||
// If the osg class is inherited by any other class we should also read this from file.
|
||||
osg::Transform* trans = dynamic_cast<osg::Transform*>(this);
|
||||
if(trans){
|
||||
((ive::Transform*)(trans))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("CameraView::read(): Could not cast this osg::CameraView to an osg::Transform.");
|
||||
// Read CameraView's properties
|
||||
setPosition(in->readVec3());
|
||||
setAttitude(in->readQuat());
|
||||
|
||||
}
|
||||
else{
|
||||
throw Exception("CameraView::read(): Expected CameraView identification.");
|
||||
}
|
||||
// Peek on CameraView's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVECAMERAVIEW)
|
||||
{
|
||||
// Read CameraView's identification.
|
||||
id = in->readInt();
|
||||
// If the osg class is inherited by any other class we should also read this from file.
|
||||
osg::Transform* trans = dynamic_cast<osg::Transform*>(this);
|
||||
if(trans)
|
||||
{
|
||||
((ive::Transform*)(trans))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("CameraView::read(): Could not cast this osg::CameraView to an osg::Transform.");
|
||||
|
||||
// Read CameraView's properties
|
||||
setPosition(in->readVec3());
|
||||
setAttitude(in->readQuat());
|
||||
setFieldOfView(in->readDouble());
|
||||
setFieldOfViewMode((FieldOfViewMode)in->readInt());
|
||||
setFocalLength(in->readDouble());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Exception("CameraView::read(): Expected CameraView identification.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "osg/CameraView"
|
||||
#include <osg/CameraView>
|
||||
#include <osg/io_utils>
|
||||
#include <osg/Notify>
|
||||
|
||||
#include "osgDB/Registry"
|
||||
#include "osgDB/Input"
|
||||
@@ -56,6 +57,38 @@ bool CameraView_readLocalData(Object& obj, Input& fr)
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
if (fr.matchSequence("fieldOfView %f"))
|
||||
{
|
||||
double fov;
|
||||
fr[1].getFloat(fov);
|
||||
cameraview.setFieldOfView(fov);
|
||||
|
||||
fr += 2;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
|
||||
if (fr.matchSequence("fieldOfViewMode %w"))
|
||||
{
|
||||
if (fr[1].matchWord("UNCONSTRAINED")) cameraview.setFieldOfViewMode(osg::CameraView::UNCONSTRAINED);
|
||||
else if (fr[1].matchWord("HORIZONTAL")) cameraview.setFieldOfViewMode(osg::CameraView::HORIZONTAL);
|
||||
else if (fr[1].matchWord("VERTICAL")) cameraview.setFieldOfViewMode(osg::CameraView::VERTICAL);
|
||||
|
||||
fr += 2;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
|
||||
if (fr.matchSequence("focalLength %f"))
|
||||
{
|
||||
double fl;
|
||||
fr[1].getFloat(fl);
|
||||
cameraview.setFocalLength(fl);
|
||||
|
||||
fr += 2;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
@@ -66,6 +99,17 @@ bool CameraView_writeLocalData(const Object& obj, Output& fw)
|
||||
|
||||
fw.indent()<<"position "<<cameraview.getPosition()<<std::endl;
|
||||
fw.indent()<<"attitude "<<cameraview.getAttitude()<<std::endl;
|
||||
|
||||
fw.indent()<<"fieldOfView "<<cameraview.getFieldOfView()<<std::endl;
|
||||
fw.indent()<<"fieldOfViewMode ";
|
||||
switch(cameraview.getFieldOfViewMode())
|
||||
{
|
||||
case(osg::CameraView::UNCONSTRAINED): fw <<"UNCONSTRAINED"<<std::endl; break;
|
||||
case(osg::CameraView::HORIZONTAL): fw <<"HORIZONTAL"<<std::endl; break;
|
||||
case(osg::CameraView::VERTICAL): fw <<"VERTICAL"<<std::endl; break;
|
||||
}
|
||||
|
||||
fw.indent()<<"focalLength "<<cameraview.getFocalLength()<<std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user