From Luc Frauciel, You'll find attached a modification in ive plugin for POLYGONSTIPPLE read/write.
This commit is contained in:
parent
9727321afe
commit
73bf2a7de9
@ -78,6 +78,7 @@ SET(TARGET_SRC
|
|||||||
PointSprite.cpp
|
PointSprite.cpp
|
||||||
PolygonMode.cpp
|
PolygonMode.cpp
|
||||||
PolygonOffset.cpp
|
PolygonOffset.cpp
|
||||||
|
PolygonStipple.cpp
|
||||||
PositionAttitudeTransform.cpp
|
PositionAttitudeTransform.cpp
|
||||||
PrimitiveSet.cpp
|
PrimitiveSet.cpp
|
||||||
Program.cpp
|
Program.cpp
|
||||||
@ -194,6 +195,7 @@ SET(TARGET_H
|
|||||||
PointSprite.h
|
PointSprite.h
|
||||||
PolygonMode.h
|
PolygonMode.h
|
||||||
PolygonOffset.h
|
PolygonOffset.h
|
||||||
|
PolygonStipple.h
|
||||||
PositionAttitudeTransform.h
|
PositionAttitudeTransform.h
|
||||||
PrimitiveSet.h
|
PrimitiveSet.h
|
||||||
Program.h
|
Program.h
|
||||||
|
@ -56,6 +56,7 @@
|
|||||||
#include "Multisample.h"
|
#include "Multisample.h"
|
||||||
#include "Fog.h"
|
#include "Fog.h"
|
||||||
#include "Light.h"
|
#include "Light.h"
|
||||||
|
#include "PolygonStipple.h"
|
||||||
|
|
||||||
|
|
||||||
#include "Group.h"
|
#include "Group.h"
|
||||||
@ -1411,6 +1412,10 @@ osg::StateAttribute* DataInputStream::readStateAttribute()
|
|||||||
attribute = new osg::Light();
|
attribute = new osg::Light();
|
||||||
((ive::Light*)(attribute))->read(this);
|
((ive::Light*)(attribute))->read(this);
|
||||||
}
|
}
|
||||||
|
else if(attributeID == IVEPOLYGONSTIPPLE){
|
||||||
|
attribute = new osg::PolygonStipple();
|
||||||
|
((ive::PolygonStipple*)(attribute))->read(this);
|
||||||
|
}
|
||||||
else{
|
else{
|
||||||
throw Exception("Unknown StateAttribute in StateSet::read()");
|
throw Exception("Unknown StateAttribute in StateSet::read()");
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@
|
|||||||
#include "Multisample.h"
|
#include "Multisample.h"
|
||||||
#include "Fog.h"
|
#include "Fog.h"
|
||||||
#include "Light.h"
|
#include "Light.h"
|
||||||
|
#include "PolygonStipple.h"
|
||||||
|
|
||||||
#include "Group.h"
|
#include "Group.h"
|
||||||
#include "MatrixTransform.h"
|
#include "MatrixTransform.h"
|
||||||
@ -1089,6 +1090,10 @@ void DataOutputStream::writeStateAttribute(const osg::StateAttribute* attribute)
|
|||||||
else if(dynamic_cast<const osg::Light*>(attribute)){
|
else if(dynamic_cast<const osg::Light*>(attribute)){
|
||||||
((ive::Light*)(attribute))->write(this);
|
((ive::Light*)(attribute))->write(this);
|
||||||
}
|
}
|
||||||
|
// This is a PolygonStipple
|
||||||
|
else if(dynamic_cast<const osg::PolygonStipple*>(attribute)){
|
||||||
|
((ive::PolygonStipple*)(attribute))->write(this);
|
||||||
|
}
|
||||||
|
|
||||||
else{
|
else{
|
||||||
std::string className = attribute->className();
|
std::string className = attribute->className();
|
||||||
|
54
src/osgPlugins/ive/PolygonStipple.cpp
Normal file
54
src/osgPlugins/ive/PolygonStipple.cpp
Normal 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.");
|
||||||
|
}
|
||||||
|
}
|
15
src/osgPlugins/ive/PolygonStipple.h
Normal file
15
src/osgPlugins/ive/PolygonStipple.h
Normal 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
|
@ -87,6 +87,7 @@ namespace ive {
|
|||||||
#define IVEMULTISAMPLE 0x00001132
|
#define IVEMULTISAMPLE 0x00001132
|
||||||
#define IVEFOG 0x00001133
|
#define IVEFOG 0x00001133
|
||||||
#define IVELINESTIPPLE 0x00001134
|
#define IVELINESTIPPLE 0x00001134
|
||||||
|
#define IVEPOLYGONSTIPPLE 0x00001135
|
||||||
|
|
||||||
// Drawables
|
// Drawables
|
||||||
#define IVEDRAWABLE 0x00001000
|
#define IVEDRAWABLE 0x00001000
|
||||||
|
Loading…
Reference in New Issue
Block a user