Added support for ColorMask to .ive plugin

This commit is contained in:
Robert Osfield
2007-02-13 14:42:00 +00:00
parent 927dfc0a52
commit 9c434274be
7 changed files with 94 additions and 0 deletions

View File

@@ -233,6 +233,10 @@ SOURCE=..\..\..\src\osgPlugins\ive\CoordinateSystemNode.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgPlugins\ive\ColorMask.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgPlugins\ive\CullFace.cpp
# End Source File
# Begin Source File

View File

@@ -0,0 +1,62 @@
/**********************************************************************
*
* FILE: ColorMask.cpp
*
* DESCRIPTION: Read/Write osg::ColorMask in binary format to disk.
*
* CREATED BY: Auto generated by iveGenerator
* and later modified by Rune Schmidt Jensen.
*
* HISTORY: Created 27.3.2003
*
* Copyright 2003 VR-C
**********************************************************************/
#include "Exception.h"
#include "ColorMask.h"
#include "Object.h"
using namespace ive;
void ColorMask::write(DataOutputStream* out){
// Write ColorMask's identification.
out->writeInt(IVECOLORMASK);
// 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("ColorMask::write(): Could not cast this osg::ColorMask to an osg::Object.");
// Write ColorMask's properties.
out->writeBool(getRedMask());
out->writeBool(getGreenMask());
out->writeBool(getBlueMask());
out->writeBool(getAlphaMask());
}
void ColorMask::read(DataInputStream* in){
// Peek on ColorMask's identification.
int id = in->peekInt();
if(id == IVECOLORMASK){
// Read ColorMask'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("ColorMask::read(): Could not cast this osg::ColorMask to an osg::Object.");
// Read ColorMask's properties
setRedMask(in->readBool());
setGreenMask(in->readBool());
setBlueMask(in->readBool());
setAlphaMask(in->readBool());
}
else{
throw Exception("ColorMask::read(): Expected ColorMask identification.");
}
}

View File

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

View File

@@ -24,6 +24,7 @@
#include "Depth.h"
#include "Material.h"
#include "CullFace.h"
#include "ColorMask.h"
#include "ClipPlane.h"
#include "PolygonOffset.h"
#include "PolygonMode.h"
@@ -998,6 +999,10 @@ osg::StateAttribute* DataInputStream::readStateAttribute()
attribute = new osg::CullFace();
((ive::CullFace*)(attribute))->read(this);
}
else if(attributeID == IVECOLORMASK){
attribute = new osg::ColorMask();
((ive::ColorMask*)(attribute))->read(this);
}
else if(attributeID == IVECLIPPLANE){
attribute = new osg::ClipPlane();
((ive::ClipPlane*)(attribute))->read(this);

View File

@@ -24,6 +24,7 @@
#include "BlendFunc.h"
#include "Material.h"
#include "CullFace.h"
#include "ColorMask.h"
#include "Depth.h"
#include "ClipPlane.h"
#include "PolygonOffset.h"
@@ -682,6 +683,10 @@ void DataOutputStream::writeStateAttribute(const osg::StateAttribute* attribute)
else if(dynamic_cast<const osg::CullFace*>(attribute)){
((ive::CullFace*)(attribute))->write(this);
}
// This is a ColorMask
else if(dynamic_cast<const osg::ColorMask*>(attribute)){
((ive::ColorMask*)(attribute))->write(this);
}
// this is a Cliplane
else if(dynamic_cast<const osg::ClipPlane*>(attribute)){
((ive::ClipPlane*)(attribute))->write(this);

View File

@@ -21,6 +21,7 @@ CXXFILES =\
ConvexPlanarOccluder.cpp\
ConvexPlanarPolygon.cpp\
CoordinateSystemNode.cpp\
ColorMask.cpp\
CullFace.cpp\
DataInputStream.cpp\
DataOutputStream.cpp\

View File

@@ -68,6 +68,8 @@ namespace ive {
#define IVEVERTEXPROGRAM 0x0000012F
#define IVEDEPTH 0x00000130
#define IVESTENCIL 0x00000131
#define IVESTENCILTWOSIDED 0x00000132
#define IVECOLORMASK 0x00000133
#define IVELIGHTMODEL 0x00001121
#define IVECLIPPLANE 0x00001122
#define IVEFRONTFACE 0x00001123