title: Move and rotate SceneNode(Sphere) in Irrlicht
body: <p>I am trying to animate a 3D sphere in Irrlicht with WASD. The moving part works properly, but the rotation does not work. As long as I press only W / S or A / D it works. If I mix them up or start from a different point, the rotation spins.</p>
  
  <p><strong>Declaration</strong></p>
  
  <pre><code>scene::ISceneNode* ballSceneNode = sceneManager-&gt;addSphereSceneNode(5);
  if (ballSceneNode) {
      ballSceneNode-&gt;setPosition(core::vector3df(0, 0, 100));
      ballSceneNode-&gt;setMaterialTexture(0, driver-&gt;getTexture("media/ball.bmp"));
      ballSceneNode-&gt;setMaterialFlag(video::EMF_LIGHTING, false);
  }
  </code></pre>
  
  <p><strong>Main Loop</strong></p>
  
  <pre><code>core::vector3df ballRotation = ballSceneNode-&gt;getRotation();
  core::vector3df ballRotation = ballSceneNode-&gt;getPosition();
  
  if(receiver.isKeyDown(irr::KEY_KEY_W)) {
      ballPosition.Z += movement;
      ballRotation.X++;
  } else if(receiver.isKeyDown(irr::KEY_KEY_S)) {
      ballPosition.Z -= movement;
      ballRotation.X--;
  }
  
  if(receiver.isKeyDown(irr::KEY_KEY_A)) {
      ballPosition.X -= movement;
      ballRotation.Z++;
  } else if(receiver.isKeyDown(irr::KEY_KEY_D)) {
      ballPosition.X += movement;
      ballRotation.Z--;
  }
  
  ballSceneNode-&gt;setPosition(ballPosition);
  ballSceneNode-&gt;setRotation(ballRotation);
  </code></pre>
  
  <p>I have read about that you need <code>core::matrix4</code> for rotation or better to say that it would be helpful / easier and maybe also correct, but I do not know how to use it.</p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>if(receiver.isKeyDown(irr::KEY_KEY_W)) {
      ballPosition.Z += movement;
      cameraPosition.Z += movement;
  
      core::quaternion test;
      test.fromAngleAxis(xAxisAngle, core::vector3df(1,0,0));
      xAxisAngle += 0.1f;
      test.normalize();
      core::vector3df rot;
      test.toEuler(rot);
      ballSceneNode-&gt;setRotation(rot * core::RADTODEG);
  } else if(receiver.isKeyDown(irr::KEY_KEY_S)) {
      ballPosition.Z -= movement;
      cameraPosition.Z -= movement;
  
      core::quaternion test;
      test.fromAngleAxis(xAxisAngle, core::vector3df(1,0,0));
      xAxisAngle -= 0.1f;
      test.normalize();
      core::vector3df rot;
      test.toEuler(rot);
      ballSceneNode-&gt;setRotation(rot * core::RADTODEG);
  }
  
  if(receiver.isKeyDown(irr::KEY_KEY_A)) {
      ballPosition.X -= movement;
      cameraPosition.X -= movement;
  
      core::quaternion test;
      test.fromAngleAxis(zAxisAngle, core::vector3df(0,0,1));
      zAxisAngle += 0.1f;
      test.normalize();
      core::vector3df rot;
      test.toEuler(rot);
      ballSceneNode-&gt;setRotation(rot * core::RADTODEG);
  } else if(receiver.isKeyDown(irr::KEY_KEY_D)) {
      ballPosition.X += movement;
      cameraPosition.X += movement;
  
      core::quaternion test;
      test.fromAngleAxis(zAxisAngle, core::vector3df(0,0,1));
      zAxisAngle -= 0.1f;
      test.normalize();
      core::vector3df rot;
      test.toEuler(rot);
      ballSceneNode-&gt;setRotation(rot * core::RADTODEG);
  }
  </code></pre>
  
  <p><code>xAxisAngle</code> and <code>zAxisAngle</code> are just f32 with default value 0.</p>
  
  <p>Now the problem is:
  W W D (jumping to original state and loosing the 2 W's)</p>