]> git.mxchange.org Git - simgear.git/commitdiff
Implement setters for velocity notes in the model placement code.
authorfrohlich <frohlich>
Sun, 1 Mar 2009 12:40:50 +0000 (12:40 +0000)
committerTim Moore <timoore@redhat.com>
Thu, 5 Mar 2009 09:32:05 +0000 (10:32 +0100)
Modified Files:
simgear/scene/model/placement.cxx
simgear/scene/model/placement.hxx

simgear/scene/model/placement.cxx
simgear/scene/model/placement.hxx

index 64ce3dad32dc197516ca41efd74ecae8d1c137c7..37d715f4338ce48fdc183bdaf729135de4127c2a 100644 (file)
@@ -9,9 +9,7 @@
 
 #include <simgear/compiler.h>
 
-#include <string.h>             // for strcmp()
-
-#include <plib/ul.h>
+#include <simgear/scene/util/SGSceneUserData.hxx>
 
 #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
index d8eb25d06065b99514d5af396e2d74ca0b512217..5c06e53211065cde833fca6073fd6b596377d817 100644 (file)
@@ -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: