Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

KingSnake

DX8 trouble with mesh animation. PLEASE!!

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

I can''t animate the mesh!! Ok. I''ve made a simple animation in 3d studio max 3, i''ve exported it to a mesh (.3ds), i''ve converted it into a .x file with frames and animations (verified it in text mode of .x file), i''ve opened the .x file as a d3d mesh with this code: //----------------------------------------------------------------------------- // Name: InitGeometry() // Desc: Create the textures and vertex buffers //----------------------------------------------------------------------------- HRESULT InitGeometry() { LPD3DXBUFFER pD3DXMtrlBuffer; //new // Load the mesh from the specified file if( FAILED( D3DXLoadMeshFromX( "alucard2.x", D3DXMESH_MANAGED,//DYNAMIC, //SYSTEMMEM, g_pd3dDevice, NULL, &pD3DXMtrlBuffer, &g_dwNumMaterials, &g_pMesh ) ) ) { return E_FAIL; } D3DXComputeNormals(g_pMesh); //calcola in automatico le normali!! // We need to extract the material properties and texture names from the // pD3DXMtrlBuffer D3DXMATERIAL* d3dxMaterials = (D3DXMATERIAL*)pD3DXMtrlBuffer->GetBufferPointer(); g_pMeshMaterials = new D3DMATERIAL8[g_dwNumMaterials]; g_pMeshTextures = new LPDIRECT3DTEXTURE8[g_dwNumMaterials]; for( DWORD i=0; i = d3dxMaterials[i].MatD3D; // Set the ambient color for the material (D3DX does not do this) g_pMeshMaterials[i].Ambient = g_pMeshMaterials[i].Diffuse= g_pMeshMaterials[i].Specular; // Create the texture if( FAILED( D3DXCreateTextureFromFile( g_pd3dDevice, d3dxMaterials[i].pTextureFilename, &g_pMeshTextures[i] ) ) ) { g_pMeshTextures[i] = NULL; } } // Done with the material buffer pD3DXMtrlBuffer->Release(); return S_OK; } i render it with this: for( j=0; jSetMaterial( &g_pMeshMaterials[j] ); g_pd3dDevice->SetTexture( 0, g_pMeshTextures[j] ); //g_pd3dDevice->SetTexture( 1, g_pTexture); // Draw the mesh subset g_pMesh->DrawSubset( j ); } BUT NO ANIMATION AT ALL! just the first key frame... how do i call the other frames? thanks! Michele.

Share this post


Link to post
Share on other sites
Advertisement
<< If one more person asks how to animate a mesh, Psionic will blow >>

you can just call frames like that. its alot harder than just

D3DXMakeGraphicsLookCool();
D3DXPlayMyAnimation();

you have to use either fixed function geometry blending, use a vertex shader, or setup animation tweening

msdn.microsoft.com/directx has a tutorial. its advanced.

Share this post


Link to post
Share on other sites
Do you think you are funny?
Do you think you are helpful?
Do you think i am stupid?
If you are SO good, don''t go around in this board.

Thank you.

Share this post


Link to post
Share on other sites
I haven''t played much with .x files, but to do animation, you have to read the animation data. ID3DXMesh simple is just static mesh data. ID3DXSkinMesh might be what you want, to make skinned animation. The SDK also has a skinmesh example. In this forum there is one topic describing that quite well. I''m writing 3d game engine and will also implement SkinMesh in very near future. Not yet decided file format (maybe MilkShape, don''t have 3DStudio). Sorry, but can''t help more just now, good luck. You just need to learn very much.

Share this post


Link to post
Share on other sites
A skinned mesh is a static mesh with ''bones'', matrices that transform some regions of it. I don''t want it. (maybe later..)
I want a simple mesh with straightforward animations, those contained in the .x file (possible, there is also the flag in conv3ds to include it..)

how do i do it?


Michele.

Share this post


Link to post
Share on other sites
What are you talking about ???

I gave you the site that has an article that shows you how to do mesh animation!

Whats eating you ???



Edited by - Psionic on June 11, 2001 4:24:41 PM

Share this post


Link to post
Share on other sites
I have the same problem and maybe more : to create the .x ( with animation data ) from .3ds it is correct : conv3ds -A -X name.3ds ?

Share this post


Link to post
Share on other sites
*Takes Deep Breath*

You can''t use D3DXLoadMeshFromX function to load a mesh that contains bones. The only way is to use the IDirectXFile objects to parse the templates of an .X file. Once you find the Mesh template, you need to load it into an ID3DXSkinMesh object via the D3DXLoadSkinMeshFromXOf function. Once done, you''ll have an array of matrices that you use to alter the orientation of the bones. Once the bones are reoriented, call the ID3DSkinMesh::UpdateSkinnedMesh function to generate an ID3DXMesh object used for rendering the mesh in the orientation.

*Exhales little remaining breath*

It really isn''t hard once you see it in working code. My book is going to contain the code to load multiple animations and apply them to meshes, but you''ll have to wait until Nov when the book is published


Jim Adams



Jim Adams
home.att.net/~rpgbook
Programming Role-Playing Games with DirectX 8

Share this post


Link to post
Share on other sites
BUT!

If i use 3ds to make an animation, it isn''t saved as ''bones'' into the mesh (that so is a skinned one) or i am wrong? In other words, meshes in dx are only static and the only way to make an animation (aparte tweening) is skinning?

let me know, it is such an important and understimated thing...



Michele.



(if you could add some chunks of code....)


Thanks everybody!

Share this post


Link to post
Share on other sites
You need to use the .X File exporter provided with the DX SDK in order to export bone data. Any other way, you could structure your scene as a series of frames, then animate the frames individually. Unforunatelly, the code is much too large to post anything here. I can describe it however.

Using the same loading mechanism, scan through each template using the IDirectXFile series of objects. When you find a mesh, load it with the appropriate mesh loading function. At that point, set the desired matrix and render each mesh attached to seperate frames.



Jim Adams
home.att.net/~rpgbook
Programming Role-Playing Games with DirectX 8

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!