Added prelimary shape support to .ive plugin

This commit is contained in:
Robert Osfield
2004-03-17 16:11:47 +00:00
parent c4deb5510f
commit 2def63605f
11 changed files with 606 additions and 5 deletions

View File

@@ -0,0 +1,78 @@
/**********************************************************************
*
* FILE: ShapeDrawable.cpp
*
* DESCRIPTION: Read/Write osg::ShapeDrawable in binary format to disk.
*
* CREATED BY: Auto generated by iveGenerator
* and later modified by Rune Schmidt Jensen.
*
* HISTORY: Created 27.3.2003
*
* Copyright 2003 VR-C
**********************************************************************/
#include "Exception.h"
#include "ShapeDrawable.h"
#include "Object.h"
using namespace ive;
void ShapeDrawable::write(DataOutputStream* out)
{
// Write CullFace's identification.
out->writeInt(IVESHAPEDRAWABLE);
// 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("ShapeDrawable::write(): Could not cast this osg::ShapeDrawable to an osg::Object.");
// Write ShapeDrawable's properties.
out->writeVec4(getColor());
if (getShape())
{
out->writeBool(true);
out->writeShape(getShape());
}
else
{
out->writeBool(false);
}
}
void ShapeDrawable::read(DataInputStream* in)
{
// Peek on ShapeDrawable's identification.
int id = in->peekInt();
if(id == IVESHAPEDRAWABLE)
{
// Read ShapeDrawable'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("ShapeDrawable::read(): Could not cast this osg::ShapeDrawable to an osg::Object.");
// Read ShapeDrawable's properties
setColor(in->readVec4());
if (in->readBool())
{
setShape(in->readShape());
}
}
else
{
throw Exception("ShapeDrawable::read(): Expected ShapeDrawable identification.");
}
}