2003-05-24 03:51:12 +08:00
|
|
|
/**********************************************************************
|
|
|
|
*
|
2005-11-17 23:03:51 +08:00
|
|
|
* FILE: TexGen.cpp
|
2003-05-24 03:51:12 +08:00
|
|
|
*
|
2005-11-17 23:03:51 +08:00
|
|
|
* DESCRIPTION: Read/Write osg::TexGen in binary format to disk.
|
2003-05-24 03:51:12 +08:00
|
|
|
*
|
2005-11-17 23:03:51 +08:00
|
|
|
* CREATED BY: Auto generated by iveGenerated
|
|
|
|
* and later modified by Rune Schmidt Jensen.
|
2003-05-24 03:51:12 +08:00
|
|
|
*
|
2005-11-17 23:03:51 +08:00
|
|
|
* HISTORY: Created 21.3.2003
|
2003-05-24 03:51:12 +08:00
|
|
|
*
|
2005-11-17 23:03:51 +08:00
|
|
|
* Copyright 2003 VR-C
|
2003-05-24 03:51:12 +08:00
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
#include "Exception.h"
|
|
|
|
#include "TexGen.h"
|
|
|
|
#include "Object.h"
|
|
|
|
|
|
|
|
using namespace ive;
|
|
|
|
|
|
|
|
void TexGen::write(DataOutputStream* out){
|
2005-11-17 23:03:51 +08:00
|
|
|
// Write TexGen's identification.
|
|
|
|
out->writeInt(IVETEXGEN);
|
|
|
|
// If the osg class is inherited by any other class we should also write this to file.
|
|
|
|
osg::Object* obj = dynamic_cast<osg::Object*>(this);
|
|
|
|
if(obj){
|
|
|
|
((ive::Object*)(obj))->write(out);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
throw Exception("TexGen::write(): Could not cast this osg::TexGen to an osg::Object.");
|
|
|
|
// Write TexGen's properties.
|
2003-05-24 03:51:12 +08:00
|
|
|
|
2005-11-17 23:03:51 +08:00
|
|
|
// Write mode
|
|
|
|
out->writeInt(getMode());
|
2003-05-24 03:51:12 +08:00
|
|
|
|
2005-11-17 23:03:51 +08:00
|
|
|
if ( out->getVersion() >= VERSION_0005 )
|
|
|
|
{
|
|
|
|
out->writePlane(getPlane(osg::TexGen::S));
|
|
|
|
out->writePlane(getPlane(osg::TexGen::T));
|
|
|
|
out->writePlane(getPlane(osg::TexGen::R));
|
|
|
|
out->writePlane(getPlane(osg::TexGen::Q));
|
|
|
|
}
|
2003-05-24 03:51:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void TexGen::read(DataInputStream* in){
|
2005-11-17 23:03:51 +08:00
|
|
|
// Peek on TexGen's identification.
|
|
|
|
int id = in->peekInt();
|
|
|
|
if(id == IVETEXGEN){
|
|
|
|
// Read TexGen's identification.
|
|
|
|
id = in->readInt();
|
|
|
|
// If the osg class is inherited by any other class we should also read this from file.
|
|
|
|
osg::Object* obj = dynamic_cast<osg::Object*>(this);
|
|
|
|
if(obj){
|
|
|
|
((ive::Object*)(obj))->read(in);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
throw Exception("TexGen::read(): Could not cast this osg::TexGen to an osg::Object.");
|
|
|
|
// Read TexGen's properties
|
|
|
|
setMode((osg::TexGen::Mode)in->readInt());
|
2004-09-30 03:10:00 +08:00
|
|
|
|
2005-11-17 23:03:51 +08:00
|
|
|
if ( in->getVersion() >= VERSION_0005 )
|
|
|
|
{
|
|
|
|
setPlane(osg::TexGen::S, in->readPlane());
|
|
|
|
setPlane(osg::TexGen::T, in->readPlane());
|
|
|
|
setPlane(osg::TexGen::R, in->readPlane());
|
|
|
|
setPlane(osg::TexGen::Q, in->readPlane());
|
|
|
|
}
|
2003-05-24 03:51:12 +08:00
|
|
|
|
2005-11-17 23:03:51 +08:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
throw Exception("TexGen::read(): Expected TexGen identification.");
|
|
|
|
}
|
2003-05-24 03:51:12 +08:00
|
|
|
}
|