Archived

This topic is now archived and is closed to further replies.

supagu

additive matrices?

Recommended Posts

supagu    148
what im trying to do is have say a node and a child node, the child node inherits position and rotation from its parent what i tryed is to multiply the parents world transform matrix with the childs world transform matrix, but this seems not to work.

Share this post


Link to post
Share on other sites
Raloth    379
You want to multiply the child''s rotation matrix with the parent''s world transformation matrix (I think). Matrix multiplication is not communitive.

Share this post


Link to post
Share on other sites
supagu    148
transform of parent class:


head parent:

D3DXMATRIXA16 matRotation;
D3DXMATRIXA16 matTranslation;
//D3DXMATRIXA16 matWorld; // this is part of the class
D3DXMATRIXA16 matScale;

D3DXMatrixRotationYawPitchRoll( &matRotation, rotation.x, rotation.y, rotation.z);
D3DXMatrixTranslation( &matTranslation, position.x, position.y, position.z);

D3DXMatrixScaling( &matScale, scale.x, scale.y, scale.z);

D3DXMatrixMultiply( &matWorld, &matRotation, &matScale);
D3DXMatrixMultiply( &matWorld, &matWorld, &matTranslation );


children:

//again matWorld is a member variable fo the class
//where parent is a pointer to the parent class
D3DXMATRIXA16 matRotation;
D3DXMATRIXA16 matTranslation;
D3DXMATRIXA16 matScale;

D3DXMATRIXA16 matParent = parent->matWorld;

D3DXMatrixRotationYawPitchRoll( &matRotation, rotation.x, rotation.y, rotation.z);
D3DXMatrixTranslation( &matTranslation, position.x, position.y, position.z);

D3DXMatrixScaling( &matScale, scale.x, scale.y, scale.z);

D3DXMatrixMultiply( &matWorld, &matRotation, &matScale);
D3DXMatrixMultiply( &matWorld, &matWorld, &matTranslation );


children can inherite from other children (im actually trying to do a skeletal/heirachical set up)

Share this post


Link to post
Share on other sites