Added 1D texture support to .ive plugin. (Fixed a couple of misspellings
as well).
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
* CREATED BY: Rune Schmidt Jensen
|
||||
*
|
||||
* HISTORY: Created 11.03.2003
|
||||
* Updated for texture1D by Don Burns, 27.1.2004
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
@@ -21,6 +22,7 @@
|
||||
#include "PolygonOffset.h"
|
||||
#include "ShadeModel.h"
|
||||
#include "Point.h"
|
||||
#include "Texture1D.h"
|
||||
#include "Texture2D.h"
|
||||
#include "TextureCubeMap.h"
|
||||
#include "TexEnv.h"
|
||||
@@ -629,6 +631,10 @@ osg::StateAttribute* DataInputStream::readStateAttribute()
|
||||
attribute = new osg::Point();
|
||||
((ive::Point*)(attribute))->read(this);
|
||||
}
|
||||
else if(attributeID == IVETEXTURE1D){
|
||||
attribute = new osg::Texture1D();
|
||||
((ive::Texture1D*)(attribute))->read(this);
|
||||
}
|
||||
else if(attributeID == IVETEXTURE2D){
|
||||
attribute = new osg::Texture2D();
|
||||
((ive::Texture2D*)(attribute))->read(this);
|
||||
@@ -654,7 +660,7 @@ osg::StateAttribute* DataInputStream::readStateAttribute()
|
||||
((ive::TexMat*)(attribute))->read(this);
|
||||
}
|
||||
else{
|
||||
throw Exception("Unkown StateAttribute in StateSet::read()");
|
||||
throw Exception("Unknown StateAttribute in StateSet::read()");
|
||||
}
|
||||
|
||||
// and add it to the stateattribute map,
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
* CREATED BY: Rune Schmidt Jensen
|
||||
*
|
||||
* HISTORY: Created 11.03.2003
|
||||
* Updated for 1D textures - Don Burns 27.1.2004
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
@@ -23,6 +24,7 @@
|
||||
#include "PolygonOffset.h"
|
||||
#include "ShadeModel.h"
|
||||
#include "Point.h"
|
||||
#include "Texture1D.h"
|
||||
#include "Texture2D.h"
|
||||
#include "TextureCubeMap.h"
|
||||
#include "TexEnv.h"
|
||||
@@ -429,6 +431,10 @@ void DataOutputStream::writeStateAttribute(const osg::StateAttribute* attribute)
|
||||
else if(dynamic_cast<const osg::Point*>(attribute)){
|
||||
((ive::Point*)(attribute))->write(this);
|
||||
}
|
||||
// This is a Texture1D
|
||||
else if(dynamic_cast<const osg::Texture1D*>(attribute)){
|
||||
((ive::Texture1D*)(attribute))->write(this);
|
||||
}
|
||||
// This is a Texture2D
|
||||
else if(dynamic_cast<const osg::Texture2D*>(attribute)){
|
||||
((ive::Texture2D*)(attribute))->write(this);
|
||||
|
||||
@@ -49,6 +49,7 @@ CXXFILES =\
|
||||
TexGen.cpp\
|
||||
TexMat.cpp\
|
||||
Texture.cpp\
|
||||
Texture1D.cpp\
|
||||
Texture2D.cpp\
|
||||
TextureCubeMap.cpp\
|
||||
Transform.cpp\
|
||||
|
||||
@@ -199,7 +199,7 @@ void Geometry::read(DataInputStream* in){
|
||||
addPrimitiveSet(prim);
|
||||
}
|
||||
else{
|
||||
throw Exception("Unkown PrimitiveSet in Geometry::read()");
|
||||
throw Exception("Unknown PrimitiveSet in Geometry::read()");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "CullFace.h"
|
||||
#include "PolygonOffset.h"
|
||||
#include "ShadeModel.h"
|
||||
#include "Texture1D.h"
|
||||
#include "Texture2D.h"
|
||||
#include "TextureCubeMap.h"
|
||||
#include "TexEnv.h"
|
||||
@@ -131,7 +132,7 @@ void StateSet::read(DataInputStream* in){
|
||||
case 3:
|
||||
setRenderBinDetails(num, name, osg::StateSet::ENCLOSE_RENDERBIN_DETAILS);
|
||||
break;
|
||||
default: throw Exception("Unkown RenderBinMode in StateSet::read()");
|
||||
default: throw Exception("Unknown RenderBinMode in StateSet::read()");
|
||||
}
|
||||
|
||||
// Read stateset modes.
|
||||
|
||||
98
src/osgPlugins/ive/Texture1D.cpp
Normal file
98
src/osgPlugins/ive/Texture1D.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: Texture2D.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::Texture2D in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Copied from Texture 2D.cpp and edited for Texture 1D
|
||||
* by Don Burns
|
||||
*
|
||||
* HISTORY: Created 27.1.2004
|
||||
*
|
||||
* Copyright 2003 VR-C, OSGPL
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "Texture1D.h"
|
||||
#include "Texture.h"
|
||||
#include "Image.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void Texture1D::write(DataOutputStream* out){
|
||||
// Write Texture1D's identification.
|
||||
out->writeInt(IVETEXTURE1D);
|
||||
// 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("Texture1D::write(): Could not cast this osg::Texture1D to an osg::Texture.");
|
||||
// Write Texture1D'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 Texture1D::read(DataInputStream* in){
|
||||
// Read Texture1D's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVETEXTURE1D){
|
||||
// Code to read Texture1D'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("Texture1D::read(): Could not cast this osg::Texture1D 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("Texture1D::read(): Expected Texture1D identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/Texture1D.h
Normal file
15
src/osgPlugins/ive/Texture1D.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_TEXTURE1D
|
||||
#define IVE_TEXTURE1D 1
|
||||
|
||||
#include <osg/Texture1D>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class Texture1D : public osg::Texture1D, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user