Jump to content

  • Log In with Google      Sign In   
  • Create Account

Parent/Child Transform problems


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 lipsryme   Members   -  Reputation: 1047

Like
0Likes
Like

Posted 20 February 2013 - 12:52 PM

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.


Sponsor:

#2 Steve_Segreto   Crossbones+   -  Reputation: 1551

Like
0Likes
Like

Posted 20 February 2013 - 02:46 PM

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



#3 lipsryme   Members   -  Reputation: 1047

Like
0Likes
Like

Posted 20 February 2013 - 03:01 PM

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.



#4 Steve_Segreto   Crossbones+   -  Reputation: 1551

Like
0Likes
Like

Posted 20 February 2013 - 04:44 PM

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.



#5 lipsryme   Members   -  Reputation: 1047

Like
0Likes
Like

Posted 21 February 2013 - 12:57 PM

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, 21 February 2013 - 01:00 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS