*
*/
-/* -*-c++-*-
- *
- * Copyright (C) 2006-2007 Mathias Froehlich
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- */
-
#ifdef HAVE_CONFIG_H
# include <simgear_config.h>
#endif
+#include <osgDB/Registry>
+#include <osgDB/Input>
+#include <osgDB/Output>
+
#include "SGScaleTransform.hxx"
SGScaleTransform::SGScaleTransform() :
setReferenceFrame(RELATIVE_RF);
}
+SGScaleTransform::SGScaleTransform(const SGScaleTransform& scale,
+ const osg::CopyOp& copyop) :
+ osg::Transform(scale, copyop),
+ _center(scale._center),
+ _scaleFactor(scale._scaleFactor),
+ _boundScale(scale._boundScale)
+{
+}
+
bool
SGScaleTransform::computeLocalToWorldMatrix(osg::Matrix& matrix,
osg::NodeVisitor* nv) const
bs.radius() *= _boundScale;
return bs;
}
+
+namespace {
+
+bool ScaleTransform_readLocalData(osg::Object& obj, osgDB::Input& fr)
+{
+ SGScaleTransform& scale = static_cast<SGScaleTransform&>(obj);
+ if (fr[0].matchWord("center")) {
+ ++fr;
+ osg::Vec3d center;
+ if (fr.readSequence(center))
+ fr += 3;
+ else
+ return false;
+ scale.setCenter(toSG(center));
+ }
+ if (fr[0].matchWord("scaleFactor")) {
+ ++fr;
+ osg::Vec3d scaleFactor;
+ if (fr.readSequence(scaleFactor))
+ fr += 3;
+ else
+ return false;
+ scale.setScaleFactor(toSG(scaleFactor));
+ }
+ return true;
+}
+
+bool ScaleTransform_writeLocalData(const osg::Object& obj, osgDB::Output& fw)
+{
+ const SGScaleTransform& scale = static_cast<const SGScaleTransform&>(obj);
+ const SGVec3d& center = scale.getCenter();
+ const SGVec3d& scaleFactor = scale.getScaleFactor();
+ int prec = fw.precision();
+ fw.precision(15);
+ fw.indent() << "center ";
+ for (int i = 0; i < 3; i++)
+ fw << center(i) << " ";
+ fw << std::endl;
+ fw.precision(prec);
+ fw.indent() << "scaleFactor ";
+ for (int i = 0; i < 3; i++)
+ fw << scaleFactor(i) << " ";
+ fw << std::endl;
+ return true;
+}
+
+}
+
+osgDB::RegisterDotOsgWrapperProxy g_ScaleTransformProxy
+(
+ new SGScaleTransform,
+ "SGScaleTransform",
+ "Object Node Transform SGScaleTransform Group",
+ &ScaleTransform_readLocalData,
+ &ScaleTransform_writeLocalData
+);