Added support for PagedLOD node into .ive format and added support for
Enabled texture object reuse by setting an expiry delay in the TextureObjectManager of 10 seconds - done for both osgDB::DatabasePager and TXP plugin.
This commit is contained in:
120
src/osgPlugins/ive/PagedLOD.cpp
Normal file
120
src/osgPlugins/ive/PagedLOD.cpp
Normal file
@@ -0,0 +1,120 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: LOD.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::LOD 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 "PagedLOD.h"
|
||||
#include "Node.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void PagedLOD::write(DataOutputStream* out){
|
||||
// Write LOD's identification.
|
||||
out->writeInt(IVEPAGEDLOD);
|
||||
// If the osg class is inherited by any other class we should also write this to file.
|
||||
|
||||
osg::Node* node = dynamic_cast<osg::Node*>(this);
|
||||
if(node){
|
||||
static_cast<ive::Node*>(node)->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("PagedLOD::write(): Could not cast this osg::PagedLOD to an osg::LOD.");
|
||||
|
||||
unsigned int numChildrenToWriteOut = 0;
|
||||
|
||||
int i;
|
||||
for(i=0; i<(int)getNumFileNames();++i)
|
||||
{
|
||||
if (getFileName(i).empty())
|
||||
{
|
||||
++numChildrenToWriteOut;
|
||||
}
|
||||
}
|
||||
|
||||
// Write Group's properties.
|
||||
// Write number of children.
|
||||
out->writeInt(numChildrenToWriteOut);
|
||||
// Write children.
|
||||
for(i=0; i<(int)getNumChildren(); i++){
|
||||
if (getFileName(i).empty())
|
||||
{
|
||||
osg::Node* child = getChild(i);
|
||||
out->writeNode(child);
|
||||
}
|
||||
}
|
||||
|
||||
// LOD properties
|
||||
// Write centermode
|
||||
out->writeInt(getCenterMode());
|
||||
out->writeVec3(getCenter());
|
||||
// Write rangelist
|
||||
int size = getNumRanges();
|
||||
out->writeInt(size);
|
||||
for(i=0;i<size;i++){
|
||||
out->writeFloat(getMinRange(i));
|
||||
out->writeFloat(getMaxRange(i));
|
||||
}
|
||||
|
||||
|
||||
// PagedLOD properties
|
||||
size = getNumFileNames();
|
||||
out->writeInt(size);
|
||||
for(i=0;i<size;i++){
|
||||
out->writeString(getFileName(i));
|
||||
}
|
||||
}
|
||||
|
||||
void PagedLOD::read(DataInputStream* in){
|
||||
// Peek on LOD's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEPAGEDLOD){
|
||||
// Read LOD's identification.
|
||||
id = in->readInt();
|
||||
// If the osg class is inherited by any other class we should also read this from file.
|
||||
osg::Node* node = dynamic_cast<osg::Node*>(this);
|
||||
if(node){
|
||||
((ive::Node*)(node))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("Group::read(): Could not cast this osg::Group to an osg::Node.");
|
||||
|
||||
|
||||
// Read groups properties.
|
||||
// Read number of children.
|
||||
int size = in->readInt();
|
||||
// Read children.
|
||||
for(int i=0; i<size; i++)
|
||||
{
|
||||
addChild(in->readNode());
|
||||
}
|
||||
|
||||
// Read centermode
|
||||
setCenterMode((osg::LOD::CenterMode)in->readInt());
|
||||
setCenter(in->readVec3());
|
||||
// Read rangelist
|
||||
size = in->readInt();
|
||||
for(int i=0;i<size;i++){
|
||||
float min = in->readFloat();
|
||||
float max = in->readFloat();
|
||||
setRange(i, min, max);
|
||||
}
|
||||
|
||||
size = in->readInt();
|
||||
for(int i=0;i<size;i++){
|
||||
setFileName(i, in->readString());
|
||||
}
|
||||
}
|
||||
else{
|
||||
throw Exception("LOD::read(): Expected LOD identification.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user