From d4310a7f3b27b8403ba1ec030cfd3b4c6c565f24 Mon Sep 17 00:00:00 2001 From: Mathias Froehlich Date: Sat, 24 Nov 2012 09:54:21 +0100 Subject: [PATCH] hla: Make use of SGLocation. --- simgear/hla/HLALocation.hxx | 39 +++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/simgear/hla/HLALocation.hxx b/simgear/hla/HLALocation.hxx index 474a39c6..a43f5160 100644 --- a/simgear/hla/HLALocation.hxx +++ b/simgear/hla/HLALocation.hxx @@ -18,6 +18,7 @@ #ifndef HLALocation_hxx #define HLALocation_hxx +#include #include "HLABasicDataElement.hxx" #include "HLATypes.hxx" @@ -27,6 +28,9 @@ class HLAAbstractLocation : public SGReferenced { public: virtual ~HLAAbstractLocation() {} + virtual SGLocationd getLocation() const = 0; + virtual void setLocation(const SGLocationd&) = 0; + virtual SGVec3d getCartPosition() const = 0; virtual void setCartPosition(const SGVec3d&) = 0; @@ -34,10 +38,21 @@ public: virtual void setCartOrientation(const SGQuatd&) = 0; virtual SGVec3d getAngularBodyVelocity() const = 0; - virtual void setAngularBodyVelocity(const SGVec3d& angular) = 0; + virtual void setAngularBodyVelocity(const SGVec3d&) = 0; virtual SGVec3d getLinearBodyVelocity() const = 0; - virtual void setLinearBodyVelocity(const SGVec3d& linear) = 0; + virtual void setLinearBodyVelocity(const SGVec3d&) = 0; + + virtual double getTimeDifference(const SGTimeStamp&) const + { return 0; } + + // Get the position and orientation extrapolated to the given time stamp. + SGLocationd getLocation(const SGTimeStamp& timeStamp) const + { + SGLocationd location = getLocation(); + location.eulerStepBodyVelocities(getTimeDifference(timeStamp), getLinearBodyVelocity(), getAngularBodyVelocity()); + return location; + } }; class HLACartesianLocation : public HLAAbstractLocation { @@ -49,6 +64,14 @@ public: _linearVelocity(SGVec3d::zeros()) { } + virtual SGLocationd getLocation() const + { return SGLocationd(_position, SGQuatd::fromPositiveRealImag(_imag)); } + virtual void setLocation(const SGLocationd& location) + { + _position = location.getPosition(); + _imag = location.getOrientation().getPositiveRealImag(); + } + virtual SGVec3d getCartPosition() const { return _position; } virtual void setCartPosition(const SGVec3d& position) @@ -260,6 +283,18 @@ public: updateCartesianFromGeodetic(); } + virtual SGLocationd getLocation() const + { + updateCartesianFromGeodetic(); + return SGLocationd(_cartPosition, _cartOrientation); + } + virtual void setLocation(const SGLocationd& location) + { + _cartPosition = location.getPosition(); + _cartOrientation = location.getOrientation(); + _dirty = true; + } + virtual SGVec3d getCartPosition() const { updateCartesianFromGeodetic(); return _cartPosition; } virtual void setCartPosition(const SGVec3d& position) -- 2.39.5