Rotation problem


I'm using FLARToolKit (flash) to create an Augmented Reality-game in Unity. I have managed to send over the rotation values and by that rotate an object in Unity.

This works fine at first glance (see a small demo here:, how ever, if you tilt the marker to the left with the front still facing the camera and rotate the marker horizontally, the object will rotate vertically and vice versa.

It seems that the object rotates verticaly even if it "lies down". I made a small video of the problem here: ( )

The code for the rotation is:

public void moveCSharp(string direction)
    string[] vec3 = direction.Split(' ');

    target = Quaternion.Euler(float.Parse(vec3[1]), float.Parse(vec3[0]), float.Parse(vec3[2]));
    transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * 20f);

Does anyone have any idea what could be the problem?

Thanks in advance Jens

It looks like maybe one of the axes is reversed. It almost seems logical if when you first turn the page on its side - if the cube went the other way (reverse the first axis you moved the cube on in that video) - it will all make sense, but kinda hard to visualize, so I'm not sure.

The best way to approach this is if you can post what you send from FLAR (what method of FLAR do you use to get the rotation and how do you send it to Unity).

Is the FLAR rotation is the rotation of the object or the camera? Is there a chance that the coordinate system of FLAR is not the same as Unity's? (RHS vs LHS if you know what I'm talking about).

Also - Euler angles are probably not the way to go. If you can get a Quaternion rotation from FLARToolkit, it will be much easier and neater to use in Unity. Since FLAR is based on ARToolkit - there must be a method to do this. In ARToolkit it's arUtilMat2QuatPos();