From Luc Frauciel, You'll find attached a modification in ive plugin for POLYGONSTIPPLE read/write.

This commit is contained in:
Robert Osfield 2009-03-23 17:08:58 +00:00
parent 9727321afe
commit 73bf2a7de9
6 changed files with 82 additions and 0 deletions

View File

@ -78,6 +78,7 @@ SET(TARGET_SRC
PointSprite.cpp
PolygonMode.cpp
PolygonOffset.cpp
PolygonStipple.cpp
PositionAttitudeTransform.cpp
PrimitiveSet.cpp
Program.cpp
@ -194,6 +195,7 @@ SET(TARGET_H
PointSprite.h
PolygonMode.h
PolygonOffset.h
PolygonStipple.h
PositionAttitudeTransform.h
PrimitiveSet.h
Program.h

View File

@ -56,6 +56,7 @@
#include "Multisample.h"
#include "Fog.h"
#include "Light.h"
#include "PolygonStipple.h"
#include "Group.h"
@ -1411,6 +1412,10 @@ osg::StateAttribute* DataInputStream::readStateAttribute()
attribute = new osg::Light();
((ive::Light*)(attribute))->read(this);
}
else if(attributeID == IVEPOLYGONSTIPPLE){
attribute = new osg::PolygonStipple();
((ive::PolygonStipple*)(attribute))->read(this);
}
else{
throw Exception("Unknown StateAttribute in StateSet::read()");
}

View File

@ -59,6 +59,7 @@
#include "Multisample.h"
#include "Fog.h"
#include "Light.h"
#include "PolygonStipple.h"
#include "Group.h"
#include "MatrixTransform.h"
@ -1089,6 +1090,10 @@ void DataOutputStream::writeStateAttribute(const osg::StateAttribute* attribute)
else if(dynamic_cast<const osg::Light*>(attribute)){
((ive::Light*)(attribute))->write(this);
}
// This is a PolygonStipple
else if(dynamic_cast<const osg::PolygonStipple*>(attribute)){
((ive::PolygonStipple*)(attribute))->write(this);
}
else{
std::string className = attribute->className();

View File

@ -0,0 +1,54 @@
/**********************************************************************
*
* FILE: PolygonStipple.cpp
*
* DESCRIPTION: Read/Write osg::PolygonStipple in binary format to disk.
*
* CREATED BY: Copied from LineStipple
* and modified by Luc Frauciel
*
* HISTORY: Created 21.3.2009
*
* Copyright 2008 VR-C
**********************************************************************/
#include "Exception.h"
#include "PolygonStipple.h"
#include "Object.h"
using namespace ive;
void PolygonStipple::write(DataOutputStream* out){
// Write CullFace's identification.
out->writeInt(IVEPOLYGONSTIPPLE);
// 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("PolygonStipple::write(): Could not cast this osg::PolygonStipple to an osg::Object.");
// Write PolygonStipple's properties.
out->writeUByteArray(new osg::UByteArray(128,const_cast<GLubyte*>(getMask())));
}
void PolygonStipple::read(DataInputStream* in){
// Peek on LineStipple's identification.
int id = in->peekInt();
if (id == IVEPOLYGONSTIPPLE) {
// Read PolygonStipple'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("PolygonStipple::read(): Could not cast this osg::PolygonStipple to an osg::Object.");
// Read PolygonStipple's properties
setMask((GLubyte *)in->readUByteArray()->getDataPointer());
}
else{
throw Exception("PolygonStipple::read(): Expected PolygonStipple identification.");
}
}

View File

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

View File

@ -87,6 +87,7 @@ namespace ive {
#define IVEMULTISAMPLE 0x00001132
#define IVEFOG 0x00001133
#define IVELINESTIPPLE 0x00001134
#define IVEPOLYGONSTIPPLE 0x00001135
// Drawables
#define IVEDRAWABLE 0x00001000