<div dir="ltr">Try this:<div><br></div><div><a href="https://github.com/gwaldron/osgearth/blob/master/src/applications/osgearth_transform/osgearth_transform.cpp#L77">https://github.com/gwaldron/osgearth/blob/master/src/applications/osgearth_transform/osgearth_transform.cpp#L77</a><br></div><div><br></div><div>Good luck.</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div class="gmail_signature">Glenn Waldron</div></div></div></div>
<br><div class="gmail_quote">On Thu, Sep 3, 2015 at 11:09 AM, Guido Knapen <span dir="ltr"><<a href="mailto:guidoknapen@gmail.com" target="_blank">guidoknapen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello everybody.<br>
<br>
I'm new to this forum. For 16 hours I've been trying to solve my problem with no success. I've tried several different methods to convert but all fail.<br>
<br>
Basicly I have this code to put some testing arrows in my scene which demonstrate yaw, pitch and roll.<br>
<br>
<br>
Code:<br>
<br>
for(int y = 0; y < 4; y++) // Vertical stuff<br>
      {<br>
          char *ID = 0;<br>
          float lat = 50.0 - 0.1f * y;<br>
          bool increaseYaw = false;<br>
          bool increasePitch = false;<br>
          bool increaseRoll = false;<br>
<br>
          switch(y)<br>
          {<br>
          case 0:<br>
                  increaseYaw = true;<br>
                  ID = "YAW";<br>
                  break;<br>
          case 1:<br>
                  increasePitch = true;<br>
                  ID = "PITCH";<br>
                  break;<br>
          case 2:<br>
                  increaseRoll = true;<br>
                  ID = "ROLL";<br>
                  break;<br>
          case 3:<br>
                  increaseYaw = true;<br>
                  increasePitch = true;<br>
                  ID = "YAW AND PITCH";<br>
                  break;<br>
          case 4:<br>
                  increaseYaw = true;<br>
                  increaseRoll = true;<br>
                  ID = "YAW AND ROLL";<br>
                  break;<br>
          case 5:<br>
                  increasePitch = true;<br>
                  increaseRoll = true;<br>
                  ID = "PITCH AND ROLL";<br>
                  break;<br>
          case 6:<br>
                  increaseYaw = true;<br>
                  increasePitch = true;<br>
                  increaseRoll = true;<br>
                  ID = "YAW, PITCH AND ROLL";<br>
                  break;<br>
          }<br>
<br>
          float yaw = 0.0f;<br>
              float pitch = 0.0f;<br>
                  float roll = 0.0f;<br>
<br>
                  for(int x = 0; x < 8; x++) // Horizontal stuff<br>
                  {<br>
                          float lon = 6.0f + 0.1f * x;<br>
<br>
                          GuiLibViewerEntity *ve = mViewer->createViewerEntity( // align<br>
                               ID,// align<br>
                               GuiLib::GuiLibPosition(lat, lon, 1000.0), // align<br>
                               20.0, // align<br>
                               path, // align<br>
                               x == 0);<br>
                      ve->setRotationRadians(yaw, pitch, roll);<br>
                      ve->setAutoScale(mAutoScale);<br>
<br>
                          if(increaseYaw)<br>
                          {<br>
                                  yaw += osg::PI / 4;<br>
                          }<br>
<br>
                          if(increasePitch)<br>
                          {<br>
                                  pitch += osg::PI / 4;<br>
                          }<br>
<br>
                          if(increaseRoll)<br>
                          {<br>
                                  roll += osg::PI / 4;<br>
                          }<br>
                  }<br>
      }<br>
<br>
<br>
<br>
<br>
However my setRotationRadius does not work properly. One of methods which got me the closest to the proper result is this one:<br>
<br>
<br>
Code:<br>
<br>
void ViewerEntity::setRotationRadians(<br>
         float aYaw,<br>
         float aPitch,<br>
         float aRoll) {<br>
<br>
osg::Matrixd mat;<br>
           mat.makeRotate(aPitch, PITCH_VEC, aYaw, YAW_VEC, aRoll, ROLL_VEC);<br>
<br>
           mModel->setLocalRotation (mat.getRotate());<br>
}<br>
<br>
<br>
<br>
<br>
Which generates this:<br>
/file/d/0B7qBNqPzsL5PMWx1ZjVRR0VHbms/view?usp=sharing<br>
<br>
EDIT: apparently I cant post images. however that's a google drive image feel free to add that to the google drive url.<br>
<br>
As you can see the yaw, pitch and roll individually are rotated correctly. However when the yaw and pitch are combined the arrows which have a red circle around them have their yaw wrong by 180 degrees.<br>
<br>
Can anybody please help me out?<br>
<br>
Thanks in advance<br>
<br>
------------------<br>
Read this topic online here:<br>
<a href="http://forum.openscenegraph.org/viewtopic.php?p=65014#65014" rel="noreferrer" target="_blank">http://forum.openscenegraph.org/viewtopic.php?p=65014#65014</a><br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</blockquote></div><br></div>