X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fscene%2Fmodel%2Fplacement.cxx;h=852844921f5424ede40e8297cf8c54a5a74dd926;hb=9f9c4cf32c2cf774c7febd7fe2b4e65a7d205294;hp=f46243d3f0929c1a69f2f7d66f8945e4bd3d1868;hpb=9eb5cf6c9815d5fdb645abd04ec1d47e597701d3;p=simgear.git diff --git a/simgear/scene/model/placement.cxx b/simgear/scene/model/placement.cxx index f46243d3..85284492 100644 --- a/simgear/scene/model/placement.cxx +++ b/simgear/scene/model/placement.cxx @@ -7,14 +7,10 @@ #include #endif -#include - -#include - -#include "placementtrans.hxx" - #include "placement.hxx" +#include +#include //////////////////////////////////////////////////////////////////////// @@ -27,7 +23,7 @@ SGModelPlacement::SGModelPlacement () : _pitch_deg(0), _heading_deg(0), _selector(new osg::Switch), - _transform(new SGPlacementTransform) + _transform(new osg::PositionAttitudeTransform) { } @@ -50,14 +46,17 @@ SGModelPlacement::update() { // The cartesian position SGVec3d position = SGVec3d::fromGeod(_position); + _transform->setPosition(toOsg(position)); // The orientation, composed from the horizontal local orientation and the // orientation wrt the horizontal local frame SGQuatd orient = SGQuatd::fromLonLat(_position); - orient *= SGQuatd::fromAngleAxisDeg(180, SGVec3d(0, 1, 0)); - orient *= SGQuatd::fromYawPitchRollDeg(-_heading_deg, _pitch_deg, -_roll_deg); - SGMatrixd rotation(inverse(orient)); - _transform->setTransform(position, rotation); + orient *= SGQuatd::fromYawPitchRollDeg(_heading_deg, _pitch_deg, _roll_deg); + // Convert to the scenegraph orientation where we just rotate around + // the y axis 180 degrees. + orient *= SGQuatd::fromRealImag(0, SGVec3d(0, 1, 0)); + + _transform->setAttitude(toOsg(orient)); } bool @@ -139,7 +138,7 @@ void SGModelPlacement::setReferenceTime(const double& referenceTime) { SGSceneUserData* userData; - userData = SGSceneUserData::getOrCreateSceneUserData(_transform); + userData = SGSceneUserData::getOrCreateSceneUserData(_transform.get()); SGSceneUserData::Velocity* vel = userData->getOrCreateVelocity(); vel->referenceTime = referenceTime; } @@ -148,20 +147,18 @@ void SGModelPlacement::setBodyLinearVelocity(const SGVec3d& linear) { SGSceneUserData* userData; - userData = SGSceneUserData::getOrCreateSceneUserData(_transform); + userData = SGSceneUserData::getOrCreateSceneUserData(_transform.get()); SGSceneUserData::Velocity* vel = userData->getOrCreateVelocity(); - SGQuatd orientation = SGQuatd::fromAngleAxisDeg(180, SGVec3d(0, 1, 0)); - vel->linear = orientation.backTransform(linear); + vel->linear = SGVec3d(-linear[0], linear[1], -linear[2]); } void SGModelPlacement::setBodyAngularVelocity(const SGVec3d& angular) { SGSceneUserData* userData; - userData = SGSceneUserData::getOrCreateSceneUserData(_transform); + userData = SGSceneUserData::getOrCreateSceneUserData(_transform.get()); SGSceneUserData::Velocity* vel = userData->getOrCreateVelocity(); - SGQuatd orientation = SGQuatd::fromAngleAxisDeg(180, SGVec3d(0, 1, 0)); - vel->angular = orientation.backTransform(angular); + vel->angular = SGVec3d(-angular[0], angular[1], -angular[2]); } // end of model.cxx