math: Remove SGMath osg dependency.
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.
This commit is contained in:
@@ -29,15 +29,14 @@ set(HEADERS
|
|||||||
leastsqs.hxx
|
leastsqs.hxx
|
||||||
sg_geodesy.hxx
|
sg_geodesy.hxx
|
||||||
sg_types.hxx
|
sg_types.hxx
|
||||||
sg_random.h
|
sg_random.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
SGGeod.cxx
|
|
||||||
SGGeodesy.cxx
|
SGGeodesy.cxx
|
||||||
interpolater.cxx
|
interpolater.cxx
|
||||||
leastsqs.cxx
|
leastsqs.cxx
|
||||||
sg_random.c
|
sg_random.c
|
||||||
)
|
)
|
||||||
|
|
||||||
simgear_component(math math "${SOURCES}" "${HEADERS}")
|
simgear_component(math math "${SOURCES}" "${HEADERS}")
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
// 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
|
|
||||||
@@ -20,10 +20,6 @@
|
|||||||
|
|
||||||
#include <simgear/constants.h>
|
#include <simgear/constants.h>
|
||||||
|
|
||||||
#ifndef NO_OPENSCENEGRAPH_INTERFACE
|
|
||||||
#include <osg/Matrix>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// #define SG_GEOD_NATIVE_DEGREE
|
// #define SG_GEOD_NATIVE_DEGREE
|
||||||
|
|
||||||
/// Class representing a geodetic location
|
/// Class representing a geodetic location
|
||||||
@@ -89,19 +85,6 @@ public:
|
|||||||
// Compare two geodetic positions for equality
|
// Compare two geodetic positions for equality
|
||||||
bool operator == ( const SGGeod & other ) const;
|
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:
|
private:
|
||||||
/// This one is private since construction is not unique if you do
|
/// This one is private since construction is not unique if you do
|
||||||
/// not know the units of the arguments. Use the factory methods for
|
/// not know the units of the arguments. Use the factory methods for
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
#ifndef SGIntersect_HXX
|
#ifndef SGIntersect_HXX
|
||||||
#define SGIntersect_HXX
|
#define SGIntersect_HXX
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline bool
|
inline bool
|
||||||
intersects(const SGSphere<T>& s1, const SGSphere<T>& s2)
|
intersects(const SGSphere<T>& s1, const SGSphere<T>& s2)
|
||||||
|
|||||||
@@ -26,10 +26,6 @@
|
|||||||
#undef max
|
#undef max
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NO_OPENSCENEGRAPH_INTERFACE
|
|
||||||
#include <osg/Quat>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// Quaternion Class
|
/// Quaternion Class
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class SGQuat {
|
class SGQuat {
|
||||||
@@ -780,16 +776,4 @@ SGQuatd
|
|||||||
toQuatd(const SGQuatf& v)
|
toQuatd(const SGQuatf& v)
|
||||||
{ return SGQuatd(v(0), v(1), v(2), v(3)); }
|
{ 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
|
#endif
|
||||||
|
|||||||
@@ -18,11 +18,6 @@
|
|||||||
#ifndef SGVec2_H
|
#ifndef SGVec2_H
|
||||||
#define SGVec2_H
|
#define SGVec2_H
|
||||||
|
|
||||||
#ifndef NO_OPENSCENEGRAPH_INTERFACE
|
|
||||||
#include <osg/Vec2f>
|
|
||||||
#include <osg/Vec2d>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// 2D Vector Class
|
/// 2D Vector Class
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class SGVec2 {
|
class SGVec2 {
|
||||||
@@ -371,27 +366,4 @@ SGVec2d
|
|||||||
toVec2d(const SGVec2f& v)
|
toVec2d(const SGVec2f& v)
|
||||||
{ return SGVec2d(v(0), v(1)); }
|
{ 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
|
#endif
|
||||||
|
|||||||
@@ -18,11 +18,6 @@
|
|||||||
#ifndef SGVec3_H
|
#ifndef SGVec3_H
|
||||||
#define SGVec3_H
|
#define SGVec3_H
|
||||||
|
|
||||||
#ifndef NO_OPENSCENEGRAPH_INTERFACE
|
|
||||||
#include <osg/Vec3f>
|
|
||||||
#include <osg/Vec3d>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// 3D Vector Class
|
/// 3D Vector Class
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class SGVec3 {
|
class SGVec3 {
|
||||||
@@ -505,26 +500,4 @@ SGVec3d
|
|||||||
toVec3d(const SGVec3f& v)
|
toVec3d(const SGVec3f& v)
|
||||||
{ return SGVec3d(v(0), v(1), v(2)); }
|
{ 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
|
#endif
|
||||||
|
|||||||
@@ -18,11 +18,6 @@
|
|||||||
#ifndef SGVec4_H
|
#ifndef SGVec4_H
|
||||||
#define SGVec4_H
|
#define SGVec4_H
|
||||||
|
|
||||||
#ifndef NO_OPENSCENEGRAPH_INTERFACE
|
|
||||||
#include <osg/Vec4f>
|
|
||||||
#include <osg/Vec4d>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// 4D Vector Class
|
/// 4D Vector Class
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class SGVec4 {
|
class SGVec4 {
|
||||||
@@ -428,26 +423,4 @@ SGVec4d
|
|||||||
toVec4d(const SGVec4f& v)
|
toVec4d(const SGVec4f& v)
|
||||||
{ return SGVec4d(v(0), v(1), v(2), v(3)); }
|
{ 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
|
#endif
|
||||||
|
|||||||
@@ -69,6 +69,7 @@
|
|||||||
|
|
||||||
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
||||||
#include <simgear/scene/tgdb/userdata.hxx>
|
#include <simgear/scene/tgdb/userdata.hxx>
|
||||||
|
#include <simgear/scene/util/OsgMath.hxx>
|
||||||
#include <simgear/scene/util/SGSceneFeatures.hxx>
|
#include <simgear/scene/util/SGSceneFeatures.hxx>
|
||||||
#include <simgear/scene/util/StateAttributeFactory.hxx>
|
#include <simgear/scene/util/StateAttributeFactory.hxx>
|
||||||
#include <simgear/structure/OSGUtils.hxx>
|
#include <simgear/structure/OSGUtils.hxx>
|
||||||
|
|||||||
@@ -38,10 +38,10 @@
|
|||||||
#include <boost/tuple/tuple.hpp>
|
#include <boost/tuple/tuple.hpp>
|
||||||
#include <boost/tuple/tuple_comparison.hpp>
|
#include <boost/tuple/tuple_comparison.hpp>
|
||||||
|
|
||||||
|
#include <simgear/scene/util/OsgMath.hxx>
|
||||||
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
||||||
#include <simgear/scene/util/SGSceneFeatures.hxx>
|
#include <simgear/scene/util/SGSceneFeatures.hxx>
|
||||||
#include <simgear/scene/util/StateAttributeFactory.hxx>
|
#include <simgear/scene/util/StateAttributeFactory.hxx>
|
||||||
#include <simgear/math/SGMath.hxx>
|
|
||||||
#include <simgear/structure/OSGUtils.hxx>
|
#include <simgear/structure/OSGUtils.hxx>
|
||||||
|
|
||||||
#include "Noise.hxx"
|
#include "Noise.hxx"
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include <osg/NodeVisitor>
|
#include <osg/NodeVisitor>
|
||||||
#include <osg/TemplatePrimitiveFunctor>
|
#include <osg/TemplatePrimitiveFunctor>
|
||||||
|
|
||||||
|
#include <simgear/scene/util/OsgMath.hxx>
|
||||||
#include <simgear/scene/util/SGSceneUserData.hxx>
|
#include <simgear/scene/util/SGSceneUserData.hxx>
|
||||||
#include <simgear/scene/bvh/BVHGroup.hxx>
|
#include <simgear/scene/bvh/BVHGroup.hxx>
|
||||||
#include <simgear/scene/bvh/BVHLineGeometry.hxx>
|
#include <simgear/scene/bvh/BVHLineGeometry.hxx>
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include <simgear/scene/material/Technique.hxx>
|
#include <simgear/scene/material/Technique.hxx>
|
||||||
#include <simgear/scene/model/model.hxx>
|
#include <simgear/scene/model/model.hxx>
|
||||||
#include <simgear/scene/model/ConditionNode.hxx>
|
#include <simgear/scene/model/ConditionNode.hxx>
|
||||||
|
#include <simgear/scene/util/OsgMath.hxx>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace simgear;
|
using namespace simgear;
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
#include <osgDB/Input>
|
#include <osgDB/Input>
|
||||||
#include <osgDB/Output>
|
#include <osgDB/Output>
|
||||||
|
|
||||||
|
#include <simgear/scene/util/OsgMath.hxx>
|
||||||
|
|
||||||
#include "SGRotateTransform.hxx"
|
#include "SGRotateTransform.hxx"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
#include <osgDB/Input>
|
#include <osgDB/Input>
|
||||||
#include <osgDB/Output>
|
#include <osgDB/Output>
|
||||||
|
|
||||||
|
#include <simgear/scene/util/OsgMath.hxx>
|
||||||
|
|
||||||
#include "SGScaleTransform.hxx"
|
#include "SGScaleTransform.hxx"
|
||||||
|
|
||||||
SGScaleTransform::SGScaleTransform() :
|
SGScaleTransform::SGScaleTransform() :
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
#include <osgDB/Input>
|
#include <osgDB/Input>
|
||||||
#include <osgDB/Output>
|
#include <osgDB/Output>
|
||||||
|
|
||||||
|
#include <simgear/scene/util/OsgMath.hxx>
|
||||||
|
|
||||||
#include "SGTranslateTransform.hxx"
|
#include "SGTranslateTransform.hxx"
|
||||||
|
|
||||||
SGTranslateTransform::SGTranslateTransform() :
|
SGTranslateTransform::SGTranslateTransform() :
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
#include <simgear/props/props.hxx>
|
#include <simgear/props/props.hxx>
|
||||||
#include <simgear/structure/SGBinding.hxx>
|
#include <simgear/structure/SGBinding.hxx>
|
||||||
#include <simgear/scene/material/EffectGeode.hxx>
|
#include <simgear/scene/material/EffectGeode.hxx>
|
||||||
|
#include <simgear/scene/util/OsgMath.hxx>
|
||||||
#include <simgear/scene/util/SGNodeMasks.hxx>
|
#include <simgear/scene/util/SGNodeMasks.hxx>
|
||||||
#include <simgear/scene/util/SGSceneUserData.hxx>
|
#include <simgear/scene/util/SGSceneUserData.hxx>
|
||||||
#include <simgear/scene/util/SGStateAttributeVisitor.hxx>
|
#include <simgear/scene/util/SGStateAttributeVisitor.hxx>
|
||||||
|
|||||||
@@ -22,10 +22,10 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <simgear/math/SGMath.hxx>
|
#include <simgear/math/SGMath.hxx>
|
||||||
#include <simgear/math/SGGeod.hxx>
|
|
||||||
#include <simgear/misc/sg_path.hxx>
|
#include <simgear/misc/sg_path.hxx>
|
||||||
#include <simgear/props/props.hxx>
|
#include <simgear/props/props.hxx>
|
||||||
#include <simgear/props/props_io.hxx>
|
#include <simgear/props/props_io.hxx>
|
||||||
|
#include <simgear/scene/util/OsgMath.hxx>
|
||||||
#include <simgear/structure/OSGVersion.hxx>
|
#include <simgear/structure/OSGVersion.hxx>
|
||||||
|
|
||||||
#include <osgParticle/SmokeTrailEffect>
|
#include <osgParticle/SmokeTrailEffect>
|
||||||
@@ -558,7 +558,7 @@ void Particles::operator()(osg::Node* node, osg::NodeVisitor* nv)
|
|||||||
// Make new frame for particle system, coincident with
|
// Make new frame for particle system, coincident with
|
||||||
// the emitter frame, but oriented with local Z.
|
// the emitter frame, but oriented with local Z.
|
||||||
SGGeod geod = SGGeod::fromCart(toSG(emitOrigin));
|
SGGeod geod = SGGeod::fromCart(toSG(emitOrigin));
|
||||||
Matrix newParticleMat = geod.makeZUpFrame();
|
Matrix newParticleMat = makeZUpFrame(geod);
|
||||||
Matrix changeParticleFrame
|
Matrix changeParticleFrame
|
||||||
= particleMat * Matrix::inverse(newParticleMat);
|
= particleMat * Matrix::inverse(newParticleMat);
|
||||||
particleFrame->setMatrix(newParticleMat);
|
particleFrame->setMatrix(newParticleMat);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "placement.hxx"
|
#include "placement.hxx"
|
||||||
|
|
||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
|
#include <simgear/scene/util/OsgMath.hxx>
|
||||||
#include <simgear/scene/util/SGSceneUserData.hxx>
|
#include <simgear/scene/util/SGSceneUserData.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
#include <simgear/scene/model/model.hxx>
|
#include <simgear/scene/model/model.hxx>
|
||||||
#include <simgear/scene/util/RenderConstants.hxx>
|
#include <simgear/scene/util/RenderConstants.hxx>
|
||||||
|
#include <simgear/scene/util/OsgMath.hxx>
|
||||||
#include <simgear/scene/util/StateAttributeFactory.hxx>
|
#include <simgear/scene/util/StateAttributeFactory.hxx>
|
||||||
#include <simgear/screen/extensions.hxx>
|
#include <simgear/screen/extensions.hxx>
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
#include <osg/CullFace>
|
#include <osg/CullFace>
|
||||||
|
|
||||||
#include <simgear/debug/logstream.hxx>
|
#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/util/VectorArrayAdapter.hxx>
|
||||||
#include <simgear/scene/material/Effect.hxx>
|
#include <simgear/scene/material/Effect.hxx>
|
||||||
#include <simgear/scene/material/EffectGeode.hxx>
|
#include <simgear/scene/material/EffectGeode.hxx>
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include <simgear/math/sg_random.h>
|
#include <simgear/math/sg_random.h>
|
||||||
#include <simgear/scene/util/RenderConstants.hxx>
|
#include <simgear/scene/util/RenderConstants.hxx>
|
||||||
|
#include <simgear/scene/util/OsgMath.hxx>
|
||||||
#include <simgear/sg_inlines.h>
|
#include <simgear/sg_inlines.h>
|
||||||
|
|
||||||
#include <osg/StateSet>
|
#include <osg/StateSet>
|
||||||
|
|||||||
@@ -32,6 +32,8 @@
|
|||||||
#include <osgDB/FileNameUtils>
|
#include <osgDB/FileNameUtils>
|
||||||
#include <osgDB/ReadFile>
|
#include <osgDB/ReadFile>
|
||||||
|
|
||||||
|
#include <simgear/scene/util/OsgMath.hxx>
|
||||||
|
|
||||||
#include "BucketBox.hxx"
|
#include "BucketBox.hxx"
|
||||||
|
|
||||||
namespace simgear {
|
namespace simgear {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <simgear/math/sg_random.h>
|
#include <simgear/math/sg_random.h>
|
||||||
#include <simgear/math/SGMath.hxx>
|
#include <simgear/scene/util/OsgMath.hxx>
|
||||||
#include "SGTriangleBin.hxx"
|
#include "SGTriangleBin.hxx"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
#include "SGVasiDrawable.hxx"
|
#include "SGVasiDrawable.hxx"
|
||||||
|
|
||||||
|
#include <simgear/scene/util/OsgMath.hxx>
|
||||||
|
|
||||||
struct SGVasiDrawable::LightData {
|
struct SGVasiDrawable::LightData {
|
||||||
LightData(const SGVec3f& p, const SGVec3f& n, const SGVec3f& up) :
|
LightData(const SGVec3f& p, const SGVec3f& n, const SGVec3f& up) :
|
||||||
position(p),
|
position(p),
|
||||||
|
|||||||
@@ -42,13 +42,13 @@
|
|||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
#include <simgear/math/sg_geodesy.hxx>
|
#include <simgear/math/sg_geodesy.hxx>
|
||||||
#include <simgear/math/sg_random.h>
|
#include <simgear/math/sg_random.h>
|
||||||
#include <simgear/math/SGMath.hxx>
|
|
||||||
#include <simgear/misc/sgstream.hxx>
|
#include <simgear/misc/sgstream.hxx>
|
||||||
#include <simgear/scene/material/mat.hxx>
|
#include <simgear/scene/material/mat.hxx>
|
||||||
#include <simgear/scene/material/matlib.hxx>
|
#include <simgear/scene/material/matlib.hxx>
|
||||||
#include <simgear/scene/model/ModelRegistry.hxx>
|
#include <simgear/scene/model/ModelRegistry.hxx>
|
||||||
#include <simgear/scene/tgdb/apt_signs.hxx>
|
#include <simgear/scene/tgdb/apt_signs.hxx>
|
||||||
#include <simgear/scene/tgdb/obj.hxx>
|
#include <simgear/scene/tgdb/obj.hxx>
|
||||||
|
#include <simgear/scene/util/OsgMath.hxx>
|
||||||
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
||||||
|
|
||||||
#include "ReaderWriterSPT.hxx"
|
#include "ReaderWriterSPT.hxx"
|
||||||
@@ -111,7 +111,7 @@ static void WorldCoordinate(osg::Matrix& obj_pos, double lat,
|
|||||||
double lon, double elev, double hdg)
|
double lon, double elev, double hdg)
|
||||||
{
|
{
|
||||||
SGGeod geod = SGGeod::fromDegM(lon, lat, elev);
|
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
|
// hdg is not a compass heading, but a counter-clockwise rotation
|
||||||
// around the Z axis
|
// around the Z axis
|
||||||
obj_pos.preMult(osg::Matrix::rotate(hdg * SGD_DEGREES_TO_RADIANS,
|
obj_pos.preMult(osg::Matrix::rotate(hdg * SGD_DEGREES_TO_RADIANS,
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
#include <osg/Group>
|
#include <osg/Group>
|
||||||
#include <osg/Matrix>
|
#include <osg/Matrix>
|
||||||
|
|
||||||
#include <simgear/math/SGMath.hxx>
|
#include <simgear/scene/util/OsgMath.hxx>
|
||||||
|
|
||||||
namespace simgear
|
namespace simgear
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -60,6 +60,7 @@
|
|||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
#include <simgear/scene/util/RenderConstants.hxx>
|
#include <simgear/scene/util/RenderConstants.hxx>
|
||||||
#include <simgear/scene/util/SGEnlargeBoundingBox.hxx>
|
#include <simgear/scene/util/SGEnlargeBoundingBox.hxx>
|
||||||
|
#include <simgear/scene/util/OsgMath.hxx>
|
||||||
#include <simgear/scene/util/StateAttributeFactory.hxx>
|
#include <simgear/scene/util/StateAttributeFactory.hxx>
|
||||||
|
|
||||||
#include <simgear/scene/material/Effect.hxx>
|
#include <simgear/scene/material/Effect.hxx>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ include (SimGearComponent)
|
|||||||
set(HEADERS
|
set(HEADERS
|
||||||
CopyOp.hxx
|
CopyOp.hxx
|
||||||
NodeAndDrawableVisitor.hxx
|
NodeAndDrawableVisitor.hxx
|
||||||
|
OsgMath.hxx
|
||||||
PrimitiveUtils.hxx
|
PrimitiveUtils.hxx
|
||||||
QuadTreeBuilder.hxx
|
QuadTreeBuilder.hxx
|
||||||
RenderConstants.hxx
|
RenderConstants.hxx
|
||||||
|
|||||||
@@ -0,0 +1,145 @@
|
|||||||
|
// 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
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
#include <osg/PagedLOD>
|
#include <osg/PagedLOD>
|
||||||
#include <osgUtil/UpdateVisitor>
|
#include <osgUtil/UpdateVisitor>
|
||||||
|
|
||||||
#include "simgear/math/SGMath.hxx"
|
#include "OsgMath.hxx"
|
||||||
|
|
||||||
class SGUpdateVisitor : public osgUtil::UpdateVisitor {
|
class SGUpdateVisitor : public osgUtil::UpdateVisitor {
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user