# quaternion

Sorry if it’s a dumb question;
I’m trying to get datas from a moven suit control a model in panda.
Every joints will be control regards to the other except one (the pelvis) which will be control regards to a dummynode.
Datas are coming with quaternion informations about orientations in the order scalar then vector(x, y, z).
My first problem is that I didn’t manage to know what are the order in the Quat object.
Is it : scalar,vecX, vecY, vecZ (like in Moven)
or (like in secondlife) vecX, vecY, vecZ, scalar
? (it seems to me that it the second solution)
The other problem is that the coordinate system in moven is not the same as the coordinate system in Panda. Then when, I’m getting something that seems “possible” (in the movement) my model is turning himself the wrong way (walking on the left when is expected to walk forward, …)
My question is : is there a way to change the system coordinates use in Panda ?
I tried to add some quaternion rotation (for example <0.707, 0., 0., 0.707> for a 90Â°deg turn around x) it doesn’t work. I mean the changement in orientations are not respected.
I saw that you can add orientation by adding quaternion. That’s why I tried this way but I must confessed that I missed something.

The easiest way to convert a coordinate system is to apply a rotation. Usually it’s a 90-degree rotation. The easiest place to apply it is to the top of your model, or to some node that your model is parented to. You can even apply it to render if you want it to be applied globally.

I believe Panda’s quaternions are in the order r, i, j, k, which is equivalent to scalar, vecX, vecY, vecZ.

David

Thanks drwr, you gave me the right way for the convertion of the system coordinates.

But, about the order in the quaternion, there is something odd.
When I use <scalar, vecX, vecY, vecZ> the orientation of the model is not correct.
when I use <vecX, vecY, vecZ, scalar> the orientation is correct

Are you sure about your inputs? Maybe you’re reading the source quaternion wrong, so that what you think is vecX, vecY, vecZ, scalar is actually scalar, vecX, vecY, vecZ.

In any case, if you find what works, might as well stick with it.

David

Actually it doesn’t work. I think I am a bit lost about changing the coordinate system in panda.
I’m using datas from a moven mocap suit which system coordinate right hand, z up and x forward.

I create a dummynode to change the system coordinates

dummy = render.attachNewNode(“dummyNode”)
dummy.setHpr(90, -90, 0)
dummy.setPos(0, 0, 0)

In my class World i load my actor parented to dummy (device will be given as an argument of my class)

self.xn = Actor(device)
self.xn.reparentTo(dummy)

I create a nodepath to define my new coordinate sytem

coordSys = dummy.attachNewNode(‘coordSysNode’)

I define my joint and put a task to control it

self.xnPelvis = self.xn.controlJoint(coordSys, ‘modelRoot’, ‘Bip01 Pelvis’)

quatPelvis=Quat(snif.matrice[11],snif.matrice[12], snif.matrice[13], snif.matrice[14])
self.xnPelvis.setQuat(quatPelvis)

where snif.matrice[… are the values of r, i, j, k of the joint in the moven system coordinates.

The curious thing is when I parented my coordSys to render instead of dummy it changes nothing. It means I didn’t manage to change the coordinate system.

That’s certainly curious. I don’t see anything obviously wrong in the code you’ve pasted, but there must be something silly.

Try loading the axis model and parenting it to both nodes, just to prove that your dummy node still has its coordinate system.

Also make sure the camera is not not parented to the coordSys node. If it is, it will inherit the same transform from the dummy node, and you won’t see any change when you reparent coordSys.

David

Using the axis model helps.
Actually I don’t get how to tell panda that my quaternions are using this sytem coordinate (this dummy node) or an other one (render for example).
I’ve tried setQuat (dummy, Quat) and set(Quat) and the movement is the same (in wrong direction). The starting orientation is different but the movements is the same.
I’m wondering whether the system coordinates used for the model is important. Does it change something if it’s left hand or right hand ?

In Panda, nodes inherit the transforms of their parent. A transform is another name for a coordinate frame. So if you want your quaternions to use the coordinate frame defined by dummy, you should parent your character to dummy. If you want them to use the coordinate frame defined by render, you should parent it to render. It’s as simple as that.

Left-handed vs. right-handed certainly makes a difference, but it should only matter on the global scale. That is, if your axes are all turning in the wrong direction because you have the wrong handedness of your coordinate system, it should still be moving OK overall, but all of the motions will be consistently backward, as if you were watching your model move in a mirror.

If your character is not moving consistently within itself, then you’ve got bigger problems.

David

Actually, I successfully applied my moven data to the panda or eve.
The orientations given by moven are well applied to both models.

About my model this how you said, it’s mirrored (when the hips turn to the left in moven it turn to the right in panda)

To un-mirror, you need to apply a -1 scale:

dummy.setScale(-1, 1, 1)

This will also reverse each polygon and turn the model inside-out, so you also need to change that:

dummy.setAttrib(CullFaceAttrib.make(MCullCounterClockwise))

David

Thanks David,

Actually I found that the problem is related to the coordinate system used in 3ds max.
in 3ds max, it’s right hand, z-up with y to the back of the model and x on the left.
in moven it’s right hand, z up, x in front and y on the left.

Transfering position are quite easy by using the dummy node.
The problem is with the quaternion. They are interpreted as quaternion in regards to the model coordinate system not to the dummy coordinate system or the panda coordinate system.
Y is place of -X
and X is the place of Y
When the quaternion send a rotation around the Y, actually it turns around X

that should help

Thanks Nemesis#13,

I managed to understand what’s going on :

I create a model in the coordinate system I use,
When I load my model and get the hpr of the pelvis, it should be 0, 0, 0
and it is -90, 0, -90

When I look into the egg file the transform matrix after the joint of the pelvis is not with 0 everywhere, but it should be because my pelvis is not rotated in 3ds max.

It seems that the conversion from 3ds max create this rotation of -90, 0, -90.
???