Added support for osg::Stencil into .ive

This commit is contained in:
Robert Osfield
2007-02-13 13:47:37 +00:00
parent e4ffa968a2
commit b695160483
8 changed files with 113 additions and 0 deletions

View File

@@ -19,6 +19,7 @@
#include "StateSet.h"
#include "AlphaFunc.h"
#include "BlendColor.h"
#include "Stencil.h"
#include "BlendFunc.h"
#include "Depth.h"
#include "Material.h"
@@ -1081,6 +1082,10 @@ osg::StateAttribute* DataInputStream::readStateAttribute()
attribute = new osg::PointSprite();
((ive::PointSprite*)(attribute))->read(this);
}
else if(attributeID == IVESTENCIL){
attribute = new osg::Stencil();
((ive::Stencil*)(attribute))->read(this);
}
else{
throw Exception("Unknown StateAttribute in StateSet::read()");
}

View File

@@ -20,6 +20,7 @@
#include "StateSet.h"
#include "AlphaFunc.h"
#include "BlendColor.h"
#include "Stencil.h"
#include "BlendFunc.h"
#include "Material.h"
#include "CullFace.h"
@@ -658,6 +659,9 @@ void DataOutputStream::writeStateAttribute(const osg::StateAttribute* attribute)
else if(dynamic_cast<const osg::BlendColor*>(attribute)){
((ive::BlendColor*)(attribute))->write(this);
}
else if(dynamic_cast<const osg::Stencil*>(attribute)){
((ive::Stencil*)(attribute))->write(this);
}
else if(dynamic_cast<const osg::BlendFunc*>(attribute)){
((ive::BlendFunc*)(attribute))->write(this);
}

View File

@@ -74,6 +74,7 @@ CXXFILES =\
Shape.cpp\
ShapeDrawable.cpp\
StateSet.cpp\
Stencil.cpp\
Switch.cpp\
TexEnvCombine.cpp\
TexEnv.cpp\

View File

@@ -67,6 +67,7 @@ namespace ive {
#define IVEFRAGMENTPROGRAM 0x0000012E
#define IVEVERTEXPROGRAM 0x0000012F
#define IVEDEPTH 0x00000130
#define IVESTENCIL 0x00000131
#define IVELIGHTMODEL 0x00001121
#define IVECLIPPLANE 0x00001122
#define IVEFRONTFACE 0x00001123

View File

@@ -0,0 +1,75 @@
/**********************************************************************
*
* FILE: Stencil.cpp
*
* DESCRIPTION: Read/Write osg::Stencil 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 "Stencil.h"
#include "Object.h"
using namespace ive;
void Stencil::write(DataOutputStream* out){
// Write Stencil's identification.
out->writeInt(IVESTENCIL);
// 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("Stencil::write(): Could not cast this osg::Stencil to an osg::Object.");
// Write Stencil's properties.
out->writeInt(getFunction());
out->writeInt(getFunctionRef());
out->writeUInt(getFunctionMask());
out->writeInt(getStencilFailOperation());
out->writeInt(getStencilPassAndDepthFailOperation());
out->writeInt(getStencilPassAndDepthPassOperation());
out->writeUInt(getWriteMask());
}
void Stencil::read(DataInputStream* in){
// Peek on Stencil's identification.
int id = in->peekInt();
if(id == IVESTENCIL)
{
// Read Stencil'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("Stencil::read(): Could not cast this osg::Stencil to an osg::Object.");
setFunction((Function)in->readInt());
setFunctionRef(in->readInt());
setFunctionMask(in->readUInt());
setStencilFailOperation((Operation)in->readInt());
setStencilPassAndDepthFailOperation((Operation)in->readInt());
setStencilPassAndDepthPassOperation((Operation)in->readInt());
setWriteMask(in->readUInt());
}
else{
throw Exception("Stencil::read(): Expected Stencil identification.");
}
}

View File

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