2002-08-07 01:07:05 +08:00
|
|
|
#include "osg/PositionAttitudeTransform"
|
|
|
|
|
|
|
|
#include "osgDB/Registry"
|
|
|
|
#include "osgDB/Input"
|
|
|
|
#include "osgDB/Output"
|
|
|
|
|
|
|
|
using namespace osg;
|
|
|
|
using namespace osgDB;
|
|
|
|
|
|
|
|
// forward declare functions to use later.
|
|
|
|
bool PositionAttitudeTransform_readLocalData(Object& obj, Input& fr);
|
|
|
|
bool PositionAttitudeTransform_writeLocalData(const Object& obj, Output& fw);
|
|
|
|
|
|
|
|
// register the read and write functions with the osgDB::Registry.
|
|
|
|
RegisterDotOsgWrapperProxy g_PositionAttitudeTransformProxy
|
|
|
|
(
|
|
|
|
osgNew osg::PositionAttitudeTransform,
|
|
|
|
"PositionAttitudeTransform",
|
|
|
|
"Object Node Transform PositionAttitudeTransform Group",
|
|
|
|
&PositionAttitudeTransform_readLocalData,
|
|
|
|
&PositionAttitudeTransform_writeLocalData,
|
|
|
|
DotOsgWrapper::READ_AND_WRITE
|
|
|
|
);
|
|
|
|
|
|
|
|
bool PositionAttitudeTransform_readLocalData(Object& obj, Input& fr)
|
|
|
|
{
|
|
|
|
bool iteratorAdvanced = false;
|
|
|
|
|
|
|
|
PositionAttitudeTransform& transform = static_cast<PositionAttitudeTransform&>(obj);
|
|
|
|
|
2002-08-27 23:46:47 +08:00
|
|
|
if (fr.matchSequence("position %f %f %f"))
|
|
|
|
{
|
|
|
|
osg::Vec3 pos;
|
|
|
|
fr[1].getFloat(pos[0]);
|
|
|
|
fr[2].getFloat(pos[1]);
|
|
|
|
fr[3].getFloat(pos[2]);
|
|
|
|
|
|
|
|
transform.setPosition(pos);
|
|
|
|
|
|
|
|
fr += 4;
|
|
|
|
iteratorAdvanced = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fr.matchSequence("attitude %f %f %f %f"))
|
|
|
|
{
|
|
|
|
osg::Quat att;
|
|
|
|
fr[1].getFloat(att[0]);
|
|
|
|
fr[2].getFloat(att[1]);
|
|
|
|
fr[3].getFloat(att[2]);
|
|
|
|
fr[4].getFloat(att[3]);
|
|
|
|
|
|
|
|
transform.setAttitude(att);
|
|
|
|
|
2002-08-28 04:18:43 +08:00
|
|
|
fr += 5;
|
|
|
|
iteratorAdvanced = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fr.matchSequence("pivot %f %f %f"))
|
|
|
|
{
|
|
|
|
osg::Vec3 pivot;
|
|
|
|
fr[1].getFloat(pivot[0]);
|
|
|
|
fr[2].getFloat(pivot[1]);
|
|
|
|
fr[3].getFloat(pivot[2]);
|
|
|
|
|
|
|
|
transform.setPivotPoint(pivot);
|
|
|
|
|
2002-08-27 23:46:47 +08:00
|
|
|
fr += 4;
|
|
|
|
iteratorAdvanced = true;
|
|
|
|
}
|
|
|
|
|
2002-08-07 01:07:05 +08:00
|
|
|
return iteratorAdvanced;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PositionAttitudeTransform_writeLocalData(const Object& obj, Output& fw)
|
|
|
|
{
|
|
|
|
const PositionAttitudeTransform& transform = static_cast<const PositionAttitudeTransform&>(obj);
|
2002-08-27 23:46:47 +08:00
|
|
|
|
|
|
|
fw.indent()<<"position "<<transform.getPosition()<<std::endl;
|
|
|
|
fw.indent()<<"attitude "<<transform.getAttitude()<<std::endl;
|
2002-08-28 04:18:43 +08:00
|
|
|
fw.indent()<<"pivotPoint "<<transform.getPivotPoint()<<std::endl;
|
2002-08-27 23:46:47 +08:00
|
|
|
|
2002-08-07 01:07:05 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|