# Parent/Child Transform problems

## Recommended Posts

I'm trying to achieve a parent-child transform hierarchy but there's always something wrong about it:

I define a parent transform:

// Create parent transform
XMMATRIX parentTrans = XMMatrixTranslation(this->position.x, this->position.y, this->position.z);
XMStoreFloat4x4(&this->parentTransform, parentTrans);


then I define the transform of my child like this:

modelTrans = XMLoadFloat4x4(&left_arm->GetTransform());
localTrans = XMMatrixScaling(0.075f, 0.075f, 0.075f) * XMMatrixRotationZ(DegToRad(-20)) * XMMatrixTranslation(-0.27f, 0.025f, 0.0f);
transform = modelTrans * localTrans * parentTrans;
XMStoreFloat4x4(&newTransform, transform);
left_arm->SetTransform(newTransform);
this->left_armSocketTransform = left_arm->GetTransform();


This is where it gets odd since I thought the transform hierarchy would be (parent * child) but it turns out that the other way around is the only thing that is correct for me.

But now when I try to parent another child onto the transform of my child...

modelTrans = XMLoadFloat4x4(&this->projectile->GetTransform());
transform = modelTrans * localTrans;
XMStoreFloat4x4(&this->local, transform);
XMMATRIX transform = XMLoadFloat4x4(&this->local) * XMLoadFloat4x4(&newOwner->GetLeftArmSocketTransform());

The normals of this child (actually just the Z-axis is inverted). I've already tried using the WorldInverseTranspose but since this is not a scaling issue it doesn't fix it.

This problem only occurs when I combine some local transform with the "LeftArmSocketTransform" (the transform of the first child)

Any ideas what I'm doing wrong ?

Edited by lipsryme

##### Share on other sites

Why is the first one transform = modelTrans * localTrans * parentTrans; and the second one is only transform = modelTrans * localTrans?

Check out Frank Luna's description of the problem here: http://mathinfo.univ-reims.fr/image/dxMesh/extra/d3dx_skinnedmesh.pdf

##### Share on other sites

Hi, the parent of the second one is in the last line "newOwner->GetLeftArmSocketTransform()"

And btw I know it's called torso, arm and stuff but it's actually not a skinned mesh. Just some meshes stuck together.

##### Share on other sites

Hi, the parent of the second one is in the last line "newOwner->GetLeftArmSocketTransform()"

And btw I know it's called torso, arm and stuff but it's actually not a skinned mesh. Just some meshes stuck together.

The link I sent you is still valid, just read section 1 and stop there. The skinning part is just aesthetic anyway.

##### Share on other sites
Ok so I now understand why I have to multiply it in the order of local * parent but this only means that everything I did was correct.
I still don't understand why the normals get screwed up after the last multiply.

LeftArmSocketTransform is the combined transform of the arm's local transform multiplied by it's parent's transform.
So then I'd multiply the local transform of e.g. the hand with this combined transform, right ? Well that's what I do. Edited by lipsryme

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628396
• Total Posts
2982438

• 10
• 9
• 19
• 24
• 10