1
/**********************************************************************
5
* DESCRIPTION: Read/Write osgFX::Cartoon in binary format to disk.
7
* CREATED BY: Liang Aibin
9
* HISTORY: Created 23.8.2008
11
**********************************************************************/
13
#include "Exception.h"
19
void Cartoon::write(DataOutputStream* out){
20
// Write Cartoon's identification.
21
out->writeInt(IVECARTOON);
22
// If the osg class is inherited by any other class we should also write this to file.
23
osgFX::Effect* effect = dynamic_cast<osgFX::Effect*>(this);
25
((ive::Effect*)(effect))->write(out);
28
throw Exception("Cartoon::write(): Could not cast this osgFX::Cartoon to an osgFX::Effect.");
30
// Write Cartoon's properties.
31
out->writeVec4(getOutlineColor());
32
out->writeFloat(getOutlineLineWidth());
33
out->writeInt(getLightNumber());
36
void Cartoon::read(DataInputStream* in){
37
// Peek on Cartoon's identification.
38
int id = in->peekInt();
40
// Read Cartoon's identification.
43
// If the osg class is inherited by any other class we should also read this from file.
44
osgFX::Effect* effect = dynamic_cast<osgFX::Effect*>(this);
46
((ive::Effect*)(effect))->read(in);
49
throw Exception("Cartoon::read(): Could not cast this osgFX::Cartoon to an osgFX::Effect.");
51
// Read Cartoon's properties
52
setOutlineColor(in->readVec4());
53
setOutlineLineWidth(in->readFloat());
54
setLightNumber(in->readInt());
57
throw Exception("Cartoon::read(): Expected Cartoon identification.");