In my (Ogre) 3d scene I have an object that should be rotated locally based on Joystick input. I have a Joystick with min/max values of [-32767, 32767] on both X and Y axes. When the Joystick is in its origin position, the object should not be rotated. When the user moves the Joystick, the object in the 3d scene should follow this movement (or better: orientation) up to a max. of +/- 45 degrees on both axes.

Or in other words: when the user moves the Joystick e.g. fully to the left, the object's orientation in the 3d scene should be set to 45 degrees on the according axis.

Being new to 3d programming I searched on the Internet on how to achieve this. I think to understand that I want to use Quaternions for this task. I found some examples and tutorials on how to use Quaternions for rotating objects. What I don't understand though is how I can map from the Joystick's current absolute axes positions to the absolute, local rotation of an object.

I see that I could use the rotate() method of the object's node to set its rotation, but I understand that this rotates the object relatively to it's current position. But instead I want to map from the Joystick's absolute position to the absolute orientation/rotation of the object in the scene.

Any advice how I should approach this?

  • \$\begingroup\$ Nice idea, I don't like the relative mapping which is normally used. \$\endgroup\$
    – danijar
    Commented May 9, 2013 at 17:42

1 Answer 1


I don't know about the rotation part but for the mapping input to rotation you can do the following:

(this doesn't go in code)

add 32768 to your input getting a value 0-65535

from here you can get your multiplier which is 90/65535 = 0.00137

then to get your rotation distance you can simply multiply your input by your multiplier

(this goes in code)

32767 * 0.00137 = ~45 (may want to do some rounding)

  • \$\begingroup\$ Thanks, but this is the part I already know. Currently I am more interested in how I can set the absolute rotation values :) \$\endgroup\$
    – Matthias
    Commented May 9, 2013 at 22:58
  • 1
    \$\begingroup\$ Right, but you already have a question about that here: gamedev.stackexchange.com/questions/55234/… \$\endgroup\$ Commented May 10, 2013 at 15:40
  • \$\begingroup\$ Indeed. I had the impression that maybe I phrased that question incorrectly or misleading, so I tried it with a different question. \$\endgroup\$
    – Matthias
    Commented May 10, 2013 at 19:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .