From Liang Aibin, added support for :
osgFX::Effect
osgFX::AnisotropicLighting
osgFX::BumpMapping
osgFX::Cartoon
osgFX::Scribe
osgFX::SpecularHighlights.
This commit is contained in:
57
src/osgPlugins/ive/AnisotropicLighting.cpp
Normal file
57
src/osgPlugins/ive/AnisotropicLighting.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: AnisotropicLighting.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osgFX::AnisotropicLighting in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Liang Aibin
|
||||
*
|
||||
* HISTORY: Created 23.8.2008
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "AnisotropicLighting.h"
|
||||
#include "Effect.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void AnisotropicLighting::write(DataOutputStream* out){
|
||||
// Write AnisotropicLighting's identification.
|
||||
out->writeInt(IVEANISOTROPICLIGHTING);
|
||||
// If the osg class is inherited by any other class we should also write this to file.
|
||||
osgFX::Effect* effect = dynamic_cast<osgFX::Effect*>(this);
|
||||
if(effect){
|
||||
((ive::Effect*)(effect))->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("AnisotropicLighting::write(): Could not cast this osgFX::AnisotropicLighting to an osgFX::Effect.");
|
||||
|
||||
// Write AnisotropicLighting's properties.
|
||||
out->writeImage(getLightingMap());
|
||||
out->writeInt(getLightNumber());
|
||||
}
|
||||
|
||||
void AnisotropicLighting::read(DataInputStream* in){
|
||||
// Peek on AnisotropicLighting's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEANISOTROPICLIGHTING){
|
||||
// Read AnisotropicLighting's identification.
|
||||
id = in->readInt();
|
||||
|
||||
// If the osg class is inherited by any other class we should also read this from file.
|
||||
osgFX::Effect* effect = dynamic_cast<osgFX::Effect*>(this);
|
||||
if(effect){
|
||||
((ive::Effect*)(effect))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("AnisotropicLighting::read(): Could not cast this osgFX::AnisotropicLighting to an osgFX::Effect.");
|
||||
|
||||
// Read AnisotropicLighting's properties
|
||||
setLightingMap(in->readImage());
|
||||
setLightNumber(in->readInt());
|
||||
}
|
||||
else{
|
||||
throw Exception("AnisotropicLighting::read(): Expected AnisotropicLighting identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/AnisotropicLighting.h
Normal file
15
src/osgPlugins/ive/AnisotropicLighting.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_ANISOTROPICLIGHTING
|
||||
#define IVE_ANISOTROPICLIGHTING 1
|
||||
|
||||
#include <osgFX/AnisotropicLighting>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class AnisotropicLighting : public osgFX::AnisotropicLighting, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
74
src/osgPlugins/ive/BumpMapping.cpp
Normal file
74
src/osgPlugins/ive/BumpMapping.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: BumpMapping.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osgFX::BumpMapping in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Liang Aibin
|
||||
*
|
||||
* HISTORY: Created 23.8.2008
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "BumpMapping.h"
|
||||
#include "Effect.h"
|
||||
#include "Texture2D.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void BumpMapping::write(DataOutputStream* out){
|
||||
// Write BumpMapping's identification.
|
||||
out->writeInt(IVEBUMPMAPPING);
|
||||
// If the osg class is inherited by any other class we should also write this to file.
|
||||
osgFX::Effect* effect = dynamic_cast<osgFX::Effect*>(this);
|
||||
if(effect){
|
||||
((ive::Effect*)(effect))->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("BumpMapping::write(): Could not cast this osgFX::BumpMapping to an osgFX::Effect.");
|
||||
|
||||
// Write BumpMapping's properties.
|
||||
out->writeInt(getLightNumber());
|
||||
out->writeInt(getDiffuseTextureUnit());
|
||||
out->writeInt(getNormalMapTextureUnit());
|
||||
|
||||
osg::Texture2D *tex=getOverrideDiffuseTexture();
|
||||
((ive::Texture2D*)(tex))->write(out);
|
||||
|
||||
tex=getOverrideNormalMapTexture();
|
||||
((ive::Texture2D*)(tex))->write(out);
|
||||
}
|
||||
|
||||
void BumpMapping::read(DataInputStream* in){
|
||||
// Peek on BumpMapping's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEBUMPMAPPING){
|
||||
// Read BumpMapping's identification.
|
||||
id = in->readInt();
|
||||
|
||||
// If the osg class is inherited by any other class we should also read this from file.
|
||||
osgFX::Effect* effect = dynamic_cast<osgFX::Effect*>(this);
|
||||
if(effect){
|
||||
((ive::Effect*)(effect))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("BumpMapping::read(): Could not cast this osgFX::BumpMapping to an osgFX::Effect.");
|
||||
|
||||
// Read BumpMapping's properties
|
||||
setLightNumber(in->readInt());
|
||||
setDiffuseTextureUnit(in->readInt());
|
||||
setNormalMapTextureUnit(in->readInt());
|
||||
|
||||
osg::Texture2D *tex=new osg::Texture2D;
|
||||
((ive::Texture2D*)(tex))->read(in);
|
||||
setOverrideDiffuseTexture(tex);
|
||||
|
||||
tex=new osg::Texture2D;
|
||||
((ive::Texture2D*)(tex))->read(in);
|
||||
setOverrideNormalMapTexture(tex);
|
||||
}
|
||||
else{
|
||||
throw Exception("BumpMapping::read(): Expected BumpMapping identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/BumpMapping.h
Normal file
15
src/osgPlugins/ive/BumpMapping.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_BUMPMAPPING
|
||||
#define IVE_BUMPMAPPING 1
|
||||
|
||||
#include <osgFX/BumpMapping>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class BumpMapping : public osgFX::BumpMapping, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,4 @@
|
||||
#this file is automatically generated
|
||||
#this file is automatically generated
|
||||
|
||||
|
||||
SET(TARGET_SRC
|
||||
@@ -108,6 +108,12 @@ SET(TARGET_SRC
|
||||
VertexProgram.cpp
|
||||
Viewport.cpp
|
||||
VisibilityGroup.cpp
|
||||
Effect.cpp
|
||||
AnisotropicLighting.cpp
|
||||
BumpMapping.cpp
|
||||
Cartoon.cpp
|
||||
Scribe.cpp
|
||||
SpecularHighlights.cpp
|
||||
)
|
||||
SET(TARGET_H
|
||||
AlphaFunc.h
|
||||
@@ -216,6 +222,12 @@ SET(TARGET_H
|
||||
VertexProgram.h
|
||||
Viewport.h
|
||||
VisibilityGroup.h
|
||||
Effect.h
|
||||
AnisotropicLighting.h
|
||||
BumpMapping.h
|
||||
Cartoon.h
|
||||
Scribe.h
|
||||
SpecularHighlights.h
|
||||
)
|
||||
SET(TARGET_ADDED_LIBRARIES osgSim osgFX osgText osgTerrain)
|
||||
#### end var setup ###
|
||||
|
||||
59
src/osgPlugins/ive/Cartoon.cpp
Normal file
59
src/osgPlugins/ive/Cartoon.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: Cartoon.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osgFX::Cartoon in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Liang Aibin
|
||||
*
|
||||
* HISTORY: Created 23.8.2008
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "Cartoon.h"
|
||||
#include "Effect.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void Cartoon::write(DataOutputStream* out){
|
||||
// Write Cartoon's identification.
|
||||
out->writeInt(IVECARTOON);
|
||||
// If the osg class is inherited by any other class we should also write this to file.
|
||||
osgFX::Effect* effect = dynamic_cast<osgFX::Effect*>(this);
|
||||
if(effect){
|
||||
((ive::Effect*)(effect))->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("Cartoon::write(): Could not cast this osgFX::Cartoon to an osgFX::Effect.");
|
||||
|
||||
// Write Cartoon's properties.
|
||||
out->writeVec4(getOutlineColor());
|
||||
out->writeFloat(getOutlineLineWidth());
|
||||
out->writeInt(getLightNumber());
|
||||
}
|
||||
|
||||
void Cartoon::read(DataInputStream* in){
|
||||
// Peek on Cartoon's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVECARTOON){
|
||||
// Read Cartoon's identification.
|
||||
id = in->readInt();
|
||||
|
||||
// If the osg class is inherited by any other class we should also read this from file.
|
||||
osgFX::Effect* effect = dynamic_cast<osgFX::Effect*>(this);
|
||||
if(effect){
|
||||
((ive::Effect*)(effect))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("Cartoon::read(): Could not cast this osgFX::Cartoon to an osgFX::Effect.");
|
||||
|
||||
// Read Cartoon's properties
|
||||
setOutlineColor(in->readVec4());
|
||||
setOutlineLineWidth(in->readFloat());
|
||||
setLightNumber(in->readInt());
|
||||
}
|
||||
else{
|
||||
throw Exception("Cartoon::read(): Expected Cartoon identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/Cartoon.h
Normal file
15
src/osgPlugins/ive/Cartoon.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_CARTOON
|
||||
#define IVE_CARTOON 1
|
||||
|
||||
#include <osgFX/Cartoon>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class Cartoon : public osgFX::Cartoon, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -87,6 +87,12 @@
|
||||
#include "VisibilityGroup.h"
|
||||
|
||||
#include "MultiTextureControl.h"
|
||||
#include "Effect.h"
|
||||
#include "AnisotropicLighting.h"
|
||||
#include "BumpMapping.h"
|
||||
#include "Cartoon.h"
|
||||
#include "Scribe.h"
|
||||
#include "SpecularHighlights.h"
|
||||
|
||||
#include "Geometry.h"
|
||||
#include "ShapeDrawable.h"
|
||||
@@ -1514,6 +1520,28 @@ osg::Node* DataInputStream::readNode()
|
||||
node = new osgFX::MultiTextureControl();
|
||||
((ive::MultiTextureControl*)(node))->read(this);
|
||||
}
|
||||
|
||||
else if(nodeTypeID== IVEANISOTROPICLIGHTING){
|
||||
node = new osgFX::AnisotropicLighting();
|
||||
((ive::AnisotropicLighting*)(node))->read(this);
|
||||
}
|
||||
else if(nodeTypeID== IVEBUMPMAPPING){
|
||||
node = new osgFX::BumpMapping();
|
||||
((ive::BumpMapping*)(node))->read(this);
|
||||
}
|
||||
else if(nodeTypeID== IVECARTOON){
|
||||
node = new osgFX::Cartoon();
|
||||
((ive::Cartoon*)(node))->read(this);
|
||||
}
|
||||
else if(nodeTypeID== IVESCRIBE){
|
||||
node = new osgFX::Scribe();
|
||||
((ive::Scribe*)(node))->read(this);
|
||||
}
|
||||
else if(nodeTypeID== IVESPECULARHIGHLIGHTS){
|
||||
node = new osgFX::SpecularHighlights();
|
||||
((ive::SpecularHighlights*)(node))->read(this);
|
||||
}
|
||||
|
||||
else if(nodeTypeID== IVETERRAINTILE){
|
||||
node = new osgTerrain::TerrainTile();
|
||||
((ive::TerrainTile*)(node))->read(this);
|
||||
|
||||
@@ -87,6 +87,12 @@
|
||||
#include "VisibilityGroup.h"
|
||||
|
||||
#include "MultiTextureControl.h"
|
||||
#include "Effect.h"
|
||||
#include "AnisotropicLighting.h"
|
||||
#include "BumpMapping.h"
|
||||
#include "Cartoon.h"
|
||||
#include "Scribe.h"
|
||||
#include "SpecularHighlights.h"
|
||||
|
||||
#include "Geometry.h"
|
||||
#include "ShapeDrawable.h"
|
||||
@@ -1077,6 +1083,24 @@ void DataOutputStream::writeNode(const osg::Node* node)
|
||||
else if(dynamic_cast<const osgFX::MultiTextureControl*>(node)){
|
||||
((ive::MultiTextureControl*)(node))->write(this);
|
||||
}
|
||||
|
||||
|
||||
else if(dynamic_cast<const osgFX::AnisotropicLighting*>(node)){
|
||||
((ive::AnisotropicLighting*)(node))->write(this);
|
||||
}
|
||||
else if(dynamic_cast<const osgFX::BumpMapping*>(node)){
|
||||
((ive::BumpMapping*)(node))->write(this);
|
||||
}
|
||||
else if(dynamic_cast<const osgFX::Cartoon*>(node)){
|
||||
((ive::Cartoon*)(node))->write(this);
|
||||
}
|
||||
else if(dynamic_cast<const osgFX::Scribe*>(node)){
|
||||
((ive::Scribe*)(node))->write(this);
|
||||
}
|
||||
else if(dynamic_cast<const osgFX::SpecularHighlights*>(node)){
|
||||
((ive::SpecularHighlights*)(node))->write(this);
|
||||
}
|
||||
|
||||
else if(dynamic_cast<const osgTerrain::TerrainTile*>(node)){
|
||||
((ive::TerrainTile*)(node))->write(this);
|
||||
}
|
||||
|
||||
59
src/osgPlugins/ive/Effect.cpp
Normal file
59
src/osgPlugins/ive/Effect.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: Effect.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osgFX::Effect in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Liang Aibin
|
||||
*
|
||||
* HISTORY: Created 23.8.2008
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "Effect.h"
|
||||
#include "Group.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void Effect::write(DataOutputStream* out){
|
||||
// Write Effect's identification.
|
||||
out->writeInt(IVEEFFECT);
|
||||
// If the osg class is inherited by any other class we should also write this to file.
|
||||
osg::Group* group = dynamic_cast<osg::Group*>(this);
|
||||
if(group){
|
||||
((ive::Group*)(group))->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("Effect::write(): Could not cast this osgFX::Effect to an osg::Group.");
|
||||
|
||||
// Write Effect's properties.
|
||||
out->writeBool(getEnabled());
|
||||
|
||||
out->writeInt(getSelectedTechnique());
|
||||
}
|
||||
|
||||
void Effect::read(DataInputStream* in){
|
||||
// Peek on Effect's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEEFFECT){
|
||||
// Read Effect's identification.
|
||||
id = in->readInt();
|
||||
|
||||
// If the osg class is inherited by any other class we should also read this from file.
|
||||
osg::Group* group = dynamic_cast<osg::Group*>(this);
|
||||
if(group){
|
||||
((ive::Group*)(group))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("Effect::read(): Could not cast this osgFX::Effect to an osg::Group.");
|
||||
|
||||
// Read Effect's properties
|
||||
setEnabled(in->readBool());
|
||||
|
||||
selectTechnique(in->readInt());
|
||||
}
|
||||
else{
|
||||
throw Exception("Effect::read(): Expected Effect identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/Effect.h
Normal file
15
src/osgPlugins/ive/Effect.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_EFFECT
|
||||
#define IVE_EFFECT 1
|
||||
|
||||
#include <osgFX/Effect>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class Effect : public osgFX::Effect, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -141,6 +141,12 @@ namespace ive {
|
||||
|
||||
// osgFX classes
|
||||
#define IVEMULTITEXTURECONTROL 0x01000001
|
||||
#define IVEEFFECT 0x01000002
|
||||
#define IVEANISOTROPICLIGHTING 0x01000003
|
||||
#define IVEBUMPMAPPING 0x01000004
|
||||
#define IVECARTOON 0x01000005
|
||||
#define IVESCRIBE 0x01000006
|
||||
#define IVESPECULARHIGHLIGHTS 0x01000007
|
||||
|
||||
//osgText classes
|
||||
#define IVETEXT 0x10000001
|
||||
|
||||
57
src/osgPlugins/ive/Scribe.cpp
Normal file
57
src/osgPlugins/ive/Scribe.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: Scribe.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osgFX::Scribe in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Liang Aibin
|
||||
*
|
||||
* HISTORY: Created 23.8.2008
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "Scribe.h"
|
||||
#include "Effect.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void Scribe::write(DataOutputStream* out){
|
||||
// Write Scribe's identification.
|
||||
out->writeInt(IVESCRIBE);
|
||||
// If the osg class is inherited by any other class we should also write this to file.
|
||||
osgFX::Effect* effect = dynamic_cast<osgFX::Effect*>(this);
|
||||
if(effect){
|
||||
((ive::Effect*)(effect))->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("Scribe::write(): Could not cast this osgFX::Scribe to an osgFX::Effect.");
|
||||
|
||||
// Write Scribe's properties.
|
||||
out->writeVec4(getWireframeColor());
|
||||
out->writeFloat(getWireframeLineWidth());
|
||||
}
|
||||
|
||||
void Scribe::read(DataInputStream* in){
|
||||
// Peek on Scribe's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVESCRIBE){
|
||||
// Read Scribe's identification.
|
||||
id = in->readInt();
|
||||
|
||||
// If the osg class is inherited by any other class we should also read this from file.
|
||||
osgFX::Effect* effect = dynamic_cast<osgFX::Effect*>(this);
|
||||
if(effect){
|
||||
((ive::Effect*)(effect))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("Scribe::read(): Could not cast this osgFX::Scribe to an osgFX::Effect.");
|
||||
|
||||
// Read Scribe's properties
|
||||
setWireframeColor(in->readVec4());
|
||||
setWireframeLineWidth(in->readFloat());
|
||||
}
|
||||
else{
|
||||
throw Exception("Scribe::read(): Expected Scribe identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/Scribe.h
Normal file
15
src/osgPlugins/ive/Scribe.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_SCRIBE
|
||||
#define IVE_SCRIBE 1
|
||||
|
||||
#include <osgFX/Scribe>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class Scribe : public osgFX::Scribe, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
61
src/osgPlugins/ive/SpecularHighlights.cpp
Normal file
61
src/osgPlugins/ive/SpecularHighlights.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: SpecularHighlights.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osgFX::SpecularHighlights in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Liang Aibin
|
||||
*
|
||||
* HISTORY: Created 23.8.2008
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "SpecularHighlights.h"
|
||||
#include "Effect.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void SpecularHighlights::write(DataOutputStream* out){
|
||||
// Write SpecularHighlights's identification.
|
||||
out->writeInt(IVEANISOTROPICLIGHTING);
|
||||
// If the osg class is inherited by any other class we should also write this to file.
|
||||
osgFX::Effect* effect = dynamic_cast<osgFX::Effect*>(this);
|
||||
if(effect){
|
||||
((ive::Effect*)(effect))->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("SpecularHighlights::write(): Could not cast this osgFX::SpecularHighlights to an osgFX::Effect.");
|
||||
|
||||
// Write SpecularHighlights's properties.
|
||||
out->writeInt(getLightNumber());
|
||||
out->writeInt(getTextureUnit());
|
||||
out->writeVec4(getSpecularColor());
|
||||
out->writeFloat(getSpecularExponent());
|
||||
}
|
||||
|
||||
void SpecularHighlights::read(DataInputStream* in){
|
||||
// Peek on SpecularHighlights's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEANISOTROPICLIGHTING){
|
||||
// Read SpecularHighlights's identification.
|
||||
id = in->readInt();
|
||||
|
||||
// If the osg class is inherited by any other class we should also read this from file.
|
||||
osgFX::Effect* effect = dynamic_cast<osgFX::Effect*>(this);
|
||||
if(effect){
|
||||
((ive::Effect*)(effect))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("SpecularHighlights::read(): Could not cast this osgFX::SpecularHighlights to an osgFX::Effect.");
|
||||
|
||||
// Read SpecularHighlights's properties
|
||||
setLightNumber(in->readInt());
|
||||
setTextureUnit(in->readInt());
|
||||
setSpecularColor(in->readVec4());
|
||||
setSpecularExponent(in->readFloat());
|
||||
}
|
||||
else{
|
||||
throw Exception("SpecularHighlights::read(): Expected SpecularHighlights identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/SpecularHighlights.h
Normal file
15
src/osgPlugins/ive/SpecularHighlights.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_SPECULARHIGHLIGHTS
|
||||
#define IVE_SPECULARHIGHLIGHTS 1
|
||||
|
||||
#include <osgFX/SpecularHighlights>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class SpecularHighlights : public osgFX::SpecularHighlights, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user