Added prelimary shape support to .ive plugin
This commit is contained in:
314
src/osgPlugins/ive/Shape.cpp
Normal file
314
src/osgPlugins/ive/Shape.cpp
Normal file
@@ -0,0 +1,314 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: HeightField.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::HeightField 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 "Shape.h"
|
||||
#include "Object.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Sphere
|
||||
//
|
||||
void Sphere::write(DataOutputStream* out)
|
||||
{
|
||||
// Write CullFace's identification.
|
||||
out->writeInt(IVESPHERE);
|
||||
// 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("Sphere::write(): Could not cast this osg::Sphere to an osg::Object.");
|
||||
|
||||
// Write Sphere's properties.
|
||||
//out->writeVec4(getColor());
|
||||
}
|
||||
|
||||
void Sphere::read(DataInputStream* in)
|
||||
{
|
||||
// Peek on Sphere's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVESPHERE)
|
||||
{
|
||||
// Read Sphere'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("Sphere::read(): Could not cast this osg::Sphere to an osg::Object.");
|
||||
|
||||
// Read Sphere's properties
|
||||
//setColor(in->readVec4());
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Exception("Sphere::read(): Expected Sphere identification.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Box
|
||||
//
|
||||
void Box::write(DataOutputStream* out)
|
||||
{
|
||||
// Write CullFace's identification.
|
||||
out->writeInt(IVEBOX);
|
||||
// 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("Box::write(): Could not cast this osg::Box to an osg::Object.");
|
||||
|
||||
// Write Box's properties.
|
||||
//out->writeVec4(getColor());
|
||||
}
|
||||
|
||||
void Box::read(DataInputStream* in)
|
||||
{
|
||||
// Peek on Box's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEBOX)
|
||||
{
|
||||
// Read Box'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("Box::read(): Could not cast this osg::Box to an osg::Object.");
|
||||
|
||||
// Read Box's properties
|
||||
//setColor(in->readVec4());
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Exception("Box::read(): Expected Box identification.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Cone
|
||||
//
|
||||
void Cone::write(DataOutputStream* out)
|
||||
{
|
||||
// Write CullFace's identification.
|
||||
out->writeInt(IVECONE);
|
||||
// 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("Cone::write(): Could not cast this osg::Cone to an osg::Object.");
|
||||
|
||||
// Write Cone's properties.
|
||||
//out->writeVec4(getColor());
|
||||
}
|
||||
|
||||
void Cone::read(DataInputStream* in)
|
||||
{
|
||||
// Peek on Cone's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVECONE)
|
||||
{
|
||||
// Read Cone'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("Cone::read(): Could not cast this osg::Cone to an osg::Object.");
|
||||
|
||||
// Read Cone's properties
|
||||
//setColor(in->readVec4());
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Exception("Cone::read(): Expected Cone identification.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Cylinder
|
||||
//
|
||||
void Cylinder::write(DataOutputStream* out)
|
||||
{
|
||||
// Write CullFace's identification.
|
||||
out->writeInt(IVECYLINDER);
|
||||
// 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("Cylinder::write(): Could not cast this osg::Cylinder to an osg::Object.");
|
||||
|
||||
// Write Cylinder's properties.
|
||||
//out->writeVec4(getColor());
|
||||
}
|
||||
|
||||
void Cylinder::read(DataInputStream* in)
|
||||
{
|
||||
// Peek on Cylinder's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVECYLINDER)
|
||||
{
|
||||
// Read Cylinder'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("Cylinder::read(): Could not cast this osg::Cylinder to an osg::Object.");
|
||||
|
||||
// Read Cylinder's properties
|
||||
//setColor(in->readVec4());
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Exception("Cylinder::read(): Expected Cylinder identification.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Capsule
|
||||
//
|
||||
void Capsule::write(DataOutputStream* out)
|
||||
{
|
||||
// Write CullFace's identification.
|
||||
out->writeInt(IVECAPSULE);
|
||||
// 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("Capsule::write(): Could not cast this osg::Capsule to an osg::Object.");
|
||||
|
||||
// Write Capsule's properties.
|
||||
//out->writeVec4(getColor());
|
||||
}
|
||||
|
||||
void Capsule::read(DataInputStream* in)
|
||||
{
|
||||
// Peek on Capsule's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVECAPSULE)
|
||||
{
|
||||
// Read Capsule'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("Capsule::read(): Could not cast this osg::Capsule to an osg::Object.");
|
||||
|
||||
// Read Capsule's properties
|
||||
//setColor(in->readVec4());
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Exception("Capsule::read(): Expected Capsule identification.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// HeightField
|
||||
//
|
||||
void HeightField::write(DataOutputStream* out)
|
||||
{
|
||||
// Write CullFace's identification.
|
||||
out->writeInt(IVEHEIGHTFIELD);
|
||||
// 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("HeightField::write(): Could not cast this osg::HeightField to an osg::Object.");
|
||||
|
||||
// Write HeightField's properties.
|
||||
//out->writeVec4(getColor());
|
||||
}
|
||||
|
||||
void HeightField::read(DataInputStream* in)
|
||||
{
|
||||
// Peek on HeightField's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEHEIGHTFIELD)
|
||||
{
|
||||
// Read HeightField'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("HeightField::read(): Could not cast this osg::HeightField to an osg::Object.");
|
||||
|
||||
// Read HeightField's properties
|
||||
//setColor(in->readVec4());
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Exception("HeightField::read(): Expected HeightField identification.");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user