2001-09-20 05:08:56 +08:00
|
|
|
#include "osg/LightSource"
|
|
|
|
|
|
|
|
#include "osgDB/Registry"
|
|
|
|
#include "osgDB/Input"
|
|
|
|
#include "osgDB/Output"
|
|
|
|
|
|
|
|
using namespace osg;
|
|
|
|
using namespace osgDB;
|
|
|
|
|
|
|
|
// forward declare functions to use later.
|
|
|
|
bool LightSource_readLocalData(Object& obj, Input& fr);
|
|
|
|
bool LightSource_writeLocalData(const Object& obj, Output& fw);
|
|
|
|
|
|
|
|
// register the read and write functions with the osgDB::Registry.
|
|
|
|
RegisterDotOsgWrapperProxy g_LightSourceProxy
|
|
|
|
(
|
2002-03-27 07:52:52 +08:00
|
|
|
osgNew osg::LightSource,
|
2001-09-20 05:08:56 +08:00
|
|
|
"LightSource",
|
|
|
|
"Object Node LightSource",
|
|
|
|
&LightSource_readLocalData,
|
|
|
|
&LightSource_writeLocalData
|
|
|
|
);
|
|
|
|
|
|
|
|
bool LightSource_readLocalData(Object& obj, Input& fr)
|
|
|
|
{
|
|
|
|
bool iteratorAdvanced = false;
|
|
|
|
|
|
|
|
LightSource& lightsource = static_cast<LightSource&>(obj);
|
|
|
|
|
2002-03-27 07:52:52 +08:00
|
|
|
static ref_ptr<Light> s_light = osgNew osg::Light;
|
2001-09-20 05:08:56 +08:00
|
|
|
|
|
|
|
Light* light = static_cast<Light*>(fr.readObjectOfType(*s_light));
|
|
|
|
if (light)
|
|
|
|
{
|
|
|
|
lightsource.setLight(light);
|
|
|
|
iteratorAdvanced = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return iteratorAdvanced;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool LightSource_writeLocalData(const Object& obj, Output& fw)
|
|
|
|
{
|
|
|
|
const LightSource& lightsource = static_cast<const LightSource&>(obj);
|
|
|
|
|
|
|
|
if (lightsource.getLight()) fw.writeObject(*lightsource.getLight());
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|