Sign in to follow this  
lucky6969b

Problems with translations or rotations

Recommended Posts

Hello, When I move a bone, and the skin vertices become spread-out, what would be the probable cause of this? rotation or translation or the length of the bone or limb? For example, Say the arm after transformed is looking 2 times longer than normal, but with the distance of vertices differ... for example the distance between vertex 1 and vertex 2 is 2 times longer than normal... And because in my project, I need to find out the length of the limb... How do I find out this value? using DX9 Thanks Jack

Share this post


Link to post
Share on other sites
Are you using quaternions for rotations? If yes, are you normalizing them?
To find out the length of a limb, check it`s initial matrix(the matrix that gives you the initial position and rotation of each bone), namely the translation component.

Share this post


Link to post
Share on other sites
Quote:
Original post by Einar89
Are you using quaternions for rotations? If yes, are you normalizing them?
To find out the length of a limb, check it`s initial matrix(the matrix that gives you the initial position and rotation of each bone), namely the translation component.



Thanks Einar89,
The problem arose because the limb of the model I twisted did not look right
For example, I had a upperarm and lower arm, when I twisted it and swinged it at the same time, they became distorted.... But I am getting there. Thanks for helping....
Jack

Share this post


Link to post
Share on other sites
Where did you get the skinned meshes skeleton and keyframe animations from? The stretching you are describing may occur because the scale, quaternion rotation and translation are designed for a different coordinate system than yours (i.e. right-hand vs. left-hand). Also, if you combine the transformations in the wrong order, you will get stretching. Finally, try simply applying the rotation and leaving out the scaling and the translation. See if the problem still occurs. In general, scaling is almost never found in 3d character animation, and you shouldn't really need translation, instead being able to take the skeleton (i.e. bone's frame's translation) in place of any key-framed one.

Share this post


Link to post
Share on other sites
Also, just to clarify for you - bone's don't have a length. In DirectX the term bone and frame are used interchangeably. A "bone" is simply a matrix that describes a change of frame from its parent to a new coordinate system. You could measure the distance from the center of the new coordinate to the old (parent) coordinate system by constructing two origin vectors and then transforming them into each coordinate system and then measuring their magnitude. i.e.

struct D3DXFRAME_DERIVED: public D3DXFRAME
{
D3DXMATRIXA16 CombinedTransformationMatrix;
};

D3DXFRAME_DERIVED* pThisBone;
D3DXFRAME_DERIVED* pParentBone;

pThisBone = (D3DXFRAME_DERIVED*)D3DXFrameFind(m_pFrameRoot, L"MyBoneName" );
pParentBone = (D3DXFRAME_DERIVED*)D3DXFrameFind(m_pFrameRoot, L"MyBoneParent" );

D3DXMATRIX w1 = pThisBone->CombinedTransformationMatrix;
D3DXMATRIX w2 = pParentBone->CombinedTransformationMatrix;

//
// Extract Translation
//
D3DXVECTOR3 vThisBone = D3DXVECTOR3( w1(3, 0), w1(3, 1), w1(3, 2) );
D3DXVECTOR3 vParentBone = D3DXVECTOR3( w2(3, 0), w2(3, 1), w2(3, 2) );

D3DXVECTOR3 a = vThisBone - vParentBone;

float length = D3DXVec3Length( &a );

Of course, you need to compute the CombinedTransformationMatrix yourself. Just follow the frame hierarchy up to the root and concatenate all the matrices together.

A simple example with 3 bones arranged thus:

Bone_First_Bone => Bone_Middle_Bone => Bone_Last_Bone
{ identity matrix } { y-rotation 90 deg } { 0.0f, 50.0f, 0.0f } translation

So the combined transformation matrix for each bone is as follows:

Bone_First_Bone = { identity_matrix }
Bone_Middle_Bone = { y-rotation 90 deg * identity_matrix = y-rotation 90 deg }
Bone_Last_Bone = { translate * y-rotation * identity = translate then rotate }

and the distance between the last bone and the middle bone is

D3DXVec3Length( &D3DXVECTOR3( 0.0f - 0.0f, 50.0f - 0.0f, 0.0f - 0.0f ) );

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this