OpenSceneGraph/src/osgPlugins/ive/Texture3D.cpp
Robert Osfield 10d139fc1f From Farshid Lashkari, "I've made some changes to the IVE loader which will add the capability
of saving image files inside the IVE file. Currently, only the raw
image data is saved into the file. If your model uses jpg images as
textures then this will cause your file size to increase.

I've added an option that will embed the original image file into the
IVE file. The IVE file will then attempt to read the image from
memory. Since most image loaders support reading from memory, this
shouldn't be a problem. To use this new feature the user must specify
the option "includeImageFileInIVEFile" when converting to IVE.

I tested this out on the "skydome.osg" model that comes with OSG.
Using the old method, the IVE file size would be 785 KB, with the new
method it is only 42 KB.

Also, I've added the support for TextureRectangle's to the IVE reader/writer."
2006-02-26 17:45:52 +00:00

69 lines
2.2 KiB
C++

/**********************************************************************
*
* FILE: Texture3D.cpp
*
* DESCRIPTION: Read/Write osg::Texture3D in binary format to disk.
*
* CREATED BY: Auto generated by iveGenerated
* and later modified by Rune Schmidt Jensen.
*
* HISTORY: Created 20.3.2003
*
* Copyright 2003 VR-C
**********************************************************************/
#include "Exception.h"
#include "Texture3D.h"
#include "Texture.h"
#include "Image.h"
using namespace ive;
void Texture3D::write(DataOutputStream* out){
// Write Texture3D's identification.
out->writeInt(IVETEXTURE3D);
// If the osg class is inherited by any other class we should also write this to file.
osg::Texture* tex = dynamic_cast<osg::Texture*>(this);
if(tex){
((ive::Texture*)(tex))->write(out);
}
else
throw Exception("Texture3D::write(): Could not cast this osg::Texture3D to an osg::Texture.");
// Write Texture3D's properties.
// Write image.
// Should we include images date in stream
IncludeImageMode includeImg = out->getIncludeImageMode();
out->writeChar(includeImg);
out->writeImage(includeImg,getImage());
}
void Texture3D::read(DataInputStream* in){
// Read Texture3D's identification.
int id = in->peekInt();
if(id == IVETEXTURE3D){
// Code to read Texture3D's properties.
id = in->readInt();
// If the osg class is inherited by any other class we should also read this from file.
osg::Texture* tex = dynamic_cast<osg::Texture*>(this);
if(tex){
((ive::Texture*)(tex))->read(in);
}
else
throw Exception("Texture3D::read(): Could not cast this osg::Texture3D to an osg::Texture.");
// Read image.
// Should we read image data from stream
IncludeImageMode includeImg = (IncludeImageMode)in->readChar();
osg::Image *image = in->readImage(includeImg);
if(image) {
setImage(image);
}
}
else{
throw Exception("Texture3D::read(): Expected Texture3D identification.");
}
}