Added support for ClipPlane, ClipNode, TexGenNode to .ive
This commit is contained in:
parent
5be0004d52
commit
a8739f952a
@ -128,6 +128,14 @@ SOURCE=..\..\..\src\osgPlugins\ive\BlinkSequence.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\ClipPlane.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\ClipNode.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\ClusterCullingCallback.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -340,6 +348,10 @@ SOURCE=..\..\..\src\osgPlugins\ive\TexGen.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\TexGenNode.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\TexMat.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -412,6 +424,14 @@ SOURCE=..\..\..\src\osgPlugins\ive\BlinkSequence.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\ClipPlane.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\ClipNode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\ClusterCullingCallback.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -628,6 +648,10 @@ SOURCE=..\..\..\src\osgPlugins\ive\TexGen.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\TexGenNode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\TexMat.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
72
src/osgPlugins/ive/ClipNode.cpp
Normal file
72
src/osgPlugins/ive/ClipNode.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: ClipNode.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::ClipNode in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerated
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 21.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "ClipNode.h"
|
||||
#include "ClipPlane.h"
|
||||
#include "Group.h"
|
||||
#include "Light.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void ClipNode::write(DataOutputStream* out){
|
||||
// Write ClipNode's identification.
|
||||
out->writeInt(IVECLIPNODE);
|
||||
// If the osg class is inherited by any other class we should also write this to file.
|
||||
osg::Group* group = dynamic_cast<osg::Group*>(this);
|
||||
if(group){
|
||||
((ive::Group*)(group))->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("ClipNode::write(): Could not cast this osg::ClipNode to an osg::Group.");
|
||||
// Write ClipNode's properties.
|
||||
|
||||
out->writeUInt(getNumClipPlanes());
|
||||
|
||||
for (unsigned int i=0;i<getNumClipPlanes();++i)
|
||||
{
|
||||
((ive::ClipPlane*)getClipPlane(i))->write(out);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ClipNode::read(DataInputStream* in){
|
||||
// Peek on ClipNode's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVECLIPNODE){
|
||||
// Read ClipNode's identification.
|
||||
id = in->readInt();
|
||||
// If the osg class is inherited by any other class we should also read this from file.
|
||||
osg::Group* group = dynamic_cast<osg::Group*>(this);
|
||||
if(group){
|
||||
((ive::Group*)(group))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("ClipNode::read(): Could not cast this osg::ClipNode to an osg::Object.");
|
||||
// Read ClipNode's properties
|
||||
|
||||
unsigned int numClipPlanes = in->readUInt();
|
||||
|
||||
for (unsigned int i=0;i<numClipPlanes;++i)
|
||||
{
|
||||
osg::ClipPlane* clipPlane = new osg::ClipPlane;
|
||||
((ive::ClipPlane*)clipPlane)->read(in);
|
||||
addClipPlane(clipPlane);
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
throw Exception("ClipNode::read(): Expected ClipNode identification.");
|
||||
}
|
||||
}
|
15
src/osgPlugins/ive/ClipNode.h
Normal file
15
src/osgPlugins/ive/ClipNode.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef IVE_ClipNode
|
||||
#define IVE_ClipNode 1
|
||||
|
||||
#include <osg/ClipNode>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class ClipNode : public osg::ClipNode, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
80
src/osgPlugins/ive/ClipPlane.cpp
Normal file
80
src/osgPlugins/ive/ClipPlane.cpp
Normal file
@ -0,0 +1,80 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: ClipPlane.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::ClipPlane (partially) in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Stanislav Blinov
|
||||
*
|
||||
* HISTORY: Created 7.09.2004
|
||||
*
|
||||
* Copyright 2004 OtherSide
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "ClipPlane.h"
|
||||
#include "Object.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void ClipPlane::write(DataOutputStream* out){
|
||||
|
||||
// write ClipPlane's identification
|
||||
out->writeInt(IVECLIPPLANE);
|
||||
|
||||
// if the osg class is inherited by any other class we should also write this to file
|
||||
osg::Object* obj = dynamic_cast<osg::Object*>(this);
|
||||
if(obj)
|
||||
((ive::Object*)(obj))->write(out);
|
||||
else
|
||||
throw Exception("ClipPlane::write(): Could not cast this osg::ClipPlane to an osg::Object.");
|
||||
|
||||
// write ClipPlane's properties
|
||||
|
||||
|
||||
|
||||
|
||||
double plane[4];
|
||||
getClipPlane(plane);
|
||||
|
||||
out->writeDouble(plane[0]);
|
||||
out->writeDouble(plane[1]);
|
||||
out->writeDouble(plane[2]);
|
||||
out->writeDouble(plane[3]);
|
||||
|
||||
out->writeUInt(getClipPlaneNum());
|
||||
|
||||
}
|
||||
|
||||
void ClipPlane::read(DataInputStream* in){
|
||||
|
||||
// peek on ClipPlane's identification
|
||||
int id = in->peekInt();
|
||||
if(id == IVECLIPPLANE)
|
||||
{
|
||||
// read ClipPlane's identification
|
||||
id = in->readInt();
|
||||
|
||||
// if the osg class is inherited by any other class we should also read this from file
|
||||
osg::Object* obj = dynamic_cast<osg::Object*>(this);
|
||||
if(obj)
|
||||
((ive::Object*)(obj))->read(in);
|
||||
else
|
||||
throw Exception("ClipPlane::read(): Could not cast this osg::ClipPlane to an osg::Object.");
|
||||
|
||||
// Read ClipPlane's properties
|
||||
double plane[4];
|
||||
|
||||
plane[0] = in->readDouble();
|
||||
plane[1] = in->readDouble();
|
||||
plane[2] = in->readDouble();
|
||||
plane[3] = in->readDouble();
|
||||
|
||||
setClipPlane(plane);
|
||||
|
||||
setClipPlaneNum(in->readUInt());
|
||||
}
|
||||
else{
|
||||
throw Exception("ClipPlane::read(): Expected ClipPlane identification.");
|
||||
}
|
||||
}
|
15
src/osgPlugins/ive/ClipPlane.h
Normal file
15
src/osgPlugins/ive/ClipPlane.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef IVE_ClipPlane
|
||||
#define IVE_ClipPlane 1
|
||||
|
||||
#include <osg/ClipPlane>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class ClipPlane : public osg::ClipPlane, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -21,6 +21,7 @@
|
||||
#include "BlendFunc.h"
|
||||
#include "Material.h"
|
||||
#include "CullFace.h"
|
||||
#include "ClipPlane.h"
|
||||
#include "PolygonOffset.h"
|
||||
#include "ShadeModel.h"
|
||||
#include "Point.h"
|
||||
@ -41,6 +42,8 @@
|
||||
#include "MatrixTransform.h"
|
||||
#include "Geode.h"
|
||||
#include "LightSource.h"
|
||||
#include "TexGenNode.h"
|
||||
#include "ClipNode.h"
|
||||
#include "Billboard.h"
|
||||
#include "Sequence.h"
|
||||
#include "LOD.h"
|
||||
@ -311,6 +314,18 @@ osg::Vec4 DataInputStream::readVec4(){
|
||||
return v;
|
||||
}
|
||||
|
||||
osg::Plane DataInputStream::readPlane(){
|
||||
osg::Plane v;
|
||||
v[0]=readFloat();
|
||||
v[1]=readFloat();
|
||||
v[2]=readFloat();
|
||||
v[3]=readFloat();
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writePlane() ["<<v<<"]"<<std::endl;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
osg::UByte4 DataInputStream::readUByte4(){
|
||||
osg::UByte4 v;
|
||||
v.r()=readChar();
|
||||
@ -634,6 +649,10 @@ osg::StateAttribute* DataInputStream::readStateAttribute()
|
||||
attribute = new osg::CullFace();
|
||||
((ive::CullFace*)(attribute))->read(this);
|
||||
}
|
||||
else if(attributeID == IVECLIPPLANE){
|
||||
attribute = new osg::ClipPlane();
|
||||
((ive::ClipPlane*)(attribute))->read(this);
|
||||
}
|
||||
else if(attributeID == IVEPOLYGONOFFSET){
|
||||
attribute = new osg::PolygonOffset();
|
||||
((ive::PolygonOffset*)(attribute))->read(this);
|
||||
@ -835,6 +854,14 @@ osg::Node* DataInputStream::readNode()
|
||||
node = new osg::LightSource();
|
||||
((ive::LightSource*)(node))->read(this);
|
||||
}
|
||||
else if(nodeTypeID== IVETEXGENNODE){
|
||||
node = new osg::TexGenNode();
|
||||
((ive::TexGenNode*)(node))->read(this);
|
||||
}
|
||||
else if(nodeTypeID== IVECLIPNODE){
|
||||
node = new osg::ClipNode();
|
||||
((ive::ClipNode*)(node))->read(this);
|
||||
}
|
||||
else if(nodeTypeID== IVESEQUENCE){
|
||||
node = new osg::Sequence();
|
||||
((ive::Sequence*)(node))->read(this);
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
osg::Vec2 readVec2();
|
||||
osg::Vec3 readVec3();
|
||||
osg::Vec4 readVec4();
|
||||
osg::Plane readPlane();
|
||||
osg::UByte4 readUByte4();
|
||||
osg::Quat readQuat();
|
||||
osg::Matrix readMatrix();
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "BlendFunc.h"
|
||||
#include "Material.h"
|
||||
#include "CullFace.h"
|
||||
#include "ClipPlane.h"
|
||||
#include "PolygonOffset.h"
|
||||
#include "ShadeModel.h"
|
||||
#include "Point.h"
|
||||
@ -43,6 +44,8 @@
|
||||
#include "MatrixTransform.h"
|
||||
#include "Geode.h"
|
||||
#include "LightSource.h"
|
||||
#include "TexGenNode.h"
|
||||
#include "ClipNode.h"
|
||||
#include "Billboard.h"
|
||||
#include "Sequence.h"
|
||||
#include "LOD.h"
|
||||
@ -179,6 +182,16 @@ void DataOutputStream::writeVec4(const osg::Vec4& v){
|
||||
if (_verboseOutput) std::cout<<"read/writeVec4() ["<<v<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writePlane(const osg::Plane& v)
|
||||
{
|
||||
writeFloat(v[0]);
|
||||
writeFloat(v[1]);
|
||||
writeFloat(v[2]);
|
||||
writeFloat(v[3]);
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writePlane() ["<<v<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeUByte4(const osg::UByte4& v){
|
||||
writeChar(v.r());
|
||||
writeChar(v.g());
|
||||
@ -432,6 +445,10 @@ void DataOutputStream::writeStateAttribute(const osg::StateAttribute* attribute)
|
||||
else if(dynamic_cast<const osg::CullFace*>(attribute)){
|
||||
((ive::CullFace*)(attribute))->write(this);
|
||||
}
|
||||
// this is a Cliplane
|
||||
else if(dynamic_cast<const osg::ClipPlane*>(attribute)){
|
||||
((ive::ClipPlane*)(attribute))->write(this);
|
||||
}
|
||||
// This is a PolygonOffset
|
||||
else if(dynamic_cast<const osg::PolygonOffset*>(attribute)){
|
||||
((ive::PolygonOffset*)(attribute))->write(this);
|
||||
@ -611,6 +628,12 @@ void DataOutputStream::writeNode(const osg::Node* node)
|
||||
else if(dynamic_cast<const osg::LightSource*>(node)){
|
||||
((ive::LightSource*)(node))->write(this);
|
||||
}
|
||||
else if(dynamic_cast<const osg::TexGenNode*>(node)){
|
||||
((ive::TexGenNode*)(node))->write(this);
|
||||
}
|
||||
else if(dynamic_cast<const osg::ClipNode*>(node)){
|
||||
((ive::ClipNode*)(node))->write(this);
|
||||
}
|
||||
else if(dynamic_cast<const osg::Sequence*>(node)){
|
||||
((ive::Sequence*)(node))->write(this);
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
void writeVec2(const osg::Vec2& v);
|
||||
void writeVec3(const osg::Vec3& v);
|
||||
void writeVec4(const osg::Vec4& v);
|
||||
void writePlane(const osg::Plane& v);
|
||||
void writeUByte4(const osg::UByte4& v);
|
||||
void writeQuat(const osg::Quat& q);
|
||||
void writeBinding(osg::Geometry::AttributeBinding b);
|
||||
|
@ -3,74 +3,77 @@ include $(TOPDIR)/Make/makedefs
|
||||
|
||||
CXXFILES =\
|
||||
AlphaFunc.cpp\
|
||||
AnimationPath.cpp\
|
||||
AnimationPathCallback.cpp\
|
||||
AnimationPath.cpp\
|
||||
AzimElevationSector.cpp\
|
||||
AzimSector.cpp\
|
||||
Billboard.cpp\
|
||||
BlendFunc.cpp\
|
||||
BlinkSequence.cpp\
|
||||
ClipNode.cpp\
|
||||
ClipPlane.cpp\
|
||||
ClusterCullingCallback.cpp\
|
||||
ConeSector.cpp\
|
||||
ConvexPlanarOccluder.cpp\
|
||||
ConvexPlanarPolygon.cpp\
|
||||
CoordinateSystemNode.cpp\
|
||||
ClusterCullingCallback.cpp\
|
||||
CullFace.cpp\
|
||||
DataInputStream.cpp\
|
||||
DataOutputStream.cpp\
|
||||
DirectionalSector.cpp\
|
||||
DOFTransform.cpp\
|
||||
Drawable.cpp\
|
||||
DrawArrayLengths.cpp\
|
||||
DrawArrays.cpp\
|
||||
DrawElementsUByte.cpp\
|
||||
DrawElementsUShort.cpp\
|
||||
DrawElementsUInt.cpp\
|
||||
Drawable.cpp\
|
||||
DrawElementsUShort.cpp\
|
||||
ElevationSector.cpp\
|
||||
EllipsoidModel.cpp\
|
||||
Exception.cpp\
|
||||
FragmentProgram.cpp\
|
||||
Geode.cpp\
|
||||
Geometry.cpp\
|
||||
Group.cpp\
|
||||
Image.cpp\
|
||||
Impostor.cpp\
|
||||
LOD.cpp\
|
||||
Light.cpp\
|
||||
LightSource.cpp\
|
||||
LightModel.cpp\
|
||||
LightPoint.cpp\
|
||||
LightPointNode.cpp\
|
||||
LightSource.cpp\
|
||||
LineWidth.cpp\
|
||||
LOD.cpp\
|
||||
Material.cpp\
|
||||
MatrixTransform.cpp\
|
||||
MultiSwitch.cpp\
|
||||
Node.cpp\
|
||||
LineWidth.cpp\
|
||||
Object.cpp\
|
||||
OccluderNode.cpp\
|
||||
PagedLOD.cpp\
|
||||
PositionAttitudeTransform.cpp\
|
||||
PolygonOffset.cpp\
|
||||
Point.cpp\
|
||||
PolygonOffset.cpp\
|
||||
PositionAttitudeTransform.cpp\
|
||||
PrimitiveSet.cpp\
|
||||
ReaderWriterIVE.cpp\
|
||||
Sequence.cpp\
|
||||
ShadeModel.cpp\
|
||||
Shape.cpp\
|
||||
ShapeDrawable.cpp\
|
||||
Switch.cpp\
|
||||
StateSet.cpp\
|
||||
TexEnv.cpp\
|
||||
Switch.cpp\
|
||||
TexEnvCombine.cpp\
|
||||
TexEnv.cpp\
|
||||
TexGen.cpp\
|
||||
TexGenNode.cpp\
|
||||
TexMat.cpp\
|
||||
Texture.cpp\
|
||||
Texture1D.cpp\
|
||||
Texture2D.cpp\
|
||||
Texture3D.cpp\
|
||||
Texture.cpp\
|
||||
TextureCubeMap.cpp\
|
||||
FragmentProgram.cpp\
|
||||
VertexProgram.cpp\
|
||||
Transform.cpp\
|
||||
ReaderWriterIVE.cpp\
|
||||
AzimElevationSector.cpp\
|
||||
AzimSector.cpp\
|
||||
BlinkSequence.cpp\
|
||||
ConeSector.cpp\
|
||||
DirectionalSector.cpp\
|
||||
ElevationSector.cpp\
|
||||
LightPoint.cpp\
|
||||
LightPointNode.cpp\
|
||||
VertexProgram.cpp\
|
||||
VisibilityGroup.cpp\
|
||||
|
||||
LIBS += -losgSim -losgText $(OSG_LIBS) $(OTHER_LIBS)
|
||||
|
@ -11,7 +11,8 @@
|
||||
#define VERSION_0002 0x00000002
|
||||
#define VERSION_0003 0x00000003
|
||||
#define VERSION_0004 0x00000004
|
||||
#define VERSION VERSION_0004
|
||||
#define VERSION_0005 0x00000005
|
||||
#define VERSION VERSION_0005
|
||||
|
||||
|
||||
/* The BYTE_SEX tag is used to check the endian
|
||||
|
@ -31,6 +31,8 @@ namespace ive {
|
||||
#define IVEDOFTRANSFORM 0x00000022
|
||||
#define IVECOORDINATESYSTEMNODE 0x00000023
|
||||
#define IVEELLIPSOIDMODEL 0x00000024
|
||||
#define IVETEXGENNODE 0x00000025
|
||||
#define IVECLIPNODE 0x00000026
|
||||
|
||||
// Node callbacks
|
||||
#define IVENODECALLBACK 0x00000050
|
||||
@ -59,6 +61,7 @@ namespace ive {
|
||||
#define IVEFRAGMENTPROGRAM 0x0000012E
|
||||
#define IVEVERTEXPROGRAM 0x0000012F
|
||||
#define IVELIGHTMODEL 0x00001121
|
||||
#define IVECLIPPLANE 0x00001122
|
||||
|
||||
// Drawables
|
||||
#define IVEDRAWABLE 0x00001000
|
||||
|
@ -15,18 +15,6 @@
|
||||
#include "Exception.h"
|
||||
#include "StateSet.h"
|
||||
#include "Object.h"
|
||||
#include "BlendFunc.h"
|
||||
#include "Material.h"
|
||||
#include "Material.h"
|
||||
#include "CullFace.h"
|
||||
#include "PolygonOffset.h"
|
||||
#include "ShadeModel.h"
|
||||
#include "Texture1D.h"
|
||||
#include "Texture2D.h"
|
||||
#include "TextureCubeMap.h"
|
||||
#include "TexEnv.h"
|
||||
#include "TexEnvCombine.h"
|
||||
#include "TexGen.h"
|
||||
|
||||
#include <osg/StateAttribute>
|
||||
|
||||
|
@ -33,7 +33,13 @@ void TexGen::write(DataOutputStream* out){
|
||||
// Write mode
|
||||
out->writeInt(getMode());
|
||||
|
||||
// Notice no support for planes yet
|
||||
if ( out->getVersion() >= VERSION_0005 )
|
||||
{
|
||||
out->writePlane(getPlane(osg::TexGen::S));
|
||||
out->writePlane(getPlane(osg::TexGen::T));
|
||||
out->writePlane(getPlane(osg::TexGen::R));
|
||||
out->writePlane(getPlane(osg::TexGen::Q));
|
||||
}
|
||||
}
|
||||
|
||||
void TexGen::read(DataInputStream* in){
|
||||
@ -52,6 +58,14 @@ void TexGen::read(DataInputStream* in){
|
||||
// Read TexGen's properties
|
||||
setMode((osg::TexGen::Mode)in->readInt());
|
||||
|
||||
if ( in->getVersion() >= VERSION_0005 )
|
||||
{
|
||||
setPlane(osg::TexGen::S, in->readPlane());
|
||||
setPlane(osg::TexGen::T, in->readPlane());
|
||||
setPlane(osg::TexGen::R, in->readPlane());
|
||||
setPlane(osg::TexGen::Q, in->readPlane());
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
throw Exception("TexGen::read(): Expected TexGen identification.");
|
||||
|
73
src/osgPlugins/ive/TexGenNode.cpp
Normal file
73
src/osgPlugins/ive/TexGenNode.cpp
Normal file
@ -0,0 +1,73 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: TexGenNode.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::TexGenNode in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerated
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 21.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "TexGenNode.h"
|
||||
#include "Group.h"
|
||||
#include "TexGen.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void TexGenNode::write(DataOutputStream* out){
|
||||
// Write TexGenNode's identification.
|
||||
out->writeInt(IVETEXGENNODE);
|
||||
// If the osg class is inherited by any other class we should also write this to file.
|
||||
osg::Group* group = dynamic_cast<osg::Group*>(this);
|
||||
if(group){
|
||||
((ive::Group*)(group))->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("TexGenNode::write(): Could not cast this osg::TexGenNode to an osg::Group.");
|
||||
// Write TexGenNode's properties.
|
||||
|
||||
|
||||
out->writeUInt(getTextureUnit());
|
||||
|
||||
// Write out light
|
||||
out->writeBool(getTexGen()!=0);
|
||||
if(getTexGen())
|
||||
{
|
||||
((ive::TexGen*)(getTexGen()))->write(out);
|
||||
}
|
||||
}
|
||||
|
||||
void TexGenNode::read(DataInputStream* in){
|
||||
// Peek on TexGenNode's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVETEXGENNODE){
|
||||
// Read TexGenNode's identification.
|
||||
id = in->readInt();
|
||||
// If the osg class is inherited by any other class we should also read this from file.
|
||||
osg::Group* group = dynamic_cast<osg::Group*>(this);
|
||||
if(group){
|
||||
((ive::Group*)(group))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("TexGenNode::read(): Could not cast this osg::TexGenNode to an osg::Object.");
|
||||
// Read TexGenNode's properties
|
||||
|
||||
|
||||
setTextureUnit(in->readUInt());
|
||||
|
||||
// Read texgen
|
||||
if(in->readBool()){
|
||||
osg::TexGen* texgen = new osg::TexGen();
|
||||
((ive::TexGen*)(texgen))->read(in);
|
||||
setTexGen(texgen);
|
||||
}
|
||||
}
|
||||
else{
|
||||
throw Exception("TexGenNode::read(): Expected TexGenNode identification.");
|
||||
}
|
||||
}
|
15
src/osgPlugins/ive/TexGenNode.h
Normal file
15
src/osgPlugins/ive/TexGenNode.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef IVE_TEXGENNODE
|
||||
#define IVE_TEXGENNODE 1
|
||||
|
||||
#include <osg/TexGenNode>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class TexGenNode : public osg::TexGenNode, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user