Merge rev 8775,8776 (BlendEquation support in .osg/.ive) onto 2.6.1.
This commit is contained in:
61
src/osgPlugins/ive/BlendEquation.cpp
Normal file
61
src/osgPlugins/ive/BlendEquation.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: BlendEquation.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::BlendEquation 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 "BlendEquation.h"
|
||||
#include "Object.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void BlendEquation::write(DataOutputStream* out){
|
||||
|
||||
// Write BlendEquation's identification.
|
||||
out->writeInt(IVEBLENDEQUATION);
|
||||
|
||||
// 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("BlendEquation::write(): Could not cast this osg::BlendEquation to an osg::Object.");
|
||||
// Write BlendEquation's properties.
|
||||
|
||||
// Write source
|
||||
out->writeInt(getEquation());
|
||||
}
|
||||
|
||||
void BlendEquation::read(DataInputStream* in){
|
||||
// Peek on BlendEquation's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEBLENDEQUATION){
|
||||
// Read BlendEquation'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("BlendEquation::read(): Could not cast this osg::BlendEquation to an osg::Object.");
|
||||
// Read BlendEquation's properties
|
||||
|
||||
// Read source
|
||||
setEquation(osg::BlendEquation::Equation(in->readInt()));
|
||||
|
||||
}
|
||||
else{
|
||||
throw Exception("BlendEquation::read(): Expected BlendEquation identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/BlendEquation.h
Normal file
15
src/osgPlugins/ive/BlendEquation.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_BLENDEQUATION
|
||||
#define IVE_BLENDEQUATION 1
|
||||
|
||||
#include <osg/BlendEquation>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class BlendEquation : public osg::BlendEquation, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -10,6 +10,7 @@ SET(TARGET_SRC
|
||||
AzimSector.cpp
|
||||
Billboard.cpp
|
||||
BlendColor.cpp
|
||||
BlendEquation.cpp
|
||||
BlendFunc.cpp
|
||||
BlinkSequence.cpp
|
||||
Camera.cpp
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "BlendColor.h"
|
||||
#include "Stencil.h"
|
||||
#include "BlendFunc.h"
|
||||
#include "BlendEquation.h"
|
||||
#include "Depth.h"
|
||||
#include "Material.h"
|
||||
#include "CullFace.h"
|
||||
@@ -1097,6 +1098,10 @@ osg::StateAttribute* DataInputStream::readStateAttribute()
|
||||
attribute = new osg::BlendFunc();
|
||||
((ive::BlendFunc*)(attribute))->read(this);
|
||||
}
|
||||
else if(attributeID == IVEBLENDEQUATION){
|
||||
attribute = new osg::BlendEquation();
|
||||
((ive::BlendEquation*)(attribute))->read(this);
|
||||
}
|
||||
else if(attributeID == IVEDEPTH){
|
||||
attribute = new osg::Depth();
|
||||
((ive::Depth*)(attribute))->read(this);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "BlendColor.h"
|
||||
#include "Stencil.h"
|
||||
#include "BlendFunc.h"
|
||||
#include "BlendEquation.h"
|
||||
#include "Material.h"
|
||||
#include "CullFace.h"
|
||||
#include "ColorMask.h"
|
||||
@@ -723,6 +724,9 @@ void DataOutputStream::writeStateAttribute(const osg::StateAttribute* attribute)
|
||||
else if(dynamic_cast<const osg::BlendFunc*>(attribute)){
|
||||
((ive::BlendFunc*)(attribute))->write(this);
|
||||
}
|
||||
else if(dynamic_cast<const osg::BlendEquation*>(attribute)){
|
||||
((ive::BlendEquation*)(attribute))->write(this);
|
||||
}
|
||||
else if(dynamic_cast<const osg::Depth*>(attribute)){
|
||||
((ive::Depth*)(attribute))->write(this);
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ namespace ive {
|
||||
#define IVESTENCIL 0x00000131
|
||||
#define IVESTENCILTWOSIDED 0x00000132
|
||||
#define IVECOLORMASK 0x00000133
|
||||
#define IVEBLENDEQUATION 0x00000134
|
||||
#define IVELIGHTMODEL 0x00001121
|
||||
#define IVECLIPPLANE 0x00001122
|
||||
#define IVEFRONTFACE 0x00001123
|
||||
|
||||
84
src/osgPlugins/osg/BlendEquation.cpp
Normal file
84
src/osgPlugins/osg/BlendEquation.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
#include "osg/BlendEquation"
|
||||
|
||||
#include "osgDB/Registry"
|
||||
#include "osgDB/Input"
|
||||
#include "osgDB/Output"
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgDB;
|
||||
|
||||
// forward declare functions to use later.
|
||||
bool BlendEquation_readLocalData(Object& obj, Input& fr);
|
||||
bool BlendEquation_writeLocalData(const Object& obj, Output& fw);
|
||||
|
||||
bool BlendEquation_matchModeStr(const char* str,int& mode);
|
||||
const char* BlendEquation_getModeStr(int value);
|
||||
|
||||
// register the read and write functions with the osgDB::Registry.
|
||||
RegisterDotOsgWrapperProxy g_BlendEquationProxy
|
||||
(
|
||||
new osg::BlendEquation,
|
||||
"BlendEquation",
|
||||
"Object StateAttribute BlendEquation",
|
||||
&BlendEquation_readLocalData,
|
||||
&BlendEquation_writeLocalData
|
||||
);
|
||||
|
||||
bool BlendEquation_readLocalData(Object& obj, Input& fr)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
|
||||
BlendEquation& transparency = static_cast<BlendEquation&>(obj);
|
||||
|
||||
int mode;
|
||||
if (fr[0].matchWord("equation") && BlendEquation_matchModeStr(fr[1].getStr(),mode))
|
||||
{
|
||||
transparency.setEquation(osg::BlendEquation::Equation(mode));
|
||||
fr+=2;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
bool BlendEquation_writeLocalData(const Object& obj, Output& fw)
|
||||
{
|
||||
const BlendEquation& transparency = static_cast<const BlendEquation&>(obj);
|
||||
|
||||
fw.indent() << "equation " << BlendEquation_getModeStr(transparency.getEquation()) << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool BlendEquation_matchModeStr(const char* str,int& mode)
|
||||
{
|
||||
if (strcmp(str,"RGBA_MIN")==0) mode = BlendEquation::RGBA_MIN;
|
||||
else if (strcmp(str,"RGBA_MAX")==0) mode = BlendEquation::RGBA_MAX;
|
||||
else if (strcmp(str,"ALPHA_MIN")==0) mode = BlendEquation::ALPHA_MIN;
|
||||
else if (strcmp(str,"ALPHA_MAX")==0) mode = BlendEquation::ALPHA_MAX;
|
||||
else if (strcmp(str,"LOGIC_OP")==0) mode = BlendEquation::LOGIC_OP;
|
||||
else if (strcmp(str,"FUNC_ADD")==0) mode = BlendEquation::FUNC_ADD;
|
||||
else if (strcmp(str,"FUNC_SUBTRACT")==0) mode = BlendEquation::FUNC_SUBTRACT;
|
||||
else if (strcmp(str,"FUNC_REVERSE_SUBTRACT")==0) mode = BlendEquation::FUNC_REVERSE_SUBTRACT;
|
||||
else return false;
|
||||
return true;
|
||||
|
||||
}
|
||||
const char* BlendEquation_getModeStr(int value)
|
||||
{
|
||||
switch(value)
|
||||
{
|
||||
case(BlendEquation::RGBA_MIN) : return "RGBA_MIN";
|
||||
case(BlendEquation::RGBA_MAX) : return "RGBA_MAX";
|
||||
case(BlendEquation::ALPHA_MIN) : return "ALPHA_MIN";
|
||||
case(BlendEquation::ALPHA_MAX) : return "ALPHA_MAX";
|
||||
case(BlendEquation::LOGIC_OP) : return "LOGIC_OP";
|
||||
case(BlendEquation::FUNC_ADD) : return "FUNC_ADD";
|
||||
case(BlendEquation::FUNC_SUBTRACT) : return "FUNC_SUBTRACT";
|
||||
case(BlendEquation::FUNC_REVERSE_SUBTRACT) : return "FUNC_REVERSE_SUBTRACT";
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -8,6 +8,7 @@ AutoTransform.cpp
|
||||
Billboard.cpp
|
||||
BlendColor.cpp
|
||||
BlendFunc.cpp
|
||||
BlendEquation.cpp
|
||||
Camera.cpp
|
||||
CameraView.cpp
|
||||
ClearNode.cpp
|
||||
|
||||
Reference in New Issue
Block a user