2003-05-24 03:51:12 +08:00
|
|
|
/**********************************************************************
|
|
|
|
*
|
2005-11-17 23:03:51 +08:00
|
|
|
* FILE: Object.cpp
|
2003-05-24 03:51:12 +08:00
|
|
|
*
|
2005-11-17 23:03:51 +08:00
|
|
|
* DESCRIPTION: Read/Write osg::Object 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 17.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 "Object.h"
|
|
|
|
|
|
|
|
using namespace ive;
|
|
|
|
|
2005-06-08 21:16:19 +08:00
|
|
|
void Object::write(DataOutputStream* out)
|
|
|
|
{
|
|
|
|
// Write Object's identification.
|
|
|
|
out->writeInt(IVEOBJECT);
|
2003-05-24 03:51:12 +08:00
|
|
|
|
2005-06-08 21:16:19 +08:00
|
|
|
if ( out->getVersion() >= VERSION_0012 )
|
|
|
|
{
|
|
|
|
// Write Name
|
|
|
|
out->writeString(getName());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write Object's properties.
|
|
|
|
switch(getDataVariance())
|
|
|
|
{
|
2005-11-17 23:03:51 +08:00
|
|
|
case(osg::Object::STATIC): out->writeChar((char)0); break;
|
|
|
|
case(osg::Object::DYNAMIC): out->writeChar((char)1); break;
|
2007-02-14 21:18:58 +08:00
|
|
|
case(osg::Object::UNSPECIFIED): out->writeChar((char)2); break;
|
2003-05-24 03:51:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Object::read(DataInputStream* in){
|
2005-06-08 21:16:19 +08:00
|
|
|
// Read Object's identification.
|
|
|
|
int id = in->peekInt();
|
|
|
|
if(id == IVEOBJECT)
|
|
|
|
{
|
2005-11-17 23:03:51 +08:00
|
|
|
// Code to read Object's properties.
|
|
|
|
id = in->readInt();
|
2005-06-08 21:16:19 +08:00
|
|
|
|
|
|
|
if ( in->getVersion() >= VERSION_0012 )
|
|
|
|
{
|
|
|
|
// Read name
|
|
|
|
setName(in->readString());
|
|
|
|
}
|
|
|
|
|
2005-11-17 23:03:51 +08:00
|
|
|
char c = in->readChar();
|
|
|
|
switch((int)c)
|
|
|
|
{
|
|
|
|
case 0: setDataVariance(osg::Object::STATIC);break;
|
|
|
|
case 1: setDataVariance(osg::Object::DYNAMIC);break;
|
2007-02-14 21:18:58 +08:00
|
|
|
case 2: setDataVariance(osg::Object::UNSPECIFIED);break;
|
2005-11-17 23:03:51 +08:00
|
|
|
}
|
2005-06-08 21:16:19 +08:00
|
|
|
}
|
|
|
|
else{
|
2005-11-17 23:03:51 +08:00
|
|
|
throw Exception("Object::read(): Expected Object identification");
|
2005-06-08 21:16:19 +08:00
|
|
|
}
|
2003-05-24 03:51:12 +08:00
|
|
|
}
|