Udates to Drawable + IVE plugin with support for new ClusterCullingCallack.

Improvement to osgbluemarble.
This commit is contained in:
Robert Osfield
2003-10-10 12:54:21 +00:00
parent 83b04bd04b
commit 5d35daa970
7 changed files with 240 additions and 169 deletions

View File

@@ -1,100 +1,107 @@
/**********************************************************************
*
* FILE: Drawable.cpp
* FILE: Drawable.cpp
*
* DESCRIPTION: Read/Write osg::Drawable in binary format to disk.
* DESCRIPTION: Read/Write osg::Drawable in binary format to disk.
*
* CREATED BY: Auto generated by iveGenerated
* and later modified by Rune Schmidt Jensen.
* CREATED BY: Auto generated by iveGenerated
* and later modified by Rune Schmidt Jensen.
*
* HISTORY: Created 18.3.2003
* HISTORY: Created 18.3.2003
*
* Copyright 2003 VR-C
* Copyright 2003 VR-C
**********************************************************************/
#include "Exception.h"
#include "Drawable.h"
#include "ClusterCullingCallback.h"
#include "Object.h"
#include "StateSet.h"
using namespace ive;
void Drawable::write(DataOutputStream* out){
// Write Drawable's identification.
out->writeInt(IVEDRAWABLE);
// 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("Drawable::write(): Could not cast this osg::Drawable to an osg::Object.");
void Drawable::write(DataOutputStream* out)
{
// Write Drawable's identification.
out->writeInt(IVEDRAWABLE);
// 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("Drawable::write(): Could not cast this osg::Drawable to an osg::Object.");
// Write Drawable's properties.
// Write stateset if any
if (getStateSet())
{
out->writeInt(1); //true we have a stateset
out->writeStateSet(getStateSet());
}
else
out->writeInt(0); //false we don't have a stateset
// Write Drawable's properties.
// Write shape
if (getShape())
{
out->writeInt(1); //true we have a shape
//static_cast<Shape*>(getShape())->write(out);
}
else
out->writeInt(0); //false we don't have a shape
// Write stateset if any
out->writeBool(getStateSet()!=0);
if (getStateSet())
{
out->writeStateSet(getStateSet());
}
osg::ClusterCullingCallback* ccc = dynamic_cast<osg::ClusterCullingCallback*>(getCullCallback());
out->writeBool(ccc!=0);
if(ccc)
{
((ive::ClusterCullingCallback*)(ccc))->write(out);
}
// Write support display list.
out->writeBool(getSupportsDisplayList());
// Write support display list.
out->writeBool(getSupportsDisplayList());
// Write use display list.
out->writeBool(getUseDisplayList());
// Write use display list.
out->writeBool(getUseDisplayList());
// Write use display list.
out->writeBool(getUseVertexBufferObjects());
}
void Drawable::read(DataInputStream* in){
// Read Drawable's identification.
int id = in->peekInt();
if(id == IVEDRAWABLE){
// Code to read Drawable's properties.
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("Drawable::read(): Could not cast this osg::Drawable to an osg::Object.");
void Drawable::read(DataInputStream* in)
{
// Read Drawable's identification.
int id = in->peekInt();
if(id == IVEDRAWABLE)
{
// Code to read Drawable's properties.
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("Drawable::read(): Could not cast this osg::Drawable to an osg::Object.");
// Read in drawable's properties
// Read in drawable's properties
// Read stateset if any
if(in->readInt()){
setStateSet(in->readStateSet());
}
// Read stateset if any
if(in->readBool())
{
setStateSet(in->readStateSet());
}
// Read shape if any
if(in->readInt()){
//osg::Shape* shape = new osg::Shape();
//static_cast<Shape*>(shape)->read(in);
//setShape(shape);
}
if(in->readBool())
{
osg::ClusterCullingCallback* ccc = new osg::ClusterCullingCallback();
((ive::ClusterCullingCallback*)(ccc))->read(in);
setCullCallback(ccc);
}
// Read support display list
setSupportsDisplayList(in->readBool());
// Read support display list
setSupportsDisplayList(in->readBool());
// Read use display list
setUseDisplayList(in->readBool());
// Read use display list
setUseDisplayList(in->readBool());
}
else{
throw Exception("Drawable::read(): Expected Drawable identification.");
}
// Read use display list
setUseVertexBufferObjects(in->readBool());
}
else{
throw Exception("Drawable::read(): Expected Drawable identification.");
}
}