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:
Robert Osfield
2003-07-23 15:52:05 +00:00
parent 46680be5eb
commit a7b7d6cefc
9 changed files with 253 additions and 91 deletions

View File

@@ -33,6 +33,7 @@
#include "Billboard.h"
#include "Sequence.h"
#include "LOD.h"
#include "PagedLOD.h"
//#include "ViewPoint.h"
#include "PositionAttitudeTransform.h"
#include "Transform.h"
@@ -556,6 +557,10 @@ osg::Node* DataInputStream::readNode()
node = new osg::LOD();
((ive::LOD*)(node))->read(this);
}
else if(nodeTypeID== IVEPAGEDLOD){
node = new osg::PagedLOD();
((ive::PagedLOD*)(node))->read(this);
}
else if(nodeTypeID== IVESWITCH){
node = new osg::Switch();
((ive::Switch*)(node))->read(this);

View File

@@ -35,6 +35,7 @@
#include "Billboard.h"
#include "Sequence.h"
#include "LOD.h"
#include "PagedLOD.h"
//#include "ViewPoint.h"
#include "PositionAttitudeTransform.h"
#include "Transform.h"
@@ -421,6 +422,9 @@ void DataOutputStream::writeNode(osg::Node* node)
else if(dynamic_cast<osg::Impostor*>(node)){
((ive::Impostor*)(node))->write(this);
}
else if(dynamic_cast<osg::PagedLOD*>(node)){
((ive::PagedLOD*)(node))->write(this);
}
else if(dynamic_cast<osg::LOD*>(node)){
((ive::LOD*)(node))->write(this);
}

View File

@@ -30,6 +30,7 @@ CXXFILES =\
Node.cpp\
Object.cpp\
OccluderNode.cpp\
PagedLOD.cpp\
PositionAttitudeTransform.cpp\
PolygonOffset.cpp\
Point.cpp\

View 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.");
}
}

View File

@@ -0,0 +1,15 @@
#ifndef IVE_PAGEDLOD
#define IVE_PAGEDLOD 1
#include <osg/PagedLOD>
#include "ReadWrite.h"
namespace ive{
class PagedLOD : public osg::PagedLOD, public ReadWrite {
public:
void write(DataOutputStream* out);
void read(DataInputStream* in);
};
}
#endif

View File

@@ -27,6 +27,7 @@ namespace ive {
#define IVEIMPOSTOR 0x00000018
#define IVECONVEXPLANAROCCLUDER 0x00000019
#define IVECONVEXPLANARPOLYGON 0x00000020
#define IVEPAGEDLOD 0x00000021
// Node callbacks
#define IVENODECALLBACK 0x00000050