Added support for osg::Stencil into .ive
This commit is contained in:
parent
e4ffa968a2
commit
b695160483
@ -441,6 +441,10 @@ SOURCE=..\..\..\src\osgPlugins\ive\Switch.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Stencil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\TexEnv.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -801,6 +805,10 @@ SOURCE=..\..\..\src\osgPlugins\ive\StateSet.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Stencil.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\ive\Switch.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include <osg/AnimationPath>
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgDB/WriteFile>
|
||||
|
||||
#include <osgUtil/Optimizer>
|
||||
#include <osgViewer/Viewer>
|
||||
|
||||
@ -359,6 +361,8 @@ int main( int argc, char **argv )
|
||||
// hint to tell viewer to request stencil buffer when setting up windows
|
||||
osg::DisplaySettings::instance()->setMinimumNumStencilBits(8);
|
||||
|
||||
osgDB::writeNodeFile(*rootNode, "test.osg");
|
||||
|
||||
return viewer.run();
|
||||
|
||||
}
|
||||
|
@ -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()");
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -74,6 +74,7 @@ CXXFILES =\
|
||||
Shape.cpp\
|
||||
ShapeDrawable.cpp\
|
||||
StateSet.cpp\
|
||||
Stencil.cpp\
|
||||
Switch.cpp\
|
||||
TexEnvCombine.cpp\
|
||||
TexEnv.cpp\
|
||||
|
@ -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
|
||||
|
75
src/osgPlugins/ive/Stencil.cpp
Normal file
75
src/osgPlugins/ive/Stencil.cpp
Normal 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.");
|
||||
}
|
||||
}
|
15
src/osgPlugins/ive/Stencil.h
Normal file
15
src/osgPlugins/ive/Stencil.h
Normal 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
|
Loading…
Reference in New Issue
Block a user