Added code to catch erroneous Dof axis settings

This commit is contained in:
Robert Osfield 2008-05-29 11:45:31 +00:00
parent e1eeabcea0
commit 7a2c403992

View File

@ -31,6 +31,10 @@
#include <osgSim/MultiSwitch> #include <osgSim/MultiSwitch>
#include <osgSim/GeographicLocation> #include <osgSim/GeographicLocation>
#include <osgSim/ObjectRecordData> #include <osgSim/ObjectRecordData>
#include <osg/Notify>
#include <osg/io_utils>
#include "Registry.h" #include "Registry.h"
#include "Document.h" #include "Document.h"
#include "RecordInputStream.h" #include "RecordInputStream.h"
@ -385,9 +389,21 @@ protected:
osg::Vec3 yAxis = zAxis ^ xAxis; osg::Vec3 yAxis = zAxis ^ xAxis;
// normalize // normalize
xAxis.normalize(); float length_x = xAxis.normalize();
yAxis.normalize(); float length_y = yAxis.normalize();
zAxis.normalize(); float length_z = zAxis.normalize();
if ((length_x*length_y*length_z)==0.0f)
{
osg::notify(osg::NOTICE)<<"Warning: OpenFlight DegreeOfFreedom::readRecord() found erroneous axis definition:"<<std::endl;
osg::notify(osg::NOTICE)<<" localOrigin="<<localOrigin<<std::endl;
osg::notify(osg::NOTICE)<<" pointOnXAxis="<<pointOnXAxis<<std::endl;
osg::notify(osg::NOTICE)<<" pointInXYPlane="<<pointInXYPlane<<std::endl;
xAxis.set(1.0f,0.0f,0.0f);
yAxis.set(0.0f,1.0f,0.0f);
zAxis.set(0.0f,0.0f,1.0f);
}
// scale origin // scale origin
osg::Vec3 origin = localOrigin * document.unitScale(); osg::Vec3 origin = localOrigin * document.unitScale();
@ -398,6 +414,7 @@ protected:
zAxis.x(), zAxis.y(), zAxis.z(), 0.0, zAxis.x(), zAxis.y(), zAxis.z(), 0.0,
origin.x(), origin.y(), origin.z(), 1.0); origin.x(), origin.y(), origin.z(), 1.0);
_dof->setInversePutMatrix(inv_putmat); _dof->setInversePutMatrix(inv_putmat);
_dof->setPutMatrix(osg::Matrix::inverse(inv_putmat)); _dof->setPutMatrix(osg::Matrix::inverse(inv_putmat));