1
0
Fork 0

fgai: Use HLACartesianLocation instead of an own implementation.

This commit is contained in:
Mathias Froehlich 2012-11-25 22:25:27 +01:00
parent 5e85bcacc8
commit 5fea5240e8
2 changed files with 1 additions and 62 deletions

View file

@ -27,65 +27,6 @@
namespace fgai {
class HLASceneObject::Location : public simgear::HLAAbstractLocation {
public:
Location() :
_position(SGVec3d::zeros()),
_imag(SGVec3d::zeros()),
_angularVelocity(SGVec3d::zeros()),
_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)
{ _position = position; }
virtual SGQuatd getCartOrientation() const
{ return SGQuatd::fromPositiveRealImag(_imag); }
virtual void setCartOrientation(const SGQuatd& orientation)
{ _imag = orientation.getPositiveRealImag(); }
virtual SGVec3d getAngularBodyVelocity() const
{ return _angularVelocity; }
virtual void setAngularBodyVelocity(const SGVec3d& angularVelocity)
{ _angularVelocity = angularVelocity; }
virtual SGVec3d getLinearBodyVelocity() const
{ return _linearVelocity; }
virtual void setLinearBodyVelocity(const SGVec3d& linearVelocity)
{ _linearVelocity = linearVelocity; }
virtual double getTimeDifference(const SGTimeStamp& timeStamp) const
{ return _position.getDataElement()->getTimeDifference(timeStamp); }
simgear::HLADataElement* getPositionDataElement()
{ return _position.getDataElement(); }
simgear::HLADataElement* getOrientationDataElement()
{ return _imag.getDataElement(); }
simgear::HLADataElement* getAngularVelocityDataElement()
{ return _angularVelocity.getDataElement(); }
simgear::HLADataElement* getLinearVelocityDataElement()
{ return _linearVelocity.getDataElement(); }
private:
simgear::HLAVec3dData _position;
simgear::HLAVec3dData _imag;
simgear::HLAVec3dData _angularVelocity;
simgear::HLAVec3dData _linearVelocity;
};
HLASceneObject::HLASceneObject(HLASceneObjectClass* objectClass) :
HLAObjectInstance(objectClass)
{
@ -104,7 +45,7 @@ HLASceneObject::createAttributeDataElements()
assert(dynamic_cast<HLASceneObjectClass*>(getObjectClass().get()));
HLASceneObjectClass& objectClass = static_cast<HLASceneObjectClass&>(*getObjectClass());
Location* location = new Location;
simgear::HLACartesianLocation* location = new simgear::HLACartesianLocation;
setAttributeDataElement(objectClass.getPositionIndex(), location->getPositionDataElement());
setAttributeDataElement(objectClass.getOrientationIndex(), location->getOrientationDataElement());
setAttributeDataElement(objectClass.getAngularVelocityIndex(), location->getAngularVelocityDataElement());

View file

@ -36,8 +36,6 @@ public:
void setLocation(const AIPhysics& physics);
private:
/// Currently we have our own location. FIXME Extend Cartesian location at some point.
class Location;
// The location of this object
SGSharedPtr<simgear::HLAAbstractLocation> _location;
};