From Lukasz Izdebski, Added StencilTwoSided support to ive plugin
This commit is contained in:
@@ -99,6 +99,7 @@ SET(TARGET_SRC
|
||||
SpecularHighlights.cpp
|
||||
StateSet.cpp
|
||||
Stencil.cpp
|
||||
StencilTwoSided.cpp
|
||||
Switch.cpp
|
||||
SwitchLayer.cpp
|
||||
Terrain.cpp
|
||||
@@ -229,6 +230,7 @@ SET(TARGET_H
|
||||
SpecularHighlights.h
|
||||
StateSet.h
|
||||
Stencil.h
|
||||
StencilTwoSided.h
|
||||
Switch.h
|
||||
SwitchLayer.h
|
||||
Terrain.h
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "AlphaFunc.h"
|
||||
#include "BlendColor.h"
|
||||
#include "Stencil.h"
|
||||
#include "StencilTwoSided.h"
|
||||
#include "BlendFunc.h"
|
||||
#include "BlendEquation.h"
|
||||
#include "Depth.h"
|
||||
@@ -59,7 +60,6 @@
|
||||
#include "Light.h"
|
||||
#include "PolygonStipple.h"
|
||||
|
||||
|
||||
#include "Node.h"
|
||||
#include "Group.h"
|
||||
#include "MatrixTransform.h"
|
||||
@@ -1507,6 +1507,10 @@ osg::StateAttribute* DataInputStream::readStateAttribute()
|
||||
attribute = new osg::Stencil();
|
||||
((ive::Stencil*)(attribute.get()))->read(this);
|
||||
}
|
||||
else if(attributeID == IVESTENCILTWOSIDED){
|
||||
attribute = new osg::StencilTwoSided();
|
||||
((ive::StencilTwoSided*)(attribute.get()))->read(this);
|
||||
}
|
||||
else if(attributeID == IVEFOG){
|
||||
attribute = new osg::Fog();
|
||||
((ive::Fog*)(attribute.get()))->read(this);
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "AlphaFunc.h"
|
||||
#include "BlendColor.h"
|
||||
#include "Stencil.h"
|
||||
#include "StencilTwoSided.h"
|
||||
#include "BlendFunc.h"
|
||||
#include "BlendEquation.h"
|
||||
#include "Material.h"
|
||||
@@ -1000,6 +1001,9 @@ void DataOutputStream::writeStateAttribute(const osg::StateAttribute* attribute)
|
||||
else if(dynamic_cast<const osg::Stencil*>(attribute)){
|
||||
((ive::Stencil*)(attribute))->write(this);
|
||||
}
|
||||
else if(dynamic_cast<const osg::StencilTwoSided*>(attribute)){
|
||||
((ive::StencilTwoSided*)(attribute))->write(this);
|
||||
}
|
||||
else if(dynamic_cast<const osg::BlendFunc*>(attribute)){
|
||||
((ive::BlendFunc*)(attribute))->write(this);
|
||||
}
|
||||
|
||||
92
src/osgPlugins/ive/StencilTwoSided.cpp
Normal file
92
src/osgPlugins/ive/StencilTwoSided.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* 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 "StencilTwoSided.h"
|
||||
#include "Object.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void StencilTwoSided::write(DataOutputStream* out){
|
||||
// Write Stencil's identification.
|
||||
out->writeInt(IVESTENCILTWOSIDED);
|
||||
// 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
|
||||
out_THROW_EXCEPTION("Stencil::write(): Could not cast this osg::Stencil to an osg::Object.");
|
||||
// Write Stencil's properties.
|
||||
|
||||
out->writeInt(getFunction(FRONT));
|
||||
out->writeInt(getFunctionRef(FRONT));
|
||||
out->writeUInt(getFunctionMask(FRONT));
|
||||
|
||||
out->writeInt(getStencilFailOperation(FRONT));
|
||||
out->writeInt(getStencilPassAndDepthFailOperation(FRONT));
|
||||
out->writeInt(getStencilPassAndDepthPassOperation(FRONT));
|
||||
|
||||
out->writeUInt(getWriteMask(FRONT));
|
||||
|
||||
out->writeInt(getFunction(BACK));
|
||||
out->writeInt(getFunctionRef(BACK));
|
||||
out->writeUInt(getFunctionMask(BACK));
|
||||
|
||||
out->writeInt(getStencilFailOperation(BACK));
|
||||
out->writeInt(getStencilPassAndDepthFailOperation(BACK));
|
||||
out->writeInt(getStencilPassAndDepthPassOperation(BACK));
|
||||
|
||||
out->writeUInt(getWriteMask(BACK));
|
||||
}
|
||||
|
||||
void StencilTwoSided::read(DataInputStream* in){
|
||||
// Peek on Stencil's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVESTENCILTWOSIDED)
|
||||
{
|
||||
// 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
|
||||
in_THROW_EXCEPTION("Stencil::read(): Could not cast this osg::Stencil to an osg::Object.");
|
||||
|
||||
setFunction(FRONT, (Function)in->readInt());
|
||||
setFunctionRef(FRONT, in->readInt());
|
||||
setFunctionMask(FRONT, in->readUInt());
|
||||
|
||||
setStencilFailOperation(FRONT, (Operation)in->readInt());
|
||||
setStencilPassAndDepthFailOperation(FRONT, (Operation)in->readInt());
|
||||
setStencilPassAndDepthPassOperation(FRONT, (Operation)in->readInt());
|
||||
|
||||
setWriteMask(FRONT, in->readUInt());
|
||||
|
||||
setFunction(BACK, (Function)in->readInt());
|
||||
setFunctionRef(BACK, in->readInt());
|
||||
setFunctionMask(BACK, in->readUInt());
|
||||
|
||||
setStencilFailOperation(BACK, (Operation)in->readInt());
|
||||
setStencilPassAndDepthFailOperation(BACK, (Operation)in->readInt());
|
||||
setStencilPassAndDepthPassOperation(BACK, (Operation)in->readInt());
|
||||
|
||||
setWriteMask(BACK, in->readUInt());
|
||||
}
|
||||
else{
|
||||
in_THROW_EXCEPTION("Stencil::read(): Expected Stencil identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/StencilTwoSided.h
Normal file
15
src/osgPlugins/ive/StencilTwoSided.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_STENCIL_TWO_SIDED
|
||||
#define IVE_STENCIL_TWO_SIDED 1
|
||||
|
||||
#include <osg/StencilTwoSided>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class StencilTwoSided : public osg::StencilTwoSided, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user