• Create Account

### #ActualRickard_Hermansson

Posted 08 January 2013 - 02:12 PM

I asked around in tge Ogre 3D forum how it's done there. I seems that the quaternion multiplication order differs from ogre and sharp dx (atleast is seems that way), I have asked on their forum. In ogre the multplication order is right to left.

in the XNA documentation is say the product of a quaternion multiplication = Q2 * Q1, e.g right to left.

any ways, my code for rotating in the desired transform space :

   case TransformSpace.Parent:

relativeOrientation =  relativeOrientation * q;
break;

case TransformSpace.World:

relativeOrientation = WorldOrientation * q * worldOrientationInverse * relativeOrientation;
break;

case TransformSpace.Local:

relativeOrientation = q * relativeOrientation;
break;


Now, the order of multiplication here is the reverse of what ogre is using.
When I send the worldmatrix to the shader I have to transpose it, Sharp DX use row major and the HLSL shader expect matrices as column major. So I transpose the world matrix before sending it to the shader.

Is this why I must reverse the order?

### #5Rickard_Hermansson

Posted 08 January 2013 - 01:19 PM

I asked around in tge Ogre 3D forum how it's done there. I seems that the quaternion multiplication order differs from ogre and sharp dx (atleast is seems that way), I have asked on their forum. In ogre the multplication order is right to left.

in the XNA documentation is say the product of a quaternion multiplication = Q2 * Q1, e.g right to left.

It's kind of confusing when there are different conventions to do the smae thing :/

### #4Rickard_Hermansson

Posted 08 January 2013 - 12:16 PM

Well, after testing more scenarios i found out that the rotations did ot behave as I wanted them to. The goal was to be able to rotate in world,local and parent space.
I asked around in tge Ogre 3D forum how it's done there. I seems that the quaternion multiplication order differs from ogre and sharp dx (atleas is seems sthat way), I have asked on their forum. In ogre the multplication order is right to left.

Anyways after chaning the order of my multiplication I got the desired effect for all three transform spaces

Using Sharp DX:

/* with parent: worldOrientation  = relativeOrientation * parent.worldOrientation
no parent: worldOrientation  = relativeOrientation */
case TransformSpace.Parent:

relativeOrientation =  relativeOrientation * q;
break;

case TransformSpace.World:

relativeOrientation = WorldOrientationInverse * q * worldOrientation * relativeOrientation;

break;

case TransformSpace.Local:
relativeOrientation = q * relativeOrientation;
break;


### #3Rickard_Hermansson

Posted 08 January 2013 - 12:14 PM

Well, after testing more scenarios i found out that the rotations did ot behave as I wanted them to. The goal was to be able to rotate in world,local and parent space.
I asked around in tge Ogre 3D forum how it's done there. I seems that the quaternion multiplication order differs from ogre and sharp dx (atleas is seems sthat way), I have asked on their forum. In ogre the multplication order is right to left.

Anyways after chaning the order of my multiplication I got the desired effect for all three transform spaces

Using Sharp DX:

/* with parent: worldOrientation  = relativeOrientation * parent.worldOrientation
no parent: worldOrientation  = relativeOrientation */
case TransformSpace.Parent:
relativeOrientation =  relativeOrientation * q;break; case TransformSpace.World:          relativeOrientation = WorldOrientationInverse * q * worldOrientation * relativeOrientation;break; case TransformSpace.Local:relativeOrientation = q * relativeOrientation;break;

### #2Rickard_Hermansson

Posted 08 January 2013 - 12:12 PM

Well, after testing more scenarios i found out that the rotations did ot behave as I wanted them to. The goal was to be able to rotate in world,local and parent space.
I asked around in tge Ogre 3D forum how it's done there. I seems that the quaternion multiplication order differs from ogre and sharp dx (atleas is seems sthat way), I have asked on their forum. In ogre the multplication order is right to left.

Anyways after chaning the order of my multiplication I got the desired effect for all three transform spaces

Using Sharp DX:
/* with parent: worldOrientation  = relativeOrientation * parent.worldOrientation    no parent: worldOrientation  = relativeOrientation */case TransformSpace.Parent: relativeOrientation =  relativeOrientation * q;break; case TransformSpace.World:          relativeOrientation = WorldOrientationInverse * q * worldOrientation * relativeOrientation;break; case TransformSpace.Local:relativeOrientation = q * relativeOrientation;break;

### #1Rickard_Hermansson

Posted 08 January 2013 - 12:11 PM

Well, after testing more scenarios i found out that the rotations did ot behave as I wanted them to. The goal was to be able to rotate in world,local and parent space.

I asked around in tge Ogre 3D forum how it's done there. I seems that the quaternion multiplication order differs from ogre and sharp dx (atleas is seems sthat way), I have asked on their forum. In ogre the multplication order is right to left.

Anyways after chaning the order of my multiplication I gor the desired effect for all three transform spaces

Using Sharp DX:

/* with parent: worldOrientation  = relativeOrientation * parent.worldOrientation
no parent: worldOrientation  = relativeOrientation */

case TransformSpace.Parent:

relativeOrientation =  relativeOrientation * q;
break;

case TransformSpace.World:

relativeOrientation = WorldOrientationInverse * q * worldOrientation * relativeOrientation;
break;

case TransformSpace.Local:
relativeOrientation = q * relativeOrientation;
break;

PARTNERS