Added Texture3D implementation.
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include "LineWidth.h"
|
||||
#include "Texture1D.h"
|
||||
#include "Texture2D.h"
|
||||
#include "Texture3D.h"
|
||||
#include "TextureCubeMap.h"
|
||||
#include "TexEnv.h"
|
||||
#include "TexEnvCombine.h"
|
||||
@@ -657,6 +658,10 @@ osg::StateAttribute* DataInputStream::readStateAttribute()
|
||||
attribute = new osg::Texture2D();
|
||||
((ive::Texture2D*)(attribute))->read(this);
|
||||
}
|
||||
else if(attributeID == IVETEXTURE3D){
|
||||
attribute = new osg::Texture3D();
|
||||
((ive::Texture3D*)(attribute))->read(this);
|
||||
}
|
||||
else if(attributeID == IVETEXTURECUBEMAP){
|
||||
attribute = new osg::TextureCubeMap();
|
||||
((ive::TextureCubeMap*)(attribute))->read(this);
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "LineWidth.h"
|
||||
#include "Texture1D.h"
|
||||
#include "Texture2D.h"
|
||||
#include "Texture3D.h"
|
||||
#include "TextureCubeMap.h"
|
||||
#include "TexEnv.h"
|
||||
#include "TexEnvCombine.h"
|
||||
@@ -455,6 +456,10 @@ void DataOutputStream::writeStateAttribute(const osg::StateAttribute* attribute)
|
||||
else if(dynamic_cast<const osg::Texture2D*>(attribute)){
|
||||
((ive::Texture2D*)(attribute))->write(this);
|
||||
}
|
||||
// This is a Texture2D
|
||||
else if(dynamic_cast<const osg::Texture3D*>(attribute)){
|
||||
((ive::Texture3D*)(attribute))->write(this);
|
||||
}
|
||||
// This is a TextureCubeMap
|
||||
else if(dynamic_cast<const osg::TextureCubeMap*>(attribute)){
|
||||
((ive::TextureCubeMap*)(attribute))->write(this);
|
||||
|
||||
@@ -57,9 +57,10 @@ CXXFILES =\
|
||||
Texture.cpp\
|
||||
Texture1D.cpp\
|
||||
Texture2D.cpp\
|
||||
Texture3D.cpp\
|
||||
TextureCubeMap.cpp\
|
||||
FragmentProgram.cpp\
|
||||
VertexProgram.cpp\
|
||||
TextureCubeMap.cpp\
|
||||
Transform.cpp\
|
||||
ReaderWriterIVE.cpp\
|
||||
AzimElevationSector.cpp\
|
||||
|
||||
99
src/osgPlugins/ive/Texture3D.cpp
Normal file
99
src/osgPlugins/ive/Texture3D.cpp
Normal file
@@ -0,0 +1,99 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* 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
|
||||
bool includeImg = out->getIncludeImageData();
|
||||
out->writeBool(includeImg);
|
||||
|
||||
// Include image data in stream
|
||||
if(includeImg){
|
||||
out->writeBool(getImage()!=0);
|
||||
if(getImage())
|
||||
((ive::Image*)getImage())->write(out);
|
||||
}
|
||||
// Only include image name in stream
|
||||
else{
|
||||
if (getImage() && !(getImage()->getFileName().empty())){
|
||||
out->writeString(getImage()->getFileName());
|
||||
}
|
||||
else{
|
||||
out->writeString("");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
bool includeImg = in->readBool();
|
||||
|
||||
// Read image data from stream
|
||||
if(includeImg)
|
||||
{
|
||||
if(in->readBool())
|
||||
{
|
||||
osg::Image* image = new osg::Image();
|
||||
((ive::Image*)image)->read(in);
|
||||
setImage(image);
|
||||
}
|
||||
}
|
||||
// Only read image name from stream.
|
||||
else{
|
||||
std::string filename = in->readString();
|
||||
if(filename.compare("")!=0){
|
||||
osg::Image* image = in->readImage(filename);
|
||||
if (image){
|
||||
setImage(image);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
throw Exception("Texture3D::read(): Expected Texture3D identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/Texture3D.h
Normal file
15
src/osgPlugins/ive/Texture3D.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_TEXTURE3D
|
||||
#define IVE_TEXTURE3D 1
|
||||
|
||||
#include <osg/Texture3D>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class Texture3D : public osg::Texture3D, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user