• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

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.

4 replies to this topic

### #1ankhd  Members

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;

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.

### #2Buckeye  GDNet+

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.

You don't forget how to play when you grow old; you grow old when you forget how to play.

### #3ankhd  Members

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;

}



### #4Buckeye  GDNet+

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.

You don't forget how to play when you grow old; you grow old when you forget how to play.

### #5ankhd  Members

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 .