Trouble converting hkRotation to hkQuaternion

Trouble converting hkRotation to hkQuaternion

jbrindle's picture

Hi. All of my existing code using quaternions to represent rotations. I am having trouble converting some of the hkTransform's rotations to quaternions.

When I step through, the data for the 3x3 matrix rotations matches what the "View XML" filter shows in the exporter so I know that data should be correct.

Here is the line that is having the problem:

hkQuaternion quat = transform.getRotation ();

Here is the hkRotation in the transformthat is causing the assert:

transform.m_rotation:

Col 0: x=0.23446380 y=0.16236414z=-0.52446860 w=0.0000000

Col 1: x=-0.053494837 y=0.98164922 z=1.4732159e-009 w=0.00000000

Col 2: x=0.14442635 y=0.10001397 z=0.85142982 w=0.00000000

getRotation returns the rotation but it raises the assert in the hkQuaternion::hkQuaternion ( hkRotation ) constructor.

Any ideas?

Thanks in advance!

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
jbrindle's picture

Some more information:

It seems that if a mesh that is attached to a bone (using a bone attachment) has a scale on it - this is what causes this data to go bad. If we have just rotation and translation information on it, it is fine.

Is there anything we can do to get scales to work?

sean.thurston's picture

Hi jbrindle,

There is a difference between an hkTransform and an hkQsTransform. It sounds like you are using the hkQsTransform since it has a scale. The hktransform and the hkQsTransform both store the position as a hkVector4 and the rotation as a hkQuaternion. In hkQsTransform, the scale is again stored separately as an hkVector4. I don't see why you would have trouble changing something that is a quaternion to another quaternion.

Are you using hkQsTransform? What is the assert that you were hitting? What are you trying to do with the scale?

I don't know how helpful this was. I am just trying to understand your use-case a little better.

Thanks,
Sean

Developer Support Engineer Havok www.havok.com

Login to leave a comment.