Added .osg support for new TexGenNode
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -27,10 +27,10 @@ bool ClipNode_readLocalData(Object& obj, Input& fr)
|
||||
|
||||
ClipNode& clipnode = static_cast<ClipNode&>(obj);
|
||||
|
||||
StateAttribute* sa=0;
|
||||
osg::ref_ptr<StateAttribute> sa=0;
|
||||
while((sa=fr.readStateAttribute())!=0)
|
||||
{
|
||||
ClipPlane* clipplane = dynamic_cast<ClipPlane*>(sa);
|
||||
ClipPlane* clipplane = dynamic_cast<ClipPlane*>(sa.get());
|
||||
if (clipplane) clipnode.addClipPlane(clipplane);
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ CXXFILES =\
|
||||
TexEnv.cpp\
|
||||
TexEnvCombine.cpp\
|
||||
TexGen.cpp\
|
||||
TexGenNode.cpp\
|
||||
TexMat.cpp\
|
||||
Texture.cpp\
|
||||
Texture1D.cpp\
|
||||
|
||||
65
src/osgPlugins/osg/TexGenNode.cpp
Normal file
65
src/osgPlugins/osg/TexGenNode.cpp
Normal file
@@ -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<TexGenNode&>(obj);
|
||||
|
||||
unsigned int textureUnit = 0;
|
||||
if (fr[0].matchWord("TextureUnit") && fr[1].getUInt(textureUnit))
|
||||
{
|
||||
|
||||
texGenNode.setTextureUnit(textureUnit);
|
||||
|
||||
fr+=2;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
|
||||
osg::ref_ptr<StateAttribute> sa=0;
|
||||
while((sa=fr.readStateAttribute())!=0)
|
||||
{
|
||||
TexGen* texgen = dynamic_cast<TexGen*>(sa.get());
|
||||
if (texgen) texGenNode.setTexGen(texgen);
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
|
||||
bool TexGenNode_writeLocalData(const Object& obj, Output& fw)
|
||||
{
|
||||
const TexGenNode& texGenNode = static_cast<const TexGenNode&>(obj);
|
||||
|
||||
fw.indent()<<"TextureUnit "<<texGenNode.getTextureUnit()<<std::endl;
|
||||
|
||||
if (texGenNode.getTexGen())
|
||||
{
|
||||
fw.writeObject(*texGenNode.getTexGen());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user