DX9 - info on multiple animation
Hi Guys,
I've done some research on the new DX9 interfaces and came up with the following which I hope will be helpful to some of you.
This has been tested in a simple graphics engine with the dx9 animation code. Anyways here goes:
LPD3DXANIMATIONCONTROLLER m_pAnimController
is the structure that will hold all the info that you will querry in order to display the animation of your choice.
D3DXLoadMeshHierarchyFromX(strMeshPath, D3DXMESH_MANAGED, m_pd3dDevice, &Alloc, NULL, &m_pFrameRoot, &m_pAnimController);
the structure will be filled up after this function call with all the animation information.
Then next comes this:
m_pAnimController->GetNumAnimationSets
this will return the number or animations from your mesh and then you can loop to querry the names of the animations (should you need them for anything).
Next:
m_pAnimController->GetAnimationSet(0, &pAnim);
the first param is the animationset you are going to use
and here:
m_pAnimController->SetTrackAnimationSet(0, pAnim);
you apply the animationset
here's everything together:
LPD3DXANIMATIONCONTROLLER m_pAnimController;
D3DXLoadMeshHierarchyFromX(strMeshPath, D3DXMESH_MANAGED, m_pd3dDevice, &Alloc, NULL, &m_pFrameRoot, &m_pAnimController);
if (m_pAnimController) {
LPD3DXANIMATIONSET pAnimSet;
UINT iAnimSet;
LPCTSTR szName;
UINT cAnimSets = m_pAnimController->GetNumAnimationSets;
for (iAnimSet = 0; iAnimSet < cAnimSets; iAnimSet++) {
m_pAnimController->GetAnimationSet(iAnimSet, &pAnimSet);
szName = pAnimSet->GetName();
GXRELEASE(pAnimSet);
}
LPD3DXANIMATIONSET pAnim;
iAnimSet = 0;
m_pAnimController->GetAnimationSet(iAnimSet, &pAnim);
m_pAnimController->SetTrackAnimationSet(0, pAnim);
GXRELEASE(pAnim);
}
You should check on the hresult value from D3DXLoadMeshHierarchyFromX() and the second part of this snippet should be somewhere in your main loop where you check for conditions on which animationset to run.
Well, hope this helps some of you folks out.
Dom
resources used: - DX9 skinnedmesh sample.
- mview source code, downloaded as a DX9 extra.
- the animations i used were created separatly in ms3d and then manually copied and pasted into one .x file (Jim described in more detail how to do this )
[edited by - oordeel on December 25, 2002 2:02:03 AM]
Anyone get the DX mesh viewer to smoothly blend two animated tracks together?
In the TrivialData::OnMessage function located in the wndproc.cpp file, the mesh viewer uses the keys 1-9 for controlling the animation.
This is what I found:
Key 1: Set the speed of both animated tracks (track 0 and 1) to 2.0f. Doubles the speed.
Key 2: Set the speed of both animated tracks (track 0 and 1) to 1.0f. Normal speed.
Key 3: Set the speed of both animated tracks (track 0 and 1) to 0.0f. Stops the animation on both tracks.
Key 4: I think this should blend from track 0 to track 1. But this doesn't work for me and instead just stops the animation.
Key 5: I think this should blend from track 1 to track 0. Again, this doesn't work so I'm not sure.
key 6-8: Not sure about these either. Does nothing to my animated X mesh.
Key 9: Stop the animation for track 0.
I wonder if Jim Adams or someone else could shed some light on the subject about blending two animated tracks together with the mesh viewer? Maybe somethings not setup right in my X file.
[edited by - MagTDK on December 25, 2002 3:05:29 AM]
In the TrivialData::OnMessage function located in the wndproc.cpp file, the mesh viewer uses the keys 1-9 for controlling the animation.
This is what I found:
Key 1: Set the speed of both animated tracks (track 0 and 1) to 2.0f. Doubles the speed.
Key 2: Set the speed of both animated tracks (track 0 and 1) to 1.0f. Normal speed.
Key 3: Set the speed of both animated tracks (track 0 and 1) to 0.0f. Stops the animation on both tracks.
Key 4: I think this should blend from track 0 to track 1. But this doesn't work for me and instead just stops the animation.
Key 5: I think this should blend from track 1 to track 0. Again, this doesn't work so I'm not sure.
key 6-8: Not sure about these either. Does nothing to my animated X mesh.
Key 9: Stop the animation for track 0.
I wonder if Jim Adams or someone else could shed some light on the subject about blending two animated tracks together with the mesh viewer? Maybe somethings not setup right in my X file.
[edited by - MagTDK on December 25, 2002 3:05:29 AM]
quote:
- the animations i used were created separatly in ms3d and then manually copied and pasted into one .x file (Jim described in more detail how to do this )
Where did he describe it? Could you post a link?
It's been in one of the animation threads from the last 2 weeks or something. I'll post the link when I find it.
The short of it is though, you export different sets of animations to .x files. Then you copy the info from
animationset {
.....
.....
}
and paste it at the end of another .x file (the file that you want to have multiple animations). So, it would be something like this:
AnimationSet Idle
{
Animation Main_BoneAnimation
{
{Main_Bone}
AnimationKey
{
}
... // all your animation keys are here
}
}
AnimationSet walk
{
Animation Main_BoneAnimation
{
{Main_Bone}
AnimationKey
{
}
...//all your animation keys are here
}
}
[edited by - oordeel on December 25, 2002 7:20:54 PM]
The short of it is though, you export different sets of animations to .x files. Then you copy the info from
animationset {
.....
.....
}
and paste it at the end of another .x file (the file that you want to have multiple animations). So, it would be something like this:
AnimationSet Idle
{
Animation Main_BoneAnimation
{
{Main_Bone}
AnimationKey
{
}
... // all your animation keys are here
}
}
AnimationSet walk
{
Animation Main_BoneAnimation
{
{Main_Bone}
AnimationKey
{
}
...//all your animation keys are here
}
}
[edited by - oordeel on December 25, 2002 7:20:54 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement