Move osg dependent stuff from SGMath into simgear/scene/util/OsgMath.hxx.
Update includes in simgear to reflect this change.
Note that this change also requires an updated flightgear version.
leastsqs.hxx
sg_geodesy.hxx
sg_types.hxx
- sg_random.h
+ sg_random.h
)
set(SOURCES
- SGGeod.cxx
SGGeodesy.cxx
interpolater.cxx
leastsqs.cxx
- sg_random.c
+ sg_random.c
)
simgear_component(math math "${SOURCES}" "${HEADERS}")
+++ /dev/null
-// Copyright (C) 2008 Tim Moore timoore@redhat.com
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Library General Public
-// License as published by the Free Software Foundation; either
-// version 2 of the License, or (at your option) any later version.
-//
-// This library 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
-// Library 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 "SGMath.hxx"
-
-#ifndef NO_OPENSCENEGRAPH_INTERFACE
-
-osg::Matrix SGGeod::makeSimulationFrameRelative() const
-{
- SGQuatd hlOr = SGQuatd::fromLonLat(*this);
- return osg::Matrix(toOsg(hlOr));
-}
-
-osg::Matrix SGGeod::makeSimulationFrame() const
-{
- osg::Matrix result(makeSimulationFrameRelative());
- SGVec3d coord;
- SGGeodesy::SGGeodToCart(*this, coord);
- result.setTrans(toOsg(coord));
- return result;
-}
-
-osg::Matrix SGGeod::makeZUpFrameRelative() const
-{
- osg::Matrix result(makeSimulationFrameRelative());
- // 180 degree rotation around Y axis
- osg::Quat flip(0.0, 1.0, 0.0, 0.0);
- result.preMult(osg::Matrix(flip));
- return result;
-}
-
-osg::Matrix SGGeod::makeZUpFrame() const
-{
- osg::Matrix result(makeZUpFrameRelative());
- SGVec3d coord;
- SGGeodesy::SGGeodToCart(*this, coord);
- result.setTrans(toOsg(coord));
- return result;
-}
-
-#endif
#include <simgear/constants.h>
-#ifndef NO_OPENSCENEGRAPH_INTERFACE
-#include <osg/Matrix>
-#endif
-
// #define SG_GEOD_NATIVE_DEGREE
/// Class representing a geodetic location
// Compare two geodetic positions for equality
bool operator == ( const SGGeod & other ) const;
-#ifndef NO_OPENSCENEGRAPH_INTERFACE
- // Create a local coordinate frame in the earth-centered frame of
- // reference. X points north, Z points down.
- // makeSimulationFrameRelative() only includes rotation.
- osg::Matrix makeSimulationFrameRelative() const;
- osg::Matrix makeSimulationFrame() const;
-
- // Create a Z-up local coordinate frame in the earth-centered frame
- // of reference. This is what scenery models, etc. expect.
- // makeZUpFrameRelative() only includes rotation.
- osg::Matrix makeZUpFrameRelative() const;
- osg::Matrix makeZUpFrame() const;
-#endif
private:
/// This one is private since construction is not unique if you do
/// not know the units of the arguments. Use the factory methods for
#ifndef SGIntersect_HXX
#define SGIntersect_HXX
+#include <algorithm>
+
template<typename T>
inline bool
intersects(const SGSphere<T>& s1, const SGSphere<T>& s2)
#undef max
#endif
-#ifndef NO_OPENSCENEGRAPH_INTERFACE
-#include <osg/Quat>
-#endif
-
/// Quaternion Class
template<typename T>
class SGQuat {
toQuatd(const SGQuatf& v)
{ return SGQuatd(v(0), v(1), v(2), v(3)); }
-#ifndef NO_OPENSCENEGRAPH_INTERFACE
-inline
-SGQuatd
-toSG(const osg::Quat& q)
-{ return SGQuatd(q[0], q[1], q[2], q[3]); }
-
-inline
-osg::Quat
-toOsg(const SGQuatd& q)
-{ return osg::Quat(q[0], q[1], q[2], q[3]); }
-#endif
-
#endif
#ifndef SGVec2_H
#define SGVec2_H
-#ifndef NO_OPENSCENEGRAPH_INTERFACE
-#include <osg/Vec2f>
-#include <osg/Vec2d>
-#endif
-
/// 2D Vector Class
template<typename T>
class SGVec2 {
toVec2d(const SGVec2f& v)
{ return SGVec2d(v(0), v(1)); }
-#ifndef NO_OPENSCENEGRAPH_INTERFACE
-inline
-SGVec2d
-toSG(const osg::Vec2d& v)
-{ return SGVec2d(v[0], v[1]); }
-
-inline
-SGVec2f
-toSG(const osg::Vec2f& v)
-{ return SGVec2f(v[0], v[1]); }
-
-inline
-osg::Vec2d
-toOsg(const SGVec2d& v)
-{ return osg::Vec2d(v[0], v[1]); }
-
-inline
-osg::Vec2f
-toOsg(const SGVec2f& v)
-{ return osg::Vec2f(v[0], v[1]); }
-
-#endif
-
#endif
#ifndef SGVec3_H
#define SGVec3_H
-#ifndef NO_OPENSCENEGRAPH_INTERFACE
-#include <osg/Vec3f>
-#include <osg/Vec3d>
-#endif
-
/// 3D Vector Class
template<typename T>
class SGVec3 {
toVec3d(const SGVec3f& v)
{ return SGVec3d(v(0), v(1), v(2)); }
-#ifndef NO_OPENSCENEGRAPH_INTERFACE
-inline
-SGVec3d
-toSG(const osg::Vec3d& v)
-{ return SGVec3d(v[0], v[1], v[2]); }
-
-inline
-SGVec3f
-toSG(const osg::Vec3f& v)
-{ return SGVec3f(v[0], v[1], v[2]); }
-
-inline
-osg::Vec3d
-toOsg(const SGVec3d& v)
-{ return osg::Vec3d(v[0], v[1], v[2]); }
-
-inline
-osg::Vec3f
-toOsg(const SGVec3f& v)
-{ return osg::Vec3f(v[0], v[1], v[2]); }
-#endif
-
#endif
#ifndef SGVec4_H
#define SGVec4_H
-#ifndef NO_OPENSCENEGRAPH_INTERFACE
-#include <osg/Vec4f>
-#include <osg/Vec4d>
-#endif
-
/// 4D Vector Class
template<typename T>
class SGVec4 {
toVec4d(const SGVec4f& v)
{ return SGVec4d(v(0), v(1), v(2), v(3)); }
-#ifndef NO_OPENSCENEGRAPH_INTERFACE
-inline
-SGVec4d
-toSG(const osg::Vec4d& v)
-{ return SGVec4d(v[0], v[1], v[2], v[3]); }
-
-inline
-SGVec4f
-toSG(const osg::Vec4f& v)
-{ return SGVec4f(v[0], v[1], v[2], v[3]); }
-
-inline
-osg::Vec4d
-toOsg(const SGVec4d& v)
-{ return osg::Vec4d(v[0], v[1], v[2], v[3]); }
-
-inline
-osg::Vec4f
-toOsg(const SGVec4f& v)
-{ return osg::Vec4f(v[0], v[1], v[2], v[3]); }
-#endif
-
#endif
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
#include <simgear/scene/tgdb/userdata.hxx>
+#include <simgear/scene/util/OsgMath.hxx>
#include <simgear/scene/util/SGSceneFeatures.hxx>
#include <simgear/scene/util/StateAttributeFactory.hxx>
#include <simgear/structure/OSGUtils.hxx>
#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_comparison.hpp>
+#include <simgear/scene/util/OsgMath.hxx>
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
#include <simgear/scene/util/SGSceneFeatures.hxx>
#include <simgear/scene/util/StateAttributeFactory.hxx>
-#include <simgear/math/SGMath.hxx>
#include <simgear/structure/OSGUtils.hxx>
#include "Noise.hxx"
#include <osg/NodeVisitor>
#include <osg/TemplatePrimitiveFunctor>
+#include <simgear/scene/util/OsgMath.hxx>
#include <simgear/scene/util/SGSceneUserData.hxx>
#include <simgear/scene/bvh/BVHGroup.hxx>
#include <simgear/scene/bvh/BVHLineGeometry.hxx>
#include <simgear/scene/material/Technique.hxx>
#include <simgear/scene/model/model.hxx>
#include <simgear/scene/model/ConditionNode.hxx>
+#include <simgear/scene/util/OsgMath.hxx>
using namespace std;
using namespace simgear;
#include <osgDB/Input>
#include <osgDB/Output>
+#include <simgear/scene/util/OsgMath.hxx>
+
#include "SGRotateTransform.hxx"
static void
#include <osgDB/Input>
#include <osgDB/Output>
+#include <simgear/scene/util/OsgMath.hxx>
+
#include "SGScaleTransform.hxx"
SGScaleTransform::SGScaleTransform() :
#include <osgDB/Input>
#include <osgDB/Output>
+#include <simgear/scene/util/OsgMath.hxx>
+
#include "SGTranslateTransform.hxx"
SGTranslateTransform::SGTranslateTransform() :
#include <simgear/props/props.hxx>
#include <simgear/structure/SGBinding.hxx>
#include <simgear/scene/material/EffectGeode.hxx>
+#include <simgear/scene/util/OsgMath.hxx>
#include <simgear/scene/util/SGNodeMasks.hxx>
#include <simgear/scene/util/SGSceneUserData.hxx>
#include <simgear/scene/util/SGStateAttributeVisitor.hxx>
#endif
#include <simgear/math/SGMath.hxx>
-#include <simgear/math/SGGeod.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/props/props.hxx>
#include <simgear/props/props_io.hxx>
+#include <simgear/scene/util/OsgMath.hxx>
#include <simgear/structure/OSGVersion.hxx>
#include <osgParticle/SmokeTrailEffect>
// Make new frame for particle system, coincident with
// the emitter frame, but oriented with local Z.
SGGeod geod = SGGeod::fromCart(toSG(emitOrigin));
- Matrix newParticleMat = geod.makeZUpFrame();
+ Matrix newParticleMat = makeZUpFrame(geod);
Matrix changeParticleFrame
= particleMat * Matrix::inverse(newParticleMat);
particleFrame->setMatrix(newParticleMat);
#include "placement.hxx"
#include <simgear/compiler.h>
+#include <simgear/scene/util/OsgMath.hxx>
#include <simgear/scene/util/SGSceneUserData.hxx>
\f
#include <simgear/debug/logstream.hxx>
#include <simgear/scene/model/model.hxx>
#include <simgear/scene/util/RenderConstants.hxx>
+#include <simgear/scene/util/OsgMath.hxx>
#include <simgear/scene/util/StateAttributeFactory.hxx>
#include <simgear/screen/extensions.hxx>
#include <osg/CullFace>
#include <simgear/debug/logstream.hxx>
-#include <simgear/math/SGMath.hxx>
+#include <simgear/scene/util/OsgMath.hxx>
#include <simgear/scene/util/VectorArrayAdapter.hxx>
#include <simgear/scene/material/Effect.hxx>
#include <simgear/scene/material/EffectGeode.hxx>
#include <simgear/math/sg_random.h>
#include <simgear/scene/util/RenderConstants.hxx>
+#include <simgear/scene/util/OsgMath.hxx>
#include <simgear/sg_inlines.h>
#include <osg/StateSet>
#include <osgDB/FileNameUtils>
#include <osgDB/ReadFile>
+#include <simgear/scene/util/OsgMath.hxx>
+
#include "BucketBox.hxx"
namespace simgear {
#include <stdio.h>
#include <simgear/math/sg_random.h>
-#include <simgear/math/SGMath.hxx>
+#include <simgear/scene/util/OsgMath.hxx>
#include "SGTriangleBin.hxx"
#include "SGVasiDrawable.hxx"
+#include <simgear/scene/util/OsgMath.hxx>
+
struct SGVasiDrawable::LightData {
LightData(const SGVec3f& p, const SGVec3f& n, const SGVec3f& up) :
position(p),
#include <simgear/debug/logstream.hxx>
#include <simgear/math/sg_geodesy.hxx>
#include <simgear/math/sg_random.h>
-#include <simgear/math/SGMath.hxx>
#include <simgear/misc/sgstream.hxx>
#include <simgear/scene/material/mat.hxx>
#include <simgear/scene/material/matlib.hxx>
#include <simgear/scene/model/ModelRegistry.hxx>
#include <simgear/scene/tgdb/apt_signs.hxx>
#include <simgear/scene/tgdb/obj.hxx>
+#include <simgear/scene/util/OsgMath.hxx>
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
#include "ReaderWriterSPT.hxx"
double lon, double elev, double hdg)
{
SGGeod geod = SGGeod::fromDegM(lon, lat, elev);
- obj_pos = geod.makeZUpFrame();
+ obj_pos = makeZUpFrame(geod);
// hdg is not a compass heading, but a counter-clockwise rotation
// around the Z axis
obj_pos.preMult(osg::Matrix::rotate(hdg * SGD_DEGREES_TO_RADIANS,
#include <osg/Group>
#include <osg/Matrix>
-#include <simgear/math/SGMath.hxx>
+#include <simgear/scene/util/OsgMath.hxx>
namespace simgear
{
#include <simgear/debug/logstream.hxx>
#include <simgear/scene/util/RenderConstants.hxx>
#include <simgear/scene/util/SGEnlargeBoundingBox.hxx>
+#include <simgear/scene/util/OsgMath.hxx>
#include <simgear/scene/util/StateAttributeFactory.hxx>
#include <simgear/scene/material/Effect.hxx>
set(HEADERS
CopyOp.hxx
NodeAndDrawableVisitor.hxx
+ OsgMath.hxx
PrimitiveUtils.hxx
QuadTreeBuilder.hxx
RenderConstants.hxx
--- /dev/null
+// Copyright (C) 2006-2009 Mathias Froehlich - Mathias.Froehlich@web.de
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library 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
+// Library 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.
+//
+
+#ifndef SIMGEAR_SCENE_UTILS_OSGMATH_HXX
+#define SIMGEAR_SCENE_UTILS_OSGMATH_HXX
+
+#include <osg/Vec2f>
+#include <osg/Vec2d>
+#include <osg/Vec3f>
+#include <osg/Vec3d>
+#include <osg/Vec4f>
+#include <osg/Vec4d>
+#include <osg/Quat>
+#include <osg/Matrix>
+
+#include <simgear/math/SGMath.hxx>
+
+inline
+SGVec2d
+toSG(const osg::Vec2d& v)
+{ return SGVec2d(v[0], v[1]); }
+
+inline
+SGVec2f
+toSG(const osg::Vec2f& v)
+{ return SGVec2f(v[0], v[1]); }
+
+inline
+osg::Vec2d
+toOsg(const SGVec2d& v)
+{ return osg::Vec2d(v[0], v[1]); }
+
+inline
+osg::Vec2f
+toOsg(const SGVec2f& v)
+{ return osg::Vec2f(v[0], v[1]); }
+
+inline
+SGVec3d
+toSG(const osg::Vec3d& v)
+{ return SGVec3d(v[0], v[1], v[2]); }
+
+inline
+SGVec3f
+toSG(const osg::Vec3f& v)
+{ return SGVec3f(v[0], v[1], v[2]); }
+
+inline
+osg::Vec3d
+toOsg(const SGVec3d& v)
+{ return osg::Vec3d(v[0], v[1], v[2]); }
+
+inline
+osg::Vec3f
+toOsg(const SGVec3f& v)
+{ return osg::Vec3f(v[0], v[1], v[2]); }
+
+inline
+SGVec4d
+toSG(const osg::Vec4d& v)
+{ return SGVec4d(v[0], v[1], v[2], v[3]); }
+
+inline
+SGVec4f
+toSG(const osg::Vec4f& v)
+{ return SGVec4f(v[0], v[1], v[2], v[3]); }
+
+inline
+osg::Vec4d
+toOsg(const SGVec4d& v)
+{ return osg::Vec4d(v[0], v[1], v[2], v[3]); }
+
+inline
+osg::Vec4f
+toOsg(const SGVec4f& v)
+{ return osg::Vec4f(v[0], v[1], v[2], v[3]); }
+
+inline
+SGQuatd
+toSG(const osg::Quat& q)
+{ return SGQuatd(q[0], q[1], q[2], q[3]); }
+
+inline
+osg::Quat
+toOsg(const SGQuatd& q)
+{ return osg::Quat(q[0], q[1], q[2], q[3]); }
+
+// Create a local coordinate frame in the earth-centered frame of
+// reference. X points north, Z points down.
+// makeSimulationFrameRelative() only includes rotation.
+inline
+osg::Matrix
+makeSimulationFrameRelative(const SGGeod& geod)
+{ return osg::Matrix(toOsg(SGQuatd::fromLonLat(geod))); }
+
+inline
+osg::Matrix
+makeSimulationFrame(const SGGeod& geod)
+{
+ osg::Matrix result(makeSimulationFrameRelative(geod));
+ SGVec3d coord;
+ SGGeodesy::SGGeodToCart(geod, coord);
+ result.setTrans(toOsg(coord));
+ return result;
+}
+
+// Create a Z-up local coordinate frame in the earth-centered frame
+// of reference. This is what scenery models, etc. expect.
+// makeZUpFrameRelative() only includes rotation.
+inline
+osg::Matrix
+makeZUpFrameRelative(const SGGeod& geod)
+{
+ osg::Matrix result(makeSimulationFrameRelative(geod));
+ // 180 degree rotation around Y axis
+ result.preMultRotate(osg::Quat(0.0, 1.0, 0.0, 0.0));
+ return result;
+}
+
+inline
+osg::Matrix
+makeZUpFrame(const SGGeod& geod)
+{
+ osg::Matrix result(makeZUpFrameRelative(geod));
+ SGVec3d coord;
+ SGGeodesy::SGGeodToCart(geod, coord);
+ result.setTrans(toOsg(coord));
+ return result;
+}
+
+#endif
#include <osg/PagedLOD>
#include <osgUtil/UpdateVisitor>
-#include "simgear/math/SGMath.hxx"
+#include "OsgMath.hxx"
class SGUpdateVisitor : public osgUtil::UpdateVisitor {
public: