Jump to content
  • Advertisement
Sign in to follow this  
ankhd

Bone Rotation Madness

This topic is 2071 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

Hi there.

 

If my skinned mesh has animation but the animation only applies its default pose, I can rotate the bone fine.

but if the skinned mesh has no animation the rotation goes like the tile say's it rotates fast and I cant even slow it down when I override

the time delta td = 0.0009.

the thing is if I applie just a rotation Like 45 degrees  it still rotates 360 degrees over and over but it is rotating on the axis Im rotating it on

like this

Angle[ctr] = 45.0;

D3DXMatrixRotationY(&mSpin D3DXToRadian(Angle[ctr]));

D3DXMatrixIdentity(&temp);

temp *= mSpin;

temp *= Frame[ctr]->TransformationMatrix;

Frame[ctr]->TransformationMatrix = temp;

 

//when the mesh has animation but not affecting the bone it works but spins out of control when no animation.

 

any ideas on what it could be I need to do.

 

I could applie default animations that'll fix it.

Share this post


Link to post
Share on other sites
Advertisement

First, I don't know DX10 well at all, so I can only speak in general terms.

 

Just for general info, what algorithm are you using for animating the mesh? Microsoft's (e.g., their skinning example)? Luna's?

 

This is just a guess, but I had a similar problem, years ago. The animation controller (whatever routine updates the matrixes during animation) uses the transformation matrix from the previous frame. That's just how the animation data was set up. If that's the case for whatever algorithm you're using, when you add a rotation to the frame, that rotation gets added every new frame, making it spin faster and faster.

 

As mentioned, it was years ago, but I think my solution was to add a D3DXMATRIX baseMatrix to the Frame structure and make a copy of each frame's base matrix after it was loaded. Then, rather than updating the frame transform itself, I set the frame matrix to the base matrix X rotation matrix. Not knowing your algorithm, that may not work.

 

// each frame

Frame[ctr]->TransformationMatrix = Frame[ctr]->baseMatrix * mSpin;

 

By the way, you can probably multiply matrices directly. I.e., rather than:

 

temp *= Frame[ctr]->TransformationMatrix; Frame[ctr]->TransformationMatrix = temp;

 

you can just use:

 

Frame[ctr]->TransformationMatrix = mSpin * Frame[ctr]->TransformationMatrix;

Edited by Buckeye

Share this post


Link to post
Share on other sites

Hi.

I'm using Key frame animation from jim adams book Advanced Animation with DirectX.

 

I tryed to apply the Original matrix and inversed but it just puts the bone in the centre of the mesh but rotates how it should.

and not inversed

 

like this in update animation



// Reset transformation

D3DXMatrixIdentity(&Anim->Bone->TransformationMatrix);




// Scaling


if(Anim->ScaleKeys ) 

{


// Loop for matching scale key


// Get 2nd key number


// Get difference in keys' times


// Calculate a scalar value to use


// Calculate interpolated scale values


// Create scale matrix and combine with transformation


Anim->Bone->TransformationMatrix *= matScale;

}


// Rotation


if(Anim->RotationKeys ) 

{


// Loop for matching rotation key



// Get 2nd key number


// Get difference in keys' times


// Calculate a scalar value to use


// slerp rotation values


// Create rotation matrix and combine with transformation




Anim->Bone->TransformationMatrix *= mInvmatRotation;

// matRotation;

}


// Translation


if(Anim->TranslationKeys ) 

{


// Loop for matching translation key


// Get 2nd key number


// Get difference in keys' times

a scalar value to use


// Calculate interpolated vector values


// Create translation matrix and combine with transformation


Anim->Bone->TransformationMatrix *= matTranslation;

}


// Matrix


if(Anim->MatrixKeys ) 

{


// Loop for matching matrix key

DWORD Key1 = 0, Key2 = 0;



// Calculate a scalar value to use



// Combine with transformation

Anim->Bone->TransformationMatrix *= matDiff;

}

}


// Go to next animation

Anim = Anim->m_Next;

}

Share this post


Link to post
Share on other sites

Unfortunately, I'm not familiar with Adams' book so I'm not sure how he implements the animation controller.

 

However, try applying the rotation matrix for a single rendering pass, not every frame. Something like:


UpdateScene(deltaTime); // calculate bone frame animation transforms

if( doRotation ) 
{
   // I assume "ctr" is the bone number for the desired bone.
   [calculate mSpin]
   Frame[ctr]->TransformationMatrix = mSpin * Frame[ctr]->TransformationMatrix;
   doRotation = false;
}
RenderScene();

That may demonstrate whether the last frame transform is used for the next one.

Edited by Buckeye

Share this post


Link to post
Share on other sites

I'm just going to set 2 key frames on meshes that dont have animation now.

Most of the meshes will be animated anyway. I did try but the time factor to find the correct trans out ways the need .

Thanks for your help.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!