From 5fddbfe85c3037c2ea0074aa48f9760142246840 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 13 Feb 2007 12:11:32 +0000 Subject: [PATCH] Added support for osg::BlendColor to .osg plugin --- VisualStudio/osgPlugins/osg/dot_osg.dsp | 4 ++ src/osgPlugins/osg/BlendColor.cpp | 57 +++++++++++++++++++++++++ src/osgPlugins/osg/GNUmakefile | 1 + 3 files changed, 62 insertions(+) create mode 100644 src/osgPlugins/osg/BlendColor.cpp diff --git a/VisualStudio/osgPlugins/osg/dot_osg.dsp b/VisualStudio/osgPlugins/osg/dot_osg.dsp index ffc53aede..330892c57 100755 --- a/VisualStudio/osgPlugins/osg/dot_osg.dsp +++ b/VisualStudio/osgPlugins/osg/dot_osg.dsp @@ -173,6 +173,10 @@ SOURCE=..\..\..\src\osgPlugins\osg\Billboard.cpp # End Source File # Begin Source File +SOURCE=..\..\..\src\osgPlugins\osg\BlendColor.cpp +# End Source File +# Begin Source File + SOURCE=..\..\..\src\osgPlugins\osg\BlendFunc.cpp # End Source File # Begin Source File diff --git a/src/osgPlugins/osg/BlendColor.cpp b/src/osgPlugins/osg/BlendColor.cpp new file mode 100644 index 000000000..8ec443198 --- /dev/null +++ b/src/osgPlugins/osg/BlendColor.cpp @@ -0,0 +1,57 @@ +#include +#include + +#include +#include +#include + +using namespace osg; +using namespace osgDB; + +// forward declare functions to use later. +bool BlendColor_readLocalData(Object& obj, Input& fr); +bool BlendColor_writeLocalData(const Object& obj, Output& fw); + +// register the read and write functions with the osgDB::Registry. + +RegisterDotOsgWrapperProxy g_BlendColorProxy +( + new osg::BlendColor, + "BlendColor", + "Object StateAttribute BlendColor", + &BlendColor_readLocalData, + &BlendColor_writeLocalData +); + +bool BlendColor_readLocalData(Object& obj, Input& fr) +{ + bool iteratorAdvanced = false; + + BlendColor& bc = static_cast(obj); + + if (fr.matchSequence("constantColor %f %f %f %f")) + { + osg::Vec4 color; + fr[1].getFloat(color[0]); + fr[2].getFloat(color[1]); + fr[3].getFloat(color[2]); + fr[4].getFloat(color[3]); + + bc.setConstantColor(color); + fr+=5; + iteratorAdvanced = true; + } + + return iteratorAdvanced; +} + +bool BlendColor_writeLocalData(const Object& obj, Output& fw) +{ + const BlendColor& bc = static_cast(obj); + + fw.indent() << "constantColor " << bc.getConstantColor() << std::endl; + + return true; +} + + diff --git a/src/osgPlugins/osg/GNUmakefile b/src/osgPlugins/osg/GNUmakefile index 91d0a7ebd..76424fe5f 100644 --- a/src/osgPlugins/osg/GNUmakefile +++ b/src/osgPlugins/osg/GNUmakefile @@ -6,6 +6,7 @@ CXXFILES =\ AnimationPath.cpp\ AutoTransform.cpp\ Billboard.cpp\ + BlendColor.cpp\ BlendFunc.cpp\ Camera.cpp\ CameraView.cpp\