]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/model/placement.cxx
pass SGReaderWriterXMLOptions to effects
[simgear.git] / simgear / scene / model / placement.cxx
index f781ab3e2b343922e2cd8c1f8d4c9a81ddec9dac..cd38181e212c611cee2ab8fb53a9921f0f697ca2 100644 (file)
@@ -7,14 +7,10 @@
 #include <simgear_config.h>
 #endif
 
-#include <simgear/compiler.h>
-
-#include <simgear/scene/util/SGSceneUserData.hxx>
-
-#include "placementtrans.hxx"
-
 #include "placement.hxx"
 
+#include <simgear/compiler.h>
+#include <simgear/scene/util/SGSceneUserData.hxx>
 
 \f
 ////////////////////////////////////////////////////////////////////////
@@ -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
@@ -135,14 +134,22 @@ SGModelPlacement::setOrientation (const SGQuatd& orientation)
   orientation.getEulerDeg(_heading_deg, _pitch_deg, _roll_deg);
 }
 
+void
+SGModelPlacement::setReferenceTime(const double& referenceTime)
+{
+  SGSceneUserData* userData;
+  userData = SGSceneUserData::getOrCreateSceneUserData(_transform);
+  SGSceneUserData::Velocity* vel = userData->getOrCreateVelocity();
+  vel->referenceTime = referenceTime;
+}
+
 void
 SGModelPlacement::setBodyLinearVelocity(const SGVec3d& linear)
 {
   SGSceneUserData* userData;
   userData = SGSceneUserData::getOrCreateSceneUserData(_transform);
   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
@@ -151,8 +158,7 @@ SGModelPlacement::setBodyAngularVelocity(const SGVec3d& angular)
   SGSceneUserData* userData;
   userData = SGSceneUserData::getOrCreateSceneUserData(_transform);
   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