Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Bone Rotation Madness


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 ankhd   Members   -  Reputation: 1363

Like
0Likes
Like

Posted 10 February 2014 - 05:12 AM

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.



Sponsor:

#2 Buckeye   Crossbones+   -  Reputation: 6350

Like
1Likes
Like

Posted 10 February 2014 - 06:30 AM

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, 10 February 2014 - 06:38 AM.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.


#3 ankhd   Members   -  Reputation: 1363

Like
0Likes
Like

Posted 11 February 2014 - 02:41 AM

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;

}



#4 Buckeye   Crossbones+   -  Reputation: 6350

Like
0Likes
Like

Posted 11 February 2014 - 06:50 AM

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, 11 February 2014 - 06:50 AM.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.


#5 ankhd   Members   -  Reputation: 1363

Like
0Likes
Like

Posted 12 February 2014 - 01:04 AM

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.






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