Jump to content
  • Advertisement
Sign in to follow this  
lipsryme

Parent/Child Transform problems

This topic is 2035 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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());
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

Share this post


Link to post
Share on other sites
Advertisement

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 this post


Link to post
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 this post


Link to post
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!