2005-03-10 00:54:10 +08:00
|
|
|
/**********************************************************************
|
|
|
|
*
|
|
|
|
* FILE: MultiTextureControl.cpp
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Read/Write osg::MultiTextureControl in binary format to disk.
|
|
|
|
*
|
|
|
|
* CREATED BY: Auto generated by iveGenerate
|
|
|
|
* and later modified by Rune Schmidt Jensen.
|
|
|
|
*
|
|
|
|
* HISTORY: Created 24.3.2003
|
|
|
|
*
|
|
|
|
* Copyright 2003 VR-C
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
#include "Exception.h"
|
|
|
|
#include "MultiTextureControl.h"
|
|
|
|
#include "Group.h"
|
|
|
|
|
|
|
|
using namespace ive;
|
|
|
|
|
|
|
|
void MultiTextureControl::write(DataOutputStream* out){
|
|
|
|
// Write MultiTextureControl's identification.
|
|
|
|
out->writeInt(IVEMULTITEXTURECONTROL);
|
|
|
|
// If the osg class is inherited by any other class we should also write this to file.
|
|
|
|
osg::Group* group = dynamic_cast<osg::Group*>(this);
|
|
|
|
if(group){
|
|
|
|
((ive::Group*)(group))->write(out);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
throw Exception("MultiTextureControl::write(): Could not cast this osg::MultiTextureControl to an osg::Group.");
|
|
|
|
// Write MultiTextureControl's properties.
|
|
|
|
|
|
|
|
|
|
|
|
// Write rangelist
|
|
|
|
unsigned int size = getNumTextureWeights();
|
|
|
|
out->writeUInt(size);
|
2005-04-05 00:06:28 +08:00
|
|
|
for(unsigned int i=0;i<size;i++)
|
|
|
|
{
|
2005-03-10 00:54:10 +08:00
|
|
|
out->writeFloat(getTextureWeight(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MultiTextureControl::read(DataInputStream* in){
|
|
|
|
// Peek on MultiTextureControl's identification.
|
|
|
|
int id = in->peekInt();
|
|
|
|
if(id == IVEMULTITEXTURECONTROL){
|
|
|
|
// Read MultiTextureControl's identification.
|
|
|
|
id = in->readInt();
|
|
|
|
|
|
|
|
// If the osg class is inherited by any other class we should also read this from file.
|
|
|
|
osg::Group* group = dynamic_cast<osg::Group*>(this);
|
|
|
|
if(group){
|
|
|
|
((ive::Group*)(group))->read(in);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
throw Exception("MultiTextureControl::read(): Could not cast this osg::MultiTextureControl to an osg::Group.");
|
|
|
|
// Read MultiTextureControl's properties
|
|
|
|
|
|
|
|
|
|
|
|
// Read rangelist
|
|
|
|
unsigned int size = in->readUInt();
|
|
|
|
for(unsigned int i=0;i<size;i++)
|
2005-04-05 00:06:28 +08:00
|
|
|
{
|
2005-03-10 00:54:10 +08:00
|
|
|
float value = in->readFloat();
|
|
|
|
setTextureWeight(i, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
throw Exception("MultiTextureControl::read(): Expected MultiTextureControl identification.");
|
|
|
|
}
|
|
|
|
}
|