2005-04-08 17:36:42 +08:00
|
|
|
#include <osg/ClearNode>
|
|
|
|
#include <osg/io_utils>
|
2001-10-03 15:56:33 +08:00
|
|
|
|
2005-04-08 17:36:42 +08:00
|
|
|
#include <osgDB/Registry>
|
|
|
|
#include <osgDB/Input>
|
|
|
|
#include <osgDB/Output>
|
2001-10-03 15:56:33 +08:00
|
|
|
|
|
|
|
using namespace osg;
|
|
|
|
using namespace osgDB;
|
|
|
|
|
|
|
|
// forward declare functions to use later.
|
2002-08-19 19:42:37 +08:00
|
|
|
bool ClearNode_readLocalData(Object& obj, Input& fr);
|
|
|
|
bool ClearNode_writeLocalData(const Object& obj, Output& fw);
|
2001-10-03 15:56:33 +08:00
|
|
|
|
|
|
|
// register the read and write functions with the osgDB::Registry.
|
2002-08-19 19:42:37 +08:00
|
|
|
|
2001-10-03 15:56:33 +08:00
|
|
|
RegisterDotOsgWrapperProxy g_EarthSkyProxy
|
|
|
|
(
|
2002-12-16 21:40:58 +08:00
|
|
|
new osg::ClearNode,
|
2001-10-03 15:56:33 +08:00
|
|
|
"EarthSky",
|
|
|
|
"Object Node EarthSky Group",
|
2002-08-19 19:42:37 +08:00
|
|
|
&ClearNode_readLocalData,
|
|
|
|
&ClearNode_writeLocalData
|
|
|
|
);
|
|
|
|
|
|
|
|
RegisterDotOsgWrapperProxy g_ClearNodeProxy
|
|
|
|
(
|
2002-12-16 21:40:58 +08:00
|
|
|
new osg::ClearNode,
|
2002-08-19 19:42:37 +08:00
|
|
|
"ClearNode",
|
|
|
|
"Object Node ClearNode Group",
|
|
|
|
&ClearNode_readLocalData,
|
|
|
|
&ClearNode_writeLocalData
|
2001-10-03 15:56:33 +08:00
|
|
|
);
|
|
|
|
|
2002-08-19 19:42:37 +08:00
|
|
|
bool ClearNode_readLocalData(Object& obj, Input& fr)
|
2001-10-03 15:56:33 +08:00
|
|
|
{
|
|
|
|
bool iteratorAdvanced = false;
|
|
|
|
|
2002-08-19 19:42:37 +08:00
|
|
|
ClearNode& es = static_cast<ClearNode&>(obj);
|
2001-10-03 15:56:33 +08:00
|
|
|
|
|
|
|
if (fr.matchSequence("requiresClear"))
|
|
|
|
{
|
|
|
|
if (fr[1].matchWord("TRUE"))
|
|
|
|
{
|
|
|
|
es.setRequiresClear(true);
|
|
|
|
iteratorAdvanced = true;
|
|
|
|
fr+=2;
|
|
|
|
}
|
|
|
|
else if (fr[1].matchWord("FALSE"))
|
|
|
|
{
|
|
|
|
es.setRequiresClear(false);
|
|
|
|
iteratorAdvanced = true;
|
|
|
|
fr+=2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
osg::Vec4 vec4(0.0f,0.0f,0.0f,1.0f);
|
|
|
|
|
|
|
|
if (fr[0].matchWord("clearColor") &&
|
|
|
|
fr[1].getFloat(vec4[0]) &&
|
|
|
|
fr[2].getFloat(vec4[1]) &&
|
|
|
|
fr[3].getFloat(vec4[2]) &&
|
|
|
|
fr[4].getFloat(vec4[3]))
|
|
|
|
{
|
|
|
|
es.setClearColor(vec4);
|
|
|
|
fr+=5;
|
|
|
|
iteratorAdvanced = true;
|
|
|
|
}
|
|
|
|
|
2005-05-19 03:55:14 +08:00
|
|
|
if (fr[0].matchWord("clearMask"))
|
|
|
|
{
|
|
|
|
if (fr[1].isUInt())
|
|
|
|
{
|
|
|
|
unsigned int value=0;
|
|
|
|
fr[1].getUInt(value);
|
|
|
|
es.setClearMask(static_cast<GLbitfield>(value));
|
|
|
|
iteratorAdvanced = true;
|
|
|
|
fr+=2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-10-03 15:56:33 +08:00
|
|
|
return iteratorAdvanced;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-19 19:42:37 +08:00
|
|
|
bool ClearNode_writeLocalData(const Object& obj, Output& fw)
|
2001-10-03 15:56:33 +08:00
|
|
|
{
|
2002-08-19 19:42:37 +08:00
|
|
|
const ClearNode& es = static_cast<const ClearNode&>(obj);
|
2001-10-03 15:56:33 +08:00
|
|
|
|
|
|
|
fw.indent() << "requiresClear ";
|
|
|
|
if (es.getRequiresClear())
|
|
|
|
{
|
2001-12-15 07:18:28 +08:00
|
|
|
fw<<"TRUE"<< std::endl;
|
2001-10-03 15:56:33 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-12-15 07:18:28 +08:00
|
|
|
fw<<"FALSE"<< std::endl;
|
2001-10-03 15:56:33 +08:00
|
|
|
}
|
|
|
|
|
2001-12-15 07:18:28 +08:00
|
|
|
fw.indent() << "clearColor "<<es.getClearColor()<< std::endl;
|
2005-05-19 03:55:14 +08:00
|
|
|
fw.indent() << "clearMask "<<static_cast<unsigned int>(es.getClearMask())<< std::endl;
|
2001-10-03 15:56:33 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|