- for(int i = 0; i < 4; i++) {
- float tmp = POS[i][3];
- for( int j=0; j<3; j++ ) {
- POS[i][j] += (tmp * trans[j]);
- }
- }
- _position->setTransform(POS);
+void
+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::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));