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()); localTrans = XMMatrixIdentity(); //XMMatrixRotationX(DegToRad(-90)); 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, 20 February 2013 - 01:32 PM.