diff --git a/VisualStudio/osgPlugins/osg/dot_osg.dsp b/VisualStudio/osgPlugins/osg/dot_osg.dsp index 81d28fb1f..b9edefa4c 100755 --- a/VisualStudio/osgPlugins/osg/dot_osg.dsp +++ b/VisualStudio/osgPlugins/osg/dot_osg.dsp @@ -306,6 +306,10 @@ SOURCE=..\..\..\src\osgPlugins\osg\TexGen.cpp # End Source File # Begin Source File +SOURCE=..\..\..\src\osgPlugins\osg\TexGenNode.cpp +# End Source File +# Begin Source File + SOURCE=..\..\..\src\osgPlugins\osg\TexMat.cpp # End Source File # Begin Source File diff --git a/src/osgPlugins/osg/ClipNode.cpp b/src/osgPlugins/osg/ClipNode.cpp index 6c5154b8f..f8161825e 100644 --- a/src/osgPlugins/osg/ClipNode.cpp +++ b/src/osgPlugins/osg/ClipNode.cpp @@ -27,10 +27,10 @@ bool ClipNode_readLocalData(Object& obj, Input& fr) ClipNode& clipnode = static_cast(obj); - StateAttribute* sa=0; + osg::ref_ptr sa=0; while((sa=fr.readStateAttribute())!=0) { - ClipPlane* clipplane = dynamic_cast(sa); + ClipPlane* clipplane = dynamic_cast(sa.get()); if (clipplane) clipnode.addClipPlane(clipplane); iteratorAdvanced = true; } diff --git a/src/osgPlugins/osg/GNUmakefile b/src/osgPlugins/osg/GNUmakefile index 535c1b5cf..5675e2415 100644 --- a/src/osgPlugins/osg/GNUmakefile +++ b/src/osgPlugins/osg/GNUmakefile @@ -56,6 +56,7 @@ CXXFILES =\ TexEnv.cpp\ TexEnvCombine.cpp\ TexGen.cpp\ + TexGenNode.cpp\ TexMat.cpp\ Texture.cpp\ Texture1D.cpp\ diff --git a/src/osgPlugins/osg/TexGenNode.cpp b/src/osgPlugins/osg/TexGenNode.cpp new file mode 100644 index 000000000..292aaf3ae --- /dev/null +++ b/src/osgPlugins/osg/TexGenNode.cpp @@ -0,0 +1,65 @@ +#include "osg/TexGenNode" + +#include "osgDB/Registry" +#include "osgDB/Input" +#include "osgDB/Output" + +using namespace osg; +using namespace osgDB; + +// forward declare functions to use later. +bool TexGenNode_readLocalData(Object& obj, Input& fr); +bool TexGenNode_writeLocalData(const Object& obj, Output& fw); + +// register the read and write functions with the osgDB::Registry. +RegisterDotOsgWrapperProxy g_TexGenNodeProxy +( + new osg::TexGenNode, + "TexGenNode", + "Object Node TexGenNode Group", + &TexGenNode_readLocalData, + &TexGenNode_writeLocalData +); + +bool TexGenNode_readLocalData(Object& obj, Input& fr) +{ + bool iteratorAdvanced = false; + + TexGenNode& texGenNode = static_cast(obj); + + unsigned int textureUnit = 0; + if (fr[0].matchWord("TextureUnit") && fr[1].getUInt(textureUnit)) + { + + texGenNode.setTextureUnit(textureUnit); + + fr+=2; + iteratorAdvanced = true; + } + + + osg::ref_ptr sa=0; + while((sa=fr.readStateAttribute())!=0) + { + TexGen* texgen = dynamic_cast(sa.get()); + if (texgen) texGenNode.setTexGen(texgen); + iteratorAdvanced = true; + } + + return iteratorAdvanced; +} + + +bool TexGenNode_writeLocalData(const Object& obj, Output& fw) +{ + const TexGenNode& texGenNode = static_cast(obj); + + fw.indent()<<"TextureUnit "<