From: frohlich Date: Sun, 1 Mar 2009 12:40:50 +0000 (+0000) Subject: Implement setters for velocity notes in the model placement code. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=fee8d0cf78fac0319ed2383af9f180f97e031754;p=simgear.git Implement setters for velocity notes in the model placement code. Modified Files: simgear/scene/model/placement.cxx simgear/scene/model/placement.hxx --- diff --git a/simgear/scene/model/placement.cxx b/simgear/scene/model/placement.cxx index 64ce3dad..37d715f4 100644 --- a/simgear/scene/model/placement.cxx +++ b/simgear/scene/model/placement.cxx @@ -9,9 +9,7 @@ #include -#include // for strcmp() - -#include +#include #include "location.hxx" #include "placementtrans.hxx" @@ -49,7 +47,6 @@ SGModelPlacement::init( osg::Node * model ) _position->addChild(model); } _selector->addChild(_position.get()); -// _selector->setNodeMask(_selector->getNodeMask() & ~SG_HOT_TRAVERSAL_BIT); _selector->setValue(0, 1); } @@ -147,4 +144,24 @@ SGModelPlacement::setOrientation (const SGQuatd& orientation) orientation.getEulerDeg(_heading_deg, _pitch_deg, _roll_deg); } +void +SGModelPlacement::setBodyLinearVelocity(const SGVec3d& linear) +{ + SGSceneUserData* userData; + userData = SGSceneUserData::getOrCreateSceneUserData(_position); + SGSceneUserData::Velocity* vel = userData->getOrCreateVelocity(); + SGQuatd orientation = SGQuatd::fromAngleAxisDeg(180, SGVec3d(0, 1, 0)); + vel->linear = orientation.backTransform(linear); +} + +void +SGModelPlacement::setBodyAngularVelocity(const SGVec3d& angular) +{ + SGSceneUserData* userData; + userData = SGSceneUserData::getOrCreateSceneUserData(_position); + SGSceneUserData::Velocity* vel = userData->getOrCreateVelocity(); + SGQuatd orientation = SGQuatd::fromAngleAxisDeg(180, SGVec3d(0, 1, 0)); + vel->angular = orientation.backTransform(angular); +} + // end of model.cxx diff --git a/simgear/scene/model/placement.hxx b/simgear/scene/model/placement.hxx index d8eb25d0..5c06e532 100644 --- a/simgear/scene/model/placement.hxx +++ b/simgear/scene/model/placement.hxx @@ -77,6 +77,9 @@ public: virtual void setOrientation (double roll_deg, double pitch_deg, double heading_deg); void setOrientation(const SGQuatd& orientation); + + void setBodyLinearVelocity(const SGVec3d& velocity); + void setBodyAngularVelocity(const SGVec3d& velocity); private: